scrobj: Create script hosts for scriptlet instance.

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:55:13 +02:00 committed by Alexandre Julliard
parent 55e01ac012
commit 03f89b60fa
2 changed files with 34 additions and 22 deletions

View File

@ -102,6 +102,7 @@ struct scriptlet_instance
{
IDispatchEx IDispatchEx_iface;
LONG ref;
struct list hosts;
};
struct script_host
@ -674,7 +675,10 @@ static ULONG WINAPI scriptlet_Release(IDispatchEx *iface)
TRACE("(%p) ref=%d\n", This, ref);
if (!ref)
{
detach_script_hosts(&This->hosts);
heap_free(This);
}
return ref;
}
@ -798,14 +802,29 @@ static IDispatchExVtbl DispatchExVtbl = {
scriptlet_GetNameSpaceParent
};
static HRESULT create_scriptlet_instance(IDispatchEx **disp)
static HRESULT create_scriptlet_instance(struct scriptlet_factory *factory, IDispatchEx **disp)
{
struct script_host *factory_host;
struct scriptlet_instance *obj;
HRESULT hres;
if (!(obj = heap_alloc(sizeof(*obj)))) return E_OUTOFMEMORY;
obj->IDispatchEx_iface.lpVtbl = &DispatchExVtbl;
obj->ref = 1;
list_init(&obj->hosts);
LIST_FOR_EACH_ENTRY(factory_host, &factory->hosts, struct script_host, entry)
{
hres = create_script_host(factory_host->language, factory_host->active_script, &obj->hosts);
if (FAILED(hres)) break;
}
if (FAILED(hres))
{
IDispatchEx_Release(&obj->IDispatchEx_iface);
return hres;
}
*disp = &obj->IDispatchEx_iface;
return S_OK;
@ -1295,7 +1314,20 @@ static HRESULT WINAPI scriptlet_factory_CreateInstance(IClassFactory *iface, IUn
if (outer) FIXME("outer not supported\n");
hres = create_scriptlet_instance(&disp);
if (list_empty(&This->hosts))
{
hres = create_scriptlet_hosts(This, &This->hosts);
if (FAILED(hres)) return hres;
hres = parse_scripts(This, &This->hosts, FALSE);
if (FAILED(hres))
{
detach_script_hosts(&This->hosts);
return hres;
}
}
hres = create_scriptlet_instance(This, &disp);
if (FAILED(hres)) return hres;
hres = IDispatchEx_QueryInterface(disp, riid, ppv);

View File

@ -778,15 +778,10 @@ static void test_create_object(void)
SET_EXPECT(Clone);
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);
@ -926,9 +921,7 @@ static void test_create_object(void)
todo_wine
SET_EXPECT(Close);
IUnknown_Release(unk);
todo_wine
CHECK_CALLED(SetScriptState_UNINITIALIZED);
todo_wine
CHECK_CALLED(Close);
parse_flags = SCRIPTTEXT_ISVISIBLE;
@ -947,15 +940,10 @@ 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);
@ -975,9 +963,7 @@ static void test_create_object(void)
SET_EXPECT(SetScriptState_UNINITIALIZED);
SET_EXPECT(Close);
IUnknown_Release(unk);
todo_wine
CHECK_CALLED(SetScriptState_UNINITIALIZED);
todo_wine
CHECK_CALLED(Close);
support_clone = TRUE;
@ -992,11 +978,8 @@ 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);
@ -1014,14 +997,11 @@ static void test_create_object(void)
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);
}