scrobj: Add scriptlet instance stub implementation.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2019-09-23 17:54:53 +02:00 committed by Alexandre Julliard
parent 98b230f851
commit 4d368c3dab
2 changed files with 259 additions and 7 deletions

View File

@ -26,6 +26,7 @@
#include "olectl.h"
#include "rpcproxy.h"
#include "activscp.h"
#include "dispex.h"
#include "mshtmhst.h"
#include "initguid.h"
@ -97,6 +98,12 @@ struct scriptlet_factory
struct list scripts;
};
struct scriptlet_instance
{
IDispatchEx IDispatchEx_iface;
LONG ref;
};
struct script_host
{
IActiveScriptSite IActiveScriptSite_iface;
@ -557,6 +564,197 @@ static HRESULT create_scriptlet_hosts(struct scriptlet_factory *factory, struct
return hres;
}
}
return S_OK;
}
static inline struct scriptlet_instance *impl_from_IDispatchEx(IDispatchEx *iface)
{
return CONTAINING_RECORD(iface, struct scriptlet_instance, IDispatchEx_iface);
}
static HRESULT WINAPI scriptlet_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
{
struct scriptlet_instance *This = impl_from_IDispatchEx(iface);
if (IsEqualGUID(&IID_IUnknown, riid))
{
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
*ppv = &This->IDispatchEx_iface;
}
else if (IsEqualGUID(&IID_IDispatch, riid))
{
TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
*ppv = &This->IDispatchEx_iface;
}
else if (IsEqualGUID(&IID_IDispatchEx, riid))
{
TRACE("(%p)->(IID_IDispatchEx %p)\n", This, ppv);
*ppv = &This->IDispatchEx_iface;
}
else
{
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
*ppv = NULL;
return E_NOINTERFACE;
}
IUnknown_AddRef((IUnknown*)*ppv);
return S_OK;
}
static ULONG WINAPI scriptlet_AddRef(IDispatchEx *iface)
{
struct scriptlet_instance *This = impl_from_IDispatchEx(iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) ref=%d\n", This, ref);
return ref;
}
static ULONG WINAPI scriptlet_Release(IDispatchEx *iface)
{
struct scriptlet_instance *This = impl_from_IDispatchEx(iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) ref=%d\n", This, ref);
if (!ref)
heap_free(This);
return ref;
}
static HRESULT WINAPI scriptlet_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
{
struct scriptlet_instance *This = impl_from_IDispatchEx(iface);
FIXME("(%p)->(%p)\n", This, pctinfo);
return E_NOTIMPL;
}
static HRESULT WINAPI scriptlet_GetTypeInfo(IDispatchEx *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
{
struct scriptlet_instance *This = impl_from_IDispatchEx(iface);
FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
return E_NOTIMPL;
}
static HRESULT WINAPI scriptlet_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
{
struct scriptlet_instance *This = impl_from_IDispatchEx(iface);
UINT i;
HRESULT hres;
TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
lcid, rgDispId);
for(i=0; i < cNames; i++)
{
hres = IDispatchEx_GetDispID(&This->IDispatchEx_iface, rgszNames[i], 0, rgDispId + i);
if(FAILED(hres))
return hres;
}
return S_OK;
}
static HRESULT WINAPI scriptlet_Invoke(IDispatchEx *iface, DISPID dispIdMember,
REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
struct scriptlet_instance *This = impl_from_IDispatchEx(iface);
TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
return IDispatchEx_InvokeEx(&This->IDispatchEx_iface, dispIdMember, lcid, wFlags,
pDispParams, pVarResult, pExcepInfo, NULL);
}
static HRESULT WINAPI scriptlet_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
{
struct scriptlet_instance *This = impl_from_IDispatchEx(iface);
FIXME("(%p)->(%s %x %p)\n", This, debugstr_w(bstrName), grfdex, pid);
return E_NOTIMPL;
}
static HRESULT WINAPI scriptlet_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD flags, DISPPARAMS *pdp,
VARIANT *res, EXCEPINFO *pei, IServiceProvider *caller)
{
struct scriptlet_instance *This = impl_from_IDispatchEx(iface);
FIXME("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, flags, pdp, res, pei, caller);
return DISP_E_MEMBERNOTFOUND;
}
static HRESULT WINAPI scriptlet_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
{
struct scriptlet_instance *This = impl_from_IDispatchEx(iface);
FIXME("(%p)->(%s %x)\n", This, debugstr_w(bstrName), grfdex);
return E_NOTIMPL;
}
static HRESULT WINAPI scriptlet_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
{
struct scriptlet_instance *This = impl_from_IDispatchEx(iface);
FIXME("(%p)->(%x)\n", This, id);
return E_NOTIMPL;
}
static HRESULT WINAPI scriptlet_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
{
struct scriptlet_instance *This = impl_from_IDispatchEx(iface);
FIXME("(%p)->(%x %x %p)\n", This, id, grfdexFetch, pgrfdex);
return E_NOTIMPL;
}
static HRESULT WINAPI scriptlet_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
{
struct scriptlet_instance *This = impl_from_IDispatchEx(iface);
FIXME("(%p)->(%x %p)\n", This, id, pbstrName);
return E_NOTIMPL;
}
static HRESULT WINAPI scriptlet_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
{
struct scriptlet_instance *This = impl_from_IDispatchEx(iface);
FIXME("(%p)->(%x %x %p)\n", This, grfdex, id, pid);
return E_NOTIMPL;
}
static HRESULT WINAPI scriptlet_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
{
struct scriptlet_instance *This = impl_from_IDispatchEx(iface);
FIXME("(%p)->(%p)\n", This, ppunk);
return E_NOTIMPL;
}
static IDispatchExVtbl DispatchExVtbl = {
scriptlet_QueryInterface,
scriptlet_AddRef,
scriptlet_Release,
scriptlet_GetTypeInfoCount,
scriptlet_GetTypeInfo,
scriptlet_GetIDsOfNames,
scriptlet_Invoke,
scriptlet_GetDispID,
scriptlet_InvokeEx,
scriptlet_DeleteMemberByName,
scriptlet_DeleteMemberByDispID,
scriptlet_GetMemberProperties,
scriptlet_GetMemberName,
scriptlet_GetNextDispID,
scriptlet_GetNameSpaceParent
};
static HRESULT create_scriptlet_instance(IDispatchEx **disp)
{
struct scriptlet_instance *obj;
if (!(obj = heap_alloc(sizeof(*obj)))) return E_OUTOFMEMORY;
obj->IDispatchEx_iface.lpVtbl = &DispatchExVtbl;
obj->ref = 1;
*disp = &obj->IDispatchEx_iface;
return S_OK;
}
@ -1037,8 +1235,19 @@ static ULONG WINAPI scriptlet_factory_Release(IClassFactory *iface)
static HRESULT WINAPI scriptlet_factory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
{
struct scriptlet_factory *This = impl_from_IClassFactory(iface);
FIXME("(%p)->(%p %s %p)\n", This, outer, debugstr_guid(riid), ppv);
return E_NOTIMPL;
IDispatchEx *disp;
HRESULT hres;
TRACE("(%p)->(%p %s %p)\n", This, outer, debugstr_guid(riid), ppv);
if (outer) FIXME("outer not supported\n");
hres = create_scriptlet_instance(&disp);
if (FAILED(hres)) return hres;
hres = IDispatchEx_QueryInterface(disp, riid, ppv);
IDispatchEx_Release(disp);
return hres;
}
static HRESULT WINAPI scriptlet_factory_LockServer(IClassFactory *iface, BOOL fLock)

View File

@ -726,8 +726,6 @@ static void register_script_object(BOOL do_register, const WCHAR *file_name)
CHECK_CALLED(SetScriptState_UNINITIALIZED);
CHECK_CALLED(Close);
ok(hres == S_OK, "DllInstall failed: %08x\n", hres);
if (FAILED(hres))
return;
if (do_register)
{
@ -781,7 +779,6 @@ static void test_create_object(void)
SET_EXPECT(SetScriptState_UNINITIALIZED);
SET_EXPECT(Clone);
hres = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (void**)&unk);
todo_wine
ok(hres == S_OK, "Could not create scriptlet instance: %08x\n", hres);
todo_wine
CHECK_CALLED(Clone);
@ -807,8 +804,6 @@ static void test_create_object(void)
CHECK_CALLED(SetScriptState_STARTED);
todo_wine
CHECK_CALLED(ParseScriptText);
if (FAILED(hres))
return;
hres = IUnknown_QueryInterface(unk, &IID_IDispatch, (void**)&disp);
ok(hres == S_OK, "Could not get IDispatch iface: %08x\n", hres);
@ -820,32 +815,39 @@ static void test_create_object(void)
str = SysAllocString(L"vbAddOne");
hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseSensitive, &vb_add_one_id);
todo_wine
ok(hres == S_OK, "Could not get vkAddOne id: %08x\n", hres);
SysFreeString(str);
str = SysAllocString(L"jsAddTwo");
hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseSensitive, &js_add_two_id);
todo_wine
ok(hres == S_OK, "Could not get jsAddTwo id: %08x\n", hres);
SysFreeString(str);
str = SysAllocString(L"wtTest");
hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseSensitive, &wt_test_id);
todo_wine
ok(hres == S_OK, "Could not get wtTest id: %08x\n", hres);
SysFreeString(str);
str = SysAllocString(L"vbaddone");
hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseSensitive, &id);
todo_wine
ok(hres == DISP_E_UNKNOWNNAME, "invalid case returned: %08x\n", hres);
SysFreeString(str);
str = SysAllocString(L"vbaddone");
hres = IDispatchEx_GetDispID(dispex, str, 0, &id);
todo_wine
ok(hres == DISP_E_UNKNOWNNAME, "invalid case returned: %08x\n", hres);
SysFreeString(str);
str = SysAllocString(L"vbaddone");
hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseInsensitive, &id);
todo_wine
ok(hres == S_OK, "case insensitive returned: %08x\n", hres);
todo_wine
ok(id == vb_add_one_id, "id = %u, expected %u\n", id, vb_add_one_id);
SysFreeString(str);
@ -857,8 +859,11 @@ static void test_create_object(void)
dp.cArgs = 1;
dp.rgvarg = &v;
hres = IDispatchEx_InvokeEx(dispex, vb_add_one_id, 0, DISPATCH_PROPERTYGET|DISPATCH_METHOD, &dp, &r, &ei, NULL);
todo_wine
ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
todo_wine
ok(V_VT(&r) == VT_I4, "V_VT(r) = %d\n", V_VT(&r));
todo_wine
ok(V_I4(&r) == 3, "V_I4(r) = %d\n", V_I4(&r));
memset(&ei, 0, sizeof(ei));
@ -869,8 +874,11 @@ static void test_create_object(void)
dp.cArgs = 1;
dp.rgvarg = &v;
hres = IDispatchEx_InvokeEx(dispex, js_add_two_id, 0, DISPATCH_PROPERTYGET|DISPATCH_METHOD, &dp, &r, &ei, NULL);
todo_wine
ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
todo_wine
ok(V_VT(&r) == VT_I4, "V_VT(r) = %d\n", V_VT(&r));
todo_wine
ok(V_I4(&r) == 6, "V_I4(r) = %d\n", V_I4(&r));
memset(&ei, 0, sizeof(ei));
@ -882,9 +890,13 @@ static void test_create_object(void)
dp.rgvarg = &v;
SET_EXPECT(InvokeEx);
hres = IDispatchEx_InvokeEx(dispex, wt_test_id, 0x100, DISPATCH_PROPERTYGET|DISPATCH_METHOD, &dp, &r, &ei, (void*)0xdeadbeef);
todo_wine
ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
todo_wine
CHECK_CALLED(InvokeEx);
todo_wine
ok(V_VT(&r) == VT_BOOL, "V_VT(r) = %d\n", V_VT(&r));
todo_wine
ok(V_BOOL(&r) == VARIANT_TRUE, "V_I4(r) = %d\n", V_I4(&r));
memset(&ei, 0, sizeof(ei));
@ -892,9 +904,13 @@ static void test_create_object(void)
V_VT(&r) = VT_ERROR;
SET_EXPECT(InvokeEx);
hres = IDispatchEx_InvokeEx(dispex, wt_test_id, 0x100, DISPATCH_METHOD, &dp, &r, &ei, (void*)0xdeadbeef);
todo_wine
ok(hres == S_OK, "InvokeEx failed: %08x\n", hres);
todo_wine
CHECK_CALLED(InvokeEx);
todo_wine
ok(V_VT(&r) == VT_BOOL, "V_VT(r) = %d\n", V_VT(&r));
todo_wine
ok(V_BOOL(&r) == VARIANT_TRUE, "V_I4(r) = %d\n", V_I4(&r));
hres = IDispatchEx_InvokeEx(dispex, wt_test_id, 0x100, DISPATCH_PROPERTYGET, &dp, &r, &ei, (void*)0xdeadbeef);
@ -909,9 +925,12 @@ static void test_create_object(void)
IDispatchEx_Release(dispex);
SET_EXPECT(SetScriptState_UNINITIALIZED);
todo_wine
SET_EXPECT(Close);
IUnknown_Release(unk);
todo_wine
CHECK_CALLED(SetScriptState_UNINITIALIZED);
todo_wine
CHECK_CALLED(Close);
parse_flags = SCRIPTTEXT_ISVISIBLE;
@ -930,24 +949,37 @@ static void test_create_object(void)
SET_EXPECT(ParseScriptText);
hres = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (void**)&unk);
ok(hres == S_OK, "Could not create scriptlet instance: %08x\n", hres);
todo_wine
CHECK_CALLED(Clone);
todo_wine
CHECK_CALLED(CreateInstance);
todo_wine
CHECK_CALLED(QI_IActiveScriptParse);
todo_wine
CHECK_CALLED(InitNew);
todo_wine
CHECK_CALLED(SetScriptSite);
todo_wine
CHECK_CALLED(AddNamedItem_scriptlet);
todo_wine
CHECK_CALLED(AddNamedItem_globals);
todo_wine
CHECK_CALLED(GetScriptDispatch);
todo_wine
CHECK_CALLED(GetDispID_vbAddOne);
todo_wine
CHECK_CALLED(GetDispID_wtTest);
todo_wine
CHECK_CALLED(SetScriptState_STARTED);
todo_wine
CHECK_CALLED(ParseScriptText);
SET_EXPECT(SetScriptState_UNINITIALIZED);
SET_EXPECT(Close);
IUnknown_Release(unk);
todo_wine
CHECK_CALLED(SetScriptState_UNINITIALIZED);
todo_wine
CHECK_CALLED(Close);
support_clone = TRUE;
@ -962,25 +994,36 @@ static void test_create_object(void)
SET_EXPECT(SetScriptState_STARTED);
hres = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (void**)&unk);
ok(hres == S_OK, "Could not create scriptlet instance: %08x\n", hres);
todo_wine
CHECK_CALLED(Clone);
todo_wine
CHECK_CALLED(QI_IActiveScriptParse);
todo_wine
CHECK_CALLED(SetScriptSite);
todo_wine
CHECK_CALLED(AddNamedItem_scriptlet);
todo_wine
CHECK_CALLED(AddNamedItem_globals);
todo_wine
CHECK_CALLED(GetScriptDispatch);
todo_wine
CHECK_CALLED(GetDispID_vbAddOne);
todo_wine
CHECK_CALLED(GetDispID_wtTest);
todo_wine
CHECK_CALLED(SetScriptState_STARTED);
SET_EXPECT(SetScriptState_UNINITIALIZED);
SET_EXPECT(Close);
IUnknown_Release(unk);
todo_wine
CHECK_CALLED(SetScriptState_UNINITIALIZED);
todo_wine
CHECK_CALLED(Close);
SET_EXPECT(Close);
IClassFactory_Release(cf);
todo_wine
CHECK_CALLED(Close);
}