[PATCH 0/1] MR10387: vbscript: Invoke default property when calling object variable with empty parens.
When a variable holding a dispatch object is called with empty parentheses (e.g. x()), invoke the object's default property (DISPID_VALUE) instead of returning the dispatch object by reference. This matches the behavior of Windows VBScript. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10387
From: Francis De Brabandere <francisdb@gmail.com> When a variable holding a dispatch object is called with empty parentheses (e.g. x()), invoke the object's default property (DISPID_VALUE) instead of returning the dispatch object by reference. This matches the behavior of Windows VBScript. --- dlls/vbscript/interp.c | 26 ++++++++++++++++++++++---- dlls/vbscript/tests/lang.vbs | 2 +- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index 127fcc2c05e..14958c3a6da 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -610,7 +610,7 @@ static HRESULT variant_call(exec_ctx_t *ctx, VARIANT *v, unsigned arg_cnt, VARIA return S_OK; } -static HRESULT do_icall(exec_ctx_t *ctx, VARIANT *res, BSTR identifier, unsigned arg_cnt) +static HRESULT do_icall(exec_ctx_t *ctx, VARIANT *res, BSTR identifier, unsigned arg_cnt, BOOL is_call) { DISPPARAMS dp; ref_t ref; @@ -628,6 +628,24 @@ static HRESULT do_icall(exec_ctx_t *ctx, VARIANT *res, BSTR identifier, unsigned if(arg_cnt) return variant_call(ctx, ref.u.v, arg_cnt, res); + if(is_call) { + VARIANT *v; + + v = V_VT(ref.u.v) == (VT_VARIANT|VT_BYREF) ? V_VARIANTREF(ref.u.v) : ref.u.v; + if(V_VT(v) == VT_DISPATCH) { + VARIANT result; + V_VT(&result) = VT_EMPTY; + hres = get_disp_value(ctx->script, V_DISPATCH(v), &result); + if(FAILED(hres)) + return hres; + if(res) + *res = result; + else + VariantClear(&result); + break; + } + } + if(!res) { FIXME("REF_VAR no res\n"); return E_NOTIMPL; @@ -687,7 +705,7 @@ static HRESULT interp_icall(exec_ctx_t *ctx) TRACE("\n"); - hres = do_icall(ctx, &v, identifier, arg_cnt); + hres = do_icall(ctx, &v, identifier, arg_cnt, TRUE); if(FAILED(hres)) return hres; @@ -701,7 +719,7 @@ static HRESULT interp_icallv(exec_ctx_t *ctx) TRACE("\n"); - return do_icall(ctx, NULL, identifier, arg_cnt); + return do_icall(ctx, NULL, identifier, arg_cnt, TRUE); } static HRESULT interp_vcall(exec_ctx_t *ctx) @@ -802,7 +820,7 @@ static HRESULT interp_ident(exec_ctx_t *ctx) return stack_push(ctx, &v); } - hres = do_icall(ctx, &v, identifier, 0); + hres = do_icall(ctx, &v, identifier, 0, FALSE); if(FAILED(hres)) return hres; diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index c364f12c00b..df14d5f2da8 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -2154,7 +2154,7 @@ set x.getprop.getprop().prop = obj call ok(x.getprop.getprop().prop is obj, "x.getprop.getprop().prop is not obj (emptyclass)") ok getVT(x) = "VT_DISPATCH*", "getVT(x) = " & getVT(x) -todo_wine_ok getVT(x()) = "VT_BSTR", "getVT(x()) = " & getVT(x()) +ok getVT(x()) = "VT_BSTR", "getVT(x()) = " & getVT(x()) Class TestClassVariablesMulti Public pub1, pub2 -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10387
This merge request was approved by Jacek Caban. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10387
participants (3)
-
Francis De Brabandere -
Francis De Brabandere (@francisdb) -
Jacek Caban (@jacek)