vbscript: Added beginning InvokeEx implementation.

This commit is contained in:
Jacek Caban 2011-09-15 14:21:33 +02:00 committed by Alexandre Julliard
parent 8b4c560d75
commit 6ee2e3ac91
3 changed files with 65 additions and 1 deletions

View File

@ -400,4 +400,9 @@ End Class
Call testDisp(new testClass) Call testDisp(new testClass)
Set obj = New TestClass
Call ok(obj.publicFunction = 4, "obj.publicFunction = " & obj.publicFunction)
Call ok(obj.publicFunction() = 4, "obj.publicFunction() = " & obj.publicFunction())
reportSuccess() reportSuccess()

View File

@ -144,7 +144,11 @@ static BOOL is_english(void)
static void test_disp(IDispatch *disp) static void test_disp(IDispatch *disp)
{ {
DISPID id, public_func_id, public_sub_id; DISPID id, public_func_id, public_sub_id;
DISPID named_args[5] = {DISPID_PROPERTYPUT};
VARIANT v, args[5];
DISPPARAMS dp = {args, named_args};
IDispatchEx *dispex; IDispatchEx *dispex;
EXCEPINFO ei = {0};
BSTR str; BSTR str;
HRESULT hres; HRESULT hres;
@ -163,6 +167,28 @@ static void test_disp(IDispatch *disp)
ok(hres == S_OK, "GetDispID(publicSub) failed: %08x\n", hres); ok(hres == S_OK, "GetDispID(publicSub) failed: %08x\n", hres);
ok(public_sub_id != -1, "public_func_id = -1\n"); ok(public_sub_id != -1, "public_func_id = -1\n");
dp.cArgs = dp.cNamedArgs = 0;
hres = IDispatchEx_InvokeEx(dispex, public_func_id, 0, DISPATCH_PROPERTYGET|DISPATCH_METHOD, &dp, &v, &ei, NULL);
ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
ok(V_VT(&v) == VT_I2, "V_VT(v) = %d\n", V_VT(&v));
ok(V_I2(&v) == 4, "V_I2(v) = %d\n", V_I2(&v));
dp.cArgs = dp.cNamedArgs = 0;
hres = IDispatchEx_InvokeEx(dispex, public_func_id, 0, DISPATCH_METHOD, &dp, &v, &ei, NULL);
ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
ok(V_VT(&v) == VT_I2, "V_VT(v) = %d\n", V_VT(&v));
ok(V_I2(&v) == 4, "V_I2(v) = %d\n", V_I2(&v));
dp.cArgs = dp.cNamedArgs = 0;
hres = IDispatchEx_InvokeEx(dispex, public_sub_id, 0, DISPATCH_PROPERTYGET|DISPATCH_METHOD, &dp, &v, &ei, NULL);
ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
ok(V_VT(&v) == VT_EMPTY, "V_VT(v) = %d\n", V_VT(&v));
dp.cArgs = dp.cNamedArgs = 0;
hres = IDispatchEx_InvokeEx(dispex, public_sub_id, 0, DISPATCH_METHOD, &dp, &v, &ei, NULL);
ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
ok(V_VT(&v) == VT_EMPTY, "V_VT(v) = %d\n", V_VT(&v));
str = a2bstr("privateSub"); str = a2bstr("privateSub");
hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseInsensitive, &id); hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseInsensitive, &id);
SysFreeString(str); SysFreeString(str);

View File

@ -22,6 +22,11 @@
WINE_DEFAULT_DEBUG_CHANNEL(vbscript); WINE_DEFAULT_DEBUG_CHANNEL(vbscript);
static inline BOOL is_func_id(vbdisp_t *This, DISPID id)
{
return id < This->desc->func_cnt;
}
static BOOL get_func_id(vbdisp_t *This, const WCHAR *name, BOOL search_private, DISPID *id) static BOOL get_func_id(vbdisp_t *This, const WCHAR *name, BOOL search_private, DISPID *id)
{ {
unsigned i; unsigned i;
@ -150,7 +155,35 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc
VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller) VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
{ {
vbdisp_t *This = impl_from_IDispatchEx(iface); vbdisp_t *This = impl_from_IDispatchEx(iface);
FIXME("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
if(pvarRes)
V_VT(pvarRes) = VT_EMPTY;
if(id < 0)
return DISP_E_MEMBERNOTFOUND;
if(is_func_id(This, id)) {
function_t *func;
switch(wFlags) {
case DISPATCH_METHOD:
case DISPATCH_METHOD|DISPATCH_PROPERTYGET:
func = This->desc->funcs[id].entries[VBDISP_CALLGET];
if(!func) {
FIXME("no invoke/getter\n");
return DISP_E_MEMBERNOTFOUND;
}
return exec_script(This->desc->ctx, func, pdp, pvarRes);
default:
FIXME("flags %x\n", wFlags);
return DISP_E_MEMBERNOTFOUND;
}
}
FIXME("not implemented for non-function ids\n");
return DISP_E_MEMBERNOTFOUND; return DISP_E_MEMBERNOTFOUND;
} }