Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/vbscript/interp.c | 4 +++- dlls/vbscript/tests/vbscript.c | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index d50ef46..342b782 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -188,7 +188,9 @@ static HRESULT lookup_identifier(exec_ctx_t *ctx, BSTR name, vbdisp_invoke_type_ return S_OK; }
- if(ctx->func->code_ctx->named_item && ctx->func->code_ctx->named_item->disp) { + if(ctx->func->code_ctx->named_item && ctx->func->code_ctx->named_item->disp && + !(ctx->func->code_ctx->named_item->flags & SCRIPTITEM_CODEONLY)) + { hres = disp_get_id(ctx->func->code_ctx->named_item->disp, name, invoke_type, TRUE, &id); if(SUCCEEDED(hres)) { ref->type = REF_DISP; diff --git a/dlls/vbscript/tests/vbscript.c b/dlls/vbscript/tests/vbscript.c index a997a51..bdd85be 100644 --- a/dlls/vbscript/tests/vbscript.c +++ b/dlls/vbscript/tests/vbscript.c @@ -2038,6 +2038,13 @@ static void test_named_items(void) CHECK_CALLED(GetIDsOfNames_visible); CHECK_CALLED(OnLeaveScript);
+ SET_EXPECT(OnEnterScript); + SET_EXPECT(OnLeaveScript); + hres = IActiveScriptParse_ParseScriptText(parse, L"dim abc\ntestVar_global = 5\n", L"visibleCodeItem", NULL, NULL, 0, 0, 0, NULL, NULL); + ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres); + CHECK_CALLED(OnEnterScript); + CHECK_CALLED(OnLeaveScript); + SET_EXPECT(OnEnterScript); SET_EXPECT(OnLeaveScript); hres = IActiveScriptParse_ParseScriptText(parse, L"set global_me = me\n", L"globalItem", NULL, NULL, 0, 0, SCRIPTTEXT_ISPERSISTENT, NULL, NULL);
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/vbscript/tests/vbscript.c | 61 +++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-)
diff --git a/dlls/vbscript/tests/vbscript.c b/dlls/vbscript/tests/vbscript.c index bdd85be..ccf70ad 100644 --- a/dlls/vbscript/tests/vbscript.c +++ b/dlls/vbscript/tests/vbscript.c @@ -98,6 +98,7 @@ DEFINE_EXPECT(OnLeaveScript); DEFINE_EXPECT(OnScriptError); DEFINE_EXPECT(GetIDsOfNames); DEFINE_EXPECT(GetIDsOfNames_visible); +DEFINE_EXPECT(GetIDsOfNames_persistent); DEFINE_EXPECT(GetItemInfo_global); DEFINE_EXPECT(GetItemInfo_global_code); DEFINE_EXPECT(GetItemInfo_visible); @@ -232,6 +233,15 @@ static HRESULT WINAPI visible_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLE return DISP_E_UNKNOWNNAME; }
+static HRESULT WINAPI persistent_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *names, UINT name_cnt, + LCID lcid, DISPID *ids) +{ + ok(name_cnt == 1, "name_cnt = %u\n", name_cnt); + + CHECK_EXPECT2(GetIDsOfNames_persistent); + return DISP_E_UNKNOWNNAME; +} + static HRESULT WINAPI Dispatch_Invoke(IDispatch *iface, DISPID id, REFIID riid, LCID lcid, WORD flags, DISPPARAMS *dp, VARIANT *res, EXCEPINFO *ei, UINT *err) { @@ -297,7 +307,7 @@ static const IDispatchVtbl persistent_named_item_vtbl = { persistent_Release, Dispatch_GetTypeInfoCount, Dispatch_GetTypeInfo, - Dispatch_GetIDsOfNames, + persistent_GetIDsOfNames, Dispatch_Invoke };
@@ -2169,6 +2179,18 @@ static void test_named_items(void) IDispatchEx_Release(script_disp2); IDispatchEx_Release(script_disp);
+ script_disp = get_script_dispatch(script, L"persistent"); + SET_EXPECT(OnEnterScript); + SET_EXPECT(OnLeaveScript); + hres = IActiveScriptParse_ParseScriptText(parse, L"me", L"persistent", NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &var, NULL); + ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres); + ok(V_VT(&var) == VT_DISPATCH && V_DISPATCH(&var) == (IDispatch*)script_disp, + "Unexpected 'me': V_VT = %d, V_DISPATCH = %p\n", V_VT(&var), V_DISPATCH(&var)); + VariantClear(&var); + CHECK_CALLED(OnEnterScript); + CHECK_CALLED(OnLeaveScript); + IDispatchEx_Release(script_disp); + SET_EXPECT(OnEnterScript); SET_EXPECT(OnLeaveScript); hres = IActiveScriptParse_ParseScriptText(parse, L"x = 13\n", L"persistent", NULL, NULL, 0, 0, SCRIPTTEXT_ISPERSISTENT, NULL, NULL); @@ -2225,11 +2247,13 @@ static void test_named_items(void) SET_EXPECT(OnStateChange_CONNECTED); SET_EXPECT_MULTI(OnEnterScript, 5); SET_EXPECT_MULTI(OnLeaveScript, 5); + SET_EXPECT(GetIDsOfNames_persistent); hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_CONNECTED); ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_CONNECTED) failed: %08x\n", hres); CHECK_CALLED(OnStateChange_CONNECTED); CHECK_CALLED_MULTI(OnEnterScript, 5); CHECK_CALLED_MULTI(OnLeaveScript, 5); + todo_wine CHECK_CALLED(GetIDsOfNames_persistent); test_state(script, SCRIPTSTATE_CONNECTED);
script_disp2 = get_script_dispatch(script, L"persistent"); @@ -2244,6 +2268,41 @@ static void test_named_items(void) CHECK_CALLED(OnEnterScript); CHECK_CALLED(OnLeaveScript);
+ /* This object is set to named item when persistent items are re-initialized, even for CODEONLY items */ + SET_EXPECT(OnEnterScript); + SET_EXPECT(OnLeaveScript); + hres = IActiveScriptParse_ParseScriptText(parse, L"me", L"persistent", NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &var, NULL); + ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres); + todo_wine + ok(V_VT(&var) == VT_DISPATCH && V_DISPATCH(&var) == &persistent_named_item, + "Unexpected 'me': V_VT = %d, V_DISPATCH = %p\n", V_VT(&var), V_DISPATCH(&var)); + VariantClear(&var); + CHECK_CALLED(OnEnterScript); + CHECK_CALLED(OnLeaveScript); + + /* Lookups also query named items */ + SET_EXPECT(OnEnterScript); + SET_EXPECT(OnLeaveScript); + SET_EXPECT(GetIDsOfNames_persistent); + hres = IActiveScriptParse_ParseScriptText(parse, L"abc123 = 10\n", L"persistent", NULL, NULL, 0, 0, 0, NULL, NULL); + ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres); + CHECK_CALLED(OnEnterScript); + CHECK_CALLED(OnLeaveScript); + todo_wine + CHECK_CALLED(GetIDsOfNames_persistent); + + SET_EXPECT(OnEnterScript); + SET_EXPECT(OnLeaveScript); + SET_EXPECT(GetIDsOfNames_persistent); + SET_EXPECT(OnScriptError); + hres = IActiveScriptParse_ParseScriptText(parse, L"testCall\n", L"persistent", NULL, NULL, 0, 0, 0, NULL, NULL); + ok(FAILED(hres), "ParseScriptText returned: %08x\n", hres); + CHECK_CALLED(OnEnterScript); + CHECK_CALLED(OnLeaveScript); + todo_wine + CHECK_CALLED(GetIDsOfNames_persistent); + CHECK_CALLED(OnScriptError); + script_disp = get_script_dispatch(script, NULL); for (i = 0; i < ARRAY_SIZE(global_idents); i++) {
Signed-off-by: Jacek Caban jacek@codeweavers.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/vbscript/tests/vbscript.c | 5 +---- dlls/vbscript/vbscript.c | 3 +++ 2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/dlls/vbscript/tests/vbscript.c b/dlls/vbscript/tests/vbscript.c index ccf70ad..04e7545 100644 --- a/dlls/vbscript/tests/vbscript.c +++ b/dlls/vbscript/tests/vbscript.c @@ -2253,7 +2253,7 @@ static void test_named_items(void) CHECK_CALLED(OnStateChange_CONNECTED); CHECK_CALLED_MULTI(OnEnterScript, 5); CHECK_CALLED_MULTI(OnLeaveScript, 5); - todo_wine CHECK_CALLED(GetIDsOfNames_persistent); + CHECK_CALLED(GetIDsOfNames_persistent); test_state(script, SCRIPTSTATE_CONNECTED);
script_disp2 = get_script_dispatch(script, L"persistent"); @@ -2273,7 +2273,6 @@ static void test_named_items(void) SET_EXPECT(OnLeaveScript); hres = IActiveScriptParse_ParseScriptText(parse, L"me", L"persistent", NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &var, NULL); ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres); - todo_wine ok(V_VT(&var) == VT_DISPATCH && V_DISPATCH(&var) == &persistent_named_item, "Unexpected 'me': V_VT = %d, V_DISPATCH = %p\n", V_VT(&var), V_DISPATCH(&var)); VariantClear(&var); @@ -2288,7 +2287,6 @@ static void test_named_items(void) ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres); CHECK_CALLED(OnEnterScript); CHECK_CALLED(OnLeaveScript); - todo_wine CHECK_CALLED(GetIDsOfNames_persistent);
SET_EXPECT(OnEnterScript); @@ -2299,7 +2297,6 @@ static void test_named_items(void) ok(FAILED(hres), "ParseScriptText returned: %08x\n", hres); CHECK_CALLED(OnEnterScript); CHECK_CALLED(OnLeaveScript); - todo_wine CHECK_CALLED(GetIDsOfNames_persistent); CHECK_CALLED(OnScriptError);
diff --git a/dlls/vbscript/vbscript.c b/dlls/vbscript/vbscript.c index 858cacb..f31bdf2 100644 --- a/dlls/vbscript/vbscript.c +++ b/dlls/vbscript/vbscript.c @@ -579,6 +579,9 @@ static HRESULT WINAPI VBScript_SetScriptSite(IActiveScript *iface, IActiveScript hres = retrieve_named_item_disp(pass, item); if(FAILED(hres)) return hres; } + + /* For some reason, CODEONLY flag is lost in re-initialized scripts */ + item->flags &= ~SCRIPTITEM_CODEONLY; }
hres = create_script_disp(This->ctx, &This->ctx->script_obj);
Signed-off-by: Jacek Caban jacek@codeweavers.com