Commit 847aebdc authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Use jsval instead of VARIANT to pass arguments to builtin functions.

parent 932b3dd0
......@@ -138,7 +138,7 @@ static IUnknown *create_activex_object(script_ctx_t *ctx, const WCHAR *progid)
return obj;
}
static HRESULT ActiveXObject_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
static HRESULT ActiveXObject_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei)
{
IDispatch *disp;
......@@ -164,7 +164,7 @@ static HRESULT ActiveXObject_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flag
return E_NOTIMPL;
}
hres = to_string(ctx, argv, ei, &progid);
hres = to_string_jsval(ctx, argv[0], ei, &progid);
if(FAILED(hres))
return hres;
......
......@@ -38,7 +38,7 @@ static inline BoolInstance *bool_this(vdisp_t *jsthis)
}
/* ECMA-262 3rd Edition 15.6.4.2 */
static HRESULT Bool_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
static HRESULT Bool_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei)
{
BoolInstance *bool;
......@@ -67,7 +67,7 @@ static HRESULT Bool_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns
}
/* ECMA-262 3rd Edition 15.6.4.3 */
static HRESULT Bool_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
static HRESULT Bool_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei)
{
BoolInstance *bool;
......@@ -82,7 +82,7 @@ static HRESULT Bool_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi
return S_OK;
}
static HRESULT Bool_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
static HRESULT Bool_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei)
{
TRACE("\n");
......@@ -121,14 +121,14 @@ static const builtin_info_t BoolInst_info = {
NULL
};
static HRESULT BoolConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
static HRESULT BoolConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei)
{
BOOL value = FALSE;
HRESULT hres;
VARIANT_BOOL value = VARIANT_FALSE;
if(argc) {
hres = to_boolean(argv, &value);
hres = to_boolean_jsval(argv[0], &value);
if(FAILED(hres))
return hres;
}
......
......@@ -35,11 +35,11 @@ static const WCHAR toStringW[] = {'t','o','S','t','r','i','n','g',0};
/* ECMA-262 3rd Edition 15.11.4.4 */
static HRESULT Error_toString(script_ctx_t *ctx, vdisp_t *vthis, WORD flags,
unsigned argc, VARIANT *argv, jsval_t *r, jsexcept_t *ei)
unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei)
{
jsdisp_t *jsthis;
BSTR name = NULL, msg = NULL, ret = NULL;
VARIANT v;
jsval_t v;
HRESULT hres;
static const WCHAR object_errorW[] = {'[','o','b','j','e','c','t',' ','E','r','r','o','r',']',0};
......@@ -61,9 +61,9 @@ static HRESULT Error_toString(script_ctx_t *ctx, vdisp_t *vthis, WORD flags,
if(FAILED(hres))
return hres;
if(V_VT(&v) != VT_EMPTY) {
hres = to_string(ctx, &v, ei, &name);
VariantClear(&v);
if(!is_undefined(v)) {
hres = to_string_jsval(ctx, v, ei, &name);
jsval_release(v);
if(FAILED(hres))
return hres;
if(!*name) {
......@@ -74,9 +74,9 @@ static HRESULT Error_toString(script_ctx_t *ctx, vdisp_t *vthis, WORD flags,
hres = jsdisp_propget_name(jsthis, messageW, &v, ei);
if(SUCCEEDED(hres)) {
if(V_VT(&v) != VT_EMPTY) {
hres = to_string(ctx, &v, ei, &msg);
VariantClear(&v);
if(!is_undefined(v)) {
hres = to_string_jsval(ctx, v, ei, &msg);
jsval_release(v);
if(SUCCEEDED(hres) && !*msg) {
SysFreeString(msg);
msg = NULL;
......@@ -124,7 +124,7 @@ static HRESULT Error_toString(script_ctx_t *ctx, vdisp_t *vthis, WORD flags,
}
static HRESULT Error_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
unsigned argc, VARIANT *argv, jsval_t *r, jsexcept_t *ei)
unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei)
{
TRACE("\n");
......@@ -189,28 +189,26 @@ static HRESULT create_error(script_ctx_t *ctx, jsdisp_t *constr,
UINT number, const WCHAR *msg, jsdisp_t **ret)
{
jsdisp_t *err;
VARIANT v;
BSTR str;
HRESULT hres;
hres = alloc_error(ctx, NULL, constr, &err);
if(FAILED(hres))
return hres;
num_set_int(&v, number);
hres = jsdisp_propput_name(err, numberW, &v, NULL/*FIXME*/);
hres = jsdisp_propput_name(err, numberW, jsval_number((INT)number), NULL/*FIXME*/);
if(FAILED(hres)) {
jsdisp_release(err);
return hres;
}
V_VT(&v) = VT_BSTR;
if(msg) V_BSTR(&v) = SysAllocString(msg);
else V_BSTR(&v) = SysAllocStringLen(NULL, 0);
if(V_BSTR(&v)) {
hres = jsdisp_propput_name(err, messageW, &v, NULL/*FIXME*/);
if(msg) str = SysAllocString(msg);
else str = SysAllocStringLen(NULL, 0);
if(str) {
hres = jsdisp_propput_name(err, messageW, jsval_string(str), NULL/*FIXME*/);
if(SUCCEEDED(hres))
hres = jsdisp_propput_name(err, descriptionW, &v, NULL/*FIXME*/);
SysFreeString(V_BSTR(&v));
hres = jsdisp_propput_name(err, descriptionW, jsval_string(str), NULL/*FIXME*/);
SysFreeString(str);
}else {
hres = E_OUTOFMEMORY;
}
......@@ -223,7 +221,7 @@ static HRESULT create_error(script_ctx_t *ctx, jsdisp_t *constr,
return S_OK;
}
static HRESULT error_constr(script_ctx_t *ctx, WORD flags, unsigned argc, VARIANT *argv,
static HRESULT error_constr(script_ctx_t *ctx, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei, jsdisp_t *constr) {
jsdisp_t *err;
UINT num = 0;
......@@ -233,18 +231,18 @@ static HRESULT error_constr(script_ctx_t *ctx, WORD flags, unsigned argc, VARIAN
if(argc) {
double n;
hres = to_number(ctx, argv, ei, &n);
hres = to_number_jsval(ctx, argv[0], ei, &n);
if(FAILED(hres)) /* FIXME: really? */
n = NAN;
if(isnan(n))
hres = to_string(ctx, argv, ei, &msg);
hres = to_string_jsval(ctx, argv[0], ei, &msg);
if(FAILED(hres))
return hres;
num = n;
}
if(argc>1 && !msg) {
hres = to_string(ctx, argv+1, ei, &msg);
hres = to_string_jsval(ctx, argv[1], ei, &msg);
if(FAILED(hres))
return hres;
}
......@@ -271,56 +269,56 @@ static HRESULT error_constr(script_ctx_t *ctx, WORD flags, unsigned argc, VARIAN
}
static HRESULT ErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
unsigned argc, VARIANT *argv, jsval_t *r, jsexcept_t *ei)
unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei)
{
TRACE("\n");
return error_constr(ctx, flags, argc, argv, r, ei, ctx->error_constr);
}
static HRESULT EvalErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
unsigned argc, VARIANT *argv, jsval_t *r, jsexcept_t *ei)
unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei)
{
TRACE("\n");
return error_constr(ctx, flags, argc, argv, r, ei, ctx->eval_error_constr);
}
static HRESULT RangeErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
unsigned argc, VARIANT *argv, jsval_t *r, jsexcept_t *ei)
unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei)
{
TRACE("\n");
return error_constr(ctx, flags, argc, argv, r, ei, ctx->range_error_constr);
}
static HRESULT ReferenceErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
unsigned argc, VARIANT *argv, jsval_t *r, jsexcept_t *ei)
unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei)
{
TRACE("\n");
return error_constr(ctx, flags, argc, argv, r, ei, ctx->reference_error_constr);
}
static HRESULT RegExpErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
unsigned argc, VARIANT *argv, jsval_t *r, jsexcept_t *ei)
unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei)
{
TRACE("\n");
return error_constr(ctx, flags, argc, argv, r, ei, ctx->regexp_error_constr);
}
static HRESULT SyntaxErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
unsigned argc, VARIANT *argv, jsval_t *r, jsexcept_t *ei)
unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei)
{
TRACE("\n");
return error_constr(ctx, flags, argc, argv, r, ei, ctx->syntax_error_constr);
}
static HRESULT TypeErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
unsigned argc, VARIANT *argv, jsval_t *r, jsexcept_t *ei)
unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei)
{
TRACE("\n");
return error_constr(ctx, flags, argc, argv, r, ei, ctx->type_error_constr);
}
static HRESULT URIErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
unsigned argc, VARIANT *argv, jsval_t *r, jsexcept_t *ei)
unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei)
{
TRACE("\n");
return error_constr(ctx, flags, argc, argv, r, ei, ctx->uri_error_constr);
......@@ -348,7 +346,7 @@ HRESULT init_error_constr(script_ctx_t *ctx, jsdisp_t *object_prototype)
jsdisp_t *err;
INT i;
VARIANT v;
BSTR str;
HRESULT hres;
for(i=0; i < sizeof(names)/sizeof(names[0]); i++) {
......@@ -356,21 +354,19 @@ HRESULT init_error_constr(script_ctx_t *ctx, jsdisp_t *object_prototype)
if(FAILED(hres))
return hres;
V_VT(&v) = VT_BSTR;
V_BSTR(&v) = SysAllocString(names[i]);
if(!V_BSTR(&v)) {
str = SysAllocString(names[i]);
if(!str) {
jsdisp_release(err);
return E_OUTOFMEMORY;
}
hres = jsdisp_propput_name(err, nameW, &v, NULL/*FIXME*/);
hres = jsdisp_propput_name(err, nameW, jsval_string(str), NULL/*FIXME*/);
SysFreeString(str);
if(SUCCEEDED(hres))
hres = create_builtin_constructor(ctx, constr_val[i], names[i], NULL,
PROPF_CONSTR|1, err, constr_addr[i]);
jsdisp_release(err);
VariantClear(&v);
if(FAILED(hres))
return hres;
}
......
......@@ -153,7 +153,7 @@ static inline jsdisp_t *get_jsdisp(vdisp_t *vdisp)
return is_jsdisp(vdisp) ? vdisp->u.jsdisp : NULL;
}
typedef HRESULT (*builtin_invoke_t)(script_ctx_t*,vdisp_t*,WORD,unsigned,VARIANT*,jsval_t*,jsexcept_t*);
typedef HRESULT (*builtin_invoke_t)(script_ctx_t*,vdisp_t*,WORD,unsigned,jsval_t*,jsval_t*,jsexcept_t*);
typedef struct {
const WCHAR *name;
......@@ -208,20 +208,20 @@ HRESULT create_dispex(script_ctx_t*,const builtin_info_t*,jsdisp_t*,jsdisp_t**)
HRESULT init_dispex(jsdisp_t*,script_ctx_t*,const builtin_info_t*,jsdisp_t*) DECLSPEC_HIDDEN;
HRESULT init_dispex_from_constr(jsdisp_t*,script_ctx_t*,const builtin_info_t*,jsdisp_t*) DECLSPEC_HIDDEN;
HRESULT disp_call(script_ctx_t*,IDispatch*,DISPID,WORD,unsigned,VARIANT*,VARIANT*,jsexcept_t*) DECLSPEC_HIDDEN;
HRESULT disp_call_value(script_ctx_t*,IDispatch*,IDispatch*,WORD,unsigned,VARIANT*,jsval_t*,jsexcept_t*) DECLSPEC_HIDDEN;
HRESULT jsdisp_call_value(jsdisp_t*,IDispatch*,WORD,unsigned,VARIANT*,jsval_t*,jsexcept_t*) DECLSPEC_HIDDEN;
HRESULT jsdisp_call(jsdisp_t*,DISPID,WORD,unsigned,VARIANT*,VARIANT*,jsexcept_t*) DECLSPEC_HIDDEN;
HRESULT jsdisp_call_name(jsdisp_t*,const WCHAR*,WORD,unsigned,VARIANT*,jsval_t*,jsexcept_t*) DECLSPEC_HIDDEN;
HRESULT disp_call(script_ctx_t*,IDispatch*,DISPID,WORD,unsigned,jsval_t*,VARIANT*,jsexcept_t*) DECLSPEC_HIDDEN;
HRESULT disp_call_value(script_ctx_t*,IDispatch*,IDispatch*,WORD,unsigned,jsval_t*,jsval_t*,jsexcept_t*) DECLSPEC_HIDDEN;
HRESULT jsdisp_call_value(jsdisp_t*,IDispatch*,WORD,unsigned,jsval_t*,jsval_t*,jsexcept_t*) DECLSPEC_HIDDEN;
HRESULT jsdisp_call(jsdisp_t*,DISPID,WORD,unsigned,jsval_t*,VARIANT*,jsexcept_t*) DECLSPEC_HIDDEN;
HRESULT jsdisp_call_name(jsdisp_t*,const WCHAR*,WORD,unsigned,jsval_t*,jsval_t*,jsexcept_t*) DECLSPEC_HIDDEN;
HRESULT disp_propget(script_ctx_t*,IDispatch*,DISPID,VARIANT*,jsexcept_t*) DECLSPEC_HIDDEN;
HRESULT disp_propput(script_ctx_t*,IDispatch*,DISPID,VARIANT*,jsexcept_t*) DECLSPEC_HIDDEN;
HRESULT jsdisp_propget(jsdisp_t*,DISPID,VARIANT*,jsexcept_t*) DECLSPEC_HIDDEN;
HRESULT jsdisp_propput_name(jsdisp_t*,const WCHAR*,VARIANT*,jsexcept_t*) DECLSPEC_HIDDEN;
HRESULT jsdisp_propget(jsdisp_t*,DISPID,jsval_t*,jsexcept_t*) DECLSPEC_HIDDEN;
HRESULT jsdisp_propput_name(jsdisp_t*,const WCHAR*,jsval_t,jsexcept_t*) DECLSPEC_HIDDEN;
HRESULT jsdisp_propput_const(jsdisp_t*,const WCHAR*,VARIANT*) DECLSPEC_HIDDEN;
HRESULT jsdisp_propput_dontenum(jsdisp_t*,const WCHAR*,VARIANT*) DECLSPEC_HIDDEN;
HRESULT jsdisp_propput_idx(jsdisp_t*,DWORD,VARIANT*,jsexcept_t*) DECLSPEC_HIDDEN;
HRESULT jsdisp_propget_name(jsdisp_t*,LPCWSTR,VARIANT*,jsexcept_t*) DECLSPEC_HIDDEN;
HRESULT jsdisp_get_idx(jsdisp_t*,DWORD,VARIANT*,jsexcept_t*) DECLSPEC_HIDDEN;
HRESULT jsdisp_propput_idx(jsdisp_t*,DWORD,jsval_t,jsexcept_t*) DECLSPEC_HIDDEN;
HRESULT jsdisp_propget_name(jsdisp_t*,LPCWSTR,jsval_t*,jsexcept_t*) DECLSPEC_HIDDEN;
HRESULT jsdisp_get_idx(jsdisp_t*,DWORD,jsval_t*,jsexcept_t*) DECLSPEC_HIDDEN;
HRESULT jsdisp_get_id(jsdisp_t*,const WCHAR*,DWORD,DISPID*) DECLSPEC_HIDDEN;
HRESULT jsdisp_delete_idx(jsdisp_t*,DWORD) DECLSPEC_HIDDEN;
HRESULT jsdisp_is_own_prop(jsdisp_t*,BSTR,VARIANT_BOOL*) DECLSPEC_HIDDEN;
......@@ -230,8 +230,8 @@ HRESULT create_builtin_function(script_ctx_t*,builtin_invoke_t,const WCHAR*,cons
jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
HRESULT create_builtin_constructor(script_ctx_t*,builtin_invoke_t,const WCHAR*,const builtin_info_t*,DWORD,
jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
HRESULT Function_value(script_ctx_t*,vdisp_t*,WORD,unsigned,VARIANT*,jsval_t*,jsexcept_t*) DECLSPEC_HIDDEN;
HRESULT Function_invoke(jsdisp_t*,IDispatch*,WORD,unsigned,VARIANT*,jsval_t*,jsexcept_t*) DECLSPEC_HIDDEN;
HRESULT Function_value(script_ctx_t*,vdisp_t*,WORD,unsigned,jsval_t*,jsval_t*,jsexcept_t*) DECLSPEC_HIDDEN;
HRESULT Function_invoke(jsdisp_t*,IDispatch*,WORD,unsigned,jsval_t*,jsval_t*,jsexcept_t*) DECLSPEC_HIDDEN;
HRESULT throw_eval_error(script_ctx_t*,jsexcept_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
HRESULT throw_generic_error(script_ctx_t*,jsexcept_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
......@@ -246,7 +246,7 @@ HRESULT create_object(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
HRESULT create_math(script_ctx_t*,jsdisp_t**) DECLSPEC_HIDDEN;
HRESULT create_array(script_ctx_t*,DWORD,jsdisp_t**) DECLSPEC_HIDDEN;
HRESULT create_regexp(script_ctx_t*,const WCHAR *,int,DWORD,jsdisp_t**) DECLSPEC_HIDDEN;
HRESULT create_regexp_var(script_ctx_t*,VARIANT*,VARIANT*,jsdisp_t**) DECLSPEC_HIDDEN;
HRESULT create_regexp_var(script_ctx_t*,jsval_t,jsval_t*,jsdisp_t**) DECLSPEC_HIDDEN;
HRESULT create_string(script_ctx_t*,const WCHAR*,DWORD,jsdisp_t**) DECLSPEC_HIDDEN;
HRESULT create_bool(script_ctx_t*,VARIANT_BOOL,jsdisp_t**) DECLSPEC_HIDDEN;
HRESULT create_number(script_ctx_t*,double,jsdisp_t**) DECLSPEC_HIDDEN;
......@@ -260,14 +260,18 @@ typedef enum {
HRESULT to_primitive(script_ctx_t*,VARIANT*,jsexcept_t*,VARIANT*, hint_t) DECLSPEC_HIDDEN;
HRESULT to_boolean(VARIANT*,VARIANT_BOOL*) DECLSPEC_HIDDEN;
HRESULT to_boolean_jsval(jsval_t,BOOL*) DECLSPEC_HIDDEN;
HRESULT to_number(script_ctx_t*,VARIANT*,jsexcept_t*,double*) DECLSPEC_HIDDEN;
HRESULT to_number_jsval(script_ctx_t*,jsval_t,jsexcept_t*,double*) DECLSPEC_HIDDEN;
HRESULT to_integer(script_ctx_t*,VARIANT*,jsexcept_t*,double*) DECLSPEC_HIDDEN;
HRESULT to_int32(script_ctx_t*,VARIANT*,jsexcept_t*,INT*) DECLSPEC_HIDDEN;
HRESULT to_integer(script_ctx_t*,jsval_t,jsexcept_t*,double*) DECLSPEC_HIDDEN;
HRESULT to_int32_var(script_ctx_t*,VARIANT*,jsexcept_t*,INT*) DECLSPEC_HIDDEN;
HRESULT to_int32(script_ctx_t*,jsval_t,jsexcept_t*,INT*) DECLSPEC_HIDDEN;
HRESULT to_uint32(script_ctx_t*,VARIANT*,jsexcept_t*,DWORD*) DECLSPEC_HIDDEN;
HRESULT to_uint32_jsval(script_ctx_t*,jsval_t,jsexcept_t*,DWORD*) DECLSPEC_HIDDEN;
HRESULT to_string(script_ctx_t*,VARIANT*,jsexcept_t*,BSTR*) DECLSPEC_HIDDEN;
HRESULT to_string_jsval(script_ctx_t*,jsval_t,jsexcept_t*,BSTR*) DECLSPEC_HIDDEN;
HRESULT to_object(script_ctx_t*,VARIANT*,IDispatch**) DECLSPEC_HIDDEN;
HRESULT to_object_jsval(script_ctx_t*,jsval_t,IDispatch**) DECLSPEC_HIDDEN;
HRESULT variant_change_type(script_ctx_t*,VARIANT*,VARIANT*,VARTYPE) DECLSPEC_HIDDEN;
......@@ -491,6 +495,7 @@ static inline BOOL is_jscript_error(HRESULT hres)
}
const char *debugstr_variant(const VARIANT*) DECLSPEC_HIDDEN;
const char *debugstr_jsval(const jsval_t) DECLSPEC_HIDDEN;
HRESULT create_jscript_object(BOOL,REFIID,void**) DECLSPEC_HIDDEN;
......
......@@ -57,6 +57,29 @@ const char *debugstr_variant(const VARIANT *v)
}
}
const char *debugstr_jsval(const jsval_t v)
{
switch(v.type) {
case JSV_UNDEFINED:
return "undefined";
case JSV_NULL:
return "null";
case JSV_OBJECT:
return wine_dbg_sprintf("obj(%p)", get_object(v));
case JSV_STRING:
return debugstr_w(get_string(v));
case JSV_NUMBER:
return wine_dbg_sprintf("%lf", get_number(v));
case JSV_BOOL:
return get_bool(v) ? "true" : "false";
case JSV_VARIANT:
return debugstr_variant(get_variant(v));
}
assert(0);
return NULL;
}
#define MIN_BLOCK_SIZE 128
#define ARENA_FREE_FILLER 0xaa
......@@ -194,7 +217,8 @@ void jsval_release(jsval_t val)
{
switch(val.type) {
case JSV_OBJECT:
IDispatch_Release(val.u.obj);
if(val.u.obj)
IDispatch_Release(val.u.obj);
break;
case JSV_STRING:
SysFreeString(val.u.str);
......@@ -224,6 +248,34 @@ HRESULT jsval_variant(jsval_t *val, VARIANT *var)
return hres;
}
HRESULT jsval_copy(jsval_t v, jsval_t *r)
{
switch(v.type) {
case JSV_UNDEFINED:
case JSV_NULL:
case JSV_NUMBER:
case JSV_BOOL:
*r = v;
return S_OK;
case JSV_OBJECT:
IDispatch_AddRef(get_object(v));
*r = v;
return S_OK;
case JSV_STRING: {
BSTR str = clone_bstr(get_string(v));
if(!str)
return E_OUTOFMEMORY;
*r = jsval_string(str);
return S_OK;
}
case JSV_VARIANT:
return jsval_variant(r, get_variant(v));
}
assert(0);
return E_FAIL;
}
HRESULT variant_to_jsval(VARIANT *var, jsval_t *r)
{
switch(V_VT(var)) {
......@@ -243,20 +295,30 @@ HRESULT variant_to_jsval(VARIANT *var, jsval_t *r)
*r = jsval_number(V_R8(var));
return S_OK;
case VT_BSTR: {
BSTR str = clone_bstr(V_BSTR(var));
if(!str)
return E_OUTOFMEMORY;
BSTR str;
if(V_BSTR(var)) {
str = clone_bstr(V_BSTR(var));
if(!str)
return E_OUTOFMEMORY;
}else {
str = NULL;
}
*r = jsval_string(str);
return S_OK;
}
case VT_DISPATCH: {
IDispatch_AddRef(V_DISPATCH(var));
if(V_DISPATCH(var))
IDispatch_AddRef(V_DISPATCH(var));
*r = jsval_disp(V_DISPATCH(var));
return S_OK;
}
case VT_I2:
*r = jsval_number(V_I2(var));
return S_OK;
case VT_INT:
assert(0);
*r = jsval_number(V_INT(var));
return S_OK;
default:
return jsval_variant(r, var);
}
......@@ -273,14 +335,19 @@ HRESULT jsval_to_variant(jsval_t val, VARIANT *retv)
return S_OK;
case JSV_OBJECT:
V_VT(retv) = VT_DISPATCH;
IDispatch_AddRef(val.u.obj);
if(val.u.obj)
IDispatch_AddRef(val.u.obj);
V_DISPATCH(retv) = val.u.obj;
return S_OK;
case JSV_STRING:
V_VT(retv) = VT_BSTR;
V_BSTR(retv) = clone_bstr(val.u.str);
if(!V_BSTR(retv))
return E_OUTOFMEMORY;
if(val.u.str) {
V_BSTR(retv) = clone_bstr(val.u.str);
if(!V_BSTR(retv))
return E_OUTOFMEMORY;
}else {
V_BSTR(retv) = NULL;
}
return S_OK;
case JSV_NUMBER:
num_set_val(retv, val.u.n);
......@@ -416,6 +483,31 @@ HRESULT to_boolean(VARIANT *v, VARIANT_BOOL *b)
return S_OK;
}
/* ECMA-262 3rd Edition 9.2 */
HRESULT to_boolean_jsval(jsval_t v, BOOL *ret)
{
VARIANT_BOOL b;
VARIANT var;
HRESULT hres;
if(v.type == JSV_BOOL) {
*ret = v.u.b;
return S_OK;
}
hres = jsval_to_variant(v, &var);
if(FAILED(hres))
return hres;
hres = to_boolean(&var, &b);
VariantClear(&var);
if(FAILED(hres))
return hres;
*ret = !!b;
return S_OK;
}
static int hex_to_int(WCHAR c)
{
if('0' <= c && c <= '9')
......@@ -590,17 +682,12 @@ HRESULT to_number_jsval(script_ctx_t *ctx, jsval_t v, jsexcept_t *ei, double *re
}
/* ECMA-262 3rd Edition 9.4 */
HRESULT to_integer(script_ctx_t *ctx, VARIANT *v, jsexcept_t *ei, double *ret)
HRESULT to_integer(script_ctx_t *ctx, jsval_t v, jsexcept_t *ei, double *ret)
{
double n;
HRESULT hres;
if(V_VT(v) == VT_I4) {
*ret = V_I4(v);
return S_OK;
}
hres = to_number(ctx, v, ei, &n);
hres = to_number_jsval(ctx, v, ei, &n);
if(FAILED(hres))
return hres;
......@@ -612,7 +699,7 @@ HRESULT to_integer(script_ctx_t *ctx, VARIANT *v, jsexcept_t *ei, double *ret)
}
/* ECMA-262 3rd Edition 9.5 */
HRESULT to_int32(script_ctx_t *ctx, VARIANT *v, jsexcept_t *ei, INT *ret)
HRESULT to_int32_var(script_ctx_t *ctx, VARIANT *v, jsexcept_t *ei, INT *ret)
{
double n;
HRESULT hres;
......@@ -630,6 +717,20 @@ HRESULT to_int32(script_ctx_t *ctx, VARIANT *v, jsexcept_t *ei, INT *ret)
return S_OK;
}
/* ECMA-262 3rd Edition 9.5 */
HRESULT to_int32(script_ctx_t *ctx, jsval_t v, jsexcept_t *ei, INT *ret)
{
double n;
HRESULT hres;
hres = to_number_jsval(ctx, v, ei, &n);
if(FAILED(hres))
return hres;
*ret = isnan(n) || isinf(n) ? 0 : n;
return S_OK;
}
/* ECMA-262 3rd Edition 9.6 */
HRESULT to_uint32(script_ctx_t *ctx, VARIANT *v, jsexcept_t *ei, DWORD *ret)
{
......@@ -649,6 +750,21 @@ HRESULT to_uint32(script_ctx_t *ctx, VARIANT *v, jsexcept_t *ei, DWORD *ret)
return S_OK;
}
/* ECMA-262 3rd Edition 9.6 */
HRESULT to_uint32_jsval(script_ctx_t *ctx, jsval_t v, jsexcept_t *ei, DWORD *ret)
{
VARIANT var;
HRESULT hres;
hres = jsval_to_variant(v, &var);
if(FAILED(hres))
return hres;
hres = to_uint32(ctx, &var, ei, ret);
VariantClear(&var);
return hres;
}
static BSTR int_to_bstr(int i)
{
WCHAR buf[12], *p;
......@@ -829,6 +945,27 @@ HRESULT to_object(script_ctx_t *ctx, VARIANT *v, IDispatch **disp)
return S_OK;
}
/* ECMA-262 3rd Edition 9.9 */
HRESULT to_object_jsval(script_ctx_t *ctx, jsval_t v, IDispatch **disp)
{
VARIANT var;
HRESULT hres;
if(is_object_instance(v)) {
*disp = get_object(v);
IDispatch_AddRef(*disp);
return S_OK;
}
hres = jsval_to_variant(v, &var);
if(FAILED(hres))
return hres;
hres = to_object(ctx, &var, disp);
VariantClear(&var);
return hres;
}
HRESULT variant_change_type(script_ctx_t *ctx, VARIANT *dst, VARIANT *src, VARTYPE vt)
{
jsexcept_t ei;
......@@ -841,7 +978,7 @@ HRESULT variant_change_type(script_ctx_t *ctx, VARIANT *dst, VARIANT *src, VARTY
case VT_I4: {
INT i;
hres = to_int32(ctx, src, &ei, &i);
hres = to_int32_var(ctx, src, &ei, &i);
if(SUCCEEDED(hres)) {
if(vt == VT_I4)
V_I4(dst) = i;
......
......@@ -218,7 +218,7 @@ static inline void number_to_exponential(double val, int prec, BSTR *out)
}
/* ECMA-262 3rd Edition 15.7.4.2 */
static HRESULT Number_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
static HRESULT Number_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei)
{
NumberInstance *number;
......@@ -233,7 +233,7 @@ static HRESULT Number_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u
return throw_type_error(ctx, ei, JS_E_NUMBER_EXPECTED, NULL);
if(argc) {
hres = to_int32(ctx, argv, ei, &radix);
hres = to_int32(ctx, argv[0], ei, &radix);
if(FAILED(hres))
return hres;
......@@ -341,14 +341,14 @@ static HRESULT Number_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u
return S_OK;
}
static HRESULT Number_toLocaleString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
static HRESULT Number_toLocaleString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT Number_toFixed(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
static HRESULT Number_toFixed(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei)
{
NumberInstance *number;
......@@ -363,7 +363,7 @@ static HRESULT Number_toFixed(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
return throw_type_error(ctx, ei, JS_E_NUMBER_EXPECTED, NULL);
if(argc) {
hres = to_int32(ctx, argv, ei, &prec);
hres = to_int32(ctx, argv[0], ei, &prec);
if(FAILED(hres))
return hres;
......@@ -390,7 +390,7 @@ static HRESULT Number_toFixed(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
return S_OK;
}
static HRESULT Number_toExponential(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
static HRESULT Number_toExponential(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei)
{
NumberInstance *number;
......@@ -405,7 +405,7 @@ static HRESULT Number_toExponential(script_ctx_t *ctx, vdisp_t *jsthis, WORD fla
return throw_type_error(ctx, ei, JS_E_NUMBER_EXPECTED, NULL);
if(argc) {
hres = to_int32(ctx, argv, ei, &prec);
hres = to_int32(ctx, argv[0], ei, &prec);
if(FAILED(hres))
return hres;
......@@ -434,7 +434,7 @@ static HRESULT Number_toExponential(script_ctx_t *ctx, vdisp_t *jsthis, WORD fla
return S_OK;
}
static HRESULT Number_toPrecision(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
static HRESULT Number_toPrecision(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei)
{
NumberInstance *number;
......@@ -447,7 +447,7 @@ static HRESULT Number_toPrecision(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
return throw_type_error(ctx, ei, JS_E_NUMBER_EXPECTED, NULL);
if(argc) {
hres = to_int32(ctx, argv, ei, &prec);
hres = to_int32(ctx, argv[0], ei, &prec);
if(FAILED(hres))
return hres;
......@@ -482,7 +482,7 @@ static HRESULT Number_toPrecision(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
return S_OK;
}
static HRESULT Number_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
static HRESULT Number_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei)
{
NumberInstance *number;
......@@ -497,7 +497,7 @@ static HRESULT Number_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
return S_OK;
}
static HRESULT Number_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
static HRESULT Number_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei)
{
NumberInstance *number = number_from_vdisp(jsthis);
......@@ -543,7 +543,7 @@ static const builtin_info_t NumberInst_info = {
NULL
};
static HRESULT NumberConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
static HRESULT NumberConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei)
{
double n;
......@@ -559,7 +559,7 @@ static HRESULT NumberConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
return S_OK;
}
hres = to_number(ctx, argv, ei, &n);
hres = to_number_jsval(ctx, argv[0], ei, &n);
if(FAILED(hres))
return hres;
......@@ -571,7 +571,7 @@ static HRESULT NumberConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
jsdisp_t *obj;
if(argc) {
hres = to_number(ctx, argv, ei, &n);
hres = to_number_jsval(ctx, argv[0], ei, &n);
if(FAILED(hres))
return hres;
}else {
......
......@@ -32,7 +32,7 @@ static const WCHAR isPrototypeOfW[] = {'i','s','P','r','o','t','o','t','y','p','
static const WCHAR default_valueW[] = {'[','o','b','j','e','c','t',' ','O','b','j','e','c','t',']',0};
static HRESULT Object_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
static HRESULT Object_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei)
{
jsdisp_t *jsdisp;
......@@ -78,7 +78,7 @@ static HRESULT Object_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u
return S_OK;
}
static HRESULT Object_toLocaleString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
static HRESULT Object_toLocaleString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei)
{
TRACE("\n");
......@@ -91,7 +91,7 @@ static HRESULT Object_toLocaleString(script_ctx_t *ctx, vdisp_t *jsthis, WORD fl
return jsdisp_call_name(jsthis->u.jsdisp, toStringW, DISPATCH_METHOD, 0, NULL, r, ei);
}
static HRESULT Object_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
static HRESULT Object_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei)
{
TRACE("\n");
......@@ -103,7 +103,7 @@ static HRESULT Object_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
return S_OK;
}
static HRESULT Object_hasOwnProperty(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
static HRESULT Object_hasOwnProperty(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei)
{
BSTR name;
......@@ -118,7 +118,7 @@ static HRESULT Object_hasOwnProperty(script_ctx_t *ctx, vdisp_t *jsthis, WORD fl
return S_OK;
}
hres = to_string(ctx, argv, ei, &name);
hres = to_string_jsval(ctx, argv[0], ei, &name);
if(FAILED(hres))
return hres;
......@@ -147,21 +147,21 @@ static HRESULT Object_hasOwnProperty(script_ctx_t *ctx, vdisp_t *jsthis, WORD fl
return S_OK;
}
static HRESULT Object_propertyIsEnumerable(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
static HRESULT Object_propertyIsEnumerable(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT Object_isPrototypeOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
static HRESULT Object_isPrototypeOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei)
{
FIXME("\n");
return E_NOTIMPL;
}
static HRESULT Object_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
static HRESULT Object_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei)
{
TRACE("\n");
......@@ -215,7 +215,7 @@ static const builtin_info_t ObjectInst_info = {
NULL
};
static HRESULT ObjectConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
static HRESULT ObjectConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei)
{
HRESULT hres;
......@@ -225,10 +225,10 @@ static HRESULT ObjectConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
switch(flags) {
case DISPATCH_METHOD:
if(argc) {
if(V_VT(argv) != VT_EMPTY && V_VT(argv) != VT_NULL && (V_VT(argv) != VT_DISPATCH || V_DISPATCH(argv))) {
if(!is_undefined(argv[0]) && !is_null(argv[0]) && (!is_object_instance(argv[0]) || get_object(argv[0]))) {
IDispatch *disp;
hres = to_object(ctx, argv, &disp);
hres = to_object_jsval(ctx, argv[0], &disp);
if(FAILED(hres))
return hres;
......
......@@ -44,7 +44,7 @@ static inline VBArrayInstance *vbarray_this(vdisp_t *jsthis)
return is_vclass(jsthis, JSCLASS_VBARRAY) ? vbarray_from_vdisp(jsthis) : NULL;
}
static HRESULT VBArray_dimensions(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, VARIANT *argv,
static HRESULT VBArray_dimensions(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei)
{
VBArrayInstance *vbarray;
......@@ -60,7 +60,7 @@ static HRESULT VBArray_dimensions(script_ctx_t *ctx, vdisp_t *vthis, WORD flags,
return S_OK;
}
static HRESULT VBArray_getItem(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, VARIANT *argv,
static HRESULT VBArray_getItem(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei)
{
VBArrayInstance *vbarray;
......@@ -82,7 +82,7 @@ static HRESULT VBArray_getItem(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, un
return E_OUTOFMEMORY;
for(i=0; i<argc; i++) {
hres = to_int32(ctx, argv+i, ei, indexes+i);
hres = to_int32(ctx, argv[i], ei, indexes+i);
if(FAILED(hres)) {
heap_free(indexes);
return hres;
......@@ -96,12 +96,14 @@ static HRESULT VBArray_getItem(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, un
else if(FAILED(hres))
return hres;
if(r)
hres = jsval_variant(r, &out);
if(r) {
hres = variant_to_jsval(&out, r);
VariantClear(&out);
}
return hres;
}
static HRESULT VBArray_lbound(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, VARIANT *argv,
static HRESULT VBArray_lbound(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei)
{
VBArrayInstance *vbarray;
......@@ -115,7 +117,7 @@ static HRESULT VBArray_lbound(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, uns
return throw_type_error(ctx, ei, JS_E_VBARRAY_EXPECTED, NULL);
if(argc) {
hres = to_int32(ctx, argv, ei, &dim);
hres = to_int32(ctx, argv[0], ei, &dim);
if(FAILED(hres))
return hres;
} else
......@@ -132,11 +134,12 @@ static HRESULT VBArray_lbound(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, uns
return S_OK;
}
static HRESULT VBArray_toArray(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, VARIANT *argv,
static HRESULT VBArray_toArray(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei)
{
VBArrayInstance *vbarray;
jsdisp_t *array;
jsval_t val;
VARIANT *v;
int i, size = 1, ubound, lbound;
HRESULT hres;
......@@ -164,7 +167,11 @@ static HRESULT VBArray_toArray(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, un
}
for(i=0; i<size; i++) {
hres = jsdisp_propput_idx(array, i, v, ei);
hres = variant_to_jsval(v, &val);
if(SUCCEEDED(hres)) {
hres = jsdisp_propput_idx(array, i, val, ei);
jsval_release(val);
}
if(FAILED(hres)) {
SafeArrayUnaccessData(vbarray->safearray);
jsdisp_release(array);
......@@ -180,7 +187,7 @@ static HRESULT VBArray_toArray(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, un
return S_OK;
}
static HRESULT VBArray_ubound(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, VARIANT *argv,
static HRESULT VBArray_ubound(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei)
{
VBArrayInstance *vbarray;
......@@ -194,7 +201,7 @@ static HRESULT VBArray_ubound(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, uns
return throw_type_error(ctx, ei, JS_E_VBARRAY_EXPECTED, NULL);
if(argc) {
hres = to_int32(ctx, argv, ei, &dim);
hres = to_int32(ctx, argv[0], ei, &dim);
if(FAILED(hres))
return hres;
} else
......@@ -211,7 +218,7 @@ static HRESULT VBArray_ubound(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, uns
return S_OK;
}
static HRESULT VBArray_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
static HRESULT VBArray_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei)
{
FIXME("\n");
......@@ -273,7 +280,7 @@ static HRESULT alloc_vbarray(script_ctx_t *ctx, jsdisp_t *object_prototype, VBAr
return S_OK;
}
static HRESULT VBArrayConstr_value(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, VARIANT *argv,
static HRESULT VBArrayConstr_value(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei)
{
VBArrayInstance *vbarray;
......@@ -283,20 +290,20 @@ static HRESULT VBArrayConstr_value(script_ctx_t *ctx, vdisp_t *vthis, WORD flags
switch(flags) {
case DISPATCH_METHOD:
if(argc<1 || V_VT(argv) != (VT_ARRAY|VT_VARIANT))
if(argc<1 || !is_variant(argv[0]) || V_VT(get_variant(argv[0])) != (VT_ARRAY|VT_VARIANT))
return throw_type_error(ctx, ei, JS_E_VBARRAY_EXPECTED, NULL);
return variant_to_jsval(argv, r);
return jsval_copy(argv[0], r);
case DISPATCH_CONSTRUCT:
if(argc<1 || V_VT(argv) != (VT_ARRAY|VT_VARIANT))
if(argc<1 || !is_variant(argv[0]) || V_VT(get_variant(argv[0])) != (VT_ARRAY|VT_VARIANT))
return throw_type_error(ctx, ei, JS_E_VBARRAY_EXPECTED, NULL);
hres = alloc_vbarray(ctx, NULL, &vbarray);
if(FAILED(hres))
return hres;
hres = SafeArrayCopy(V_ARRAY(argv), &vbarray->safearray);
hres = SafeArrayCopy(V_ARRAY(get_variant(argv[0])), &vbarray->safearray);
if(FAILED(hres)) {
jsdisp_release(&vbarray->dispex);
return hres;
......
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