Commit 0809a285 authored by Gabriel Ivăncescu's avatar Gabriel Ivăncescu Committed by Alexandre Julliard

vbscript: Return the dispatch object directly in retval, rather than its value.

parent 553cb05b
......@@ -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);
......
......@@ -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");
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment