Commit 13d8e7b8 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

vbscript: Added error object stub implementation.

parent 32a7a812
......@@ -3,6 +3,7 @@ IMPORTS = oleaut32
C_SRCS = \
compile.c \
error.c \
global.c \
interp.c \
lex.c \
......
/*
* 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);
}
......@@ -1399,5 +1399,5 @@ HRESULT init_global(script_ctx_t *ctx)
if(FAILED(hres))
return hres;
return S_OK;
return init_err(ctx);
}
......@@ -48,6 +48,7 @@ typedef enum {
REF_NONE,
REF_DISP,
REF_VAR,
REF_OBJ,
REF_FUNC
} ref_type_t;
......@@ -60,6 +61,7 @@ typedef struct {
} d;
VARIANT *v;
function_t *f;
IDispatch *obj;
} u;
} ref_t;
......@@ -92,6 +94,8 @@ 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)
&& !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);
if(SUCCEEDED(hres)) {
ref->type = REF_DISP;
......@@ -291,8 +301,8 @@ static HRESULT do_icall(exec_ctx_t *ctx, VARIANT *res)
{
BSTR identifier = ctx->instr->arg1.bstr;
const unsigned arg_cnt = ctx->instr->arg2.uint;
ref_t ref = {0};
DISPPARAMS dp;
ref_t ref;
HRESULT hres;
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))
return hres;
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:
FIXME("%s not found\n", debugstr_w(identifier));
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:
FIXME("functions not implemented\n");
return E_NOTIMPL;
case REF_OBJ:
FIXME("REF_OBJ\n");
return E_NOTIMPL;
case REF_NONE:
FIXME("%s not found\n", debugstr_w(name));
if(own_val)
......
......@@ -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(Null), "isObject(Null) is true?")
Call ok(getVT(err) = "VT_DISPATCH", "getVT(err) = " & getVT(err))
Call reportSuccess()
......@@ -131,6 +131,8 @@ static void destroy_script(script_ctx_t *ctx)
IDispatch_Release(ctx->host_global);
if(ctx->site)
IActiveScriptSite_Release(ctx->site);
if(ctx->err_obj)
IDispatchEx_Release(&ctx->err_obj->IDispatchEx_iface);
if(ctx->global_obj)
IDispatchEx_Release(&ctx->global_obj->IDispatchEx_iface);
if(ctx->script_obj)
......
......@@ -150,6 +150,9 @@ struct _script_ctx_t {
class_desc_t global_desc;
vbdisp_t *global_obj;
class_desc_t err_desc;
vbdisp_t *err_obj;
dynamic_var_t *global_vars;
function_t *global_funcs;
class_desc_t *classes;
......@@ -160,6 +163,7 @@ struct _script_ctx_t {
};
HRESULT init_global(script_ctx_t*);
HRESULT init_err(script_ctx_t*);
typedef enum {
ARG_NONE = 0,
......
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