From 03f89b60facaa59ad4532b902b304743140c0597 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Mon, 23 Sep 2019 17:55:13 +0200 Subject: [PATCH] scrobj: Create script hosts for scriptlet instance. Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- dlls/scrobj/scrobj.c | 36 ++++++++++++++++++++++++++++++++++-- dlls/scrobj/tests/scrobj.c | 20 -------------------- 2 files changed, 34 insertions(+), 22 deletions(-) diff --git a/dlls/scrobj/scrobj.c b/dlls/scrobj/scrobj.c index 6b3b3ea6e87..251507ecf55 100644 --- a/dlls/scrobj/scrobj.c +++ b/dlls/scrobj/scrobj.c @@ -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); diff --git a/dlls/scrobj/tests/scrobj.c b/dlls/scrobj/tests/scrobj.c index f968fe21ce5..ef80dfb7d4d 100644 --- a/dlls/scrobj/tests/scrobj.c +++ b/dlls/scrobj/tests/scrobj.c @@ -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); }