From: Jacek Caban Subject: [PATCH 1/9] vbscript: Use global object property to expose Err object. Message-Id: <7a75f0a1-df9d-b23b-dbaf-1cce27352c4e@codeweavers.com> Date: Fri, 18 Oct 2019 16:20:03 +0200 Signed-off-by: Jacek Caban --- dlls/vbscript/global.c | 16 ++++++++++++++++ dlls/vbscript/interp.c | 8 -------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/dlls/vbscript/global.c b/dlls/vbscript/global.c index 50f54f38a6..0f85f66bad 100644 --- a/dlls/vbscript/global.c +++ b/dlls/vbscript/global.c @@ -2486,6 +2486,21 @@ static HRESULT Global_GetRef(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, return E_NOTIMPL; } +static HRESULT Global_Err(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res) +{ + TRACE("\n"); + + if(args_cnt) { + FIXME("Setter not supported\n"); + return E_NOTIMPL; + } + + V_VT(res) = VT_DISPATCH; + V_DISPATCH(res) = &This->ctx->err_obj->IDispatch_iface; + IDispatch_AddRef(V_DISPATCH(res)); + return S_OK; +} + static const string_constant_t vbCr = {1, {'\r'}}; static const string_constant_t vbCrLf = {2, {'\r','\n'}}; static const string_constant_t vbNewLine = {2, {'\r','\n'}}; @@ -2526,6 +2541,7 @@ static const builtin_prop_t global_props[] = { {L"DateValue", Global_DateValue, 0, 1}, {L"Day", Global_Day, 0, 1}, {L"Erase", Global_Erase, 0, 1}, + {L"Err", Global_Err, BP_GETPUT}, {L"Escape", Global_Escape, 0, 1}, {L"Eval", Global_Eval, 0, 1}, {L"Execute", Global_Execute, 0, 1}, diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index 45dcb45303..251fd785cf 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -104,8 +104,6 @@ static HRESULT lookup_identifier(exec_ctx_t *ctx, BSTR name, vbdisp_invoke_type_ DISPID id; HRESULT hres; - static const WCHAR errW[] = {'e','r','r',0}; - if(invoke_type == VBDISP_LET && (ctx->func->type == FUNC_FUNCTION || ctx->func->type == FUNC_PROPGET || ctx->func->type == FUNC_DEFGET) && !wcsicmp(name, ctx->func->name)) { @@ -175,12 +173,6 @@ static HRESULT lookup_identifier(exec_ctx_t *ctx, BSTR name, vbdisp_invoke_type_ } } - if(!wcsicmp(name, errW)) { - ref->type = REF_OBJ; - ref->u.obj = &ctx->script->err_obj->IDispatch_iface; - return S_OK; - } - hres = get_builtin_id(ctx->script->global_obj, name, &id); if(SUCCEEDED(hres)) { ref->type = REF_DISP;