From 847aebdc877482cb3954dbaa3bbe3f52bb7f1b21 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Mon, 17 Sep 2012 15:16:42 +0200 Subject: [PATCH] jscript: Use jsval instead of VARIANT to pass arguments to builtin functions. --- dlls/jscript/activex.c | 4 +- dlls/jscript/array.c | 263 ++++++++++++++++++++-------------------- dlls/jscript/bool.c | 12 +- dlls/jscript/date.c | 190 +++++++++++++++-------------- dlls/jscript/dispex.c | 168 ++++++++++++++----------- dlls/jscript/engine.c | 146 +++++++++++++++++----- dlls/jscript/error.c | 72 ++++++----- dlls/jscript/function.c | 101 +++++++-------- dlls/jscript/global.c | 119 +++++++++--------- dlls/jscript/jscript.h | 37 +++--- dlls/jscript/jsutils.c | 175 +++++++++++++++++++++++--- dlls/jscript/math.c | 78 ++++++------ dlls/jscript/number.c | 28 ++--- dlls/jscript/object.c | 22 ++-- dlls/jscript/regexp.c | 139 ++++++++++----------- dlls/jscript/string.c | 260 +++++++++++++++++++-------------------- dlls/jscript/vbarray.c | 41 ++++--- 17 files changed, 1035 insertions(+), 820 deletions(-) diff --git a/dlls/jscript/activex.c b/dlls/jscript/activex.c index 39515081ed..2dd803801e 100644 --- a/dlls/jscript/activex.c +++ b/dlls/jscript/activex.c @@ -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; diff --git a/dlls/jscript/array.c b/dlls/jscript/array.c index f557fcf8fc..00911933d5 100644 --- a/dlls/jscript/array.c +++ b/dlls/jscript/array.c @@ -62,7 +62,7 @@ static inline ArrayInstance *array_this(vdisp_t *jsthis) static HRESULT get_length(script_ctx_t *ctx, vdisp_t *vdisp, jsexcept_t *ei, jsdisp_t **jsthis, DWORD *ret) { ArrayInstance *array; - VARIANT var; + jsval_t val; HRESULT hres; array = array_this(vdisp); @@ -75,12 +75,12 @@ static HRESULT get_length(script_ctx_t *ctx, vdisp_t *vdisp, jsexcept_t *ei, jsd if(!is_jsdisp(vdisp)) return throw_type_error(ctx, ei, JS_E_JSCRIPT_EXPECTED, NULL); - hres = jsdisp_propget_name(vdisp->u.jsdisp, lengthW, &var, ei); + hres = jsdisp_propget_name(vdisp->u.jsdisp, lengthW, &val, ei); if(FAILED(hres)) return hres; - hres = to_uint32(ctx, &var, ei, ret); - VariantClear(&var); + hres = to_uint32_jsval(ctx, val, ei, ret); + jsval_release(val); if(FAILED(hres)) return hres; @@ -90,15 +90,12 @@ static HRESULT get_length(script_ctx_t *ctx, vdisp_t *vdisp, jsexcept_t *ei, jsd static HRESULT set_length(jsdisp_t *obj, jsexcept_t *ei, DWORD length) { - VARIANT var; - if(is_class(obj, JSCLASS_ARRAY)) { ((ArrayInstance*)obj)->length = length; return S_OK; } - num_set_int(&var, length); - return jsdisp_propput_name(obj, lengthW, &var, ei); + return jsdisp_propput_name(obj, lengthW, jsval_number(length), ei); } static WCHAR *idx_to_str(DWORD idx, WCHAR *ptr) @@ -116,7 +113,7 @@ static WCHAR *idx_to_str(DWORD idx, WCHAR *ptr) return ptr+1; } -static HRESULT Array_length(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Array_length(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { ArrayInstance *This = array_from_vdisp(jsthis); @@ -132,7 +129,7 @@ static HRESULT Array_length(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi DWORD i; HRESULT hres; - hres = to_number(ctx, argv, ei, &len); + hres = to_number_jsval(ctx, argv[0], ei, &len); if(FAILED(hres)) return hres; @@ -159,19 +156,19 @@ static HRESULT Array_length(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi static HRESULT concat_array(jsdisp_t *array, ArrayInstance *obj, DWORD *len, jsexcept_t *ei) { - VARIANT var; + jsval_t val; DWORD i; HRESULT hres; for(i=0; i < obj->length; i++) { - hres = jsdisp_get_idx(&obj->dispex, i, &var, ei); + hres = jsdisp_get_idx(&obj->dispex, i, &val, ei); if(hres == DISP_E_UNKNOWNNAME) continue; if(FAILED(hres)) return hres; - hres = jsdisp_propput_idx(array, *len+i, &var, ei); - VariantClear(&var); + hres = jsdisp_propput_idx(array, *len+i, val, ei); + jsval_release(val); if(FAILED(hres)) return hres; } @@ -183,7 +180,6 @@ static HRESULT concat_array(jsdisp_t *array, ArrayInstance *obj, DWORD *len, jse static HRESULT concat_obj(jsdisp_t *array, IDispatch *obj, DWORD *len, jsexcept_t *ei) { jsdisp_t *jsobj; - VARIANT var; HRESULT hres; jsobj = iface_to_jsdisp((IUnknown*)obj); @@ -196,12 +192,10 @@ static HRESULT concat_obj(jsdisp_t *array, IDispatch *obj, DWORD *len, jsexcept_ jsdisp_release(jsobj); } - V_VT(&var) = VT_DISPATCH; - V_DISPATCH(&var) = obj; - return jsdisp_propput_idx(array, (*len)++, &var, ei); + return jsdisp_propput_idx(array, (*len)++, jsval_disp(obj), ei); } -static HRESULT Array_concat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Array_concat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { jsdisp_t *ret; @@ -216,15 +210,13 @@ static HRESULT Array_concat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi hres = concat_obj(ret, jsthis->u.disp, &len, ei); if(SUCCEEDED(hres)) { - VARIANT *arg; DWORD i; for(i=0; i < argc; i++) { - arg = argv+i; - if(V_VT(arg) == VT_DISPATCH) - hres = concat_obj(ret, V_DISPATCH(arg), &len, ei); + if(is_object_instance(argv[i])) + hres = concat_obj(ret, get_object(argv[i]), &len, ei); else - hres = jsdisp_propput_idx(ret, len++, arg, ei); + hres = jsdisp_propput_idx(ret, len++, argv[i], ei); if(FAILED(hres)) break; } @@ -243,7 +235,7 @@ static HRESULT Array_concat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi static HRESULT array_join(script_ctx_t *ctx, jsdisp_t *array, DWORD length, const WCHAR *sep, jsval_t *r, jsexcept_t *ei) { BSTR *str_tab, ret = NULL; - VARIANT var; + jsval_t val; DWORD i; HRESULT hres = E_FAIL; @@ -262,18 +254,19 @@ static HRESULT array_join(script_ctx_t *ctx, jsdisp_t *array, DWORD length, cons return E_OUTOFMEMORY; for(i=0; i < length; i++) { - hres = jsdisp_get_idx(array, i, &var, ei); + hres = jsdisp_get_idx(array, i, &val, ei); if(hres == DISP_E_UNKNOWNNAME) { hres = S_OK; continue; } else if(FAILED(hres)) break; - if(V_VT(&var) != VT_EMPTY && V_VT(&var) != VT_NULL) - hres = to_string(ctx, &var, ei, str_tab+i); - VariantClear(&var); - if(FAILED(hres)) - break; + if(!is_undefined(val) && !is_null(val)) { + hres = to_string_jsval(ctx, val, ei, str_tab+i); + jsval_release(val); + if(FAILED(hres)) + break; + } } if(SUCCEEDED(hres)) { @@ -339,7 +332,7 @@ static HRESULT array_join(script_ctx_t *ctx, jsdisp_t *array, DWORD length, cons } /* ECMA-262 3rd Edition 15.4.4.5 */ -static HRESULT Array_join(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Array_join(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { jsdisp_t *jsthis; @@ -355,7 +348,7 @@ static HRESULT Array_join(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigne if(argc) { BSTR sep; - hres = to_string(ctx, argv, ei, &sep); + hres = to_string_jsval(ctx, argv[0], ei, &sep); if(FAILED(hres)) return hres; @@ -369,11 +362,11 @@ static HRESULT Array_join(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigne return hres; } -static HRESULT Array_pop(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Array_pop(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { jsdisp_t *jsthis; - VARIANT val; + jsval_t val; DWORD length; HRESULT hres; @@ -395,30 +388,30 @@ static HRESULT Array_pop(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned length--; hres = jsdisp_get_idx(jsthis, length, &val, ei); - if(SUCCEEDED(hres)) { + if(SUCCEEDED(hres)) hres = jsdisp_delete_idx(jsthis, length); - } else if(hres == DISP_E_UNKNOWNNAME) { - V_VT(&val) = VT_EMPTY; - hres = S_OK; - } else + else if(hres == DISP_E_UNKNOWNNAME) + val = jsval_undefined(); + else return hres; if(SUCCEEDED(hres)) hres = set_length(jsthis, ei, length); if(FAILED(hres)) { - VariantClear(&val); + jsval_release(val); return hres; } if(r) - hres = variant_to_jsval(&val, r); - VariantClear(&val); + *r = val; + else + jsval_release(val); return hres; } /* ECMA-262 3rd Edition 15.4.4.7 */ -static HRESULT Array_push(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Array_push(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { jsdisp_t *jsthis; @@ -433,7 +426,7 @@ static HRESULT Array_push(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigne return hres; for(i=0; i < argc; i++) { - hres = jsdisp_propput_idx(jsthis, length+i, argv+i, ei); + hres = jsdisp_propput_idx(jsthis, length+i, argv[i], ei); if(FAILED(hres)) return hres; } @@ -447,12 +440,12 @@ static HRESULT Array_push(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigne return S_OK; } -static HRESULT Array_reverse(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Array_reverse(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { jsdisp_t *jsthis; DWORD length, k, l; - VARIANT v1, v2; + jsval_t v1, v2; HRESULT hres1, hres2; TRACE("\n"); @@ -470,28 +463,28 @@ static HRESULT Array_reverse(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsi hres2 = jsdisp_get_idx(jsthis, l, &v2, ei); if(FAILED(hres2) && hres2!=DISP_E_UNKNOWNNAME) { - VariantClear(&v1); + jsval_release(v1); return hres2; } if(hres1 == DISP_E_UNKNOWNNAME) hres1 = jsdisp_delete_idx(jsthis, l); else - hres1 = jsdisp_propput_idx(jsthis, l, &v1, ei); + hres1 = jsdisp_propput_idx(jsthis, l, v1, ei); if(FAILED(hres1)) { - VariantClear(&v1); - VariantClear(&v2); + jsval_release(v1); + jsval_release(v2); return hres1; } if(hres2 == DISP_E_UNKNOWNNAME) hres2 = jsdisp_delete_idx(jsthis, k); else - hres2 = jsdisp_propput_idx(jsthis, k, &v2, ei); + hres2 = jsdisp_propput_idx(jsthis, k, v2, ei); if(FAILED(hres2)) { - VariantClear(&v2); + jsval_release(v2); return hres2; } } @@ -502,12 +495,12 @@ static HRESULT Array_reverse(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsi } /* ECMA-262 3rd Edition 15.4.4.9 */ -static HRESULT Array_shift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Array_shift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { jsdisp_t *jsthis; DWORD length = 0, i; - VARIANT v, ret; + jsval_t v, ret; HRESULT hres; TRACE("\n"); @@ -530,7 +523,7 @@ static HRESULT Array_shift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsign hres = jsdisp_get_idx(jsthis, 0, &ret, ei); if(hres == DISP_E_UNKNOWNNAME) { - V_VT(&ret) = VT_EMPTY; + ret = jsval_undefined(); hres = S_OK; } @@ -539,7 +532,7 @@ static HRESULT Array_shift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsign if(hres == DISP_E_UNKNOWNNAME) hres = jsdisp_delete_idx(jsthis, i-1); else if(SUCCEEDED(hres)) - hres = jsdisp_propput_idx(jsthis, i-1, &v, ei); + hres = jsdisp_propput_idx(jsthis, i-1, v, ei); } if(SUCCEEDED(hres)) { @@ -548,14 +541,18 @@ static HRESULT Array_shift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsign hres = set_length(jsthis, ei, length-1); } - if(SUCCEEDED(hres) && r) - hres = variant_to_jsval(&ret, r); - VariantClear(&ret); + if(FAILED(hres)) + return hres; + + if(r) + *r = ret; + else + jsval_release(ret); return hres; } /* ECMA-262 3rd Edition 15.4.4.10 */ -static HRESULT Array_slice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Array_slice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { jsdisp_t *arr, *jsthis; @@ -570,7 +567,7 @@ static HRESULT Array_slice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsign return hres; if(argc) { - hres = to_number(ctx, argv, ei, &range); + hres = to_number_jsval(ctx, argv[0], ei, &range); if(FAILED(hres)) return hres; @@ -583,7 +580,7 @@ static HRESULT Array_slice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsign else start = 0; if(argc > 1) { - hres = to_number(ctx, argv+1, ei, &range); + hres = to_number_jsval(ctx, argv[1], ei, &range); if(FAILED(hres)) return hres; @@ -600,15 +597,15 @@ static HRESULT Array_slice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsign return hres; for(idx=start; idx 0.0 ? 1 : -1; - }else if(V_VT(v1) == VT_EMPTY) { - *cmp = V_VT(v2) == VT_EMPTY ? 0 : 1; - }else if(V_VT(v2) == VT_EMPTY) { + }else if(is_undefined(v1)) { + *cmp = is_undefined(v2) ? 0 : 1; + }else if(is_undefined(v2)) { *cmp = -1; - }else if(is_num_vt(V_VT(v1)) && is_num_vt(V_VT(v2))) { - DOUBLE d = num_val(v1)-num_val(v2); + }else if(is_number(v1) && is_number(v2)) { + double d = get_number(v1)-get_number(v2); if(d > 0.0) *cmp = 1; else @@ -662,11 +656,11 @@ static HRESULT sort_cmp(script_ctx_t *ctx, jsdisp_t *cmp_func, VARIANT *v1, VARI }else { BSTR x, y; - hres = to_string(ctx, v1, ei, &x); + hres = to_string_jsval(ctx, v1, ei, &x); if(FAILED(hres)) return hres; - hres = to_string(ctx, v2, ei, &y); + hres = to_string_jsval(ctx, v2, ei, &y); if(SUCCEEDED(hres)) { *cmp = strcmpW(x, y); SysFreeString(y); @@ -680,11 +674,11 @@ static HRESULT sort_cmp(script_ctx_t *ctx, jsdisp_t *cmp_func, VARIANT *v1, VARI } /* ECMA-262 3rd Edition 15.4.4.11 */ -static HRESULT Array_sort(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Array_sort(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { jsdisp_t *jsthis, *cmp_func = NULL; - VARIANT *vtab, **sorttab = NULL; + jsval_t *vtab, **sorttab = NULL; DWORD length; DWORD i; HRESULT hres = S_OK; @@ -701,13 +695,12 @@ static HRESULT Array_sort(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigne } if(argc == 1) { - if(V_VT(argv) != VT_DISPATCH) { + if(!is_object_instance(argv[0])) { WARN("arg is not dispatch\n"); return E_FAIL; } - - cmp_func = iface_to_jsdisp((IUnknown*)V_DISPATCH(argv)); + cmp_func = iface_to_jsdisp((IUnknown*)get_object(argv[0])); if(!cmp_func || !is_class(cmp_func, JSCLASS_FUNCTION)) { WARN("cmp_func is not a function\n"); if(cmp_func) @@ -724,12 +717,12 @@ static HRESULT Array_sort(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigne return S_OK; } - vtab = heap_alloc_zero(length * sizeof(VARIANT)); + vtab = heap_alloc_zero(length * sizeof(*vtab)); if(vtab) { for(i=0; i= 2) { - hres = to_integer(ctx, argv+1, ei, &d); + hres = to_integer(ctx, argv[1], ei, &d); if(FAILED(hres)) return hres; @@ -880,47 +873,49 @@ static HRESULT Array_splice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsig return hres; for(i=0; SUCCEEDED(hres) && i < delete_cnt; i++) { - hres = jsdisp_get_idx(jsthis, start+i, &v, ei); - if(hres == DISP_E_UNKNOWNNAME) + hres = jsdisp_get_idx(jsthis, start+i, &val, ei); + if(hres == DISP_E_UNKNOWNNAME) { hres = S_OK; - else if(SUCCEEDED(hres)) - hres = jsdisp_propput_idx(ret_array, i, &v, ei); + }else if(SUCCEEDED(hres)) { + hres = jsdisp_propput_idx(ret_array, i, val, ei); + jsval_release(val); + } } - if(SUCCEEDED(hres)) { - num_set_int(&v, delete_cnt); - hres = jsdisp_propput_name(ret_array, lengthW, &v, ei); - } + if(SUCCEEDED(hres)) + hres = jsdisp_propput_name(ret_array, lengthW, jsval_number(delete_cnt), ei); } if(add_args < delete_cnt) { for(i = start; SUCCEEDED(hres) && i < length-delete_cnt; i++) { - hres = jsdisp_get_idx(jsthis, i+delete_cnt, &v, ei); - if(hres == DISP_E_UNKNOWNNAME) + hres = jsdisp_get_idx(jsthis, i+delete_cnt, &val, ei); + if(hres == DISP_E_UNKNOWNNAME) { hres = jsdisp_delete_idx(jsthis, i+add_args); - else if(SUCCEEDED(hres)) - hres = jsdisp_propput_idx(jsthis, i+add_args, &v, ei); + }else if(SUCCEEDED(hres)) { + hres = jsdisp_propput_idx(jsthis, i+add_args, val, ei); + jsval_release(val); + } } for(i=length; SUCCEEDED(hres) && i != length-delete_cnt+add_args; i--) hres = jsdisp_delete_idx(jsthis, i-1); }else if(add_args > delete_cnt) { for(i=length-delete_cnt; SUCCEEDED(hres) && i != start; i--) { - hres = jsdisp_get_idx(jsthis, i+delete_cnt-1, &v, ei); - if(hres == DISP_E_UNKNOWNNAME) + hres = jsdisp_get_idx(jsthis, i+delete_cnt-1, &val, ei); + if(hres == DISP_E_UNKNOWNNAME) { hres = jsdisp_delete_idx(jsthis, i+add_args-1); - else if(SUCCEEDED(hres)) - hres = jsdisp_propput_idx(jsthis, i+add_args-1, &v, ei); + }else if(SUCCEEDED(hres)) { + hres = jsdisp_propput_idx(jsthis, i+add_args-1, val, ei); + jsval_release(val); + } } } for(i=0; SUCCEEDED(hres) && i < add_args; i++) - hres = jsdisp_propput_idx(jsthis, start+i, argv+i+2, ei); + hres = jsdisp_propput_idx(jsthis, start+i, argv[i+2], ei); - if(SUCCEEDED(hres)) { - num_set_int(&v, length-delete_cnt+add_args); - hres = jsdisp_propput_name(jsthis, lengthW, &v, ei); - } + if(SUCCEEDED(hres)) + hres = jsdisp_propput_name(jsthis, lengthW, jsval_number(length-delete_cnt+add_args), ei); if(FAILED(hres)) { if(ret_array) @@ -934,7 +929,7 @@ static HRESULT Array_splice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsig } /* ECMA-262 3rd Edition 15.4.4.2 */ -static HRESULT Array_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Array_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { ArrayInstance *array; @@ -948,7 +943,7 @@ static HRESULT Array_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un return array_join(ctx, &array->dispex, array->length, default_separatorW, r, ei); } -static HRESULT Array_toLocaleString(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Array_toLocaleString(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { FIXME("\n"); @@ -956,13 +951,13 @@ static HRESULT Array_toLocaleString(script_ctx_t *ctx, vdisp_t *vthis, WORD flag } /* ECMA-262 3rd Edition 15.4.4.13 */ -static HRESULT Array_unshift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Array_unshift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { jsdisp_t *jsthis; WCHAR buf[14], *buf_end, *str; DWORD i, length; - VARIANT var; + jsval_t val; DISPID id; HRESULT hres; @@ -982,12 +977,12 @@ static HRESULT Array_unshift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsi hres = jsdisp_get_id(jsthis, str, 0, &id); if(SUCCEEDED(hres)) { - hres = jsdisp_propget(jsthis, id, &var, ei); + hres = jsdisp_propget(jsthis, id, &val, ei); if(FAILED(hres)) return hres; - hres = jsdisp_propput_idx(jsthis, i+argc, &var, ei); - VariantClear(&var); + hres = jsdisp_propput_idx(jsthis, i+argc, val, ei); + jsval_release(val); }else if(hres == DISP_E_UNKNOWNNAME) { hres = IDispatchEx_DeleteMemberByDispID(vthis->u.dispex, id); } @@ -998,7 +993,7 @@ static HRESULT Array_unshift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsi } for(i=0; itime, date); - hres = to_number(ctx, argv, ei, &sec); + hres = to_number_jsval(ctx, argv[0], ei, &sec); if(FAILED(hres)) return hres; if(argc > 1) { - hres = to_number(ctx, argv+1, ei, &ms); + hres = to_number_jsval(ctx, argv[1], ei, &ms); if(FAILED(hres)) return hres; }else { @@ -1459,7 +1459,7 @@ static HRESULT Date_setSeconds(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u } /* ECMA-262 3rd Edition 15.9.5.31 */ -static HRESULT Date_setUTCSeconds(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Date_setUTCSeconds(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { DateInstance *date; @@ -1476,12 +1476,12 @@ static HRESULT Date_setUTCSeconds(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags t = date->time; - hres = to_number(ctx, argv, ei, &sec); + hres = to_number_jsval(ctx, argv[0], ei, &sec); if(FAILED(hres)) return hres; if(argc > 1) { - hres = to_number(ctx, argv+1, ei, &ms); + hres = to_number_jsval(ctx, argv[1], ei, &ms); if(FAILED(hres)) return hres; }else { @@ -1498,7 +1498,7 @@ static HRESULT Date_setUTCSeconds(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags } /* ECMA-262 3rd Edition 15.9.5.33 */ -static HRESULT Date_setMinutes(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Date_setMinutes(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { DateInstance *date; @@ -1515,12 +1515,12 @@ static HRESULT Date_setMinutes(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u t = local_time(date->time, date); - hres = to_number(ctx, argv, ei, &min); + hres = to_number_jsval(ctx, argv[0], ei, &min); if(FAILED(hres)) return hres; if(argc > 1) { - hres = to_number(ctx, argv+1, ei, &sec); + hres = to_number_jsval(ctx, argv[1], ei, &sec); if(FAILED(hres)) return hres; }else { @@ -1528,7 +1528,7 @@ static HRESULT Date_setMinutes(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u } if(argc > 2) { - hres = to_number(ctx, argv+2, ei, &ms); + hres = to_number_jsval(ctx, argv[2], ei, &ms); if(FAILED(hres)) return hres; }else { @@ -1545,7 +1545,7 @@ static HRESULT Date_setMinutes(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u } /* ECMA-262 3rd Edition 15.9.5.34 */ -static HRESULT Date_setUTCMinutes(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Date_setUTCMinutes(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { DateInstance *date; @@ -1562,12 +1562,12 @@ static HRESULT Date_setUTCMinutes(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags t = date->time; - hres = to_number(ctx, argv, ei, &min); + hres = to_number_jsval(ctx, argv[0], ei, &min); if(FAILED(hres)) return hres; if(argc > 1) { - hres = to_number(ctx, argv+1, ei, &sec); + hres = to_number_jsval(ctx, argv[1], ei, &sec); if(FAILED(hres)) return hres; }else { @@ -1575,7 +1575,7 @@ static HRESULT Date_setUTCMinutes(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags } if(argc > 2) { - hres = to_number(ctx, argv+2, ei, &ms); + hres = to_number_jsval(ctx, argv[2], ei, &ms); if(FAILED(hres)) return hres; }else { @@ -1592,7 +1592,7 @@ static HRESULT Date_setUTCMinutes(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags } /* ECMA-262 3rd Edition 15.9.5.35 */ -static HRESULT Date_setHours(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Date_setHours(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { DateInstance *date; @@ -1609,12 +1609,12 @@ static HRESULT Date_setHours(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns t = local_time(date->time, date); - hres = to_number(ctx, argv, ei, &hour); + hres = to_number_jsval(ctx, argv[0], ei, &hour); if(FAILED(hres)) return hres; if(argc > 1) { - hres = to_number(ctx, argv+1, ei, &min); + hres = to_number_jsval(ctx, argv[1], ei, &min); if(FAILED(hres)) return hres; }else { @@ -1622,7 +1622,7 @@ static HRESULT Date_setHours(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns } if(argc > 2) { - hres = to_number(ctx, argv+2, ei, &sec); + hres = to_number_jsval(ctx, argv[2], ei, &sec); if(FAILED(hres)) return hres; }else { @@ -1630,7 +1630,7 @@ static HRESULT Date_setHours(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns } if(argc > 3) { - hres = to_number(ctx, argv+3, ei, &ms); + hres = to_number_jsval(ctx, argv[3], ei, &ms); if(FAILED(hres)) return hres; }else { @@ -1646,7 +1646,7 @@ static HRESULT Date_setHours(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns } /* ECMA-262 3rd Edition 15.9.5.36 */ -static HRESULT Date_setUTCHours(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Date_setUTCHours(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { DateInstance *date; @@ -1663,12 +1663,12 @@ static HRESULT Date_setUTCHours(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, t = date->time; - hres = to_number(ctx, argv, ei, &hour); + hres = to_number_jsval(ctx, argv[0], ei, &hour); if(FAILED(hres)) return hres; if(argc > 1) { - hres = to_number(ctx, argv+1, ei, &min); + hres = to_number_jsval(ctx, argv[1], ei, &min); if(FAILED(hres)) return hres; }else { @@ -1676,7 +1676,7 @@ static HRESULT Date_setUTCHours(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, } if(argc > 2) { - hres = to_number(ctx, argv+2, ei, &sec); + hres = to_number_jsval(ctx, argv[2], ei, &sec); if(FAILED(hres)) return hres; }else { @@ -1684,7 +1684,7 @@ static HRESULT Date_setUTCHours(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, } if(argc > 3) { - hres = to_number(ctx, argv+3, ei, &ms); + hres = to_number_jsval(ctx, argv[3], ei, &ms); if(FAILED(hres)) return hres; }else { @@ -1700,7 +1700,7 @@ static HRESULT Date_setUTCHours(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, } /* ECMA-262 3rd Edition 15.9.5.36 */ -static HRESULT Date_setDate(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Date_setDate(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { DateInstance *date; @@ -1715,7 +1715,7 @@ static HRESULT Date_setDate(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi if(!argc) return throw_type_error(ctx, ei, JS_E_MISSING_ARG, NULL); - hres = to_number(ctx, argv, ei, &n); + hres = to_number_jsval(ctx, argv[0], ei, &n); if(FAILED(hres)) return hres; @@ -1729,7 +1729,7 @@ static HRESULT Date_setDate(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi } /* ECMA-262 3rd Edition 15.9.5.37 */ -static HRESULT Date_setUTCDate(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Date_setUTCDate(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { DateInstance *date; @@ -1744,7 +1744,7 @@ static HRESULT Date_setUTCDate(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u if(!argc) return throw_type_error(ctx, ei, JS_E_MISSING_ARG, NULL); - hres = to_number(ctx, argv, ei, &n); + hres = to_number_jsval(ctx, argv[0], ei, &n); if(FAILED(hres)) return hres; @@ -1758,7 +1758,7 @@ static HRESULT Date_setUTCDate(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u } /* ECMA-262 3rd Edition 15.9.5.38 */ -static HRESULT Date_setMonth(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Date_setMonth(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { DateInstance *date; @@ -1775,12 +1775,12 @@ static HRESULT Date_setMonth(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns t = local_time(date->time, date); - hres = to_number(ctx, argv, ei, &month); + hres = to_number_jsval(ctx, argv[0], ei, &month); if(FAILED(hres)) return hres; if(argc > 1) { - hres = to_number(ctx, argv+1, ei, &ddate); + hres = to_number_jsval(ctx, argv[1], ei, &ddate); if(FAILED(hres)) return hres; }else { @@ -1797,7 +1797,7 @@ static HRESULT Date_setMonth(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns } /* ECMA-262 3rd Edition 15.9.5.39 */ -static HRESULT Date_setUTCMonth(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Date_setUTCMonth(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { DateInstance *date; @@ -1814,12 +1814,12 @@ static HRESULT Date_setUTCMonth(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, t = date->time; - hres = to_number(ctx, argv, ei, &month); + hres = to_number_jsval(ctx, argv[0], ei, &month); if(FAILED(hres)) return hres; if(argc > 1) { - hres = to_number(ctx, argv+1, ei, &ddate); + hres = to_number_jsval(ctx, argv[1], ei, &ddate); if(FAILED(hres)) return hres; }else { @@ -1836,7 +1836,7 @@ static HRESULT Date_setUTCMonth(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, } /* ECMA-262 3rd Edition 15.9.5.40 */ -static HRESULT Date_setFullYear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Date_setFullYear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { DateInstance *date; @@ -1853,12 +1853,12 @@ static HRESULT Date_setFullYear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, t = local_time(date->time, date); - hres = to_number(ctx, argv, ei, &year); + hres = to_number_jsval(ctx, argv[0], ei, &year); if(FAILED(hres)) return hres; if(argc > 1) { - hres = to_number(ctx, argv+1, ei, &month); + hres = to_number_jsval(ctx, argv[1], ei, &month); if(FAILED(hres)) return hres; }else { @@ -1866,7 +1866,7 @@ static HRESULT Date_setFullYear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, } if(argc > 2) { - hres = to_number(ctx, argv+2, ei, &ddate); + hres = to_number_jsval(ctx, argv[2], ei, &ddate); if(FAILED(hres)) return hres; }else { @@ -1882,7 +1882,7 @@ static HRESULT Date_setFullYear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, } /* ECMA-262 3rd Edition 15.9.5.41 */ -static HRESULT Date_setUTCFullYear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Date_setUTCFullYear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { DateInstance *date; @@ -1899,12 +1899,12 @@ static HRESULT Date_setUTCFullYear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flag t = date->time; - hres = to_number(ctx, argv, ei, &year); + hres = to_number_jsval(ctx, argv[0], ei, &year); if(FAILED(hres)) return hres; if(argc > 1) { - hres = to_number(ctx, argv+1, ei, &month); + hres = to_number_jsval(ctx, argv[1], ei, &month); if(FAILED(hres)) return hres; }else { @@ -1912,7 +1912,7 @@ static HRESULT Date_setUTCFullYear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flag } if(argc > 2) { - hres = to_number(ctx, argv+2, ei, &ddate); + hres = to_number_jsval(ctx, argv[2], ei, &ddate); if(FAILED(hres)) return hres; }else { @@ -1928,7 +1928,7 @@ static HRESULT Date_setUTCFullYear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flag } /* ECMA-262 3rd Edition B2.4 */ -static HRESULT Date_getYear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Date_getYear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { DateInstance *date; @@ -1953,7 +1953,7 @@ static HRESULT Date_getYear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi } /* ECMA-262 3rd Edition B2.5 */ -static HRESULT Date_setYear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Date_setYear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { DateInstance *date; @@ -1970,7 +1970,7 @@ static HRESULT Date_setYear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi t = local_time(date->time, date); - hres = to_number(ctx, argv, ei, &year); + hres = to_number_jsval(ctx, argv[0], ei, &year); if(FAILED(hres)) return hres; @@ -1992,7 +1992,7 @@ static HRESULT Date_setYear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi return S_OK; } -static HRESULT Date_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Date_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { TRACE("\n"); @@ -2365,7 +2365,7 @@ static inline HRESULT date_parse(BSTR input, double *ret) { return S_OK; } -static HRESULT DateConstr_parse(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT DateConstr_parse(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { BSTR parse_str; @@ -2380,7 +2380,7 @@ static HRESULT DateConstr_parse(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, return S_OK; } - hres = to_string(ctx, argv, ei, &parse_str); + hres = to_string_jsval(ctx, argv[0], ei, &parse_str); if(FAILED(hres)) return hres; @@ -2393,7 +2393,7 @@ static HRESULT DateConstr_parse(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, return S_OK; } -static HRESULT date_utc(script_ctx_t *ctx, unsigned argc, VARIANT *argv, double *ret, jsexcept_t *ei) +static HRESULT date_utc(script_ctx_t *ctx, unsigned argc, jsval_t *argv, double *ret, jsexcept_t *ei) { double year, month, vdate, hours, minutes, seconds, ms; HRESULT hres; @@ -2401,7 +2401,7 @@ static HRESULT date_utc(script_ctx_t *ctx, unsigned argc, VARIANT *argv, double TRACE("\n"); if(argc) { - hres = to_number(ctx, argv, ei, &year); + hres = to_number_jsval(ctx, argv[0], ei, &year); if(FAILED(hres)) return hres; if(0 <= year && year <= 99) @@ -2411,7 +2411,7 @@ static HRESULT date_utc(script_ctx_t *ctx, unsigned argc, VARIANT *argv, double } if(argc>1) { - hres = to_number(ctx, argv+1, ei, &month); + hres = to_number_jsval(ctx, argv[1], ei, &month); if(FAILED(hres)) return hres; }else { @@ -2419,7 +2419,7 @@ static HRESULT date_utc(script_ctx_t *ctx, unsigned argc, VARIANT *argv, double } if(argc>2) { - hres = to_number(ctx, argv+2, ei, &vdate); + hres = to_number_jsval(ctx, argv[2], ei, &vdate); if(FAILED(hres)) return hres; }else { @@ -2427,7 +2427,7 @@ static HRESULT date_utc(script_ctx_t *ctx, unsigned argc, VARIANT *argv, double } if(argc>3) { - hres = to_number(ctx, argv+3, ei, &hours); + hres = to_number_jsval(ctx, argv[3], ei, &hours); if(FAILED(hres)) return hres; }else { @@ -2435,7 +2435,7 @@ static HRESULT date_utc(script_ctx_t *ctx, unsigned argc, VARIANT *argv, double } if(argc>4) { - hres = to_number(ctx, argv+4, ei, &minutes); + hres = to_number_jsval(ctx, argv[4], ei, &minutes); if(FAILED(hres)) return hres; }else { @@ -2443,7 +2443,7 @@ static HRESULT date_utc(script_ctx_t *ctx, unsigned argc, VARIANT *argv, double } if(argc>5) { - hres = to_number(ctx, argv+5, ei, &seconds); + hres = to_number_jsval(ctx, argv[5], ei, &seconds); if(FAILED(hres)) return hres; }else { @@ -2451,7 +2451,7 @@ static HRESULT date_utc(script_ctx_t *ctx, unsigned argc, VARIANT *argv, double } if(argc>6) { - hres = to_number(ctx, argv+6, ei, &ms); + hres = to_number_jsval(ctx, argv[6], ei, &ms); if(FAILED(hres)) return hres; } else { @@ -2463,7 +2463,7 @@ static HRESULT date_utc(script_ctx_t *ctx, unsigned argc, VARIANT *argv, double return S_OK; } -static HRESULT DateConstr_UTC(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT DateConstr_UTC(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { double n; @@ -2477,7 +2477,7 @@ static HRESULT DateConstr_UTC(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un return hres; } -static HRESULT DateConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT DateConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { jsdisp_t *date; @@ -2505,10 +2505,14 @@ static HRESULT DateConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, /* ECMA-262 3rd Edition 15.9.3.2 */ case 1: { - VARIANT prim; + VARIANT prim,var; double n; - hres = to_primitive(ctx, argv, ei, &prim, NO_HINT); + hres = jsval_to_variant(argv[0], &var); + if(SUCCEEDED(hres)) { + hres = to_primitive(ctx, &var, ei, &prim, NO_HINT); + VariantClear(&var); + } if(FAILED(hres)) return hres; diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c index e0912fbb0d..e3680c5abb 100644 --- a/dlls/jscript/dispex.c +++ b/dlls/jscript/dispex.c @@ -309,17 +309,17 @@ static IDispatch *get_this(DISPPARAMS *dp) return NULL; } -static HRESULT convert_params(const DISPPARAMS *dp, VARIANT *buf, unsigned *argc, VARIANT **ret) +static HRESULT convert_params(const DISPPARAMS *dp, jsval_t *buf, unsigned *argc, jsval_t **ret) { - const VARIANT *s; - VARIANT *argv; + jsval_t *argv; unsigned cnt; unsigned i; + HRESULT hres; cnt = dp->cArgs - dp->cNamedArgs; if(cnt > 6) { - argv = heap_alloc(cnt * sizeof(VARIANT)); + argv = heap_alloc(cnt * sizeof(*argv)); if(!argv) return E_OUTOFMEMORY; }else { @@ -327,18 +327,13 @@ static HRESULT convert_params(const DISPPARAMS *dp, VARIANT *buf, unsigned *argc } for(i = 0; i < cnt; i++) { - s = dp->rgvarg+dp->cArgs-i-1; - switch(V_VT(s)) { - case VT_I2: - V_VT(argv+i) = VT_I4; - V_I4(argv+i) = V_I2(s); - break; - case VT_INT: - V_VT(argv+i) = VT_I4; - V_I4(argv+i) = V_INT(s); - break; - default: - argv[i] = *s; + hres = variant_to_jsval(dp->rgvarg+dp->cArgs-i-1, argv+i); + if(FAILED(hres)) { + while(i--) + jsval_release(argv[i]); + if(argv != buf) + heap_free(argv); + return hres; } } @@ -348,7 +343,7 @@ static HRESULT convert_params(const DISPPARAMS *dp, VARIANT *buf, unsigned *argc } static HRESULT invoke_prop_func(jsdisp_t *This, IDispatch *jsthis, dispex_prop_t *prop, WORD flags, - unsigned argc, VARIANT *argv, jsval_t *r, jsexcept_t *ei, IServiceProvider *caller) + unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei, IServiceProvider *caller) { HRESULT hres; @@ -395,7 +390,7 @@ static HRESULT invoke_prop_func(jsdisp_t *This, IDispatch *jsthis, dispex_prop_t } static HRESULT prop_get(jsdisp_t *This, dispex_prop_t *prop, DISPPARAMS *dp, - VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller) + jsval_t *r, jsexcept_t *ei, IServiceProvider *caller) { HRESULT hres; @@ -410,25 +405,20 @@ static HRESULT prop_get(jsdisp_t *This, dispex_prop_t *prop, DISPPARAMS *dp, prop->type = PROP_VARIANT; var_set_jsdisp(&prop->u.var, obj); - hres = VariantCopy(retv, &prop->u.var); + hres = variant_to_jsval(&prop->u.var, r); }else { vdisp_t vthis; - jsval_t r; set_jsdisp(&vthis, This); - hres = prop->u.p->invoke(This->ctx, &vthis, DISPATCH_PROPERTYGET, 0, NULL, &r, ei); + hres = prop->u.p->invoke(This->ctx, &vthis, DISPATCH_PROPERTYGET, 0, NULL, r, ei); vdisp_release(&vthis); - if(SUCCEEDED(hres)) { - hres = jsval_to_variant(r, retv); - jsval_release(r); - } } break; case PROP_PROTREF: - hres = prop_get(This->prototype, This->prototype->props+prop->u.ref, dp, retv, ei, caller); + hres = prop_get(This->prototype, This->prototype->props+prop->u.ref, dp, r, ei, caller); break; case PROP_VARIANT: - hres = VariantCopy(retv, &prop->u.var); + hres = variant_to_jsval(&prop->u.var, r); break; default: ERR("type %d\n", prop->type); @@ -440,11 +430,11 @@ static HRESULT prop_get(jsdisp_t *This, dispex_prop_t *prop, DISPPARAMS *dp, return hres; } - TRACE("%s ret %s\n", debugstr_w(prop->name), debugstr_variant(retv)); + TRACE("%s ret %s\n", debugstr_w(prop->name), debugstr_jsval(*r)); return hres; } -static HRESULT prop_put(jsdisp_t *This, dispex_prop_t *prop, VARIANT *val, +static HRESULT prop_put(jsdisp_t *This, dispex_prop_t *prop, jsval_t val, jsexcept_t *ei, IServiceProvider *caller) { HRESULT hres; @@ -458,7 +448,7 @@ static HRESULT prop_put(jsdisp_t *This, dispex_prop_t *prop, VARIANT *val, vdisp_t vthis; set_jsdisp(&vthis, This); - hres = prop->u.p->invoke(This->ctx, &vthis, DISPATCH_PROPERTYPUT, 1, val, NULL, ei); + hres = prop->u.p->invoke(This->ctx, &vthis, DISPATCH_PROPERTYPUT, 1, &val, NULL, ei); vdisp_release(&vthis); return hres; } @@ -475,14 +465,14 @@ static HRESULT prop_put(jsdisp_t *This, dispex_prop_t *prop, VARIANT *val, return E_FAIL; } - hres = VariantCopy(&prop->u.var, val); + hres = jsval_to_variant(val, &prop->u.var); if(FAILED(hres)) return hres; if(This->builtin_info->on_put) This->builtin_info->on_put(This, prop->name); - TRACE("%s = %s\n", debugstr_w(prop->name), debugstr_variant(val)); + TRACE("%s = %s\n", debugstr_w(prop->name), debugstr_jsval(val)); return S_OK; } @@ -682,10 +672,8 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc /* fall through */ case DISPATCH_METHOD: case DISPATCH_CONSTRUCT: { - VARIANT *argv; + jsval_t *argv, buf[6], r; unsigned argc; - jsval_t r; - VARIANT buf[6]; hres = convert_params(pdp, buf, &argc, &argv); if(FAILED(hres)) @@ -700,10 +688,18 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc } break; } - case DISPATCH_PROPERTYGET: - hres = prop_get(This, prop, pdp, pvarRes, &jsexcept, pspCaller); + case DISPATCH_PROPERTYGET: { + jsval_t r; + + hres = prop_get(This, prop, pdp, &r, &jsexcept, pspCaller); + if(SUCCEEDED(hres)) { + hres = jsval_to_variant(r, pvarRes); + jsval_release(r); + } break; + } case DISPATCH_PROPERTYPUT: { + jsval_t val; DWORD i; for(i=0; i < pdp->cNamedArgs; i++) { @@ -716,7 +712,12 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc return DISP_E_PARAMNOTOPTIONAL; } - hres = prop_put(This, prop, pdp->rgvarg+i, &jsexcept, pspCaller); + hres = variant_to_jsval(pdp->rgvarg+i, &val); + if(FAILED(hres)) + return hres; + + hres = prop_put(This, prop, val, &jsexcept, pspCaller); + jsval_release(val); break; } default: @@ -937,19 +938,18 @@ HRESULT init_dispex_from_constr(jsdisp_t *dispex, script_ctx_t *ctx, const built hres = find_prop_name_prot(constr, string_hash(prototypeW), prototypeW, &prop); if(SUCCEEDED(hres) && prop && prop->type!=PROP_DELETED) { jsexcept_t jsexcept; - VARIANT var; + jsval_t val; - V_VT(&var) = VT_EMPTY; memset(&jsexcept, 0, sizeof(jsexcept)); - hres = prop_get(constr, prop, NULL, &var, &jsexcept, NULL/*FIXME*/); + hres = prop_get(constr, prop, NULL, &val, &jsexcept, NULL/*FIXME*/); if(FAILED(hres)) { ERR("Could not get prototype\n"); return hres; } - if(V_VT(&var) == VT_DISPATCH) - prot = iface_to_jsdisp((IUnknown*)V_DISPATCH(&var)); - VariantClear(&var); + if(is_object_instance(val)) + prot = iface_to_jsdisp((IUnknown*)get_object(val)); + jsval_release(val); } hres = init_dispex(dispex, ctx, builtin_info, prot); @@ -1005,7 +1005,7 @@ HRESULT jsdisp_get_id(jsdisp_t *jsdisp, const WCHAR *name, DWORD flags, DISPID * return DISP_E_UNKNOWNNAME; } -HRESULT jsdisp_call_value(jsdisp_t *jsfunc, IDispatch *jsthis, WORD flags, unsigned argc, VARIANT *argv, jsval_t *r, +HRESULT jsdisp_call_value(jsdisp_t *jsfunc, IDispatch *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { HRESULT hres; @@ -1022,7 +1022,7 @@ HRESULT jsdisp_call_value(jsdisp_t *jsfunc, IDispatch *jsthis, WORD flags, unsig return hres; } -HRESULT jsdisp_call(jsdisp_t *disp, DISPID id, WORD flags, unsigned argc, VARIANT *argv, VARIANT *retv, jsexcept_t *ei) +HRESULT jsdisp_call(jsdisp_t *disp, DISPID id, WORD flags, unsigned argc, jsval_t *argv, VARIANT *retv, jsexcept_t *ei) { dispex_prop_t *prop; jsval_t r; @@ -1047,7 +1047,7 @@ HRESULT jsdisp_call(jsdisp_t *disp, DISPID id, WORD flags, unsigned argc, VARIAN return hres; } -HRESULT jsdisp_call_name(jsdisp_t *disp, const WCHAR *name, WORD flags, unsigned argc, VARIANT *argv, jsval_t *r, +HRESULT jsdisp_call_name(jsdisp_t *disp, const WCHAR *name, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { dispex_prop_t *prop; @@ -1061,7 +1061,7 @@ HRESULT jsdisp_call_name(jsdisp_t *disp, const WCHAR *name, WORD flags, unsigned return invoke_prop_func(disp, to_disp(disp), prop, flags, argc, argv, r, ei, NULL); } -HRESULT disp_call(script_ctx_t *ctx, IDispatch *disp, DISPID id, WORD flags, unsigned argc, VARIANT *argv, +HRESULT disp_call(script_ctx_t *ctx, IDispatch *disp, DISPID id, WORD flags, unsigned argc, jsval_t *argv, VARIANT *retv, jsexcept_t *ei) { IDispatchEx *dispex; @@ -1107,8 +1107,16 @@ HRESULT disp_call(script_ctx_t *ctx, IDispatch *disp, DISPID id, WORD flags, uns dp.rgvarg = buf; } - for(i=0; ilcid, flags, &dp, retv, &ei->ei, &err); } + for(i=0; ilcid, flags, &dp, r ? &retv : NULL, &ei->ei, &err); } + for(i=0; iu.var, val); } -HRESULT jsdisp_propput_idx(jsdisp_t *obj, DWORD idx, VARIANT *val, jsexcept_t *ei) +HRESULT jsdisp_propput_idx(jsdisp_t *obj, DWORD idx, jsval_t val, jsexcept_t *ei) { WCHAR buf[12]; @@ -1270,7 +1290,7 @@ HRESULT jsdisp_propput_idx(jsdisp_t *obj, DWORD idx, VARIANT *val, jsexcept_t *e return jsdisp_propput_name(obj, buf, val, ei); } -HRESULT disp_propput(script_ctx_t *ctx, IDispatch *disp, DISPID id, VARIANT *val, jsexcept_t *ei) +HRESULT disp_propput(script_ctx_t *ctx, IDispatch *disp, DISPID id, VARIANT *var, jsexcept_t *ei) { jsdisp_t *jsdisp; HRESULT hres; @@ -1278,6 +1298,11 @@ HRESULT disp_propput(script_ctx_t *ctx, IDispatch *disp, DISPID id, VARIANT *val jsdisp = iface_to_jsdisp((IUnknown*)disp); if(jsdisp) { dispex_prop_t *prop; + jsval_t val; + + hres = variant_to_jsval(var, &val); + if(FAILED(hres)) + return hres; prop = get_prop(jsdisp, id); if(prop) @@ -1285,10 +1310,11 @@ HRESULT disp_propput(script_ctx_t *ctx, IDispatch *disp, DISPID id, VARIANT *val else hres = DISP_E_MEMBERNOTFOUND; + jsval_release(val); jsdisp_release(jsdisp); }else { DISPID dispid = DISPID_PROPERTYPUT; - DISPPARAMS dp = {val, &dispid, 1, 1}; + DISPPARAMS dp = {var, &dispid, 1, 1}; IDispatchEx *dispex; hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex); @@ -1307,7 +1333,7 @@ HRESULT disp_propput(script_ctx_t *ctx, IDispatch *disp, DISPID id, VARIANT *val return hres; } -HRESULT jsdisp_propget_name(jsdisp_t *obj, const WCHAR *name, VARIANT *var, jsexcept_t *ei) +HRESULT jsdisp_propget_name(jsdisp_t *obj, const WCHAR *name, jsval_t *val, jsexcept_t *ei) { DISPPARAMS dp = {NULL, NULL, 0, 0}; dispex_prop_t *prop; @@ -1317,14 +1343,15 @@ HRESULT jsdisp_propget_name(jsdisp_t *obj, const WCHAR *name, VARIANT *var, jsex if(FAILED(hres)) return hres; - V_VT(var) = VT_EMPTY; - if(!prop || prop->type==PROP_DELETED) + if(!prop || prop->type==PROP_DELETED) { + *val = jsval_undefined(); return S_OK; + } - return prop_get(obj, prop, &dp, var, ei, NULL); + return prop_get(obj, prop, &dp, val, ei, NULL); } -HRESULT jsdisp_get_idx(jsdisp_t *obj, DWORD idx, VARIANT *var, jsexcept_t *ei) +HRESULT jsdisp_get_idx(jsdisp_t *obj, DWORD idx, jsval_t *r, jsexcept_t *ei) { WCHAR name[12]; DISPPARAMS dp = {NULL, NULL, 0, 0}; @@ -1339,14 +1366,15 @@ HRESULT jsdisp_get_idx(jsdisp_t *obj, DWORD idx, VARIANT *var, jsexcept_t *ei) if(FAILED(hres)) return hres; - V_VT(var) = VT_EMPTY; - if(!prop || prop->type==PROP_DELETED) + if(!prop || prop->type==PROP_DELETED) { + *r = jsval_undefined(); return DISP_E_UNKNOWNNAME; + } - return prop_get(obj, prop, &dp, var, ei, NULL); + return prop_get(obj, prop, &dp, r, ei, NULL); } -HRESULT jsdisp_propget(jsdisp_t *jsdisp, DISPID id, VARIANT *val, jsexcept_t *ei) +HRESULT jsdisp_propget(jsdisp_t *jsdisp, DISPID id, jsval_t *val, jsexcept_t *ei) { DISPPARAMS dp = {NULL,NULL,0,0}; dispex_prop_t *prop; @@ -1355,7 +1383,6 @@ HRESULT jsdisp_propget(jsdisp_t *jsdisp, DISPID id, VARIANT *val, jsexcept_t *ei if(!prop) return DISP_E_MEMBERNOTFOUND; - V_VT(val) = VT_EMPTY; return prop_get(jsdisp, prop, &dp, val, ei, NULL); } @@ -1368,8 +1395,13 @@ HRESULT disp_propget(script_ctx_t *ctx, IDispatch *disp, DISPID id, VARIANT *val jsdisp = iface_to_jsdisp((IUnknown*)disp); if(jsdisp) { - hres = jsdisp_propget(jsdisp, id, val, ei); + jsval_t v; + hres = jsdisp_propget(jsdisp, id, &v, ei); jsdisp_release(jsdisp); + if(SUCCEEDED(hres)) { + hres = jsval_to_variant(v, val); + jsval_release(v); + } return hres; } diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c index 26258ec4ee..4575a79133 100644 --- a/dlls/jscript/engine.c +++ b/dlls/jscript/engine.c @@ -184,7 +184,7 @@ static HRESULT stack_pop_object(exec_ctx_t *ctx, IDispatch **r) static inline HRESULT stack_pop_int(exec_ctx_t *ctx, INT *r) { - return to_int32(ctx->script, stack_pop(ctx), ctx->ei, r); + return to_int32_var(ctx->script, stack_pop(ctx), ctx->ei, r); } static inline HRESULT stack_pop_uint(exec_ctx_t *ctx, DWORD *r) @@ -385,7 +385,7 @@ static HRESULT disp_get_id(script_ctx_t *ctx, IDispatch *disp, BSTR name, DWORD return hres; } -static inline BOOL is_null_var(const VARIANT *v) +static inline BOOL var_is_null(const VARIANT *v) { return V_VT(v) == VT_NULL || (V_VT(v) == VT_DISPATCH && !V_DISPATCH(v)); } @@ -442,8 +442,8 @@ static HRESULT equal2_values(VARIANT *lval, VARIANT *rval, BOOL *ret) if(V_VT(lval) != V_VT(rval)) { if(is_num_vt(V_VT(lval)) && is_num_vt(V_VT(rval))) *ret = num_val(lval) == num_val(rval); - else if(is_null_var(lval)) - *ret = is_null_var(rval); + else if(var_is_null(lval)) + *ret = var_is_null(rval); else *ret = FALSE; return S_OK; @@ -591,13 +591,19 @@ static HRESULT interp_var_set(exec_ctx_t *ctx) { const BSTR name = get_op_bstr(ctx, 0); VARIANT *v; + jsval_t val; HRESULT hres; TRACE("%s\n", debugstr_w(name)); v = stack_pop(ctx); - hres = jsdisp_propput_name(ctx->var_disp, name, v, ctx->ei); + hres = variant_to_jsval(v, &val); VariantClear(v); + if(FAILED(hres)) + return hres; + + hres = jsdisp_propput_name(ctx->var_disp, name, val, ctx->ei); + jsval_release(val); return hres; } @@ -976,17 +982,48 @@ static HRESULT interp_refval(exec_ctx_t *ctx) return stack_push(ctx, &v); } +static HRESULT convert_args(exec_ctx_t *ctx, unsigned argc, jsval_t **ret) +{ + VARIANT *args = stack_args(ctx, argc); + jsval_t *argv; + unsigned i; + HRESULT hres; + + if(!argc) { + *ret = NULL; + return S_OK; + } + + argv = heap_alloc(argc * sizeof(jsval_t)); + if(!argv) + return E_OUTOFMEMORY; + + for(i=0; iscript, ctx->ei, JS_E_INVALID_PROPERTY, NULL); - hres = disp_call_value(ctx->script, V_DISPATCH(constr), NULL, DISPATCH_CONSTRUCT, arg, stack_args(ctx, arg), &r, ctx->ei); + hres = convert_args(ctx, argc, &argv); + if(FAILED(hres)) + return hres; + + hres = disp_call_value(ctx->script, V_DISPATCH(constr), NULL, DISPATCH_CONSTRUCT, argc, argv, &r, ctx->ei); + for(i=0; i < argc; i++) + jsval_release(argv[i]); + heap_free(argv); if(FAILED(hres)) return hres; @@ -1006,7 +1050,7 @@ static HRESULT interp_new(exec_ctx_t *ctx) if(FAILED(hres)) return hres; - stack_popn(ctx, arg+1); + stack_popn(ctx, argc+1); return stack_push(ctx, &v); } @@ -1016,7 +1060,8 @@ static HRESULT interp_call(exec_ctx_t *ctx) const unsigned argn = get_op_uint(ctx, 0); const int do_ret = get_op_int(ctx, 1); VARIANT v, *objv; - jsval_t r; + jsval_t *argv, r; + unsigned i; HRESULT hres; TRACE("%d %d\n", argn, do_ret); @@ -1025,8 +1070,15 @@ static HRESULT interp_call(exec_ctx_t *ctx) if(V_VT(objv) != VT_DISPATCH) return throw_type_error(ctx->script, ctx->ei, JS_E_INVALID_PROPERTY, NULL); - hres = disp_call_value(ctx->script, V_DISPATCH(objv), NULL, DISPATCH_METHOD, argn, stack_args(ctx, argn), + hres = convert_args(ctx, argn, &argv); + if(FAILED(hres)) + return hres; + + hres = disp_call_value(ctx->script, V_DISPATCH(objv), NULL, DISPATCH_METHOD, argn, argv, do_ret ? &r : NULL, ctx->ei); + for(i=0; i < argn; i++) + jsval_release(argv[i]); + heap_free(argv); if(FAILED(hres)) return hres; @@ -1050,6 +1102,8 @@ static HRESULT interp_call_member(exec_ctx_t *ctx) const unsigned argn = get_op_uint(ctx, 0); const int do_ret = get_op_int(ctx, 1); IDispatch *obj; + jsval_t *argv; + unsigned i; VARIANT v; DISPID id; HRESULT hres; @@ -1060,7 +1114,14 @@ static HRESULT interp_call_member(exec_ctx_t *ctx) if(!obj) return throw_type_error(ctx->script, ctx->ei, id, NULL); - hres = disp_call(ctx->script, obj, id, DISPATCH_METHOD, argn, stack_args(ctx, argn), do_ret ? &v : NULL, ctx->ei); + hres = convert_args(ctx, argn, &argv); + if(FAILED(hres)) + return hres; + + hres = disp_call(ctx->script, obj, id, DISPATCH_METHOD, argn, argv, do_ret ? &v : NULL, ctx->ei); + for(i=0; i < argn; i++) + jsval_release(argv[i]); + heap_free(argv); if(FAILED(hres)) return hres; @@ -1225,6 +1286,7 @@ static HRESULT interp_carray(exec_ctx_t *ctx) const unsigned arg = get_op_uint(ctx, 0); jsdisp_t *array; VARIANT *v, r; + jsval_t val; unsigned i; HRESULT hres; @@ -1237,7 +1299,11 @@ static HRESULT interp_carray(exec_ctx_t *ctx) i = arg; while(i--) { v = stack_pop(ctx); - hres = jsdisp_propput_idx(array, i, v, ctx->ei); + hres = variant_to_jsval(v, &val); + if(SUCCEEDED(hres)) { + hres = jsdisp_propput_idx(array, i, val, ctx->ei); + jsval_release(val); + } VariantClear(v); if(FAILED(hres)) { jsdisp_release(array); @@ -1272,6 +1338,7 @@ static HRESULT interp_obj_prop(exec_ctx_t *ctx) const BSTR name = get_op_bstr(ctx, 0); jsdisp_t *obj; VARIANT *v; + jsval_t val; HRESULT hres; TRACE("%s\n", debugstr_w(name)); @@ -1281,7 +1348,11 @@ static HRESULT interp_obj_prop(exec_ctx_t *ctx) assert(V_VT(stack_top(ctx)) == VT_DISPATCH); obj = as_jsdisp(V_DISPATCH(stack_top(ctx))); - hres = jsdisp_propput_name(obj, name, v, ctx->ei); + hres = variant_to_jsval(v, &val); + if(SUCCEEDED(hres)) { + hres = jsdisp_propput_name(obj, name, val, ctx->ei); + jsval_release(val); + } VariantClear(v); return hres; } @@ -1391,7 +1462,8 @@ static HRESULT interp_and(exec_ctx_t *ctx) static HRESULT interp_instanceof(exec_ctx_t *ctx) { jsdisp_t *obj, *iter, *tmp = NULL; - VARIANT prot, *v; + jsval_t prot; + VARIANT *v; BOOL ret = FALSE; HRESULT hres; @@ -1421,11 +1493,11 @@ static HRESULT interp_instanceof(exec_ctx_t *ctx) v = stack_pop(ctx); - if(V_VT(&prot) == VT_DISPATCH) { + if(is_object_instance(prot)) { if(V_VT(v) == VT_DISPATCH) tmp = iface_to_jsdisp((IUnknown*)V_DISPATCH(v)); for(iter = tmp; !ret && iter; iter = iter->prototype) { - hres = disp_cmp(V_DISPATCH(&prot), to_disp(iter), &ret); + hres = disp_cmp(get_object(prot), to_disp(iter), &ret); if(FAILED(hres)) break; } @@ -1437,7 +1509,7 @@ static HRESULT interp_instanceof(exec_ctx_t *ctx) hres = E_FAIL; } - VariantClear(&prot); + jsval_release(prot); VariantClear(v); if(FAILED(hres)) return hres; @@ -2283,7 +2355,7 @@ static HRESULT interp_bneg(exec_ctx_t *ctx) TRACE("\n"); v = stack_pop(ctx); - hres = to_int32(ctx->script, v, ctx->ei, &i); + hres = to_int32_var(ctx->script, v, ctx->ei, &i); VariantClear(v); if(FAILED(hres)) return hres; @@ -2391,24 +2463,33 @@ static HRESULT interp_assign(exec_ctx_t *ctx) /* JScript extension */ static HRESULT interp_assign_call(exec_ctx_t *ctx) { - const unsigned arg = get_op_uint(ctx, 0); + const unsigned argc = get_op_uint(ctx, 0); IDispatch *disp; + jsval_t *argv; + unsigned i; VARIANT *v; DISPID id; HRESULT hres; - TRACE("%u\n", arg); + TRACE("%u\n", argc); - disp = stack_topn_objid(ctx, arg+1, &id); + disp = stack_topn_objid(ctx, argc+1, &id); if(!disp) return throw_reference_error(ctx->script, ctx->ei, JS_E_ILLEGAL_ASSIGN, NULL); - hres = disp_call(ctx->script, disp, id, DISPATCH_PROPERTYPUT, arg+1, stack_args(ctx,arg+1), NULL, ctx->ei); + hres = convert_args(ctx, argc+1, &argv); + if(FAILED(hres)) + return hres; + + hres = disp_call(ctx->script, disp, id, DISPATCH_PROPERTYPUT, argc+1, argv, NULL, ctx->ei); + for(i=0; i < argc; i++) + jsval_release(argv[i]); + heap_free(argv); if(FAILED(hres)) return hres; v = stack_pop(ctx); - stack_popn(ctx, arg+2); + stack_popn(ctx, argc+2); return stack_push(ctx, v); } @@ -2513,7 +2594,13 @@ static HRESULT unwind_exception(exec_ctx_t *ctx) hres = create_dispex(ctx->script, NULL, NULL, &scope_obj); if(SUCCEEDED(hres)) { - hres = jsdisp_propput_name(scope_obj, ident, &except_val, ctx->ei); + jsval_t val; + + hres = variant_to_jsval(&except_val, &val); + if(SUCCEEDED(hres)) { + hres = jsdisp_propput_name(scope_obj, ident, val, ctx->ei); + jsval_release(val); + } if(FAILED(hres)) jsdisp_release(scope_obj); } @@ -2570,6 +2657,7 @@ static HRESULT enter_bytecode(script_ctx_t *ctx, bytecode_t *code, function_code while(exec_ctx->ip != -1) { op = code->instrs[exec_ctx->ip].op; + TRACE("top %d\n", exec_ctx->top); hres = op_funcs[op](exec_ctx); if(FAILED(hres)) { TRACE("EXCEPTION\n"); @@ -2618,7 +2706,6 @@ HRESULT exec_source(exec_ctx_t *ctx, bytecode_t *code, function_code_t *func, BO for(i = 0; i < func->func_cnt; i++) { jsdisp_t *func_obj; - VARIANT var; if(!func->funcs[i].name) continue; @@ -2627,8 +2714,7 @@ HRESULT exec_source(exec_ctx_t *ctx, bytecode_t *code, function_code_t *func, BO if(FAILED(hres)) return hres; - var_set_jsdisp(&var, func_obj); - hres = jsdisp_propput_name(ctx->var_disp, func->funcs[i].name, &var, ei); + hres = jsdisp_propput_name(ctx->var_disp, func->funcs[i].name, jsval_obj(func_obj), ei); jsdisp_release(func_obj); if(FAILED(hres)) return hres; diff --git a/dlls/jscript/error.c b/dlls/jscript/error.c index 67ccf0d4c6..407bd3ba5a 100644 --- a/dlls/jscript/error.c +++ b/dlls/jscript/error.c @@ -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; } diff --git a/dlls/jscript/function.c b/dlls/jscript/function.c index 197b2728e1..cfeb2691a6 100644 --- a/dlls/jscript/function.c +++ b/dlls/jscript/function.c @@ -55,18 +55,15 @@ static const WCHAR applyW[] = {'a','p','p','l','y',0}; static const WCHAR callW[] = {'c','a','l','l',0}; static const WCHAR argumentsW[] = {'a','r','g','u','m','e','n','t','s',0}; -static HRESULT init_parameters(jsdisp_t *var_disp, FunctionInstance *function, unsigned argc, VARIANT *argv, +static HRESULT init_parameters(jsdisp_t *var_disp, FunctionInstance *function, unsigned argc, jsval_t *argv, jsexcept_t *ei) { - VARIANT var_empty; DWORD i=0; HRESULT hres; - V_VT(&var_empty) = VT_EMPTY; - for(i=0; i < function->func_code->param_cnt; i++) { hres = jsdisp_propput_name(var_disp, function->func_code->params[i], - i < argc ? argv+i : &var_empty, ei); + i < argc ? argv[i] : jsval_undefined(), ei); if(FAILED(hres)) return hres; } @@ -74,7 +71,7 @@ static HRESULT init_parameters(jsdisp_t *var_disp, FunctionInstance *function, u return S_OK; } -static HRESULT Arguments_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Arguments_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { FIXME("\n"); @@ -89,11 +86,10 @@ static const builtin_info_t Arguments_info = { NULL }; -static HRESULT create_arguments(script_ctx_t *ctx, IDispatch *calee, unsigned argc, VARIANT *argv, +static HRESULT create_arguments(script_ctx_t *ctx, IDispatch *calee, unsigned argc, jsval_t *argv, jsexcept_t *ei, jsdisp_t **ret) { jsdisp_t *args; - VARIANT var; DWORD i; HRESULT hres; @@ -110,20 +106,16 @@ static HRESULT create_arguments(script_ctx_t *ctx, IDispatch *calee, unsigned ar } for(i=0; i < argc; i++) { - hres = jsdisp_propput_idx(args, i, argv+i, ei); + hres = jsdisp_propput_idx(args, i, argv[i], ei); if(FAILED(hres)) break; } if(SUCCEEDED(hres)) { - num_set_int(&var, argc); - hres = jsdisp_propput_name(args, lengthW, &var, ei); + hres = jsdisp_propput_name(args, lengthW, jsval_number(argc), ei); - if(SUCCEEDED(hres)) { - V_VT(&var) = VT_DISPATCH; - V_DISPATCH(&var) = calee; - hres = jsdisp_propput_name(args, caleeW, &var, ei); - } + if(SUCCEEDED(hres)) + hres = jsdisp_propput_name(args, caleeW, jsval_disp(calee), ei); } if(FAILED(hres)) { @@ -136,18 +128,16 @@ static HRESULT create_arguments(script_ctx_t *ctx, IDispatch *calee, unsigned ar } static HRESULT create_var_disp(script_ctx_t *ctx, FunctionInstance *function, jsdisp_t *arg_disp, - unsigned argc, VARIANT *argv, jsexcept_t *ei, jsdisp_t **ret) + unsigned argc, jsval_t *argv, jsexcept_t *ei, jsdisp_t **ret) { jsdisp_t *var_disp; - VARIANT var; HRESULT hres; hres = create_dispex(ctx, NULL, NULL, &var_disp); if(FAILED(hres)) return hres; - var_set_jsdisp(&var, arg_disp); - hres = jsdisp_propput_name(var_disp, argumentsW, &var, ei); + hres = jsdisp_propput_name(var_disp, argumentsW, jsval_obj(arg_disp), ei); if(SUCCEEDED(hres)) hres = init_parameters(var_disp, function, argc, argv, ei); if(FAILED(hres)) { @@ -159,7 +149,7 @@ static HRESULT create_var_disp(script_ctx_t *ctx, FunctionInstance *function, js return S_OK; } -static HRESULT invoke_source(script_ctx_t *ctx, FunctionInstance *function, IDispatch *this_obj, unsigned argc, VARIANT *argv, +static HRESULT invoke_source(script_ctx_t *ctx, FunctionInstance *function, IDispatch *this_obj, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { jsdisp_t *var_disp, *arg_disp; @@ -207,7 +197,7 @@ static HRESULT invoke_source(script_ctx_t *ctx, FunctionInstance *function, IDis return hres; } -static HRESULT invoke_constructor(script_ctx_t *ctx, FunctionInstance *function, unsigned argc, VARIANT *argv, +static HRESULT invoke_constructor(script_ctx_t *ctx, FunctionInstance *function, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { jsdisp_t *this_obj; @@ -234,7 +224,7 @@ static HRESULT invoke_constructor(script_ctx_t *ctx, FunctionInstance *function, return S_OK; } -static HRESULT invoke_value_proc(script_ctx_t *ctx, FunctionInstance *function, IDispatch *this_disp, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT invoke_value_proc(script_ctx_t *ctx, FunctionInstance *function, IDispatch *this_disp, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { vdisp_t vthis; @@ -254,7 +244,7 @@ static HRESULT invoke_value_proc(script_ctx_t *ctx, FunctionInstance *function, } static HRESULT call_function(script_ctx_t *ctx, FunctionInstance *function, IDispatch *this_obj, - unsigned argc, VARIANT *argv, jsval_t *r, jsexcept_t *ei) + unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { if(function->value_proc) return invoke_value_proc(ctx, function, this_obj, DISPATCH_METHOD, argc, argv, r, ei); @@ -291,7 +281,7 @@ static HRESULT function_to_string(FunctionInstance *function, BSTR *ret) return S_OK; } -HRESULT Function_invoke(jsdisp_t *func_this, IDispatch *jsthis, WORD flags, unsigned argc, VARIANT *argv, jsval_t *r, jsexcept_t *ei) +HRESULT Function_invoke(jsdisp_t *func_this, IDispatch *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { FunctionInstance *function; @@ -310,7 +300,7 @@ HRESULT Function_invoke(jsdisp_t *func_this, IDispatch *jsthis, WORD flags, unsi return invoke_source(function->dispex.ctx, function, jsthis, argc, argv, r, ei); } -static HRESULT Function_length(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Function_length(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { FunctionInstance *This = function_from_vdisp(jsthis); @@ -329,7 +319,7 @@ static HRESULT Function_length(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u return S_OK; } -static HRESULT Function_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Function_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { FunctionInstance *function; @@ -352,32 +342,32 @@ static HRESULT Function_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, return S_OK; } -static HRESULT array_to_args(script_ctx_t *ctx, jsdisp_t *arg_array, jsexcept_t *ei, unsigned *argc, VARIANT **ret) +static HRESULT array_to_args(script_ctx_t *ctx, jsdisp_t *arg_array, jsexcept_t *ei, unsigned *argc, jsval_t **ret) { - VARIANT var, *argv; + jsval_t *argv, val; DWORD length, i; HRESULT hres; - hres = jsdisp_propget_name(arg_array, lengthW, &var, ei); + hres = jsdisp_propget_name(arg_array, lengthW, &val, ei); if(FAILED(hres)) return hres; - hres = to_uint32(ctx, &var, ei, &length); - VariantClear(&var); + hres = to_uint32_jsval(ctx, val, ei, &length); + jsval_release(val); if(FAILED(hres)) return hres; - argv = heap_alloc(length * sizeof(VARIANT)); + argv = heap_alloc(length * sizeof(*argv)); if(!argv) return E_OUTOFMEMORY; for(i=0; i= 2) { jsdisp_t *arg_array = NULL; - if(V_VT(argv+1) == VT_DISPATCH) { - arg_array = iface_to_jsdisp((IUnknown*)V_DISPATCH(argv+1)); + if(is_object_instance(argv[1])) { + arg_array = iface_to_jsdisp((IUnknown*)get_object(argv[1])); if(arg_array && (!is_class(arg_array, JSCLASS_ARRAY) && !is_class(arg_array, JSCLASS_ARGUMENTS) )) { jsdisp_release(arg_array); @@ -437,12 +427,12 @@ static HRESULT Function_apply(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un if(this_obj) IDispatch_Release(this_obj); for(i=0; i < cnt; i++) - VariantClear(args+i); + jsval_release(args[i]); heap_free(args); return hres; } -static HRESULT Function_call(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Function_call(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { FunctionInstance *function; @@ -456,8 +446,8 @@ static HRESULT Function_call(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns return throw_type_error(ctx, ei, JS_E_FUNCTION_EXPECTED, NULL); if(argc) { - if(V_VT(argv) != VT_EMPTY && V_VT(argv) != VT_NULL) { - hres = to_object(ctx, argv, &this_obj); + if(!is_undefined(argv[0]) && !is_null(argv[0])) { + hres = to_object_jsval(ctx, argv[0], &this_obj); if(FAILED(hres)) return hres; } @@ -472,7 +462,7 @@ static HRESULT Function_call(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns return hres; } -HRESULT Function_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +HRESULT Function_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { FunctionInstance *function; @@ -516,7 +506,7 @@ HRESULT Function_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned } static HRESULT Function_arguments(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) { FunctionInstance *function = (FunctionInstance*)jsthis->u.jsdisp; HRESULT hres = S_OK; @@ -609,12 +599,9 @@ static HRESULT create_function(script_ctx_t *ctx, const builtin_info_t *builtin_ static HRESULT set_prototype(script_ctx_t *ctx, jsdisp_t *dispex, jsdisp_t *prototype) { jsexcept_t jsexcept; - VARIANT var; - var_set_jsdisp(&var, prototype); memset(&jsexcept, 0, sizeof(jsexcept)); - - return jsdisp_propput_name(dispex, prototypeW, &var, &jsexcept); + return jsdisp_propput_name(dispex, prototypeW, jsval_obj(prototype), &jsexcept); } HRESULT create_builtin_function(script_ctx_t *ctx, builtin_invoke_t value_proc, const WCHAR *name, @@ -716,7 +703,7 @@ HRESULT create_source_function(script_ctx_t *ctx, bytecode_t *code, function_cod return S_OK; } -static HRESULT construct_function(script_ctx_t *ctx, unsigned argc, VARIANT *argv, jsexcept_t *ei, IDispatch **ret) +static HRESULT construct_function(script_ctx_t *ctx, unsigned argc, jsval_t *argv, jsexcept_t *ei, IDispatch **ret) { WCHAR *str = NULL, *ptr; DWORD len = 0, l; @@ -738,7 +725,7 @@ static HRESULT construct_function(script_ctx_t *ctx, unsigned argc, VARIANT *arg if(argc > 2) len = (argc-2)*2; /* separating commas */ for(i=0; i < argc; i++) { - hres = to_string(ctx, argv+i, ei, params+i); + hres = to_string_jsval(ctx, argv[i], ei, params+i); if(FAILED(hres)) break; len += SysStringLen(params[i]); @@ -803,7 +790,7 @@ static HRESULT construct_function(script_ctx_t *ctx, unsigned argc, VARIANT *arg return S_OK; } -static HRESULT FunctionConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT FunctionConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { HRESULT hres; @@ -829,7 +816,7 @@ static HRESULT FunctionConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD fla return S_OK; } -static HRESULT FunctionProt_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT FunctionProt_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { FIXME("\n"); diff --git a/dlls/jscript/global.c b/dlls/jscript/global.c index f486a0194f..97c580473b 100644 --- a/dlls/jscript/global.c +++ b/dlls/jscript/global.c @@ -114,7 +114,7 @@ static WCHAR int_to_char(int i) return 'A'+i-10; } -static HRESULT constructor_call(jsdisp_t *constr, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT constructor_call(jsdisp_t *constr, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { if(flags != DISPATCH_PROPERTYGET) @@ -124,7 +124,7 @@ static HRESULT constructor_call(jsdisp_t *constr, WORD flags, unsigned argc, VAR return S_OK; } -static HRESULT JSGlobal_Array(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT JSGlobal_Array(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { TRACE("\n"); @@ -132,7 +132,7 @@ static HRESULT JSGlobal_Array(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un return constructor_call(ctx->array_constr, flags, argc, argv, r, ei); } -static HRESULT JSGlobal_Boolean(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT JSGlobal_Boolean(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { TRACE("\n"); @@ -140,7 +140,7 @@ static HRESULT JSGlobal_Boolean(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, return constructor_call(ctx->bool_constr, flags, argc, argv, r, ei); } -static HRESULT JSGlobal_Date(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT JSGlobal_Date(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { TRACE("\n"); @@ -148,7 +148,7 @@ static HRESULT JSGlobal_Date(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns return constructor_call(ctx->date_constr, flags, argc, argv, r, ei); } -static HRESULT JSGlobal_Error(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT JSGlobal_Error(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { TRACE("\n"); @@ -156,7 +156,7 @@ static HRESULT JSGlobal_Error(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un return constructor_call(ctx->error_constr, flags, argc, argv, r, ei); } -static HRESULT JSGlobal_EvalError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT JSGlobal_EvalError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { TRACE("\n"); @@ -164,7 +164,7 @@ static HRESULT JSGlobal_EvalError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags return constructor_call(ctx->eval_error_constr, flags, argc, argv, r, ei); } -static HRESULT JSGlobal_RangeError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT JSGlobal_RangeError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { TRACE("\n"); @@ -172,7 +172,7 @@ static HRESULT JSGlobal_RangeError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flag return constructor_call(ctx->range_error_constr, flags, argc, argv, r, ei); } -static HRESULT JSGlobal_RegExpError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT JSGlobal_RegExpError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { TRACE("\n"); @@ -180,7 +180,7 @@ static HRESULT JSGlobal_RegExpError(script_ctx_t *ctx, vdisp_t *jsthis, WORD fla return constructor_call(ctx->regexp_error_constr, flags, argc, argv, r, ei); } -static HRESULT JSGlobal_ReferenceError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT JSGlobal_ReferenceError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { TRACE("\n"); @@ -188,7 +188,7 @@ static HRESULT JSGlobal_ReferenceError(script_ctx_t *ctx, vdisp_t *jsthis, WORD return constructor_call(ctx->reference_error_constr, flags, argc, argv, r, ei); } -static HRESULT JSGlobal_SyntaxError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT JSGlobal_SyntaxError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { TRACE("\n"); @@ -196,7 +196,7 @@ static HRESULT JSGlobal_SyntaxError(script_ctx_t *ctx, vdisp_t *jsthis, WORD fla return constructor_call(ctx->syntax_error_constr, flags, argc, argv, r, ei); } -static HRESULT JSGlobal_TypeError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT JSGlobal_TypeError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { TRACE("\n"); @@ -204,7 +204,7 @@ static HRESULT JSGlobal_TypeError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags return constructor_call(ctx->type_error_constr, flags, argc, argv, r, ei); } -static HRESULT JSGlobal_URIError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT JSGlobal_URIError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { TRACE("\n"); @@ -212,7 +212,7 @@ static HRESULT JSGlobal_URIError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, return constructor_call(ctx->uri_error_constr, flags, argc, argv, r, ei); } -static HRESULT JSGlobal_Function(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT JSGlobal_Function(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { TRACE("\n"); @@ -220,7 +220,7 @@ static HRESULT JSGlobal_Function(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, return constructor_call(ctx->function_constr, flags, argc, argv, r, ei); } -static HRESULT JSGlobal_Number(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT JSGlobal_Number(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { TRACE("\n"); @@ -228,7 +228,7 @@ static HRESULT JSGlobal_Number(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u return constructor_call(ctx->number_constr, flags, argc, argv, r, ei); } -static HRESULT JSGlobal_Object(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT JSGlobal_Object(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { TRACE("\n"); @@ -236,7 +236,7 @@ static HRESULT JSGlobal_Object(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u return constructor_call(ctx->object_constr, flags, argc, argv, r, ei); } -static HRESULT JSGlobal_String(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT JSGlobal_String(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { TRACE("\n"); @@ -244,7 +244,7 @@ static HRESULT JSGlobal_String(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u return constructor_call(ctx->string_constr, flags, argc, argv, r, ei); } -static HRESULT JSGlobal_RegExp(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT JSGlobal_RegExp(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { TRACE("\n"); @@ -252,7 +252,7 @@ static HRESULT JSGlobal_RegExp(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u return constructor_call(ctx->regexp_constr, flags, argc, argv, r, ei); } -static HRESULT JSGlobal_ActiveXObject(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT JSGlobal_ActiveXObject(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { TRACE("\n"); @@ -260,7 +260,7 @@ static HRESULT JSGlobal_ActiveXObject(script_ctx_t *ctx, vdisp_t *jsthis, WORD f return constructor_call(ctx->activex_constr, flags, argc, argv, r, ei); } -static HRESULT JSGlobal_VBArray(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT JSGlobal_VBArray(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { TRACE("\n"); @@ -268,14 +268,14 @@ static HRESULT JSGlobal_VBArray(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, return constructor_call(ctx->vbarray_constr, flags, argc, argv, r, ei); } -static HRESULT JSGlobal_Enumerator(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT JSGlobal_Enumerator(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 JSGlobal_escape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT JSGlobal_escape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { BSTR ret, str; @@ -297,7 +297,7 @@ static HRESULT JSGlobal_escape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u return S_OK; } - hres = to_string(ctx, argv, ei, &str); + hres = to_string_jsval(ctx, argv[0], ei, &str); if(FAILED(hres)) return hres; @@ -345,7 +345,7 @@ static HRESULT JSGlobal_escape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u } /* ECMA-262 3rd Edition 15.1.2.1 */ -static HRESULT JSGlobal_eval(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT JSGlobal_eval(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { bytecode_t *code; @@ -360,9 +360,9 @@ static HRESULT JSGlobal_eval(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns return S_OK; } - if(V_VT(argv) != VT_BSTR) { + if(!is_string(argv[0])) { if(r) - return variant_to_jsval(argv, r); + return jsval_copy(argv[0], r); return S_OK; } @@ -371,10 +371,10 @@ static HRESULT JSGlobal_eval(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns return E_UNEXPECTED; } - TRACE("parsing %s\n", debugstr_w(V_BSTR(argv))); - hres = compile_script(ctx, V_BSTR(argv), NULL, TRUE, FALSE, &code); + TRACE("parsing %s\n", debugstr_jsval(argv[0])); + hres = compile_script(ctx, get_string(argv[0]), NULL, TRUE, FALSE, &code); if(FAILED(hres)) { - WARN("parse (%s) failed: %08x\n", debugstr_w(V_BSTR(argv)), hres); + WARN("parse (%s) failed: %08x\n", debugstr_jsval(argv[0]), hres); return throw_syntax_error(ctx, ei, hres, NULL); } @@ -390,7 +390,7 @@ static HRESULT JSGlobal_eval(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns return hres; } -static HRESULT JSGlobal_isNaN(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT JSGlobal_isNaN(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { BOOL ret = TRUE; @@ -400,7 +400,7 @@ static HRESULT JSGlobal_isNaN(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un TRACE("\n"); if(argc) { - hres = to_number(ctx, argv, ei, &n); + hres = to_number_jsval(ctx, argv[0], ei, &n); if(FAILED(hres)) return hres; @@ -413,7 +413,7 @@ static HRESULT JSGlobal_isNaN(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un return S_OK; } -static HRESULT JSGlobal_isFinite(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT JSGlobal_isFinite(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { BOOL ret = FALSE; @@ -424,7 +424,7 @@ static HRESULT JSGlobal_isFinite(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, if(argc) { double n; - hres = to_number(ctx, argv, ei, &n); + hres = to_number_jsval(ctx, argv[0], ei, &n); if(FAILED(hres)) return hres; @@ -448,7 +448,7 @@ static INT char_to_int(WCHAR c) return 100; } -static HRESULT JSGlobal_parseInt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT JSGlobal_parseInt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { BOOL neg = FALSE, empty = TRUE; @@ -465,7 +465,7 @@ static HRESULT JSGlobal_parseInt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, } if(argc >= 2) { - hres = to_int32(ctx, argv+1, ei, &radix); + hres = to_int32(ctx, argv[1], ei, &radix); if(FAILED(hres)) return hres; @@ -477,7 +477,7 @@ static HRESULT JSGlobal_parseInt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, } } - hres = to_string(ctx, argv, ei, &str); + hres = to_string_jsval(ctx, argv[0], ei, &str); if(FAILED(hres)) return hres; @@ -528,7 +528,7 @@ static HRESULT JSGlobal_parseInt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, return S_OK; } -static HRESULT JSGlobal_parseFloat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT JSGlobal_parseFloat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { LONGLONG d = 0, hlp; @@ -544,7 +544,7 @@ static HRESULT JSGlobal_parseFloat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flag return S_OK; } - hres = to_string(ctx, argv, ei, &val_str); + hres = to_string_jsval(ctx, argv[0], ei, &val_str); if(FAILED(hres)) return hres; @@ -635,7 +635,7 @@ static inline int hex_to_int(const WCHAR wch) { return -1; } -static HRESULT JSGlobal_unescape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT JSGlobal_unescape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { BSTR ret, str; @@ -656,7 +656,7 @@ static HRESULT JSGlobal_unescape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, return S_OK; } - hres = to_string(ctx, argv, ei, &str); + hres = to_string_jsval(ctx, argv[0], ei, &str); if(FAILED(hres)) return hres; @@ -709,14 +709,14 @@ static HRESULT JSGlobal_unescape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, return S_OK; } -static HRESULT JSGlobal_GetObject(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT JSGlobal_GetObject(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 JSGlobal_ScriptEngine(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT JSGlobal_ScriptEngine(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { static const WCHAR JScriptW[] = {'J','S','c','r','i','p','t',0}; @@ -736,7 +736,7 @@ static HRESULT JSGlobal_ScriptEngine(script_ctx_t *ctx, vdisp_t *jsthis, WORD fl return S_OK; } -static HRESULT JSGlobal_ScriptEngineMajorVersion(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT JSGlobal_ScriptEngineMajorVersion(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { TRACE("\n"); @@ -746,7 +746,7 @@ static HRESULT JSGlobal_ScriptEngineMajorVersion(script_ctx_t *ctx, vdisp_t *jst return S_OK; } -static HRESULT JSGlobal_ScriptEngineMinorVersion(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT JSGlobal_ScriptEngineMinorVersion(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { TRACE("\n"); @@ -756,7 +756,7 @@ static HRESULT JSGlobal_ScriptEngineMinorVersion(script_ctx_t *ctx, vdisp_t *jst return S_OK; } -static HRESULT JSGlobal_ScriptEngineBuildVersion(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT JSGlobal_ScriptEngineBuildVersion(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { TRACE("\n"); @@ -766,14 +766,14 @@ static HRESULT JSGlobal_ScriptEngineBuildVersion(script_ctx_t *ctx, vdisp_t *jst return S_OK; } -static HRESULT JSGlobal_CollectGarbage(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT JSGlobal_CollectGarbage(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 JSGlobal_encodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { const WCHAR *ptr; @@ -797,7 +797,7 @@ static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags return S_OK; } - hres = to_string(ctx, argv, ei, &str); + hres = to_string_jsval(ctx, argv[0], ei, &str); if(FAILED(hres)) return hres; @@ -844,7 +844,7 @@ static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags return S_OK; } -static HRESULT JSGlobal_decodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT JSGlobal_decodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { BSTR str, ret; @@ -868,7 +868,7 @@ static HRESULT JSGlobal_decodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags return S_OK; } - hres = to_string(ctx, argv, ei, &str); + hres = to_string_jsval(ctx, argv[0], ei, &str); if(FAILED(hres)) return hres; @@ -936,7 +936,7 @@ static HRESULT JSGlobal_decodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags return S_OK; } -static HRESULT JSGlobal_encodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT JSGlobal_encodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { BSTR str, ret; @@ -959,7 +959,7 @@ static HRESULT JSGlobal_encodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, W return S_OK; } - hres = to_string(ctx, argv, ei, &str); + hres = to_string_jsval(ctx, argv[0], ei, &str); if(FAILED(hres)) return hres; @@ -1006,7 +1006,7 @@ static HRESULT JSGlobal_encodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, W } /* ECMA-262 3rd Edition 15.1.3.2 */ -static HRESULT JSGlobal_decodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT JSGlobal_decodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { BSTR str, ret; @@ -1029,7 +1029,7 @@ static HRESULT JSGlobal_decodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, W return S_OK; } - hres = to_string(ctx, argv, ei, &str); + hres = to_string_jsval(ctx, argv[0], ei, &str); if(FAILED(hres)) return hres; @@ -1226,7 +1226,6 @@ static HRESULT init_constructors(script_ctx_t *ctx, jsdisp_t *object_prototype) HRESULT init_global(script_ctx_t *ctx) { jsdisp_t *math, *object_prototype; - VARIANT var; HRESULT hres; if(ctx->global) @@ -1249,23 +1248,19 @@ HRESULT init_global(script_ctx_t *ctx) if(FAILED(hres)) return hres; - var_set_jsdisp(&var, math); - hres = jsdisp_propput_name(ctx->global, MathW, &var, NULL/*FIXME*/); + hres = jsdisp_propput_name(ctx->global, MathW, jsval_obj(math), NULL/*FIXME*/); jsdisp_release(math); if(FAILED(hres)) return hres; - V_VT(&var) = VT_EMPTY; - hres = jsdisp_propput_name(ctx->global, undefinedW, &var, NULL/*FIXME*/); + hres = jsdisp_propput_name(ctx->global, undefinedW, jsval_undefined(), NULL/*FIXME*/); if(FAILED(hres)) return hres; - num_set_val(&var, NAN); - hres = jsdisp_propput_name(ctx->global, NaNW, &var, NULL/*FIXME*/); + hres = jsdisp_propput_name(ctx->global, NaNW, jsval_number(NAN), NULL/*FIXME*/); if(FAILED(hres)) return hres; - num_set_val(&var, INFINITY); - hres = jsdisp_propput_name(ctx->global, InfinityW, &var, NULL/*FIXME*/); + hres = jsdisp_propput_name(ctx->global, InfinityW, jsval_number(INFINITY), NULL/*FIXME*/); return hres; } diff --git a/dlls/jscript/jscript.h b/dlls/jscript/jscript.h index 24125a8a88..f9fcd73c51 100644 --- a/dlls/jscript/jscript.h +++ b/dlls/jscript/jscript.h @@ -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; diff --git a/dlls/jscript/jsutils.c b/dlls/jscript/jsutils.c index 474f3473cf..b0a2047674 100644 --- a/dlls/jscript/jsutils.c +++ b/dlls/jscript/jsutils.c @@ -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; diff --git a/dlls/jscript/math.c b/dlls/jscript/math.c index 901657d4eb..679e37e31a 100644 --- a/dlls/jscript/math.c +++ b/dlls/jscript/math.c @@ -58,7 +58,7 @@ static const WCHAR sqrtW[] = {'s','q','r','t',0}; static const WCHAR tanW[] = {'t','a','n',0}; /* ECMA-262 3rd Edition 15.8.2.12 */ -static HRESULT Math_abs(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Math_abs(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { double d; @@ -72,7 +72,7 @@ static HRESULT Math_abs(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned return S_OK; } - hres = to_number(ctx, argv, ei, &d); + hres = to_number_jsval(ctx, argv[0], ei, &d); if(FAILED(hres)) return hres; @@ -81,7 +81,7 @@ static HRESULT Math_abs(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned return S_OK; } -static HRESULT Math_acos(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Math_acos(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { double x; @@ -95,7 +95,7 @@ static HRESULT Math_acos(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigne return S_OK; } - hres = to_number(ctx, argv, ei, &x); + hres = to_number_jsval(ctx, argv[0], ei, &x); if(FAILED(hres)) return hres; @@ -104,7 +104,7 @@ static HRESULT Math_acos(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigne return S_OK; } -static HRESULT Math_asin(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Math_asin(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { double x; @@ -118,7 +118,7 @@ static HRESULT Math_asin(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigne return S_OK; } - hres = to_number(ctx, argv, ei, &x); + hres = to_number_jsval(ctx, argv[0], ei, &x); if(FAILED(hres)) return hres; @@ -127,7 +127,7 @@ static HRESULT Math_asin(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigne return S_OK; } -static HRESULT Math_atan(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Math_atan(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { double x; @@ -141,7 +141,7 @@ static HRESULT Math_atan(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigne return S_OK; } - hres = to_number(ctx, argv, ei, &x); + hres = to_number_jsval(ctx, argv[0], ei, &x); if(FAILED(hres)) return hres; @@ -150,7 +150,7 @@ static HRESULT Math_atan(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigne return S_OK; } -static HRESULT Math_atan2(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Math_atan2(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { double x, y; @@ -164,11 +164,11 @@ static HRESULT Math_atan2(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsign return S_OK; } - hres = to_number(ctx, argv, ei, &y); + hres = to_number_jsval(ctx, argv[0], ei, &y); if(FAILED(hres)) return hres; - hres = to_number(ctx, argv+1, ei, &x); + hres = to_number_jsval(ctx, argv[1], ei, &x); if(FAILED(hres)) return hres; @@ -178,7 +178,7 @@ static HRESULT Math_atan2(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsign } /* ECMA-262 3rd Edition 15.8.2.6 */ -static HRESULT Math_ceil(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Math_ceil(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { double x; @@ -192,7 +192,7 @@ static HRESULT Math_ceil(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigne return S_OK; } - hres = to_number(ctx, argv, ei, &x); + hres = to_number_jsval(ctx, argv[0], ei, &x); if(FAILED(hres)) return hres; @@ -201,7 +201,7 @@ static HRESULT Math_ceil(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigne return S_OK; } -static HRESULT Math_cos(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Math_cos(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { double x; @@ -215,7 +215,7 @@ static HRESULT Math_cos(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned return S_OK; } - hres = to_number(ctx, argv, ei, &x); + hres = to_number_jsval(ctx, argv[0], ei, &x); if(FAILED(hres)) return hres; @@ -224,7 +224,7 @@ static HRESULT Math_cos(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned return S_OK; } -static HRESULT Math_exp(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Math_exp(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { double x; @@ -238,7 +238,7 @@ static HRESULT Math_exp(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned return S_OK; } - hres = to_number(ctx, argv, ei, &x); + hres = to_number_jsval(ctx, argv[0], ei, &x); if(FAILED(hres)) return hres; @@ -247,7 +247,7 @@ static HRESULT Math_exp(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned return S_OK; } -static HRESULT Math_floor(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Math_floor(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { double x; @@ -261,7 +261,7 @@ static HRESULT Math_floor(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsign return S_OK; } - hres = to_number(ctx, argv, ei, &x); + hres = to_number_jsval(ctx, argv[0], ei, &x); if(FAILED(hres)) return hres; @@ -270,7 +270,7 @@ static HRESULT Math_floor(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsign return S_OK; } -static HRESULT Math_log(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Math_log(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { double x; @@ -284,7 +284,7 @@ static HRESULT Math_log(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned return S_OK; } - hres = to_number(ctx, argv, ei, &x); + hres = to_number_jsval(ctx, argv[0], ei, &x); if(FAILED(hres)) return hres; @@ -294,7 +294,7 @@ static HRESULT Math_log(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned } /* ECMA-262 3rd Edition 15.8.2.11 */ -static HRESULT Math_max(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Math_max(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { DOUBLE max, d; @@ -309,12 +309,12 @@ static HRESULT Math_max(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned return S_OK; } - hres = to_number(ctx, argv, ei, &max); + hres = to_number_jsval(ctx, argv[0], ei, &max); if(FAILED(hres)) return hres; for(i=1; i < argc; i++) { - hres = to_number(ctx, argv+i, ei, &d); + hres = to_number_jsval(ctx, argv[i], ei, &d); if(FAILED(hres)) return hres; @@ -328,7 +328,7 @@ static HRESULT Math_max(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned } /* ECMA-262 3rd Edition 15.8.2.12 */ -static HRESULT Math_min(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Math_min(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { DOUBLE min, d; @@ -343,12 +343,12 @@ static HRESULT Math_min(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned return S_OK; } - hres = to_number(ctx, argv, ei, &min); + hres = to_number_jsval(ctx, argv[0], ei, &min); if(FAILED(hres)) return hres; for(i=1; i < argc; i++) { - hres = to_number(ctx, argv+i, ei, &d); + hres = to_number_jsval(ctx, argv[i], ei, &d); if(FAILED(hres)) return hres; @@ -362,7 +362,7 @@ static HRESULT Math_min(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned } /* ECMA-262 3rd Edition 15.8.2.13 */ -static HRESULT Math_pow(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Math_pow(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { double x, y; @@ -376,11 +376,11 @@ static HRESULT Math_pow(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned return S_OK; } - hres = to_number(ctx, argv, ei, &x); + hres = to_number_jsval(ctx, argv[0], ei, &x); if(FAILED(hres)) return hres; - hres = to_number(ctx, argv+1, ei, &y); + hres = to_number_jsval(ctx, argv[1], ei, &y); if(FAILED(hres)) return hres; @@ -390,7 +390,7 @@ static HRESULT Math_pow(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned } /* ECMA-262 3rd Edition 15.8.2.14 */ -static HRESULT Math_random(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Math_random(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { UINT x; @@ -406,7 +406,7 @@ static HRESULT Math_random(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsig } /* ECMA-262 3rd Edition 15.8.2.15 */ -static HRESULT Math_round(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Math_round(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { double x; @@ -420,7 +420,7 @@ static HRESULT Math_round(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsign return S_OK; } - hres = to_number(ctx, argv, ei, &x); + hres = to_number_jsval(ctx, argv[0], ei, &x); if(FAILED(hres)) return hres; @@ -429,7 +429,7 @@ static HRESULT Math_round(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsign return S_OK; } -static HRESULT Math_sin(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Math_sin(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { double x; @@ -443,7 +443,7 @@ static HRESULT Math_sin(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned return S_OK; } - hres = to_number(ctx, argv, ei, &x); + hres = to_number_jsval(ctx, argv[0], ei, &x); if(FAILED(hres)) return hres; @@ -452,7 +452,7 @@ static HRESULT Math_sin(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned return S_OK; } -static HRESULT Math_sqrt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Math_sqrt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { double x; @@ -466,7 +466,7 @@ static HRESULT Math_sqrt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigne return S_OK; } - hres = to_number(ctx, argv, ei, &x); + hres = to_number_jsval(ctx, argv[0], ei, &x); if(FAILED(hres)) return hres; @@ -475,7 +475,7 @@ static HRESULT Math_sqrt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigne return S_OK; } -static HRESULT Math_tan(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT Math_tan(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { double x; @@ -489,7 +489,7 @@ static HRESULT Math_tan(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned return S_OK; } - hres = to_number(ctx, argv, ei, &x); + hres = to_number_jsval(ctx, argv[0], ei, &x); if(FAILED(hres)) return hres; diff --git a/dlls/jscript/number.c b/dlls/jscript/number.c index 46b83ab38b..b72ec28beb 100644 --- a/dlls/jscript/number.c +++ b/dlls/jscript/number.c @@ -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 { diff --git a/dlls/jscript/object.c b/dlls/jscript/object.c index fa0e25a8c2..a00f1c7591 100644 --- a/dlls/jscript/object.c +++ b/dlls/jscript/object.c @@ -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; diff --git a/dlls/jscript/regexp.c b/dlls/jscript/regexp.c index 8a55d7e83b..e783c540a1 100644 --- a/dlls/jscript/regexp.c +++ b/dlls/jscript/regexp.c @@ -3473,7 +3473,7 @@ HRESULT regexp_match(script_ctx_t *ctx, jsdisp_t *dispex, const WCHAR *str, DWOR return S_OK; } -static HRESULT RegExp_source(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT RegExp_source(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { TRACE("\n"); @@ -3495,35 +3495,35 @@ static HRESULT RegExp_source(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns return S_OK; } -static HRESULT RegExp_global(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT RegExp_global(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 RegExp_ignoreCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT RegExp_ignoreCase(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 RegExp_multiline(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT RegExp_multiline(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 INT index_from_var(script_ctx_t *ctx, VARIANT *v) +static INT index_from_val(script_ctx_t *ctx, jsval_t v) { jsexcept_t ei; double n; HRESULT hres; memset(&ei, 0, sizeof(ei)); - hres = to_number(ctx, v, &ei, &n); + hres = to_number_jsval(ctx, v, &ei, &n); if(FAILED(hres)) { /* FIXME: Move ignoring exceptions to to_primitive */ VariantClear(&ei.var); return 0; @@ -3533,7 +3533,7 @@ static INT index_from_var(script_ctx_t *ctx, VARIANT *v) return is_int32(n) ? n : 0; } -static HRESULT RegExp_lastIndex(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT RegExp_lastIndex(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { TRACE("\n"); @@ -3548,11 +3548,11 @@ static HRESULT RegExp_lastIndex(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, RegExpInstance *regexp = regexp_from_vdisp(jsthis); HRESULT hres; - hres = VariantCopy(®exp->last_index_var, argv); + hres = jsval_to_variant(argv[0], ®exp->last_index_var); if(FAILED(hres)) return hres; - regexp->last_index = index_from_var(ctx, argv); + regexp->last_index = index_from_val(ctx, argv[0]); break; } default: @@ -3563,7 +3563,7 @@ static HRESULT RegExp_lastIndex(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, return S_OK; } -static HRESULT RegExp_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT RegExp_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { FIXME("\n"); @@ -3574,7 +3574,7 @@ static HRESULT create_match_array(script_ctx_t *ctx, BSTR input, const match_res const match_result_t *parens, DWORD parens_cnt, jsexcept_t *ei, IDispatch **ret) { jsdisp_t *array; - VARIANT var; + BSTR str; int i; HRESULT hres = S_OK; @@ -3588,43 +3588,38 @@ static HRESULT create_match_array(script_ctx_t *ctx, BSTR input, const match_res return hres; for(i=0; i < parens_cnt; i++) { - V_VT(&var) = VT_BSTR; - V_BSTR(&var) = SysAllocStringLen(parens[i].str, parens[i].len); - if(!V_BSTR(&var)) { + str = SysAllocStringLen(parens[i].str, parens[i].len); + if(!str) { hres = E_OUTOFMEMORY; break; } - hres = jsdisp_propput_idx(array, i+1, &var, ei); - SysFreeString(V_BSTR(&var)); + hres = jsdisp_propput_idx(array, i+1, jsval_string(str), ei); + SysFreeString(str); if(FAILED(hres)) break; } while(SUCCEEDED(hres)) { - num_set_int(&var, result->str-input); - hres = jsdisp_propput_name(array, indexW, &var, ei); + hres = jsdisp_propput_name(array, indexW, jsval_number(result->str-input), ei); if(FAILED(hres)) break; - num_set_int(&var, result->str-input+result->len); - hres = jsdisp_propput_name(array, lastIndexW, &var, ei); + hres = jsdisp_propput_name(array, lastIndexW, jsval_number(result->str-input+result->len), ei); if(FAILED(hres)) break; - V_VT(&var) = VT_BSTR; - V_BSTR(&var) = input; - hres = jsdisp_propput_name(array, inputW, &var, ei); + hres = jsdisp_propput_name(array, inputW, jsval_string(input), ei); if(FAILED(hres)) break; - V_BSTR(&var) = SysAllocStringLen(result->str, result->len); - if(!V_BSTR(&var)) { + str = SysAllocStringLen(result->str, result->len); + if(!str) { hres = E_OUTOFMEMORY; break; } - hres = jsdisp_propput_name(array, zeroW, &var, ei); - SysFreeString(V_BSTR(&var)); + hres = jsdisp_propput_name(array, zeroW, jsval_string(str), ei); + SysFreeString(str); break; } @@ -3637,7 +3632,7 @@ static HRESULT create_match_array(script_ctx_t *ctx, BSTR input, const match_res return S_OK; } -static HRESULT run_exec(script_ctx_t *ctx, vdisp_t *jsthis, VARIANT *arg, jsexcept_t *ei, BSTR *input, +static HRESULT run_exec(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t arg, jsexcept_t *ei, BSTR *input, match_result_t *match, match_result_t **parens, DWORD *parens_cnt, VARIANT_BOOL *ret) { RegExpInstance *regexp; @@ -3653,15 +3648,10 @@ static HRESULT run_exec(script_ctx_t *ctx, vdisp_t *jsthis, VARIANT *arg, jsexce regexp = regexp_from_vdisp(jsthis); - if(arg) { - hres = to_string(ctx, arg, ei, &string); - if(FAILED(hres)) - return hres; - length = SysStringLen(string); - }else { - string = NULL; - length = 0; - } + hres = to_string_jsval(ctx, arg, ei, &string); + if(FAILED(hres)) + return hres; + length = SysStringLen(string); if(regexp->jsregexp->flags & JSREG_GLOB) { if(regexp->last_index < 0) { @@ -3694,7 +3684,7 @@ static HRESULT run_exec(script_ctx_t *ctx, vdisp_t *jsthis, VARIANT *arg, jsexce return S_OK; } -static HRESULT RegExp_exec(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT RegExp_exec(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { match_result_t *parens = NULL, match; @@ -3705,7 +3695,7 @@ static HRESULT RegExp_exec(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsig TRACE("\n"); - hres = run_exec(ctx, jsthis, argc ? argv : NULL, ei, &string, &match, &parens, &parens_cnt, &b); + hres = run_exec(ctx, jsthis, argc ? argv[0] : jsval_string(NULL), ei, &string, &match, &parens, &parens_cnt, &b); if(FAILED(hres)) return hres; @@ -3726,26 +3716,25 @@ static HRESULT RegExp_exec(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsig return hres; } -static HRESULT RegExp_test(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT RegExp_test(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { match_result_t match; - VARIANT undef_var; + BSTR undef_str; VARIANT_BOOL b; HRESULT hres; TRACE("\n"); if(!argc) { - V_VT(&undef_var) = VT_BSTR; - V_BSTR(&undef_var) = SysAllocString(undefinedW); - if(!V_BSTR(&undef_var)) + undef_str = SysAllocString(undefinedW); + if(!undef_str) return E_OUTOFMEMORY; } - hres = run_exec(ctx, jsthis, argc ? argv : &undef_var, ei, NULL, &match, NULL, NULL, &b); + hres = run_exec(ctx, jsthis, argc ? argv[0] : jsval_string(undef_str), ei, NULL, &match, NULL, NULL, &b); if(!argc) - SysFreeString(V_BSTR(&undef_var)); + SysFreeString(undef_str); if(FAILED(hres)) return hres; @@ -3754,7 +3743,7 @@ static HRESULT RegExp_test(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsig return S_OK; } -static HRESULT RegExp_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT RegExp_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { TRACE("\n"); @@ -3874,16 +3863,16 @@ HRESULT create_regexp(script_ctx_t *ctx, const WCHAR *exp, int len, DWORD flags, return S_OK; } -HRESULT create_regexp_var(script_ctx_t *ctx, VARIANT *src_arg, VARIANT *flags_arg, jsdisp_t **ret) +HRESULT create_regexp_var(script_ctx_t *ctx, jsval_t src_arg, jsval_t *flags_arg, jsdisp_t **ret) { const WCHAR *opt = emptyW, *src; DWORD flags; HRESULT hres; - if(V_VT(src_arg) == VT_DISPATCH) { + if(is_object_instance(src_arg)) { jsdisp_t *obj; - obj = iface_to_jsdisp((IUnknown*)V_DISPATCH(src_arg)); + obj = iface_to_jsdisp((IUnknown*)get_object(src_arg)); if(obj) { if(is_class(obj, JSCLASS_REGEXP)) { RegExpInstance *regexp = (RegExpInstance*)obj; @@ -3897,20 +3886,20 @@ HRESULT create_regexp_var(script_ctx_t *ctx, VARIANT *src_arg, VARIANT *flags_ar } } - if(V_VT(src_arg) != VT_BSTR) { - FIXME("flags_arg = %s\n", debugstr_variant(flags_arg)); + if(!is_string(src_arg)) { + FIXME("src_arg = %s\n", debugstr_jsval(src_arg)); return E_NOTIMPL; } - src = V_BSTR(src_arg); + src = get_string(src_arg); if(flags_arg) { - if(V_VT(flags_arg) != VT_BSTR) { - FIXME("unimplemented for vt %d\n", V_VT(flags_arg)); + if(!is_string(*flags_arg)) { + FIXME("unimplemented for %s\n", debugstr_jsval(*flags_arg)); return E_NOTIMPL; } - opt = V_BSTR(flags_arg); + opt = get_string(*flags_arg); } hres = parse_regexp_flags(opt, strlenW(opt), &flags); @@ -3931,7 +3920,6 @@ HRESULT regexp_string_match(script_ctx_t *ctx, jsdisp_t *re, BSTR str, match_result_t *match_result; DWORD match_cnt, i, length; jsdisp_t *array; - VARIANT var; HRESULT hres; length = SysStringLen(str); @@ -3977,35 +3965,32 @@ HRESULT regexp_string_match(script_ctx_t *ctx, jsdisp_t *re, BSTR str, if(FAILED(hres)) return hres; - V_VT(&var) = VT_BSTR; - for(i=0; i < match_cnt; i++) { - V_BSTR(&var) = SysAllocStringLen(match_result[i].str, match_result[i].len); - if(!V_BSTR(&var)) { + BSTR tmp_str; + + tmp_str = SysAllocStringLen(match_result[i].str, match_result[i].len); + if(!tmp_str) { hres = E_OUTOFMEMORY; break; } - hres = jsdisp_propput_idx(array, i, &var, ei); - SysFreeString(V_BSTR(&var)); + hres = jsdisp_propput_idx(array, i, jsval_string(tmp_str), ei); + SysFreeString(tmp_str); if(FAILED(hres)) break; } while(SUCCEEDED(hres)) { - num_set_int(&var, match_result[match_cnt-1].str-str); - hres = jsdisp_propput_name(array, indexW, &var, ei); + hres = jsdisp_propput_name(array, indexW, jsval_number(match_result[match_cnt-1].str-str), ei); if(FAILED(hres)) break; - num_set_int(&var, match_result[match_cnt-1].str-str+match_result[match_cnt-1].len); - hres = jsdisp_propput_name(array, lastIndexW, &var, ei); + hres = jsdisp_propput_name(array, lastIndexW, + jsval_number(match_result[match_cnt-1].str-str+match_result[match_cnt-1].len), ei); if(FAILED(hres)) break; - V_VT(&var) = VT_BSTR; - V_BSTR(&var) = str; - hres = jsdisp_propput_name(array, inputW, &var, ei); + hres = jsdisp_propput_name(array, inputW, jsval_string(str), ei); break; } @@ -4019,7 +4004,7 @@ HRESULT regexp_string_match(script_ctx_t *ctx, jsdisp_t *re, BSTR str, } static HRESULT RegExpConstr_leftContext(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"); @@ -4045,7 +4030,7 @@ static HRESULT RegExpConstr_leftContext(script_ctx_t *ctx, vdisp_t *jsthis, WORD } static HRESULT RegExpConstr_rightContext(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"); @@ -4070,7 +4055,7 @@ static HRESULT RegExpConstr_rightContext(script_ctx_t *ctx, vdisp_t *jsthis, WOR return S_OK; } -static HRESULT RegExpConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT RegExpConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { TRACE("\n"); @@ -4078,11 +4063,11 @@ static HRESULT RegExpConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags switch(flags) { case DISPATCH_METHOD: if(argc) { - if(V_VT(argv) == VT_DISPATCH) { - jsdisp_t *jsdisp = iface_to_jsdisp((IUnknown*)V_DISPATCH(argv)); + if(is_object_instance(argv[0])) { + jsdisp_t *jsdisp = iface_to_jsdisp((IUnknown*)get_object(argv[0])); if(jsdisp) { if(is_class(jsdisp, JSCLASS_REGEXP)) { - if(argc > 1 && V_VT(argv+1) != VT_EMPTY) { + if(argc > 1 && !is_undefined(argv[1])) { jsdisp_release(jsdisp); return throw_regexp_error(ctx, ei, JS_E_REGEXP_SYNTAX, NULL); } @@ -4107,7 +4092,7 @@ static HRESULT RegExpConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags return E_NOTIMPL; } - hres = create_regexp_var(ctx, argv, argc > 1 ? argv+1 : NULL, &ret); + hres = create_regexp_var(ctx, argv[0], argc > 1 ? argv+1 : NULL, &ret); if(FAILED(hres)) return hres; diff --git a/dlls/jscript/string.c b/dlls/jscript/string.c index 89d7aee1e4..1549ca1bf2 100644 --- a/dlls/jscript/string.c +++ b/dlls/jscript/string.c @@ -102,7 +102,7 @@ static HRESULT get_string_val(script_ctx_t *ctx, vdisp_t *jsthis, jsexcept_t *ei return S_OK; } -static HRESULT String_length(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT String_length(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { TRACE("%p\n", jsthis); @@ -142,7 +142,7 @@ static HRESULT stringobj_to_string(vdisp_t *jsthis, jsval_t *r) } /* ECMA-262 3rd Edition 15.5.4.2 */ -static HRESULT String_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT String_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { TRACE("\n"); @@ -151,7 +151,7 @@ static HRESULT String_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u } /* ECMA-262 3rd Edition 15.5.4.2 */ -static HRESULT String_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT String_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { TRACE("\n"); @@ -188,7 +188,7 @@ static HRESULT do_attributeless_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, j return S_OK; } -static HRESULT do_attribute_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, unsigned argc, VARIANT *argv, jsval_t *r, +static HRESULT do_attribute_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei, const WCHAR *tagname, const WCHAR *attr) { static const WCHAR tagfmtW[] @@ -220,7 +220,7 @@ static HRESULT do_attribute_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, unsig } if(argc) { - hres = to_string(ctx, argv, ei, &attr_value); + hres = to_string_jsval(ctx, argv[0], ei, &attr_value); if(FAILED(hres)) { SysFreeString(val_str); return hres; @@ -252,7 +252,7 @@ static HRESULT do_attribute_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, unsig return S_OK; } -static HRESULT String_anchor(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT String_anchor(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { static const WCHAR fontW[] = {'A',0}; @@ -261,21 +261,21 @@ static HRESULT String_anchor(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns return do_attribute_tag_format(ctx, jsthis, argc, argv, r, ei, fontW, colorW); } -static HRESULT String_big(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT String_big(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { static const WCHAR bigtagW[] = {'B','I','G',0}; return do_attributeless_tag_format(ctx, jsthis, r, ei, bigtagW); } -static HRESULT String_blink(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT String_blink(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { static const WCHAR blinktagW[] = {'B','L','I','N','K',0}; return do_attributeless_tag_format(ctx, jsthis, r, ei, blinktagW); } -static HRESULT String_bold(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT String_bold(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { static const WCHAR boldtagW[] = {'B',0}; @@ -283,7 +283,7 @@ static HRESULT String_bold(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsig } /* ECMA-262 3rd Edition 15.5.4.5 */ -static HRESULT String_charAt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT String_charAt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { const WCHAR *str; @@ -301,7 +301,7 @@ static HRESULT String_charAt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns if(argc) { double d; - hres = to_integer(ctx, argv, ei, &d); + hres = to_integer(ctx, argv[0], ei, &d); if(FAILED(hres)) { SysFreeString(val_str); return hres; @@ -328,7 +328,7 @@ static HRESULT String_charAt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns } /* ECMA-262 3rd Edition 15.5.4.5 */ -static HRESULT String_charCodeAt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT String_charCodeAt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { const WCHAR *str; @@ -345,7 +345,7 @@ static HRESULT String_charCodeAt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, if(argc > 0) { double d; - hres = to_integer(ctx, argv, ei, &d); + hres = to_integer(ctx, argv[0], ei, &d); if(FAILED(hres)) { SysFreeString(val_str); return hres; @@ -369,7 +369,7 @@ static HRESULT String_charCodeAt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, } /* ECMA-262 3rd Edition 15.5.4.6 */ -static HRESULT String_concat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT String_concat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { BSTR *strs = NULL, ret = NULL; @@ -391,7 +391,7 @@ static HRESULT String_concat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns hres = to_string(ctx, &var, ei, strs); if(SUCCEEDED(hres)) { for(i=0; i < argc; i++) { - hres = to_string(ctx, argv+i, ei, strs+i+1); + hres = to_string_jsval(ctx, argv[i], ei, strs+i+1); if(FAILED(hres)) break; } @@ -424,14 +424,14 @@ static HRESULT String_concat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns return S_OK; } -static HRESULT String_fixed(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT String_fixed(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { static const WCHAR fixedtagW[] = {'T','T',0}; return do_attributeless_tag_format(ctx, jsthis, r, ei, fixedtagW); } -static HRESULT String_fontcolor(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT String_fontcolor(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { static const WCHAR fontW[] = {'F','O','N','T',0}; @@ -440,7 +440,7 @@ static HRESULT String_fontcolor(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, return do_attribute_tag_format(ctx, jsthis, argc, argv, r, ei, fontW, colorW); } -static HRESULT String_fontsize(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT String_fontsize(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { static const WCHAR fontW[] = {'F','O','N','T',0}; @@ -449,7 +449,7 @@ static HRESULT String_fontsize(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u return do_attribute_tag_format(ctx, jsthis, argc, argv, r, ei, fontW, colorW); } -static HRESULT String_indexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT String_indexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { DWORD length, pos = 0; @@ -471,7 +471,7 @@ static HRESULT String_indexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un return S_OK; } - hres = to_string(ctx, argv, ei, &search_str); + hres = to_string_jsval(ctx, argv[0], ei, &search_str); if(FAILED(hres)) { SysFreeString(val_str); return hres; @@ -480,7 +480,7 @@ static HRESULT String_indexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un if(argc >= 2) { double d; - hres = to_integer(ctx, argv+1, ei, &d); + hres = to_integer(ctx, argv[1], ei, &d); if(SUCCEEDED(hres) && d > 0.0) pos = is_int32(d) ? min(length, d) : length; } @@ -505,7 +505,7 @@ static HRESULT String_indexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un return S_OK; } -static HRESULT String_italics(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT String_italics(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { static const WCHAR italicstagW[] = {'I',0}; @@ -513,7 +513,7 @@ static HRESULT String_italics(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un } /* ECMA-262 3rd Edition 15.5.4.8 */ -static HRESULT String_lastIndexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT String_lastIndexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { BSTR search_str, val_str; @@ -535,7 +535,7 @@ static HRESULT String_lastIndexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags return S_OK; } - hres = to_string(ctx, argv, ei, &search_str); + hres = to_string_jsval(ctx, argv[0], ei, &search_str); if(FAILED(hres)) { SysFreeString(val_str); return hres; @@ -546,7 +546,7 @@ static HRESULT String_lastIndexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags if(argc >= 2) { double d; - hres = to_integer(ctx, argv+1, ei, &d); + hres = to_integer(ctx, argv[1], ei, &d); if(SUCCEEDED(hres) && d > 0) pos = is_int32(d) ? min(length, d) : length; }else { @@ -574,7 +574,7 @@ static HRESULT String_lastIndexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags return S_OK; } -static HRESULT String_link(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT String_link(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { static const WCHAR fontW[] = {'A',0}; @@ -584,11 +584,11 @@ static HRESULT String_link(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsig } /* ECMA-262 3rd Edition 15.5.4.10 */ -static HRESULT String_match(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT String_match(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { + jsdisp_t *regexp = NULL; const WCHAR *str; - jsdisp_t *regexp; DWORD length; BSTR val_str = NULL; HRESULT hres = S_OK; @@ -601,18 +601,18 @@ static HRESULT String_match(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi return S_OK; } - switch(V_VT(argv)) { - case VT_DISPATCH: - regexp = iface_to_jsdisp((IUnknown*)V_DISPATCH(argv)); - if(regexp) { - if(is_class(regexp, JSCLASS_REGEXP)) - break; + if(is_object_instance(argv[0])) { + regexp = iface_to_jsdisp((IUnknown*)get_object(argv[0])); + if(regexp && !is_class(regexp, JSCLASS_REGEXP)) { jsdisp_release(regexp); + regexp = NULL; } - default: { + } + + if(!regexp) { BSTR match_str; - hres = to_string(ctx, argv, ei, &match_str); + hres = to_string_jsval(ctx, argv[0], ei, &match_str); if(FAILED(hres)) return hres; @@ -621,7 +621,6 @@ static HRESULT String_match(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi if(FAILED(hres)) return hres; } - } hres = get_string_val(ctx, jsthis, ei, &str, &length, &val_str); if(SUCCEEDED(hres)) { @@ -675,40 +674,41 @@ static HRESULT strbuf_append(strbuf_t *buf, const WCHAR *str, DWORD len) static HRESULT rep_call(script_ctx_t *ctx, jsdisp_t *func, const WCHAR *str, match_result_t *match, match_result_t *parens, DWORD parens_cnt, BSTR *ret, jsexcept_t *ei) { - VARIANT *argv; + jsval_t *argv; unsigned argc; jsval_t val; + BSTR tmp_str; DWORD i; HRESULT hres = S_OK; argc = parens_cnt+3; - argv = heap_alloc_zero(sizeof(VARIANT)*argc); + argv = heap_alloc_zero(sizeof(*argv)*argc); if(!argv) return E_OUTOFMEMORY; - V_VT(argv) = VT_BSTR; - V_BSTR(argv) = SysAllocStringLen(match->str, match->len); - if(!V_BSTR(argv)) + tmp_str = SysAllocStringLen(match->str, match->len); + if(!tmp_str) hres = E_OUTOFMEMORY; + argv[0] = jsval_string(tmp_str); if(SUCCEEDED(hres)) { for(i=0; i < parens_cnt; i++) { - V_VT(argv+i+1) = VT_BSTR; - V_BSTR(argv+i+1) = SysAllocStringLen(parens[i].str, parens[i].len); - if(!V_BSTR(argv+i+1)) { + tmp_str = SysAllocStringLen(parens[i].str, parens[i].len); + if(!tmp_str) { hres = E_OUTOFMEMORY; break; } + argv[i+1] = jsval_string(tmp_str); } } if(SUCCEEDED(hres)) { - num_set_int(argv+parens_cnt+1, match->str - str); + argv[parens_cnt+1] = jsval_number(match->str - str); - V_VT(argv+parens_cnt+2) = VT_BSTR; - V_BSTR(argv+parens_cnt+2) = SysAllocString(str); - if(!V_BSTR(argv+parens_cnt+2)) + tmp_str = SysAllocString(str); + if(!tmp_str) hres = E_OUTOFMEMORY; + argv[parens_cnt+2] = jsval_string(tmp_str); } if(SUCCEEDED(hres)) @@ -716,7 +716,7 @@ static HRESULT rep_call(script_ctx_t *ctx, jsdisp_t *func, const WCHAR *str, mat for(i=0; i < parens_cnt+3; i++) { if(i != parens_cnt+1) - SysFreeString(V_BSTR(argv+i)); + SysFreeString(get_string(argv[i])); } heap_free(argv); @@ -729,7 +729,7 @@ static HRESULT rep_call(script_ctx_t *ctx, jsdisp_t *func, const WCHAR *str, mat } /* ECMA-262 3rd Edition 15.5.4.11 */ -static HRESULT String_replace(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT String_replace(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { const WCHAR *str; @@ -760,20 +760,16 @@ static HRESULT String_replace(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un return S_OK; } - switch(V_VT(argv)) { - case VT_DISPATCH: - regexp = iface_to_jsdisp((IUnknown*)V_DISPATCH(argv)); - if(regexp) { - if(is_class(regexp, JSCLASS_REGEXP)) { - break; - }else { - jsdisp_release(regexp); - regexp = NULL; - } + if(is_object_instance(argv[0])) { + regexp = iface_to_jsdisp((IUnknown*)get_object(argv[0])); + if(regexp && !is_class(regexp, JSCLASS_REGEXP)) { + jsdisp_release(regexp); + regexp = NULL; } + } - default: - hres = to_string(ctx, argv, ei, &match_str); + if(!regexp) { + hres = to_string_jsval(ctx, argv[0], ei, &match_str); if(FAILED(hres)) { SysFreeString(val_str); return hres; @@ -781,26 +777,21 @@ static HRESULT String_replace(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un } if(argc >= 2) { - switch(V_VT(argv+1)) { - case VT_DISPATCH: - rep_func = iface_to_jsdisp((IUnknown*)V_DISPATCH(argv+1)); - if(rep_func) { - if(is_class(rep_func, JSCLASS_FUNCTION)) { - break; - }else { - jsdisp_release(rep_func); - rep_func = NULL; - } + if(is_object_instance(argv[1])) { + rep_func = iface_to_jsdisp((IUnknown*)get_object(argv[1])); + if(rep_func && !is_class(rep_func, JSCLASS_FUNCTION)) { + jsdisp_release(rep_func); + rep_func = NULL; } + } - default: - hres = to_string(ctx, argv+1, ei, &rep_str); - if(FAILED(hres)) - break; - - rep_len = SysStringLen(rep_str); - if(!strchrW(rep_str, '$')) - parens_ptr = NULL; + if(!rep_func) { + hres = to_string_jsval(ctx, argv[1], ei, &rep_str); + if(SUCCEEDED(hres)) { + rep_len = SysStringLen(rep_str); + if(!strchrW(rep_str, '$')) + parens_ptr = NULL; + } } } @@ -963,7 +954,7 @@ static HRESULT String_replace(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un return hres; } -static HRESULT String_search(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT String_search(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { jsdisp_t *regexp = NULL; @@ -986,18 +977,16 @@ static HRESULT String_search(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns return S_OK; } - if(V_VT(argv) == VT_DISPATCH) { - regexp = iface_to_jsdisp((IUnknown*)V_DISPATCH(argv)); - if(regexp) { - if(!is_class(regexp, JSCLASS_REGEXP)) { - jsdisp_release(regexp); - regexp = NULL; - } + if(is_object_instance(argv[0])) { + regexp = iface_to_jsdisp((IUnknown*)get_object(argv[0])); + if(regexp && !is_class(regexp, JSCLASS_REGEXP)) { + jsdisp_release(regexp); + regexp = NULL; } } if(!regexp) { - hres = create_regexp_var(ctx, argv, NULL, ®exp); + hres = create_regexp_var(ctx, argv[0], NULL, ®exp); if(FAILED(hres)) { SysFreeString(val_str); return hres; @@ -1017,7 +1006,7 @@ static HRESULT String_search(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns } /* ECMA-262 3rd Edition 15.5.4.13 */ -static HRESULT String_slice(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT String_slice(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { const WCHAR *str; @@ -1034,7 +1023,7 @@ static HRESULT String_slice(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi return hres; if(argc) { - hres = to_integer(ctx, argv, ei, &d); + hres = to_integer(ctx, argv[0], ei, &d); if(FAILED(hres)) { SysFreeString(val_str); return hres; @@ -1055,7 +1044,7 @@ static HRESULT String_slice(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi } if(argc >= 2) { - hres = to_integer(ctx, argv+1, ei, &d); + hres = to_integer(ctx, argv[1], ei, &d); if(FAILED(hres)) { SysFreeString(val_str); return hres; @@ -1094,23 +1083,22 @@ static HRESULT String_slice(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi return S_OK; } -static HRESULT String_small(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT String_small(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { static const WCHAR smalltagW[] = {'S','M','A','L','L',0}; return do_attributeless_tag_format(ctx, jsthis, r, ei, smalltagW); } -static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { match_result_t *match_result = NULL; DWORD length, match_cnt, i, match_len = 0; const WCHAR *str, *ptr, *ptr2; BOOL use_regexp = FALSE; - VARIANT var; jsdisp_t *array; - BSTR val_str, match_str = NULL; + BSTR val_str, match_str = NULL, tmp_str; HRESULT hres; TRACE("\n"); @@ -1124,27 +1112,25 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi if(FAILED(hres)) return hres; - switch(V_VT(argv)) { - case VT_DISPATCH: { + if(is_object_instance(argv[0])) { jsdisp_t *regexp; - regexp = iface_to_jsdisp((IUnknown*)V_DISPATCH(argv)); + regexp = iface_to_jsdisp((IUnknown*)get_object(argv[0])); if(regexp) { if(is_class(regexp, JSCLASS_REGEXP)) { use_regexp = TRUE; hres = regexp_match(ctx, regexp, str, length, TRUE, &match_result, &match_cnt); - jsdisp_release(regexp); - if(FAILED(hres)) { - SysFreeString(val_str); - return hres; - } - break; } jsdisp_release(regexp); + if(FAILED(hres)) { + SysFreeString(val_str); + return hres; + } } } - default: - hres = to_string(ctx, argv, ei, &match_str); + + if(!use_regexp) { + hres = to_string_jsval(ctx, argv[0], ei, &match_str); if(FAILED(hres)) { SysFreeString(val_str); return hres; @@ -1176,15 +1162,14 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi ptr2 = ptr+1; } - V_VT(&var) = VT_BSTR; - V_BSTR(&var) = SysAllocStringLen(ptr, ptr2-ptr); - if(!V_BSTR(&var)) { + tmp_str = SysAllocStringLen(ptr, ptr2-ptr); + if(!tmp_str) { hres = E_OUTOFMEMORY; break; } - hres = jsdisp_propput_idx(array, i, &var, ei); - SysFreeString(V_BSTR(&var)); + hres = jsdisp_propput_idx(array, i, jsval_string(tmp_str), ei); + SysFreeString(tmp_str); if(FAILED(hres)) break; @@ -1201,12 +1186,11 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi DWORD len = (str+length) - ptr; if(len || match_str) { - V_VT(&var) = VT_BSTR; - V_BSTR(&var) = SysAllocStringLen(ptr, len); + tmp_str = SysAllocStringLen(ptr, len); - if(V_BSTR(&var)) { - hres = jsdisp_propput_idx(array, i, &var, ei); - SysFreeString(V_BSTR(&var)); + if(tmp_str) { + hres = jsdisp_propput_idx(array, i, jsval_string(tmp_str), ei); + SysFreeString(tmp_str); }else { hres = E_OUTOFMEMORY; } @@ -1225,14 +1209,14 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi return hres; } -static HRESULT String_strike(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT String_strike(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { static const WCHAR striketagW[] = {'S','T','R','I','K','E',0}; return do_attributeless_tag_format(ctx, jsthis, r, ei, striketagW); } -static HRESULT String_sub(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT String_sub(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { static const WCHAR subtagW[] = {'S','U','B',0}; @@ -1240,7 +1224,7 @@ static HRESULT String_sub(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsign } /* ECMA-262 3rd Edition 15.5.4.15 */ -static HRESULT String_substring(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT String_substring(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { const WCHAR *str; @@ -1257,7 +1241,7 @@ static HRESULT String_substring(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, return hres; if(argc >= 1) { - hres = to_integer(ctx, argv, ei, &d); + hres = to_integer(ctx, argv[0], ei, &d); if(FAILED(hres)) { SysFreeString(val_str); return hres; @@ -1268,7 +1252,7 @@ static HRESULT String_substring(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, } if(argc >= 2) { - hres = to_integer(ctx, argv+1, ei, &d); + hres = to_integer(ctx, argv[1], ei, &d); if(FAILED(hres)) { SysFreeString(val_str); return hres; @@ -1301,7 +1285,7 @@ static HRESULT String_substring(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, } /* ECMA-262 3rd Edition B.2.3 */ -static HRESULT String_substr(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT String_substr(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { BSTR val_str; @@ -1318,7 +1302,7 @@ static HRESULT String_substr(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns return hres; if(argc >= 1) { - hres = to_integer(ctx, argv, ei, &d); + hres = to_integer(ctx, argv[0], ei, &d); if(FAILED(hres)) { SysFreeString(val_str); return hres; @@ -1329,7 +1313,7 @@ static HRESULT String_substr(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns } if(argc >= 2) { - hres = to_integer(ctx, argv+1, ei, &d); + hres = to_integer(ctx, argv[1], ei, &d); if(FAILED(hres)) { SysFreeString(val_str); return hres; @@ -1356,14 +1340,14 @@ static HRESULT String_substr(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns return hres; } -static HRESULT String_sup(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT String_sup(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { static const WCHAR suptagW[] = {'S','U','P',0}; return do_attributeless_tag_format(ctx, jsthis, r, ei, suptagW); } -static HRESULT String_toLowerCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT String_toLowerCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { const WCHAR* str; @@ -1391,7 +1375,7 @@ static HRESULT String_toLowerCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags return S_OK; } -static HRESULT String_toUpperCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT String_toUpperCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { const WCHAR* str; @@ -1419,28 +1403,28 @@ static HRESULT String_toUpperCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags return S_OK; } -static HRESULT String_toLocaleLowerCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT String_toLocaleLowerCase(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 String_toLocaleUpperCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT String_toLocaleUpperCase(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 String_localeCompare(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT String_localeCompare(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 String_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv, +static HRESULT String_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) { StringInstance *This = string_from_vdisp(jsthis); @@ -1534,7 +1518,7 @@ static const builtin_info_t StringInst_info = { /* ECMA-262 3rd Edition 15.5.3.2 */ static HRESULT StringConstr_fromCharCode(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) { DWORD i, code; BSTR ret; @@ -1547,7 +1531,7 @@ static HRESULT StringConstr_fromCharCode(script_ctx_t *ctx, vdisp_t *jsthis, WOR return E_OUTOFMEMORY; for(i=0; isafearray); 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; -- 2.32.0.93.g670b81a890