vbscript: Use global object property to expose Err object.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2019-10-18 16:20:03 +02:00 committed by Alexandre Julliard
parent 2ef00173e1
commit 087adea7dc
2 changed files with 16 additions and 8 deletions

View File

@ -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},

View File

@ -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;