vbscript: Added error object stub implementation.

This commit is contained in:
Jacek Caban 2011-09-19 14:09:21 +02:00 committed by Alexandre Julliard
parent 32a7a81257
commit 13d8e7b853
7 changed files with 73 additions and 2 deletions

View File

@ -3,6 +3,7 @@ IMPORTS = oleaut32
C_SRCS = \ C_SRCS = \
compile.c \ compile.c \
error.c \
global.c \ global.c \
interp.c \ interp.c \
lex.c \ lex.c \

37
dlls/vbscript/error.c Normal file
View File

@ -0,0 +1,37 @@
/*
* Copyright 2011 Jacek Caban for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "vbscript.h"
#include "vbscript_defs.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(vbscript);
HRESULT init_err(script_ctx_t *ctx)
{
HRESULT hres;
ctx->err_desc.ctx = ctx;
hres = get_typeinfo(ErrObj_tid, &ctx->err_desc.typeinfo);
if(FAILED(hres))
return hres;
return create_vbdisp(&ctx->err_desc, &ctx->err_obj);
}

View File

@ -1399,5 +1399,5 @@ HRESULT init_global(script_ctx_t *ctx)
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
return S_OK; return init_err(ctx);
} }

View File

@ -48,6 +48,7 @@ typedef enum {
REF_NONE, REF_NONE,
REF_DISP, REF_DISP,
REF_VAR, REF_VAR,
REF_OBJ,
REF_FUNC REF_FUNC
} ref_type_t; } ref_type_t;
@ -60,6 +61,7 @@ typedef struct {
} d; } d;
VARIANT *v; VARIANT *v;
function_t *f; function_t *f;
IDispatch *obj;
} u; } u;
} ref_t; } ref_t;
@ -92,6 +94,8 @@ static HRESULT lookup_identifier(exec_ctx_t *ctx, BSTR name, vbdisp_invoke_type_
DISPID id; DISPID id;
HRESULT hres; HRESULT hres;
static const WCHAR errW[] = {'e','r','r',0};
if(invoke_type == VBDISP_LET if(invoke_type == VBDISP_LET
&& (ctx->func->type == FUNC_FUNCTION || ctx->func->type == FUNC_PROPGET || ctx->func->type == FUNC_DEFGET) && (ctx->func->type == FUNC_FUNCTION || ctx->func->type == FUNC_PROPGET || ctx->func->type == FUNC_DEFGET)
&& !strcmpiW(name, ctx->func->name)) { && !strcmpiW(name, ctx->func->name)) {
@ -147,6 +151,12 @@ static HRESULT lookup_identifier(exec_ctx_t *ctx, BSTR name, vbdisp_invoke_type_
} }
} }
if(!strcmpiW(name, errW)) {
ref->type = REF_OBJ;
ref->u.obj = (IDispatch*)&ctx->script->err_obj->IDispatchEx_iface;
return S_OK;
}
hres = vbdisp_get_id(ctx->script->global_obj, name, invoke_type, TRUE, &id); hres = vbdisp_get_id(ctx->script->global_obj, name, invoke_type, TRUE, &id);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
ref->type = REF_DISP; ref->type = REF_DISP;
@ -291,8 +301,8 @@ static HRESULT do_icall(exec_ctx_t *ctx, VARIANT *res)
{ {
BSTR identifier = ctx->instr->arg1.bstr; BSTR identifier = ctx->instr->arg1.bstr;
const unsigned arg_cnt = ctx->instr->arg2.uint; const unsigned arg_cnt = ctx->instr->arg2.uint;
ref_t ref = {0};
DISPPARAMS dp; DISPPARAMS dp;
ref_t ref;
HRESULT hres; HRESULT hres;
hres = lookup_identifier(ctx, identifier, VBDISP_CALLGET, &ref); hres = lookup_identifier(ctx, identifier, VBDISP_CALLGET, &ref);
@ -326,6 +336,18 @@ static HRESULT do_icall(exec_ctx_t *ctx, VARIANT *res)
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
break; break;
case REF_OBJ:
if(arg_cnt) {
FIXME("arguments on object\n");
return E_NOTIMPL;
}
if(res) {
IDispatch_AddRef(ref.u.obj);
V_VT(res) = VT_DISPATCH;
V_DISPATCH(res) = ref.u.obj;
}
break;
case REF_NONE: case REF_NONE:
FIXME("%s not found\n", debugstr_w(identifier)); FIXME("%s not found\n", debugstr_w(identifier));
return DISP_E_UNKNOWNNAME; return DISP_E_UNKNOWNNAME;
@ -440,6 +462,9 @@ static HRESULT assign_ident(exec_ctx_t *ctx, BSTR name, VARIANT *val, BOOL own_v
case REF_FUNC: case REF_FUNC:
FIXME("functions not implemented\n"); FIXME("functions not implemented\n");
return E_NOTIMPL; return E_NOTIMPL;
case REF_OBJ:
FIXME("REF_OBJ\n");
return E_NOTIMPL;
case REF_NONE: case REF_NONE:
FIXME("%s not found\n", debugstr_w(name)); FIXME("%s not found\n", debugstr_w(name));
if(own_val) if(own_val)

View File

@ -32,4 +32,6 @@ Call ok(not isObject(4), "isObject(4) is true?")
Call ok(not isObject("x"), "isObject(""x"") is true?") Call ok(not isObject("x"), "isObject(""x"") is true?")
Call ok(not isObject(Null), "isObject(Null) is true?") Call ok(not isObject(Null), "isObject(Null) is true?")
Call ok(getVT(err) = "VT_DISPATCH", "getVT(err) = " & getVT(err))
Call reportSuccess() Call reportSuccess()

View File

@ -131,6 +131,8 @@ static void destroy_script(script_ctx_t *ctx)
IDispatch_Release(ctx->host_global); IDispatch_Release(ctx->host_global);
if(ctx->site) if(ctx->site)
IActiveScriptSite_Release(ctx->site); IActiveScriptSite_Release(ctx->site);
if(ctx->err_obj)
IDispatchEx_Release(&ctx->err_obj->IDispatchEx_iface);
if(ctx->global_obj) if(ctx->global_obj)
IDispatchEx_Release(&ctx->global_obj->IDispatchEx_iface); IDispatchEx_Release(&ctx->global_obj->IDispatchEx_iface);
if(ctx->script_obj) if(ctx->script_obj)

View File

@ -150,6 +150,9 @@ struct _script_ctx_t {
class_desc_t global_desc; class_desc_t global_desc;
vbdisp_t *global_obj; vbdisp_t *global_obj;
class_desc_t err_desc;
vbdisp_t *err_obj;
dynamic_var_t *global_vars; dynamic_var_t *global_vars;
function_t *global_funcs; function_t *global_funcs;
class_desc_t *classes; class_desc_t *classes;
@ -160,6 +163,7 @@ struct _script_ctx_t {
}; };
HRESULT init_global(script_ctx_t*); HRESULT init_global(script_ctx_t*);
HRESULT init_err(script_ctx_t*);
typedef enum { typedef enum {
ARG_NONE = 0, ARG_NONE = 0,