Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com ---
This matches Windows behavior and allows us to test 'me' with named item script dispatches too.
dlls/vbscript/interp.c | 4 +--- dlls/vbscript/tests/run.c | 13 +++++++++++++ dlls/vbscript/tests/vbscript.c | 20 ++++++++++++++++++++ 3 files changed, 34 insertions(+), 3 deletions(-)
diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index 4f5e463..b0046cb 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -1494,9 +1494,7 @@ static HRESULT interp_retval(exec_ctx_t *ctx)
TRACE("\n");
- hres = stack_pop_val(ctx, &val); - if(FAILED(hres)) - return hres; + stack_pop_deref(ctx, &val);
if(val.owned) { VariantClear(&ctx->ret_val); diff --git a/dlls/vbscript/tests/run.c b/dlls/vbscript/tests/run.c index 8acf220..474fe1d 100644 --- a/dlls/vbscript/tests/run.c +++ b/dlls/vbscript/tests/run.c @@ -2685,6 +2685,7 @@ static void test_isexpression(void) { IActiveScriptParse *parser; IActiveScript *engine; + IDispatch *disp; SCRIPTSTATE ss; HRESULT hres; VARIANT var; @@ -2747,6 +2748,18 @@ static void test_isexpression(void) VariantClear(&var); SysFreeString(str);
+ /* Without a global host or named item context, "me" returns the script dispatch */ + hres = IActiveScript_GetScriptDispatch(engine, NULL, &disp); + ok(hres == S_OK, "GetScriptDispatch failed: %08x\n", hres); + str = a2bstr("me"); + hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &var, NULL); + ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres); + ok(V_VT(&var) == VT_DISPATCH, "Expected VT_DISPATCH, got %s\n", vt2a(&var)); + ok(V_DISPATCH(&var) == disp, "Wrong dispatch returned for 'me'\n"); + IDispatch_Release(disp); + VariantClear(&var); + SysFreeString(str); + /* An expression can also refer to a variable, function, class, etc previously set */ V_VT(&var) = VT_I2; str = a2bstr("If True Then foo = 42 Else foo = 0\n"); diff --git a/dlls/vbscript/tests/vbscript.c b/dlls/vbscript/tests/vbscript.c index ac458f1..19689b5 100644 --- a/dlls/vbscript/tests/vbscript.c +++ b/dlls/vbscript/tests/vbscript.c @@ -1767,6 +1767,7 @@ static void test_named_items(void) IActiveScriptParse *parse; IActiveScript *script; IDispatch *disp; + VARIANT var; unsigned i; DISPID id; ULONG ref; @@ -1981,6 +1982,25 @@ static void test_named_items(void) CHECK_CALLED(OnEnterScript); CHECK_CALLED(OnLeaveScript);
+ SET_EXPECT(OnEnterScript); + SET_EXPECT(OnLeaveScript); + hres = IActiveScriptParse_ParseScriptText(parse, L"me", NULL, 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) == &global_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); + SET_EXPECT(OnEnterScript); + SET_EXPECT(OnLeaveScript); + hres = IActiveScriptParse_ParseScriptText(parse, L"me", L"codeOnlyItem", 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_disp2, + "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_disp2); IDispatchEx_Release(script_disp);