jscript: Don't use DISPPARAMS for internal arguments.

This commit is contained in:
Jacek Caban 2012-06-25 14:08:38 +02:00 committed by Alexandre Julliard
parent 0307d73569
commit f8383c3417
17 changed files with 744 additions and 845 deletions

View File

@ -138,7 +138,7 @@ static IUnknown *create_activex_object(script_ctx_t *ctx, const WCHAR *progid)
return obj; return obj;
} }
static HRESULT ActiveXObject_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT ActiveXObject_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
IDispatch *disp; IDispatch *disp;
@ -159,12 +159,12 @@ static HRESULT ActiveXObject_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flag
return E_NOTIMPL; return E_NOTIMPL;
} }
if(arg_cnt(dp) != 1) { if(argc != 1) {
FIXME("unsupported arg_cnt %d\n", arg_cnt(dp)); FIXME("unsupported argc %d\n", argc);
return E_NOTIMPL; return E_NOTIMPL;
} }
hres = to_string(ctx, get_arg(dp,0), ei, &progid); hres = to_string(ctx, argv, ei, &progid);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;

View File

@ -116,7 +116,7 @@ static WCHAR *idx_to_str(DWORD idx, WCHAR *ptr)
return ptr+1; return ptr+1;
} }
static HRESULT Array_length(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Array_length(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
ArrayInstance *This = array_from_vdisp(jsthis); ArrayInstance *This = array_from_vdisp(jsthis);
@ -132,7 +132,7 @@ static HRESULT Array_length(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP
DWORD i; DWORD i;
HRESULT hres; HRESULT hres;
hres = to_number(ctx, get_arg(dp, 0), ei, &len); hres = to_number(ctx, argv, ei, &len);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -201,7 +201,7 @@ static HRESULT concat_obj(jsdisp_t *array, IDispatch *obj, DWORD *len, jsexcept_
return jsdisp_propput_idx(array, (*len)++, &var, ei); return jsdisp_propput_idx(array, (*len)++, &var, ei);
} }
static HRESULT Array_concat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Array_concat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
jsdisp_t *ret; jsdisp_t *ret;
@ -219,8 +219,8 @@ static HRESULT Array_concat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP
VARIANT *arg; VARIANT *arg;
DWORD i; DWORD i;
for(i=0; i < arg_cnt(dp); i++) { for(i=0; i < argc; i++) {
arg = get_arg(dp, i); arg = argv+i;
if(V_VT(arg) == VT_DISPATCH) if(V_VT(arg) == VT_DISPATCH)
hres = concat_obj(ret, V_DISPATCH(arg), &len, ei); hres = concat_obj(ret, V_DISPATCH(arg), &len, ei);
else else
@ -340,7 +340,7 @@ static HRESULT array_join(script_ctx_t *ctx, jsdisp_t *array, DWORD length, cons
} }
/* ECMA-262 3rd Edition 15.4.4.5 */ /* ECMA-262 3rd Edition 15.4.4.5 */
static HRESULT Array_join(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPARAMS *dp, static HRESULT Array_join(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
jsdisp_t *jsthis; jsdisp_t *jsthis;
@ -353,10 +353,10 @@ static HRESULT Array_join(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPAR
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(arg_cnt(dp)) { if(argc) {
BSTR sep; BSTR sep;
hres = to_string(ctx, get_arg(dp,0), ei, &sep); hres = to_string(ctx, argv, ei, &sep);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -370,7 +370,7 @@ static HRESULT Array_join(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPAR
return hres; return hres;
} }
static HRESULT Array_pop(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPARAMS *dp, static HRESULT Array_pop(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
jsdisp_t *jsthis; jsdisp_t *jsthis;
@ -421,12 +421,12 @@ static HRESULT Array_pop(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPARA
} }
/* ECMA-262 3rd Edition 15.4.4.7 */ /* ECMA-262 3rd Edition 15.4.4.7 */
static HRESULT Array_push(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPARAMS *dp, static HRESULT Array_push(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
jsdisp_t *jsthis; jsdisp_t *jsthis;
DWORD length = 0; DWORD length = 0;
int i, n; unsigned i;
HRESULT hres; HRESULT hres;
TRACE("\n"); TRACE("\n");
@ -435,23 +435,22 @@ static HRESULT Array_push(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPAR
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
n = arg_cnt(dp); for(i=0; i < argc; i++) {
for(i=0; i < n; i++) { hres = jsdisp_propput_idx(jsthis, length+i, argv+i, ei);
hres = jsdisp_propput_idx(jsthis, length+i, get_arg(dp, i), ei);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
} }
hres = set_length(jsthis, ei, length+n); hres = set_length(jsthis, ei, length+argc);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(retv) if(retv)
num_set_int(retv, length+n); num_set_int(retv, length+argc);
return S_OK; return S_OK;
} }
static HRESULT Array_reverse(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPARAMS *dp, static HRESULT Array_reverse(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
jsdisp_t *jsthis; jsdisp_t *jsthis;
@ -509,7 +508,7 @@ static HRESULT Array_reverse(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISP
} }
/* ECMA-262 3rd Edition 15.4.4.9 */ /* ECMA-262 3rd Edition 15.4.4.9 */
static HRESULT Array_shift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPARAMS *dp, static HRESULT Array_shift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
jsdisp_t *jsthis; jsdisp_t *jsthis;
@ -563,7 +562,7 @@ static HRESULT Array_shift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPA
} }
/* ECMA-262 3rd Edition 15.4.4.10 */ /* ECMA-262 3rd Edition 15.4.4.10 */
static HRESULT Array_slice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPARAMS *dp, static HRESULT Array_slice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
jsdisp_t *arr, *jsthis; jsdisp_t *arr, *jsthis;
@ -577,8 +576,8 @@ static HRESULT Array_slice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPA
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(arg_cnt(dp)) { if(argc) {
hres = to_number(ctx, get_arg(dp, 0), ei, &range); hres = to_number(ctx, argv, ei, &range);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -590,8 +589,8 @@ static HRESULT Array_slice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPA
} }
else start = 0; else start = 0;
if(arg_cnt(dp)>1) { if(argc > 1) {
hres = to_number(ctx, get_arg(dp, 1), ei, &range); hres = to_number(ctx, argv+1, ei, &range);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -639,14 +638,13 @@ static HRESULT sort_cmp(script_ctx_t *ctx, jsdisp_t *cmp_func, VARIANT *v1, VARI
if(cmp_func) { if(cmp_func) {
VARIANTARG args[2]; VARIANTARG args[2];
DISPPARAMS dp = {args, NULL, 2, 0};
double n; double n;
VARIANT res; VARIANT res;
args[0] = *v2; args[0] = *v1;
args[1] = *v1; args[1] = *v2;
hres = jsdisp_call_value(cmp_func, NULL, DISPATCH_METHOD, &dp, &res, ei); hres = jsdisp_call_value(cmp_func, NULL, DISPATCH_METHOD, 2, args, &res, ei);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -689,7 +687,7 @@ static HRESULT sort_cmp(script_ctx_t *ctx, jsdisp_t *cmp_func, VARIANT *v1, VARI
} }
/* ECMA-262 3rd Edition 15.4.4.11 */ /* ECMA-262 3rd Edition 15.4.4.11 */
static HRESULT Array_sort(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPARAMS *dp, static HRESULT Array_sort(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
jsdisp_t *jsthis, *cmp_func = NULL; jsdisp_t *jsthis, *cmp_func = NULL;
@ -704,21 +702,19 @@ static HRESULT Array_sort(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPAR
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(arg_cnt(dp) > 1) { if(argc > 1) {
WARN("invalid arg_cnt %d\n", arg_cnt(dp)); WARN("invalid arg_cnt %d\n", argc);
return E_FAIL; return E_FAIL;
} }
if(arg_cnt(dp) == 1) { if(argc == 1) {
VARIANT *arg = get_arg(dp, 0); if(V_VT(argv) != VT_DISPATCH) {
if(V_VT(arg) != VT_DISPATCH) {
WARN("arg is not dispatch\n"); WARN("arg is not dispatch\n");
return E_FAIL; return E_FAIL;
} }
cmp_func = iface_to_jsdisp((IUnknown*)V_DISPATCH(arg)); cmp_func = iface_to_jsdisp((IUnknown*)V_DISPATCH(argv));
if(!cmp_func || !is_class(cmp_func, JSCLASS_FUNCTION)) { if(!cmp_func || !is_class(cmp_func, JSCLASS_FUNCTION)) {
WARN("cmp_func is not a function\n"); WARN("cmp_func is not a function\n");
if(cmp_func) if(cmp_func)
@ -844,10 +840,10 @@ static HRESULT Array_sort(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPAR
} }
/* ECMA-262 3rd Edition 15.4.4.12 */ /* ECMA-262 3rd Edition 15.4.4.12 */
static HRESULT Array_splice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPARAMS *dp, static HRESULT Array_splice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DWORD length, start=0, delete_cnt=0, argc, i, add_args = 0; DWORD length, start=0, delete_cnt=0, i, add_args = 0;
jsdisp_t *ret_array = NULL, *jsthis; jsdisp_t *ret_array = NULL, *jsthis;
VARIANT v; VARIANT v;
double d; double d;
@ -860,9 +856,8 @@ static HRESULT Array_splice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPP
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
argc = arg_cnt(dp); if(argc) {
if(argc >= 1) { hres = to_integer(ctx, argv, ei, &d);
hres = to_integer(ctx, get_arg(dp,0), ei, &d);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -877,7 +872,7 @@ static HRESULT Array_splice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPP
} }
if(argc >= 2) { if(argc >= 2) {
hres = to_integer(ctx, get_arg(dp,1), ei, &d); hres = to_integer(ctx, argv+1, ei, &d);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -932,7 +927,7 @@ static HRESULT Array_splice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPP
} }
for(i=0; SUCCEEDED(hres) && i < add_args; i++) for(i=0; SUCCEEDED(hres) && i < add_args; i++)
hres = jsdisp_propput_idx(jsthis, start+i, get_arg(dp,i+2), ei); hres = jsdisp_propput_idx(jsthis, start+i, argv+i+2, ei);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
num_set_int(&v, length-delete_cnt+add_args); num_set_int(&v, length-delete_cnt+add_args);
@ -951,7 +946,7 @@ static HRESULT Array_splice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPP
} }
/* ECMA-262 3rd Edition 15.4.4.2 */ /* ECMA-262 3rd Edition 15.4.4.2 */
static HRESULT Array_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Array_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
ArrayInstance *array; ArrayInstance *array;
@ -965,7 +960,7 @@ static HRESULT Array_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI
return array_join(ctx, &array->dispex, array->length, default_separatorW, retv, ei); return array_join(ctx, &array->dispex, array->length, default_separatorW, retv, ei);
} }
static HRESULT Array_toLocaleString(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPARAMS *dp, static HRESULT Array_toLocaleString(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
FIXME("\n"); FIXME("\n");
@ -973,12 +968,12 @@ static HRESULT Array_toLocaleString(script_ctx_t *ctx, vdisp_t *vthis, WORD flag
} }
/* ECMA-262 3rd Edition 15.4.4.13 */ /* ECMA-262 3rd Edition 15.4.4.13 */
static HRESULT Array_unshift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPARAMS *dp, static HRESULT Array_unshift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
jsdisp_t *jsthis; jsdisp_t *jsthis;
WCHAR buf[14], *buf_end, *str; WCHAR buf[14], *buf_end, *str;
DWORD argc, i, length; DWORD i, length;
VARIANT var; VARIANT var;
DISPID id; DISPID id;
HRESULT hres; HRESULT hres;
@ -989,7 +984,6 @@ static HRESULT Array_unshift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISP
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
argc = arg_cnt(dp);
if(argc) { if(argc) {
buf_end = buf + sizeof(buf)/sizeof(WCHAR)-1; buf_end = buf + sizeof(buf)/sizeof(WCHAR)-1;
*buf_end-- = 0; *buf_end-- = 0;
@ -1016,7 +1010,7 @@ static HRESULT Array_unshift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISP
} }
for(i=0; i<argc; i++) { for(i=0; i<argc; i++) {
hres = jsdisp_propput_idx(jsthis, i, get_arg(dp,i), ei); hres = jsdisp_propput_idx(jsthis, i, argv+i, ei);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
} }
@ -1037,7 +1031,7 @@ static HRESULT Array_unshift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISP
return S_OK; return S_OK;
} }
static HRESULT Array_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Array_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
@ -1106,11 +1100,10 @@ static const builtin_info_t Array_info = {
Array_on_put Array_on_put
}; };
static HRESULT ArrayConstr_value(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPARAMS *dp, static HRESULT ArrayConstr_value(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
jsdisp_t *obj; jsdisp_t *obj;
VARIANT *arg_var;
DWORD i; DWORD i;
HRESULT hres; HRESULT hres;
@ -1119,11 +1112,11 @@ static HRESULT ArrayConstr_value(script_ctx_t *ctx, vdisp_t *vthis, WORD flags,
switch(flags) { switch(flags) {
case DISPATCH_METHOD: case DISPATCH_METHOD:
case DISPATCH_CONSTRUCT: { case DISPATCH_CONSTRUCT: {
if(arg_cnt(dp) == 1 && V_VT((arg_var = get_arg(dp, 0))) == VT_I4) { if(argc == 1 && V_VT(argv) == VT_I4) {
if(V_I4(arg_var) < 0) if(V_I4(argv) < 0)
return throw_range_error(ctx, ei, JS_E_INVALID_LENGTH, NULL); return throw_range_error(ctx, ei, JS_E_INVALID_LENGTH, NULL);
hres = create_array(ctx, V_I4(arg_var), &obj); hres = create_array(ctx, V_I4(argv), &obj);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -1131,12 +1124,12 @@ static HRESULT ArrayConstr_value(script_ctx_t *ctx, vdisp_t *vthis, WORD flags,
return S_OK; return S_OK;
} }
hres = create_array(ctx, arg_cnt(dp), &obj); hres = create_array(ctx, argc, &obj);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
for(i=0; i < arg_cnt(dp); i++) { for(i=0; i < argc; i++) {
hres = jsdisp_propput_idx(obj, i, get_arg(dp, i), ei); hres = jsdisp_propput_idx(obj, i, argv+i, ei);
if(FAILED(hres)) if(FAILED(hres))
break; break;
} }

View File

@ -38,7 +38,7 @@ static inline BoolInstance *bool_this(vdisp_t *jsthis)
} }
/* ECMA-262 3rd Edition 15.6.4.2 */ /* ECMA-262 3rd Edition 15.6.4.2 */
static HRESULT Bool_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Bool_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
BoolInstance *bool; BoolInstance *bool;
@ -68,7 +68,7 @@ static HRESULT Bool_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DIS
} }
/* ECMA-262 3rd Edition 15.6.4.3 */ /* ECMA-262 3rd Edition 15.6.4.3 */
static HRESULT Bool_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Bool_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
BoolInstance *bool; BoolInstance *bool;
@ -86,7 +86,7 @@ static HRESULT Bool_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP
return S_OK; return S_OK;
} }
static HRESULT Bool_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Bool_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
@ -117,14 +117,14 @@ static const builtin_info_t Bool_info = {
NULL NULL
}; };
static HRESULT BoolConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT BoolConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
HRESULT hres; HRESULT hres;
VARIANT_BOOL value = VARIANT_FALSE; VARIANT_BOOL value = VARIANT_FALSE;
if(arg_cnt(dp)) { if(argc) {
hres = to_boolean(get_arg(dp,0), &value); hres = to_boolean(argv, &value);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
} }

View File

@ -602,7 +602,7 @@ static HRESULT dateobj_to_string(DateInstance *date, VARIANT *retv)
return date_to_string(time, TRUE, offset, retv); return date_to_string(time, TRUE, offset, retv);
} }
static HRESULT Date_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DateInstance *date; DateInstance *date;
@ -616,7 +616,7 @@ static HRESULT Date_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DIS
} }
/* ECMA-262 3rd Edition 15.9.1.5 */ /* ECMA-262 3rd Edition 15.9.1.5 */
static HRESULT Date_toLocaleString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_toLocaleString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
static const WCHAR NaNW[] = { 'N','a','N',0 }; static const WCHAR NaNW[] = { 'N','a','N',0 };
@ -661,7 +661,7 @@ static HRESULT Date_toLocaleString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flag
return S_OK; return S_OK;
} }
static HRESULT Date_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DateInstance *date; DateInstance *date;
@ -780,14 +780,14 @@ static inline HRESULT create_utc_string(script_ctx_t *ctx, vdisp_t *jsthis,
} }
/* ECMA-262 3rd Edition 15.9.5.42 */ /* ECMA-262 3rd Edition 15.9.5.42 */
static HRESULT Date_toUTCString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_toUTCString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
return create_utc_string(ctx, jsthis, retv, ei); return create_utc_string(ctx, jsthis, retv, ei);
} }
static HRESULT Date_toGMTString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_toGMTString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
@ -892,7 +892,7 @@ static HRESULT dateobj_to_date_string(DateInstance *date, VARIANT *retv)
return S_OK; return S_OK;
} }
static HRESULT Date_toDateString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_toDateString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DateInstance *date; DateInstance *date;
@ -904,7 +904,7 @@ static HRESULT Date_toDateString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
} }
/* ECMA-262 3rd Edition 15.9.5.4 */ /* ECMA-262 3rd Edition 15.9.5.4 */
static HRESULT Date_toTimeString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_toTimeString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
static const WCHAR NaNW[] = { 'N','a','N',0 }; static const WCHAR NaNW[] = { 'N','a','N',0 };
@ -964,7 +964,7 @@ static HRESULT Date_toTimeString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
} }
/* ECMA-262 3rd Edition 15.9.5.6 */ /* ECMA-262 3rd Edition 15.9.5.6 */
static HRESULT Date_toLocaleDateString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_toLocaleDateString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
static const WCHAR NaNW[] = { 'N','a','N',0 }; static const WCHAR NaNW[] = { 'N','a','N',0 };
@ -1007,7 +1007,7 @@ static HRESULT Date_toLocaleDateString(script_ctx_t *ctx, vdisp_t *jsthis, WORD
} }
/* ECMA-262 3rd Edition 15.9.5.7 */ /* ECMA-262 3rd Edition 15.9.5.7 */
static HRESULT Date_toLocaleTimeString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_toLocaleTimeString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
static const WCHAR NaNW[] = { 'N','a','N',0 }; static const WCHAR NaNW[] = { 'N','a','N',0 };
@ -1034,7 +1034,7 @@ static HRESULT Date_toLocaleTimeString(script_ctx_t *ctx, vdisp_t *jsthis, WORD
st = create_systemtime(local_time(date->time, date)); st = create_systemtime(local_time(date->time, date));
if(st.wYear<1601 || st.wYear>9999) if(st.wYear<1601 || st.wYear>9999)
return Date_toTimeString(ctx, jsthis, flags, dp, retv, ei); return Date_toTimeString(ctx, jsthis, flags, argc, argv, retv, ei);
if(retv) { if(retv) {
len = GetTimeFormatW(ctx->lcid, 0, &st, NULL, NULL, 0); len = GetTimeFormatW(ctx->lcid, 0, &st, NULL, NULL, 0);
@ -1050,7 +1050,7 @@ static HRESULT Date_toLocaleTimeString(script_ctx_t *ctx, vdisp_t *jsthis, WORD
} }
/* ECMA-262 3rd Edition 15.9.5.9 */ /* ECMA-262 3rd Edition 15.9.5.9 */
static HRESULT Date_getTime(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_getTime(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DateInstance *date; DateInstance *date;
@ -1066,7 +1066,7 @@ static HRESULT Date_getTime(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP
} }
/* ECMA-262 3rd Edition 15.9.5.10 */ /* ECMA-262 3rd Edition 15.9.5.10 */
static HRESULT Date_getFullYear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_getFullYear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DateInstance *date; DateInstance *date;
@ -1085,7 +1085,7 @@ static HRESULT Date_getFullYear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
} }
/* ECMA-262 3rd Edition 15.9.5.11 */ /* ECMA-262 3rd Edition 15.9.5.11 */
static HRESULT Date_getUTCFullYear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_getUTCFullYear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DateInstance *date; DateInstance *date;
@ -1101,7 +1101,7 @@ static HRESULT Date_getUTCFullYear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flag
} }
/* ECMA-262 3rd Edition 15.9.5.12 */ /* ECMA-262 3rd Edition 15.9.5.12 */
static HRESULT Date_getMonth(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_getMonth(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DateInstance *date; DateInstance *date;
@ -1120,7 +1120,7 @@ static HRESULT Date_getMonth(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DIS
} }
/* ECMA-262 3rd Edition 15.9.5.13 */ /* ECMA-262 3rd Edition 15.9.5.13 */
static HRESULT Date_getUTCMonth(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_getUTCMonth(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DateInstance *date; DateInstance *date;
@ -1136,7 +1136,7 @@ static HRESULT Date_getUTCMonth(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
} }
/* ECMA-262 3rd Edition 15.9.5.14 */ /* ECMA-262 3rd Edition 15.9.5.14 */
static HRESULT Date_getDate(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_getDate(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DateInstance *date; DateInstance *date;
@ -1155,7 +1155,7 @@ static HRESULT Date_getDate(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP
} }
/* ECMA-262 3rd Edition 15.9.5.15 */ /* ECMA-262 3rd Edition 15.9.5.15 */
static HRESULT Date_getUTCDate(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_getUTCDate(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DateInstance *date; DateInstance *date;
@ -1171,7 +1171,7 @@ static HRESULT Date_getUTCDate(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, D
} }
/* ECMA-262 3rd Edition 15.9.5.16 */ /* ECMA-262 3rd Edition 15.9.5.16 */
static HRESULT Date_getDay(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_getDay(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DateInstance *date; DateInstance *date;
@ -1190,7 +1190,7 @@ static HRESULT Date_getDay(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPP
} }
/* ECMA-262 3rd Edition 15.9.5.17 */ /* ECMA-262 3rd Edition 15.9.5.17 */
static HRESULT Date_getUTCDay(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_getUTCDay(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DateInstance *date; DateInstance *date;
@ -1206,7 +1206,7 @@ static HRESULT Date_getUTCDay(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI
} }
/* ECMA-262 3rd Edition 15.9.5.18 */ /* ECMA-262 3rd Edition 15.9.5.18 */
static HRESULT Date_getHours(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_getHours(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DateInstance *date; DateInstance *date;
@ -1225,7 +1225,7 @@ static HRESULT Date_getHours(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DIS
} }
/* ECMA-262 3rd Edition 15.9.5.19 */ /* ECMA-262 3rd Edition 15.9.5.19 */
static HRESULT Date_getUTCHours(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_getUTCHours(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DateInstance *date; DateInstance *date;
@ -1241,7 +1241,7 @@ static HRESULT Date_getUTCHours(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
} }
/* ECMA-262 3rd Edition 15.9.5.20 */ /* ECMA-262 3rd Edition 15.9.5.20 */
static HRESULT Date_getMinutes(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_getMinutes(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DateInstance *date; DateInstance *date;
@ -1260,7 +1260,7 @@ static HRESULT Date_getMinutes(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, D
} }
/* ECMA-262 3rd Edition 15.9.5.21 */ /* ECMA-262 3rd Edition 15.9.5.21 */
static HRESULT Date_getUTCMinutes(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_getUTCMinutes(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DateInstance *date; DateInstance *date;
@ -1276,7 +1276,7 @@ static HRESULT Date_getUTCMinutes(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
} }
/* ECMA-262 3rd Edition 15.9.5.22 */ /* ECMA-262 3rd Edition 15.9.5.22 */
static HRESULT Date_getSeconds(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_getSeconds(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DateInstance *date; DateInstance *date;
@ -1295,7 +1295,7 @@ static HRESULT Date_getSeconds(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, D
} }
/* ECMA-262 3rd Edition 15.9.5.23 */ /* ECMA-262 3rd Edition 15.9.5.23 */
static HRESULT Date_getUTCSeconds(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_getUTCSeconds(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DateInstance *date; DateInstance *date;
@ -1311,7 +1311,7 @@ static HRESULT Date_getUTCSeconds(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
} }
/* ECMA-262 3rd Edition 15.9.5.24 */ /* ECMA-262 3rd Edition 15.9.5.24 */
static HRESULT Date_getMilliseconds(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_getMilliseconds(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DateInstance *date; DateInstance *date;
@ -1330,7 +1330,7 @@ static HRESULT Date_getMilliseconds(script_ctx_t *ctx, vdisp_t *jsthis, WORD fla
} }
/* ECMA-262 3rd Edition 15.9.5.25 */ /* ECMA-262 3rd Edition 15.9.5.25 */
static HRESULT Date_getUTCMilliseconds(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_getUTCMilliseconds(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DateInstance *date; DateInstance *date;
@ -1346,7 +1346,7 @@ static HRESULT Date_getUTCMilliseconds(script_ctx_t *ctx, vdisp_t *jsthis, WORD
} }
/* ECMA-262 3rd Edition 15.9.5.26 */ /* ECMA-262 3rd Edition 15.9.5.26 */
static HRESULT Date_getTimezoneOffset(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_getTimezoneOffset(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DateInstance *date; DateInstance *date;
@ -1363,7 +1363,7 @@ static HRESULT Date_getTimezoneOffset(script_ctx_t *ctx, vdisp_t *jsthis, WORD f
} }
/* ECMA-262 3rd Edition 15.9.5.27 */ /* ECMA-262 3rd Edition 15.9.5.27 */
static HRESULT Date_setTime(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_setTime(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
double n; double n;
@ -1375,10 +1375,10 @@ static HRESULT Date_setTime(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP
if(!(date = date_this(jsthis))) if(!(date = date_this(jsthis)))
return throw_type_error(ctx, ei, JS_E_DATE_EXPECTED, NULL); return throw_type_error(ctx, ei, JS_E_DATE_EXPECTED, NULL);
if(!arg_cnt(dp)) if(!argc)
return throw_type_error(ctx, ei, JS_E_MISSING_ARG, NULL); return throw_type_error(ctx, ei, JS_E_MISSING_ARG, NULL);
hres = to_number(ctx, get_arg(dp, 0), ei, &n); hres = to_number(ctx, argv, ei, &n);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -1391,7 +1391,7 @@ static HRESULT Date_setTime(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP
} }
/* ECMA-262 3rd Edition 15.9.5.28 */ /* ECMA-262 3rd Edition 15.9.5.28 */
static HRESULT Date_setMilliseconds(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_setMilliseconds(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DateInstance *date; DateInstance *date;
@ -1403,10 +1403,10 @@ static HRESULT Date_setMilliseconds(script_ctx_t *ctx, vdisp_t *jsthis, WORD fla
if(!(date = date_this(jsthis))) if(!(date = date_this(jsthis)))
return throw_type_error(ctx, ei, JS_E_DATE_EXPECTED, NULL); return throw_type_error(ctx, ei, JS_E_DATE_EXPECTED, NULL);
if(!arg_cnt(dp)) if(!argc)
return throw_type_error(ctx, ei, JS_E_MISSING_ARG, NULL); return throw_type_error(ctx, ei, JS_E_MISSING_ARG, NULL);
hres = to_number(ctx, get_arg(dp, 0), ei, &n); hres = to_number(ctx, argv, ei, &n);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -1422,7 +1422,7 @@ static HRESULT Date_setMilliseconds(script_ctx_t *ctx, vdisp_t *jsthis, WORD fla
} }
/* ECMA-262 3rd Edition 15.9.5.29 */ /* ECMA-262 3rd Edition 15.9.5.29 */
static HRESULT Date_setUTCMilliseconds(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_setUTCMilliseconds(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DateInstance *date; DateInstance *date;
@ -1434,10 +1434,10 @@ static HRESULT Date_setUTCMilliseconds(script_ctx_t *ctx, vdisp_t *jsthis, WORD
if(!(date = date_this(jsthis))) if(!(date = date_this(jsthis)))
return throw_type_error(ctx, ei, JS_E_DATE_EXPECTED, NULL); return throw_type_error(ctx, ei, JS_E_DATE_EXPECTED, NULL);
if(!arg_cnt(dp)) if(!argc)
return throw_type_error(ctx, ei, JS_E_MISSING_ARG, NULL); return throw_type_error(ctx, ei, JS_E_MISSING_ARG, NULL);
hres = to_number(ctx, get_arg(dp, 0), ei, &n); hres = to_number(ctx, argv, ei, &n);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -1453,7 +1453,7 @@ static HRESULT Date_setUTCMilliseconds(script_ctx_t *ctx, vdisp_t *jsthis, WORD
} }
/* ECMA-262 3rd Edition 15.9.5.30 */ /* ECMA-262 3rd Edition 15.9.5.30 */
static HRESULT Date_setSeconds(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_setSeconds(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DateInstance *date; DateInstance *date;
@ -1465,17 +1465,17 @@ static HRESULT Date_setSeconds(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, D
if(!(date = date_this(jsthis))) if(!(date = date_this(jsthis)))
return throw_type_error(ctx, ei, JS_E_DATE_EXPECTED, NULL); return throw_type_error(ctx, ei, JS_E_DATE_EXPECTED, NULL);
if(!arg_cnt(dp)) if(!argc)
return throw_type_error(ctx, ei, JS_E_MISSING_ARG, NULL); return throw_type_error(ctx, ei, JS_E_MISSING_ARG, NULL);
t = local_time(date->time, date); t = local_time(date->time, date);
hres = to_number(ctx, get_arg(dp, 0), ei, &sec); hres = to_number(ctx, argv, ei, &sec);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(arg_cnt(dp) > 1) { if(argc > 1) {
hres = to_number(ctx, get_arg(dp, 1), ei, &ms); hres = to_number(ctx, argv+1, ei, &ms);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
}else { }else {
@ -1493,7 +1493,7 @@ static HRESULT Date_setSeconds(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, D
} }
/* ECMA-262 3rd Edition 15.9.5.31 */ /* ECMA-262 3rd Edition 15.9.5.31 */
static HRESULT Date_setUTCSeconds(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_setUTCSeconds(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DateInstance *date; DateInstance *date;
@ -1505,17 +1505,17 @@ static HRESULT Date_setUTCSeconds(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
if(!(date = date_this(jsthis))) if(!(date = date_this(jsthis)))
return throw_type_error(ctx, ei, JS_E_DATE_EXPECTED, NULL); return throw_type_error(ctx, ei, JS_E_DATE_EXPECTED, NULL);
if(!arg_cnt(dp)) if(!argc)
return throw_type_error(ctx, ei, JS_E_MISSING_ARG, NULL); return throw_type_error(ctx, ei, JS_E_MISSING_ARG, NULL);
t = date->time; t = date->time;
hres = to_number(ctx, get_arg(dp, 0), ei, &sec); hres = to_number(ctx, argv, ei, &sec);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(arg_cnt(dp) > 1) { if(argc > 1) {
hres = to_number(ctx, get_arg(dp, 1), ei, &ms); hres = to_number(ctx, argv+1, ei, &ms);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
}else { }else {
@ -1533,7 +1533,7 @@ static HRESULT Date_setUTCSeconds(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
} }
/* ECMA-262 3rd Edition 15.9.5.33 */ /* ECMA-262 3rd Edition 15.9.5.33 */
static HRESULT Date_setMinutes(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_setMinutes(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DateInstance *date; DateInstance *date;
@ -1545,25 +1545,25 @@ static HRESULT Date_setMinutes(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, D
if(!(date = date_this(jsthis))) if(!(date = date_this(jsthis)))
return throw_type_error(ctx, ei, JS_E_DATE_EXPECTED, NULL); return throw_type_error(ctx, ei, JS_E_DATE_EXPECTED, NULL);
if(!arg_cnt(dp)) if(!argc)
return throw_type_error(ctx, ei, JS_E_MISSING_ARG, NULL); return throw_type_error(ctx, ei, JS_E_MISSING_ARG, NULL);
t = local_time(date->time, date); t = local_time(date->time, date);
hres = to_number(ctx, get_arg(dp, 0), ei, &min); hres = to_number(ctx, argv, ei, &min);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(arg_cnt(dp) > 1) { if(argc > 1) {
hres = to_number(ctx, get_arg(dp, 1), ei, &sec); hres = to_number(ctx, argv+1, ei, &sec);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
}else { }else {
sec = sec_from_time(t); sec = sec_from_time(t);
} }
if(arg_cnt(dp) > 2) { if(argc > 2) {
hres = to_number(ctx, get_arg(dp, 2), ei, &ms); hres = to_number(ctx, argv+2, ei, &ms);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
}else { }else {
@ -1581,7 +1581,7 @@ static HRESULT Date_setMinutes(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, D
} }
/* ECMA-262 3rd Edition 15.9.5.34 */ /* ECMA-262 3rd Edition 15.9.5.34 */
static HRESULT Date_setUTCMinutes(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_setUTCMinutes(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DateInstance *date; DateInstance *date;
@ -1593,25 +1593,25 @@ static HRESULT Date_setUTCMinutes(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
if(!(date = date_this(jsthis))) if(!(date = date_this(jsthis)))
return throw_type_error(ctx, ei, JS_E_DATE_EXPECTED, NULL); return throw_type_error(ctx, ei, JS_E_DATE_EXPECTED, NULL);
if(!arg_cnt(dp)) if(!argc)
return throw_type_error(ctx, ei, JS_E_MISSING_ARG, NULL); return throw_type_error(ctx, ei, JS_E_MISSING_ARG, NULL);
t = date->time; t = date->time;
hres = to_number(ctx, get_arg(dp, 0), ei, &min); hres = to_number(ctx, argv, ei, &min);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(arg_cnt(dp) > 1) { if(argc > 1) {
hres = to_number(ctx, get_arg(dp, 1), ei, &sec); hres = to_number(ctx, argv+1, ei, &sec);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
}else { }else {
sec = sec_from_time(t); sec = sec_from_time(t);
} }
if(arg_cnt(dp) > 2) { if(argc > 2) {
hres = to_number(ctx, get_arg(dp, 2), ei, &ms); hres = to_number(ctx, argv+2, ei, &ms);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
}else { }else {
@ -1629,7 +1629,7 @@ static HRESULT Date_setUTCMinutes(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
} }
/* ECMA-262 3rd Edition 15.9.5.35 */ /* ECMA-262 3rd Edition 15.9.5.35 */
static HRESULT Date_setHours(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_setHours(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DateInstance *date; DateInstance *date;
@ -1641,33 +1641,33 @@ static HRESULT Date_setHours(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DIS
if(!(date = date_this(jsthis))) if(!(date = date_this(jsthis)))
return throw_type_error(ctx, ei, JS_E_DATE_EXPECTED, NULL); return throw_type_error(ctx, ei, JS_E_DATE_EXPECTED, NULL);
if(!arg_cnt(dp)) if(!argc)
return throw_type_error(ctx, ei, JS_E_MISSING_ARG, NULL); return throw_type_error(ctx, ei, JS_E_MISSING_ARG, NULL);
t = local_time(date->time, date); t = local_time(date->time, date);
hres = to_number(ctx, get_arg(dp, 0), ei, &hour); hres = to_number(ctx, argv, ei, &hour);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(arg_cnt(dp) > 1) { if(argc > 1) {
hres = to_number(ctx, get_arg(dp, 1), ei, &min); hres = to_number(ctx, argv+1, ei, &min);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
}else { }else {
min = min_from_time(t); min = min_from_time(t);
} }
if(arg_cnt(dp) > 2) { if(argc > 2) {
hres = to_number(ctx, get_arg(dp, 2), ei, &sec); hres = to_number(ctx, argv+2, ei, &sec);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
}else { }else {
sec = sec_from_time(t); sec = sec_from_time(t);
} }
if(arg_cnt(dp) > 3) { if(argc > 3) {
hres = to_number(ctx, get_arg(dp, 3), ei, &ms); hres = to_number(ctx, argv+3, ei, &ms);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
}else { }else {
@ -1684,7 +1684,7 @@ static HRESULT Date_setHours(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DIS
} }
/* ECMA-262 3rd Edition 15.9.5.36 */ /* ECMA-262 3rd Edition 15.9.5.36 */
static HRESULT Date_setUTCHours(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_setUTCHours(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DateInstance *date; DateInstance *date;
@ -1696,33 +1696,33 @@ static HRESULT Date_setUTCHours(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
if(!(date = date_this(jsthis))) if(!(date = date_this(jsthis)))
return throw_type_error(ctx, ei, JS_E_DATE_EXPECTED, NULL); return throw_type_error(ctx, ei, JS_E_DATE_EXPECTED, NULL);
if(!arg_cnt(dp)) if(!argc)
return throw_type_error(ctx, ei, JS_E_MISSING_ARG, NULL); return throw_type_error(ctx, ei, JS_E_MISSING_ARG, NULL);
t = date->time; t = date->time;
hres = to_number(ctx, get_arg(dp, 0), ei, &hour); hres = to_number(ctx, argv, ei, &hour);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(arg_cnt(dp) > 1) { if(argc > 1) {
hres = to_number(ctx, get_arg(dp, 1), ei, &min); hres = to_number(ctx, argv+1, ei, &min);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
}else { }else {
min = min_from_time(t); min = min_from_time(t);
} }
if(arg_cnt(dp) > 2) { if(argc > 2) {
hres = to_number(ctx, get_arg(dp, 2), ei, &sec); hres = to_number(ctx, argv+2, ei, &sec);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
}else { }else {
sec = sec_from_time(t); sec = sec_from_time(t);
} }
if(arg_cnt(dp) > 3) { if(argc > 3) {
hres = to_number(ctx, get_arg(dp, 3), ei, &ms); hres = to_number(ctx, argv+3, ei, &ms);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
}else { }else {
@ -1739,7 +1739,7 @@ static HRESULT Date_setUTCHours(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
} }
/* ECMA-262 3rd Edition 15.9.5.36 */ /* ECMA-262 3rd Edition 15.9.5.36 */
static HRESULT Date_setDate(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_setDate(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DateInstance *date; DateInstance *date;
@ -1751,10 +1751,10 @@ static HRESULT Date_setDate(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP
if(!(date = date_this(jsthis))) if(!(date = date_this(jsthis)))
return throw_type_error(ctx, ei, JS_E_DATE_EXPECTED, NULL); return throw_type_error(ctx, ei, JS_E_DATE_EXPECTED, NULL);
if(!arg_cnt(dp)) if(!argc)
return throw_type_error(ctx, ei, JS_E_MISSING_ARG, NULL); return throw_type_error(ctx, ei, JS_E_MISSING_ARG, NULL);
hres = to_number(ctx, get_arg(dp, 0), ei, &n); hres = to_number(ctx, argv, ei, &n);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -1769,7 +1769,7 @@ static HRESULT Date_setDate(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP
} }
/* ECMA-262 3rd Edition 15.9.5.37 */ /* ECMA-262 3rd Edition 15.9.5.37 */
static HRESULT Date_setUTCDate(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_setUTCDate(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DateInstance *date; DateInstance *date;
@ -1781,10 +1781,10 @@ static HRESULT Date_setUTCDate(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, D
if(!(date = date_this(jsthis))) if(!(date = date_this(jsthis)))
return throw_type_error(ctx, ei, JS_E_DATE_EXPECTED, NULL); return throw_type_error(ctx, ei, JS_E_DATE_EXPECTED, NULL);
if(!arg_cnt(dp)) if(!argc)
return throw_type_error(ctx, ei, JS_E_MISSING_ARG, NULL); return throw_type_error(ctx, ei, JS_E_MISSING_ARG, NULL);
hres = to_number(ctx, get_arg(dp, 0), ei, &n); hres = to_number(ctx, argv, ei, &n);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -1799,7 +1799,7 @@ static HRESULT Date_setUTCDate(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, D
} }
/* ECMA-262 3rd Edition 15.9.5.38 */ /* ECMA-262 3rd Edition 15.9.5.38 */
static HRESULT Date_setMonth(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_setMonth(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DateInstance *date; DateInstance *date;
@ -1811,17 +1811,17 @@ static HRESULT Date_setMonth(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DIS
if(!(date = date_this(jsthis))) if(!(date = date_this(jsthis)))
return throw_type_error(ctx, ei, JS_E_DATE_EXPECTED, NULL); return throw_type_error(ctx, ei, JS_E_DATE_EXPECTED, NULL);
if(!arg_cnt(dp)) if(!argc)
return throw_type_error(ctx, ei, JS_E_MISSING_ARG, NULL); return throw_type_error(ctx, ei, JS_E_MISSING_ARG, NULL);
t = local_time(date->time, date); t = local_time(date->time, date);
hres = to_number(ctx, get_arg(dp, 0), ei, &month); hres = to_number(ctx, argv, ei, &month);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(arg_cnt(dp) > 1) { if(argc > 1) {
hres = to_number(ctx, get_arg(dp, 1), ei, &ddate); hres = to_number(ctx, argv+1, ei, &ddate);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
}else { }else {
@ -1839,7 +1839,7 @@ static HRESULT Date_setMonth(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DIS
} }
/* ECMA-262 3rd Edition 15.9.5.39 */ /* ECMA-262 3rd Edition 15.9.5.39 */
static HRESULT Date_setUTCMonth(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_setUTCMonth(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DateInstance *date; DateInstance *date;
@ -1851,17 +1851,17 @@ static HRESULT Date_setUTCMonth(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
if(!(date = date_this(jsthis))) if(!(date = date_this(jsthis)))
return throw_type_error(ctx, ei, JS_E_DATE_EXPECTED, NULL); return throw_type_error(ctx, ei, JS_E_DATE_EXPECTED, NULL);
if(!arg_cnt(dp)) if(!argc)
return throw_type_error(ctx, ei, JS_E_MISSING_ARG, NULL); return throw_type_error(ctx, ei, JS_E_MISSING_ARG, NULL);
t = date->time; t = date->time;
hres = to_number(ctx, get_arg(dp, 0), ei, &month); hres = to_number(ctx, argv, ei, &month);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(arg_cnt(dp) > 1) { if(argc > 1) {
hres = to_number(ctx, get_arg(dp, 1), ei, &ddate); hres = to_number(ctx, argv+1, ei, &ddate);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
}else { }else {
@ -1879,7 +1879,7 @@ static HRESULT Date_setUTCMonth(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
} }
/* ECMA-262 3rd Edition 15.9.5.40 */ /* ECMA-262 3rd Edition 15.9.5.40 */
static HRESULT Date_setFullYear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_setFullYear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DateInstance *date; DateInstance *date;
@ -1891,25 +1891,25 @@ static HRESULT Date_setFullYear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
if(!(date = date_this(jsthis))) if(!(date = date_this(jsthis)))
return throw_type_error(ctx, ei, JS_E_DATE_EXPECTED, NULL); return throw_type_error(ctx, ei, JS_E_DATE_EXPECTED, NULL);
if(!arg_cnt(dp)) if(!argc)
return throw_type_error(ctx, ei, JS_E_MISSING_ARG, NULL); return throw_type_error(ctx, ei, JS_E_MISSING_ARG, NULL);
t = local_time(date->time, date); t = local_time(date->time, date);
hres = to_number(ctx, get_arg(dp, 0), ei, &year); hres = to_number(ctx, argv, ei, &year);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(arg_cnt(dp) > 1) { if(argc > 1) {
hres = to_number(ctx, get_arg(dp, 1), ei, &month); hres = to_number(ctx, argv+1, ei, &month);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
}else { }else {
month = month_from_time(t); month = month_from_time(t);
} }
if(arg_cnt(dp) > 2) { if(argc > 2) {
hres = to_number(ctx, get_arg(dp, 2), ei, &ddate); hres = to_number(ctx, argv+2, ei, &ddate);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
}else { }else {
@ -1926,7 +1926,7 @@ static HRESULT Date_setFullYear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
} }
/* ECMA-262 3rd Edition 15.9.5.41 */ /* ECMA-262 3rd Edition 15.9.5.41 */
static HRESULT Date_setUTCFullYear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_setUTCFullYear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DateInstance *date; DateInstance *date;
@ -1938,25 +1938,25 @@ static HRESULT Date_setUTCFullYear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flag
if(!(date = date_this(jsthis))) if(!(date = date_this(jsthis)))
return throw_type_error(ctx, ei, JS_E_DATE_EXPECTED, NULL); return throw_type_error(ctx, ei, JS_E_DATE_EXPECTED, NULL);
if(!arg_cnt(dp)) if(!argc)
return throw_type_error(ctx, ei, JS_E_MISSING_ARG, NULL); return throw_type_error(ctx, ei, JS_E_MISSING_ARG, NULL);
t = date->time; t = date->time;
hres = to_number(ctx, get_arg(dp, 0), ei, &year); hres = to_number(ctx, argv, ei, &year);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(arg_cnt(dp) > 1) { if(argc > 1) {
hres = to_number(ctx, get_arg(dp, 1), ei, &month); hres = to_number(ctx, argv+1, ei, &month);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
}else { }else {
month = month_from_time(t); month = month_from_time(t);
} }
if(arg_cnt(dp) > 2) { if(argc > 2) {
hres = to_number(ctx, get_arg(dp, 2), ei, &ddate); hres = to_number(ctx, argv+2, ei, &ddate);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
}else { }else {
@ -1973,7 +1973,7 @@ static HRESULT Date_setUTCFullYear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flag
} }
/* ECMA-262 3rd Edition B2.4 */ /* ECMA-262 3rd Edition B2.4 */
static HRESULT Date_getYear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_getYear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DateInstance *date; DateInstance *date;
@ -1999,7 +1999,7 @@ static HRESULT Date_getYear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP
} }
/* ECMA-262 3rd Edition B2.5 */ /* ECMA-262 3rd Edition B2.5 */
static HRESULT Date_setYear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_setYear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DateInstance *date; DateInstance *date;
@ -2011,12 +2011,12 @@ static HRESULT Date_setYear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP
if(!(date = date_this(jsthis))) if(!(date = date_this(jsthis)))
return throw_type_error(ctx, ei, JS_E_DATE_EXPECTED, NULL); return throw_type_error(ctx, ei, JS_E_DATE_EXPECTED, NULL);
if(!arg_cnt(dp)) if(!argc)
return throw_type_error(ctx, ei, JS_E_MISSING_ARG, NULL); return throw_type_error(ctx, ei, JS_E_MISSING_ARG, NULL);
t = local_time(date->time, date); t = local_time(date->time, date);
hres = to_number(ctx, get_arg(dp, 0), ei, &year); hres = to_number(ctx, argv, ei, &year);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -2038,7 +2038,7 @@ static HRESULT Date_setYear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP
return S_OK; return S_OK;
} }
static HRESULT Date_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Date_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
@ -2403,7 +2403,7 @@ static inline HRESULT date_parse(BSTR input, double *ret) {
return S_OK; return S_OK;
} }
static HRESULT DateConstr_parse(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT DateConstr_parse(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
BSTR parse_str; BSTR parse_str;
@ -2412,13 +2412,13 @@ static HRESULT DateConstr_parse(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
TRACE("\n"); TRACE("\n");
if(!arg_cnt(dp)) { if(!argc) {
if(retv) if(retv)
num_set_val(retv, NAN); num_set_val(retv, NAN);
return S_OK; return S_OK;
} }
hres = to_string(ctx, get_arg(dp,0), ei, &parse_str); hres = to_string(ctx, argv, ei, &parse_str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -2431,16 +2431,15 @@ static HRESULT DateConstr_parse(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
return S_OK; return S_OK;
} }
static HRESULT date_utc(script_ctx_t *ctx, DISPPARAMS *dp, double *ret, jsexcept_t *ei) static HRESULT date_utc(script_ctx_t *ctx, unsigned argc, VARIANT *argv, double *ret, jsexcept_t *ei)
{ {
double year, month, vdate, hours, minutes, seconds, ms; double year, month, vdate, hours, minutes, seconds, ms;
int arg_no = arg_cnt(dp);
HRESULT hres; HRESULT hres;
TRACE("\n"); TRACE("\n");
if(arg_no>0) { if(argc) {
hres = to_number(ctx, get_arg(dp, 0), ei, &year); hres = to_number(ctx, argv, ei, &year);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(0 <= year && year <= 99) if(0 <= year && year <= 99)
@ -2449,48 +2448,48 @@ static HRESULT date_utc(script_ctx_t *ctx, DISPPARAMS *dp, double *ret, jsexcept
year = 1900; year = 1900;
} }
if(arg_no>1) { if(argc>1) {
hres = to_number(ctx, get_arg(dp, 1), ei, &month); hres = to_number(ctx, argv+1, ei, &month);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
}else { }else {
month = 0; month = 0;
} }
if(arg_no>2) { if(argc>2) {
hres = to_number(ctx, get_arg(dp, 2), ei, &vdate); hres = to_number(ctx, argv+2, ei, &vdate);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
}else { }else {
vdate = 1; vdate = 1;
} }
if(arg_no>3) { if(argc>3) {
hres = to_number(ctx, get_arg(dp, 3), ei, &hours); hres = to_number(ctx, argv+3, ei, &hours);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
}else { }else {
hours = 0; hours = 0;
} }
if(arg_no>4) { if(argc>4) {
hres = to_number(ctx, get_arg(dp, 4), ei, &minutes); hres = to_number(ctx, argv+4, ei, &minutes);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
}else { }else {
minutes = 0; minutes = 0;
} }
if(arg_no>5) { if(argc>5) {
hres = to_number(ctx, get_arg(dp, 5), ei, &seconds); hres = to_number(ctx, argv+5, ei, &seconds);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
}else { }else {
seconds = 0; seconds = 0;
} }
if(arg_no>6) { if(argc>6) {
hres = to_number(ctx, get_arg(dp, 6), ei, &ms); hres = to_number(ctx, argv+6, ei, &ms);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
} else { } else {
@ -2502,7 +2501,7 @@ static HRESULT date_utc(script_ctx_t *ctx, DISPPARAMS *dp, double *ret, jsexcept
return S_OK; return S_OK;
} }
static HRESULT DateConstr_UTC(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT DateConstr_UTC(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
double n; double n;
@ -2510,13 +2509,13 @@ static HRESULT DateConstr_UTC(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI
TRACE("\n"); TRACE("\n");
hres = date_utc(ctx, dp, &n, ei); hres = date_utc(ctx, argc, argv, &n, ei);
if(SUCCEEDED(hres) && retv) if(SUCCEEDED(hres) && retv)
num_set_val(retv, n); num_set_val(retv, n);
return hres; return hres;
} }
static HRESULT DateConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT DateConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
jsdisp_t *date; jsdisp_t *date;
@ -2526,7 +2525,7 @@ static HRESULT DateConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
switch(flags) { switch(flags) {
case DISPATCH_CONSTRUCT: case DISPATCH_CONSTRUCT:
switch(arg_cnt(dp)) { switch(argc) {
/* ECMA-262 3rd Edition 15.9.3.3 */ /* ECMA-262 3rd Edition 15.9.3.3 */
case 0: { case 0: {
FILETIME time; FILETIME time;
@ -2547,7 +2546,7 @@ static HRESULT DateConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
VARIANT prim; VARIANT prim;
double n; double n;
hres = to_primitive(ctx, get_arg(dp,0), ei, &prim, NO_HINT); hres = to_primitive(ctx, argv, ei, &prim, NO_HINT);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -2571,7 +2570,7 @@ static HRESULT DateConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
double ret_date; double ret_date;
DateInstance *di; DateInstance *di;
hres = date_utc(ctx, dp, &ret_date, ei); hres = date_utc(ctx, argc, argv, &ret_date, ei);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;

View File

@ -291,48 +291,6 @@ static HRESULT ensure_prop_name(jsdisp_t *This, const WCHAR *name, BOOL search_p
return hres; return hres;
} }
static HRESULT set_this(DISPPARAMS *dp, const DISPPARAMS *olddp, IDispatch *jsthis)
{
VARIANTARG *oldargs;
int i;
static DISPID this_id = DISPID_THIS;
*dp = *olddp;
for(i = 0; i < dp->cNamedArgs; i++) {
if(dp->rgdispidNamedArgs[i] == DISPID_THIS)
return S_OK;
}
oldargs = dp->rgvarg;
dp->rgvarg = heap_alloc((dp->cArgs+1) * sizeof(VARIANTARG));
if(!dp->rgvarg)
return E_OUTOFMEMORY;
memcpy(dp->rgvarg+1, oldargs, dp->cArgs*sizeof(VARIANTARG));
V_VT(dp->rgvarg) = VT_DISPATCH;
V_DISPATCH(dp->rgvarg) = jsthis;
dp->cArgs++;
if(dp->cNamedArgs) {
DISPID *old = dp->rgdispidNamedArgs;
dp->rgdispidNamedArgs = heap_alloc((dp->cNamedArgs+1)*sizeof(DISPID));
if(!dp->rgdispidNamedArgs) {
heap_free(dp->rgvarg);
return E_OUTOFMEMORY;
}
memcpy(dp->rgdispidNamedArgs+1, old, dp->cNamedArgs*sizeof(DISPID));
dp->rgdispidNamedArgs[0] = DISPID_THIS;
dp->cNamedArgs++;
}else {
dp->rgdispidNamedArgs = &this_id;
dp->cNamedArgs = 1;
}
return S_OK;
}
static IDispatch *get_this(DISPPARAMS *dp) static IDispatch *get_this(DISPPARAMS *dp)
{ {
DWORD i; DWORD i;
@ -351,60 +309,46 @@ static IDispatch *get_this(DISPPARAMS *dp)
return NULL; return NULL;
} }
static HRESULT convert_params(const DISPPARAMS *dp, VARIANT *buf, DISPPARAMS *ret) static HRESULT convert_params(const DISPPARAMS *dp, VARIANT *buf, unsigned *argc, VARIANT **ret)
{ {
BOOL need_conversion = FALSE;
const VARIANT *s; const VARIANT *s;
VARIANT *d; VARIANT *argv;
unsigned cnt;
unsigned i; unsigned i;
ret->cArgs = dp->cArgs - dp->cNamedArgs; cnt = dp->cArgs - dp->cNamedArgs;
ret->cNamedArgs = 0;
for(i = 0; i < ret->cArgs && !need_conversion; i++) { if(cnt > 6) {
switch(V_VT(get_arg(dp, i))) { argv = heap_alloc(cnt * sizeof(VARIANT));
case VT_I2: if(!argv)
case VT_INT:
need_conversion = TRUE;
break;
}
}
if(!need_conversion) {
ret->rgvarg = dp->rgvarg + dp->cNamedArgs;
return S_OK;
}
if(ret->cArgs > 6) {
ret->rgvarg = heap_alloc(ret->cArgs * sizeof(VARIANT));
if(!ret->rgvarg)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
}else { }else {
ret->rgvarg = buf; argv = buf;
} }
for(i = 0; i < ret->cArgs; i++) { for(i = 0; i < cnt; i++) {
s = get_arg(dp, i); s = get_arg(dp, i);
d = get_arg(ret, i);
switch(V_VT(s)) { switch(V_VT(s)) {
case VT_I2: case VT_I2:
V_VT(d) = VT_I4; V_VT(argv+i) = VT_I4;
V_I4(d) = V_I2(s); V_I4(argv+i) = V_I2(s);
break; break;
case VT_INT: case VT_INT:
V_VT(d) = VT_I4; V_VT(argv+i) = VT_I4;
V_I4(d) = V_INT(s); V_I4(argv+i) = V_INT(s);
break; break;
default: default:
*d = *s; argv[i] = *s;
} }
} }
*argc = cnt;
*ret = argv;
return S_OK; return S_OK;
} }
static HRESULT invoke_prop_func(jsdisp_t *This, IDispatch *jsthis, dispex_prop_t *prop, WORD flags, static HRESULT invoke_prop_func(jsdisp_t *This, IDispatch *jsthis, dispex_prop_t *prop, WORD flags,
DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller) unsigned argc, VARIANT *argv, VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller)
{ {
HRESULT hres; HRESULT hres;
@ -422,16 +366,17 @@ static HRESULT invoke_prop_func(jsdisp_t *This, IDispatch *jsthis, dispex_prop_t
set_disp(&vthis, jsthis); set_disp(&vthis, jsthis);
else else
set_jsdisp(&vthis, This); set_jsdisp(&vthis, This);
hres = prop->u.p->invoke(This->ctx, &vthis, flags, dp, retv, ei); hres = prop->u.p->invoke(This->ctx, &vthis, flags, argc, argv, retv, ei);
vdisp_release(&vthis); vdisp_release(&vthis);
}else { }else {
/* Function object calls are special case */ /* Function object calls are special case */
hres = Function_invoke(This, jsthis, flags, dp, retv, ei); hres = Function_invoke(This, jsthis, flags, argc, argv, retv, ei);
} }
return hres; return hres;
} }
case PROP_PROTREF: case PROP_PROTREF:
return invoke_prop_func(This->prototype, jsthis, This->prototype->props+prop->u.ref, flags, dp, retv, ei, caller); return invoke_prop_func(This->prototype, jsthis, This->prototype->props+prop->u.ref,
flags, argc, argv, retv, ei, caller);
case PROP_VARIANT: { case PROP_VARIANT: {
if(V_VT(&prop->u.var) != VT_DISPATCH) { if(V_VT(&prop->u.var) != VT_DISPATCH) {
FIXME("invoke vt %d\n", V_VT(&prop->u.var)); FIXME("invoke vt %d\n", V_VT(&prop->u.var));
@ -440,7 +385,7 @@ static HRESULT invoke_prop_func(jsdisp_t *This, IDispatch *jsthis, dispex_prop_t
TRACE("call %s %p\n", debugstr_w(prop->name), V_DISPATCH(&prop->u.var)); TRACE("call %s %p\n", debugstr_w(prop->name), V_DISPATCH(&prop->u.var));
return disp_call_value(This->ctx, V_DISPATCH(&prop->u.var), jsthis, flags, dp, retv, ei); return disp_call_value(This->ctx, V_DISPATCH(&prop->u.var), jsthis, flags, argc, argv, retv, ei);
} }
default: default:
ERR("type %d\n", prop->type); ERR("type %d\n", prop->type);
@ -470,7 +415,7 @@ static HRESULT prop_get(jsdisp_t *This, dispex_prop_t *prop, DISPPARAMS *dp,
vdisp_t vthis; vdisp_t vthis;
set_jsdisp(&vthis, This); set_jsdisp(&vthis, This);
hres = prop->u.p->invoke(This->ctx, &vthis, DISPATCH_PROPERTYGET, dp, retv, ei); hres = prop->u.p->invoke(This->ctx, &vthis, DISPATCH_PROPERTYGET, 0, NULL, retv, ei);
vdisp_release(&vthis); vdisp_release(&vthis);
} }
break; break;
@ -505,11 +450,10 @@ static HRESULT prop_put(jsdisp_t *This, dispex_prop_t *prop, VARIANT *val,
switch(prop->type) { switch(prop->type) {
case PROP_BUILTIN: case PROP_BUILTIN:
if(!(prop->flags & PROPF_METHOD)) { if(!(prop->flags & PROPF_METHOD)) {
DISPPARAMS dp = {val, NULL, 1, 0};
vdisp_t vthis; vdisp_t vthis;
set_jsdisp(&vthis, This); set_jsdisp(&vthis, This);
hres = prop->u.p->invoke(This->ctx, &vthis, DISPATCH_PROPERTYPUT, &dp, NULL, ei); hres = prop->u.p->invoke(This->ctx, &vthis, DISPATCH_PROPERTYPUT, 1, val, NULL, ei);
vdisp_release(&vthis); vdisp_release(&vthis);
return hres; return hres;
} }
@ -733,16 +677,17 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc
/* fall through */ /* fall through */
case DISPATCH_METHOD: case DISPATCH_METHOD:
case DISPATCH_CONSTRUCT: { case DISPATCH_CONSTRUCT: {
DISPPARAMS params; VARIANT *argv;
unsigned argc;
VARIANT buf[6]; VARIANT buf[6];
hres = convert_params(pdp, buf, &params); hres = convert_params(pdp, buf, &argc, &argv);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
hres = invoke_prop_func(This, get_this(pdp), prop, wFlags, &params, pvarRes, &jsexcept, pspCaller); hres = invoke_prop_func(This, get_this(pdp), prop, wFlags, argc, argv, pvarRes, &jsexcept, pspCaller);
if(params.rgvarg != buf && params.rgvarg != pdp->rgvarg) if(argv != buf)
heap_free(params.rgvarg); heap_free(argv);
break; break;
} }
case DISPATCH_PROPERTYGET: case DISPATCH_PROPERTYGET:
@ -1066,25 +1011,24 @@ HRESULT jsdisp_get_id(jsdisp_t *jsdisp, const WCHAR *name, DWORD flags, DISPID *
return DISP_E_UNKNOWNNAME; return DISP_E_UNKNOWNNAME;
} }
HRESULT jsdisp_call_value(jsdisp_t *jsfunc, IDispatch *jsthis, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei) HRESULT jsdisp_call_value(jsdisp_t *jsfunc, IDispatch *jsthis, WORD flags, unsigned argc, VARIANT *argv, VARIANT *retv,
jsexcept_t *ei)
{ {
HRESULT hres; HRESULT hres;
TRACE("args %p\n", dp->rgvarg);
if(is_class(jsfunc, JSCLASS_FUNCTION)) { if(is_class(jsfunc, JSCLASS_FUNCTION)) {
hres = Function_invoke(jsfunc, jsthis, flags, dp, retv, ei); hres = Function_invoke(jsfunc, jsthis, flags, argc, argv, retv, ei);
}else { }else {
vdisp_t vdisp; vdisp_t vdisp;
set_disp(&vdisp, jsthis); set_disp(&vdisp, jsthis);
hres = jsfunc->builtin_info->value_prop.invoke(jsfunc->ctx, &vdisp, flags, dp, retv, ei); hres = jsfunc->builtin_info->value_prop.invoke(jsfunc->ctx, &vdisp, flags, argc, argv, retv, ei);
vdisp_release(&vdisp); vdisp_release(&vdisp);
} }
return hres; return hres;
} }
HRESULT jsdisp_call(jsdisp_t *disp, DISPID id, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei) HRESULT jsdisp_call(jsdisp_t *disp, DISPID id, WORD flags, unsigned argc, VARIANT *argv, VARIANT *retv, jsexcept_t *ei)
{ {
dispex_prop_t *prop; dispex_prop_t *prop;
@ -1096,10 +1040,10 @@ HRESULT jsdisp_call(jsdisp_t *disp, DISPID id, WORD flags, DISPPARAMS *dp, VARIA
if(!prop) if(!prop)
return DISP_E_MEMBERNOTFOUND; return DISP_E_MEMBERNOTFOUND;
return invoke_prop_func(disp, to_disp(disp), prop, flags, dp, retv, ei, NULL); return invoke_prop_func(disp, to_disp(disp), prop, flags, argc, argv, retv, ei, NULL);
} }
HRESULT jsdisp_call_name(jsdisp_t *disp, const WCHAR *name, WORD flags, DISPPARAMS *dp, VARIANT *retv, HRESULT jsdisp_call_name(jsdisp_t *disp, const WCHAR *name, WORD flags, unsigned argc, VARIANT *argv, VARIANT *retv,
jsexcept_t *ei) jsexcept_t *ei)
{ {
dispex_prop_t *prop; dispex_prop_t *prop;
@ -1113,13 +1057,17 @@ HRESULT jsdisp_call_name(jsdisp_t *disp, const WCHAR *name, WORD flags, DISPPARA
if(retv) if(retv)
V_VT(retv) = VT_EMPTY; V_VT(retv) = VT_EMPTY;
return invoke_prop_func(disp, to_disp(disp), prop, flags, dp, retv, ei, NULL); return invoke_prop_func(disp, to_disp(disp), prop, flags, argc, argv, retv, ei, NULL);
} }
HRESULT disp_call(script_ctx_t *ctx, IDispatch *disp, DISPID id, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei) HRESULT disp_call(script_ctx_t *ctx, IDispatch *disp, DISPID id, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei)
{ {
jsdisp_t *jsdisp;
IDispatchEx *dispex; IDispatchEx *dispex;
jsdisp_t *jsdisp;
VARIANT buf[6];
DISPPARAMS dp;
unsigned i;
HRESULT hres; HRESULT hres;
jsdisp = iface_to_jsdisp((IUnknown*)disp); jsdisp = iface_to_jsdisp((IUnknown*)disp);
@ -1129,20 +1077,44 @@ HRESULT disp_call(script_ctx_t *ctx, IDispatch *disp, DISPID id, WORD flags, DIS
return E_FAIL; return E_FAIL;
} }
hres = jsdisp_call(jsdisp, id, flags, dp, retv, ei); hres = jsdisp_call(jsdisp, id, flags, argc, argv, retv, ei);
jsdisp_release(jsdisp); jsdisp_release(jsdisp);
return hres; return hres;
} }
memset(ei, 0, sizeof(*ei)); memset(ei, 0, sizeof(*ei));
if(retv && arg_cnt(dp)) if(retv && argc)
flags |= DISPATCH_PROPERTYGET; flags |= DISPATCH_PROPERTYGET;
dp.cArgs = argc;
if(flags & DISPATCH_PROPERTYPUT) {
static DISPID propput_dispid = DISPID_PROPERTYPUT;
dp.cNamedArgs = 1;
dp.rgdispidNamedArgs = &propput_dispid;
}else {
dp.cNamedArgs = 0;
dp.rgdispidNamedArgs = NULL;
}
if(argc > 6) {
dp.rgvarg = heap_alloc(argc*sizeof(VARIANT));
if(!dp.rgvarg)
return E_OUTOFMEMORY;
}else {
dp.rgvarg = buf;
}
for(i=0; i<argc; i++)
dp.rgvarg[argc-i-1] = argv[i];
if(retv) if(retv)
V_VT(retv) = VT_EMPTY; V_VT(retv) = VT_EMPTY;
hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex); hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
hres = IDispatchEx_InvokeEx(dispex, id, ctx->lcid, flags, dp, retv, &ei->ei, &ctx->jscaller->IServiceProvider_iface); hres = IDispatchEx_InvokeEx(dispex, id, ctx->lcid, flags, &dp, retv, &ei->ei, &ctx->jscaller->IServiceProvider_iface);
IDispatchEx_Release(dispex); IDispatchEx_Release(dispex);
}else { }else {
UINT err = 0; UINT err = 0;
@ -1153,9 +1125,11 @@ HRESULT disp_call(script_ctx_t *ctx, IDispatch *disp, DISPID id, WORD flags, DIS
} }
TRACE("using IDispatch\n"); TRACE("using IDispatch\n");
hres = IDispatch_Invoke(disp, id, &IID_NULL, ctx->lcid, flags, dp, retv, &ei->ei, &err); hres = IDispatch_Invoke(disp, id, &IID_NULL, ctx->lcid, flags, &dp, retv, &ei->ei, &err);
} }
if(dp.rgvarg != buf)
heap_free(dp.rgvarg);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -1164,12 +1138,14 @@ HRESULT disp_call(script_ctx_t *ctx, IDispatch *disp, DISPID id, WORD flags, DIS
return S_OK; return S_OK;
} }
HRESULT disp_call_value(script_ctx_t *ctx, IDispatch *disp, IDispatch *jsthis, WORD flags, DISPPARAMS *dp, HRESULT disp_call_value(script_ctx_t *ctx, IDispatch *disp, IDispatch *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DISPPARAMS params;
jsdisp_t *jsdisp; jsdisp_t *jsdisp;
IDispatchEx *dispex; IDispatchEx *dispex;
VARIANT buf[6];
DISPPARAMS dp;
unsigned i;
HRESULT hres; HRESULT hres;
jsdisp = iface_to_jsdisp((IUnknown*)disp); jsdisp = iface_to_jsdisp((IUnknown*)disp);
@ -1179,28 +1155,48 @@ HRESULT disp_call_value(script_ctx_t *ctx, IDispatch *disp, IDispatch *jsthis, W
return E_FAIL; return E_FAIL;
} }
hres = jsdisp_call_value(jsdisp, jsthis, flags, dp, retv, ei); hres = jsdisp_call_value(jsdisp, jsthis, flags, argc, argv, retv, ei);
jsdisp_release(jsdisp); jsdisp_release(jsdisp);
return hres; return hres;
} }
memset(ei, 0, sizeof(*ei)); memset(ei, 0, sizeof(*ei));
if(retv && arg_cnt(dp)) if(retv && argc)
flags |= DISPATCH_PROPERTYGET; flags |= DISPATCH_PROPERTYGET;
if(jsthis) { if(jsthis) {
hres = set_this(&params, dp, jsthis); static DISPID this_id = DISPID_THIS;
if(FAILED(hres))
return hres; dp.cArgs = argc+1;
dp.cNamedArgs = 1;
dp.rgdispidNamedArgs = &this_id;
}else { }else {
params = *dp; dp.cArgs = argc;
dp.cNamedArgs = 0;
dp.rgdispidNamedArgs = NULL;
}
if(dp.cArgs > sizeof(buf)/sizeof(*buf)) {
dp.rgvarg = heap_alloc(dp.cArgs*sizeof(VARIANT));
if(!dp.rgvarg)
return E_OUTOFMEMORY;
}else {
dp.rgvarg = buf;
}
for(i=0; i<argc; i++)
dp.rgvarg[argc-i-1] = argv[i];
if(jsthis) {
V_VT(dp.rgvarg) = VT_DISPATCH;
V_DISPATCH(dp.rgvarg) = jsthis;
} }
if(retv) if(retv)
V_VT(retv) = VT_EMPTY; V_VT(retv) = VT_EMPTY;
hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex); hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
hres = IDispatchEx_InvokeEx(dispex, DISPID_VALUE, ctx->lcid, flags, &params, retv, &ei->ei, hres = IDispatchEx_InvokeEx(dispex, DISPID_VALUE, ctx->lcid, flags, &dp, retv, &ei->ei,
&ctx->jscaller->IServiceProvider_iface); &ctx->jscaller->IServiceProvider_iface);
IDispatchEx_Release(dispex); IDispatchEx_Release(dispex);
}else { }else {
@ -1212,15 +1208,11 @@ HRESULT disp_call_value(script_ctx_t *ctx, IDispatch *disp, IDispatch *jsthis, W
} }
TRACE("using IDispatch\n"); TRACE("using IDispatch\n");
hres = IDispatch_Invoke(disp, DISPID_VALUE, &IID_NULL, ctx->lcid, flags, &params, retv, &ei->ei, &err); hres = IDispatch_Invoke(disp, DISPID_VALUE, &IID_NULL, ctx->lcid, flags, &dp, retv, &ei->ei, &err);
}
if(params.rgvarg != dp->rgvarg) {
heap_free(params.rgvarg);
if(params.cNamedArgs > 1)
heap_free(params.rgdispidNamedArgs);
} }
if(dp.rgvarg != buf)
heap_free(dp.rgvarg);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;

View File

@ -133,6 +133,14 @@ static inline VARIANT *stack_topn(exec_ctx_t *ctx, unsigned n)
return ctx->stack + ctx->top-1-n; return ctx->stack + ctx->top-1-n;
} }
static inline VARIANT *stack_args(exec_ctx_t *ctx, unsigned n)
{
if(!n)
return NULL;
assert(ctx->top > n-1);
return ctx->stack + ctx->top-n;
}
static inline VARIANT *stack_pop(exec_ctx_t *ctx) static inline VARIANT *stack_pop(exec_ctx_t *ctx)
{ {
assert(ctx->top); assert(ctx->top);
@ -972,32 +980,11 @@ static HRESULT interp_refval(exec_ctx_t *ctx)
return stack_push(ctx, &v); return stack_push(ctx, &v);
} }
static void jsstack_to_dp(exec_ctx_t *ctx, unsigned arg_cnt, DISPPARAMS *dp)
{
VARIANT tmp;
unsigned i;
dp->cArgs = arg_cnt;
dp->rgdispidNamedArgs = NULL;
dp->cNamedArgs = 0;
assert(ctx->top >= arg_cnt);
for(i=1; i*2 <= arg_cnt; i++) {
tmp = ctx->stack[ctx->top-i];
ctx->stack[ctx->top-i] = ctx->stack[ctx->top-arg_cnt+i-1];
ctx->stack[ctx->top-arg_cnt+i-1] = tmp;
}
dp->rgvarg = ctx->stack + ctx->top-arg_cnt;
}
/* ECMA-262 3rd Edition 11.2.2 */ /* ECMA-262 3rd Edition 11.2.2 */
static HRESULT interp_new(exec_ctx_t *ctx) static HRESULT interp_new(exec_ctx_t *ctx)
{ {
const unsigned arg = get_op_uint(ctx, 0); const unsigned arg = get_op_uint(ctx, 0);
VARIANT *constr, v; VARIANT *constr, v;
DISPPARAMS dp;
HRESULT hres; HRESULT hres;
TRACE("%d\n", arg); TRACE("%d\n", arg);
@ -1013,8 +1000,7 @@ static HRESULT interp_new(exec_ctx_t *ctx)
else if(!V_DISPATCH(constr)) else if(!V_DISPATCH(constr))
return throw_type_error(ctx->script, ctx->ei, JS_E_INVALID_PROPERTY, NULL); return throw_type_error(ctx->script, ctx->ei, JS_E_INVALID_PROPERTY, NULL);
jsstack_to_dp(ctx, arg, &dp); hres = disp_call_value(ctx->script, V_DISPATCH(constr), NULL, DISPATCH_CONSTRUCT, arg, stack_args(ctx, arg), &v, ctx->ei);
hres = disp_call_value(ctx->script, V_DISPATCH(constr), NULL, DISPATCH_CONSTRUCT, &dp, &v, ctx->ei);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -1028,7 +1014,6 @@ static HRESULT interp_call(exec_ctx_t *ctx)
const unsigned argn = get_op_uint(ctx, 0); const unsigned argn = get_op_uint(ctx, 0);
const int do_ret = get_op_int(ctx, 1); const int do_ret = get_op_int(ctx, 1);
VARIANT v, *objv; VARIANT v, *objv;
DISPPARAMS dp;
HRESULT hres; HRESULT hres;
TRACE("%d %d\n", argn, do_ret); TRACE("%d %d\n", argn, do_ret);
@ -1037,8 +1022,7 @@ static HRESULT interp_call(exec_ctx_t *ctx)
if(V_VT(objv) != VT_DISPATCH) if(V_VT(objv) != VT_DISPATCH)
return throw_type_error(ctx->script, ctx->ei, JS_E_INVALID_PROPERTY, NULL); return throw_type_error(ctx->script, ctx->ei, JS_E_INVALID_PROPERTY, NULL);
jsstack_to_dp(ctx, argn, &dp); hres = disp_call_value(ctx->script, V_DISPATCH(objv), NULL, DISPATCH_METHOD, argn, stack_args(ctx, argn),
hres = disp_call_value(ctx->script, V_DISPATCH(objv), NULL, DISPATCH_METHOD, &dp,
do_ret ? &v : NULL, ctx->ei); do_ret ? &v : NULL, ctx->ei);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -1054,7 +1038,6 @@ static HRESULT interp_call_member(exec_ctx_t *ctx)
const unsigned argn = get_op_uint(ctx, 0); const unsigned argn = get_op_uint(ctx, 0);
const int do_ret = get_op_int(ctx, 1); const int do_ret = get_op_int(ctx, 1);
IDispatch *obj; IDispatch *obj;
DISPPARAMS dp;
VARIANT v; VARIANT v;
DISPID id; DISPID id;
HRESULT hres; HRESULT hres;
@ -1065,8 +1048,7 @@ static HRESULT interp_call_member(exec_ctx_t *ctx)
if(!obj) if(!obj)
return throw_type_error(ctx->script, ctx->ei, id, NULL); return throw_type_error(ctx->script, ctx->ei, id, NULL);
jsstack_to_dp(ctx, argn, &dp); hres = disp_call(ctx->script, obj, id, DISPATCH_METHOD, argn, stack_args(ctx, argn), do_ret ? &v : NULL, ctx->ei);
hres = disp_call(ctx->script, obj, id, DISPATCH_METHOD, &dp, do_ret ? &v : NULL, ctx->ei);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -2398,9 +2380,7 @@ static HRESULT interp_assign(exec_ctx_t *ctx)
static HRESULT interp_assign_call(exec_ctx_t *ctx) static HRESULT interp_assign_call(exec_ctx_t *ctx)
{ {
const unsigned arg = get_op_uint(ctx, 0); const unsigned arg = get_op_uint(ctx, 0);
DISPID propput_dispid = DISPID_PROPERTYPUT;
IDispatch *disp; IDispatch *disp;
DISPPARAMS dp;
VARIANT *v; VARIANT *v;
DISPID id; DISPID id;
HRESULT hres; HRESULT hres;
@ -2411,10 +2391,7 @@ static HRESULT interp_assign_call(exec_ctx_t *ctx)
if(!disp) if(!disp)
return throw_reference_error(ctx->script, ctx->ei, JS_E_ILLEGAL_ASSIGN, NULL); return throw_reference_error(ctx->script, ctx->ei, JS_E_ILLEGAL_ASSIGN, NULL);
jsstack_to_dp(ctx, arg+1, &dp); hres = disp_call(ctx->script, disp, id, DISPATCH_PROPERTYPUT, arg+1, stack_args(ctx,arg+1), NULL, ctx->ei);
dp.cNamedArgs = 1;
dp.rgdispidNamedArgs = &propput_dispid;
hres = disp_call(ctx->script, disp, id, DISPATCH_PROPERTYPUT, &dp, NULL, ctx->ei);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;

View File

@ -35,7 +35,7 @@ static const WCHAR toStringW[] = {'t','o','S','t','r','i','n','g',0};
/* ECMA-262 3rd Edition 15.11.4.4 */ /* ECMA-262 3rd Edition 15.11.4.4 */
static HRESULT Error_toString(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, static HRESULT Error_toString(script_ctx_t *ctx, vdisp_t *vthis, WORD flags,
DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei) unsigned argc, VARIANT *argv, VARIANT *retv, jsexcept_t *ei)
{ {
jsdisp_t *jsthis; jsdisp_t *jsthis;
BSTR name = NULL, msg = NULL, ret = NULL; BSTR name = NULL, msg = NULL, ret = NULL;
@ -127,7 +127,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, static HRESULT Error_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei) unsigned argc, VARIANT *argv, VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
@ -226,28 +226,28 @@ static HRESULT create_error(script_ctx_t *ctx, jsdisp_t *constr,
return S_OK; return S_OK;
} }
static HRESULT error_constr(script_ctx_t *ctx, WORD flags, DISPPARAMS *dp, static HRESULT error_constr(script_ctx_t *ctx, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei, jsdisp_t *constr) { VARIANT *retv, jsexcept_t *ei, jsdisp_t *constr) {
jsdisp_t *err; jsdisp_t *err;
UINT num = 0; UINT num = 0;
BSTR msg = NULL; BSTR msg = NULL;
HRESULT hres; HRESULT hres;
if(arg_cnt(dp)) { if(argc) {
double n; double n;
hres = to_number(ctx, get_arg(dp, 0), ei, &n); hres = to_number(ctx, argv, ei, &n);
if(FAILED(hres)) /* FIXME: really? */ if(FAILED(hres)) /* FIXME: really? */
n = NAN; n = NAN;
if(isnan(n)) if(isnan(n))
hres = to_string(ctx, get_arg(dp, 0), ei, &msg); hres = to_string(ctx, argv, ei, &msg);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
num = n; num = n;
} }
if(arg_cnt(dp)>1 && !msg) { if(argc>1 && !msg) {
hres = to_string(ctx, get_arg(dp, 1), ei, &msg); hres = to_string(ctx, argv+1, ei, &msg);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
} }
@ -275,59 +275,59 @@ static HRESULT error_constr(script_ctx_t *ctx, WORD flags, DISPPARAMS *dp,
} }
static HRESULT ErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, static HRESULT ErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei) unsigned argc, VARIANT *argv, VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
return error_constr(ctx, flags, dp, retv, ei, ctx->error_constr); return error_constr(ctx, flags, argc, argv, retv, ei, ctx->error_constr);
} }
static HRESULT EvalErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, static HRESULT EvalErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei) unsigned argc, VARIANT *argv, VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
return error_constr(ctx, flags, dp, retv, ei, ctx->eval_error_constr); return error_constr(ctx, flags, argc, argv, retv, ei, ctx->eval_error_constr);
} }
static HRESULT RangeErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, static HRESULT RangeErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei) unsigned argc, VARIANT *argv, VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
return error_constr(ctx, flags, dp, retv, ei, ctx->range_error_constr); return error_constr(ctx, flags, argc, argv, retv, ei, ctx->range_error_constr);
} }
static HRESULT ReferenceErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, static HRESULT ReferenceErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei) unsigned argc, VARIANT *argv, VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
return error_constr(ctx, flags, dp, retv, ei, ctx->reference_error_constr); return error_constr(ctx, flags, argc, argv, retv, ei, ctx->reference_error_constr);
} }
static HRESULT RegExpErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, static HRESULT RegExpErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei) unsigned argc, VARIANT *argv, VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
return error_constr(ctx, flags, dp, retv, ei, ctx->regexp_error_constr); return error_constr(ctx, flags, argc, argv, retv, ei, ctx->regexp_error_constr);
} }
static HRESULT SyntaxErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, static HRESULT SyntaxErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei) unsigned argc, VARIANT *argv, VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
return error_constr(ctx, flags, dp, retv, ei, ctx->syntax_error_constr); return error_constr(ctx, flags, argc, argv, retv, ei, ctx->syntax_error_constr);
} }
static HRESULT TypeErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, static HRESULT TypeErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei) unsigned argc, VARIANT *argv, VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
return error_constr(ctx, flags, dp, retv, ei, ctx->type_error_constr); return error_constr(ctx, flags, argc, argv, retv, ei, ctx->type_error_constr);
} }
static HRESULT URIErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, static HRESULT URIErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei) unsigned argc, VARIANT *argv, VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
return error_constr(ctx, flags, dp, retv, ei, ctx->uri_error_constr); return error_constr(ctx, flags, argc, argv, retv, ei, ctx->uri_error_constr);
} }
HRESULT init_error_constr(script_ctx_t *ctx, jsdisp_t *object_prototype) HRESULT init_error_constr(script_ctx_t *ctx, jsdisp_t *object_prototype)

View File

@ -55,37 +55,18 @@ static const WCHAR applyW[] = {'a','p','p','l','y',0};
static const WCHAR callW[] = {'c','a','l','l',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 const WCHAR argumentsW[] = {'a','r','g','u','m','e','n','t','s',0};
static IDispatch *get_this(DISPPARAMS *dp) static HRESULT init_parameters(jsdisp_t *var_disp, FunctionInstance *function, unsigned argc, VARIANT *argv,
{
DWORD i;
for(i=0; i < dp->cNamedArgs; i++) {
if(dp->rgdispidNamedArgs[i] == DISPID_THIS) {
if(V_VT(dp->rgvarg+i) == VT_DISPATCH)
return V_DISPATCH(dp->rgvarg+i);
WARN("This is not VT_DISPATCH\n");
return NULL;
}
}
TRACE("no this passed\n");
return NULL;
}
static HRESULT init_parameters(jsdisp_t *var_disp, FunctionInstance *function, DISPPARAMS *dp,
jsexcept_t *ei) jsexcept_t *ei)
{ {
VARIANT var_empty; VARIANT var_empty;
DWORD cargs, i=0; DWORD i=0;
HRESULT hres; HRESULT hres;
V_VT(&var_empty) = VT_EMPTY; V_VT(&var_empty) = VT_EMPTY;
cargs = arg_cnt(dp);
for(i=0; i < function->func_code->param_cnt; i++) { for(i=0; i < function->func_code->param_cnt; i++) {
hres = jsdisp_propput_name(var_disp, function->func_code->params[i], hres = jsdisp_propput_name(var_disp, function->func_code->params[i],
i < cargs ? get_arg(dp,i) : &var_empty, ei); i < argc ? argv+i : &var_empty, ei);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
} }
@ -93,7 +74,7 @@ static HRESULT init_parameters(jsdisp_t *var_disp, FunctionInstance *function, D
return S_OK; return S_OK;
} }
static HRESULT Arguments_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Arguments_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
FIXME("\n"); FIXME("\n");
@ -108,7 +89,7 @@ static const builtin_info_t Arguments_info = {
NULL NULL
}; };
static HRESULT create_arguments(script_ctx_t *ctx, IDispatch *calee, DISPPARAMS *dp, static HRESULT create_arguments(script_ctx_t *ctx, IDispatch *calee, unsigned argc, VARIANT *argv,
jsexcept_t *ei, jsdisp_t **ret) jsexcept_t *ei, jsdisp_t **ret)
{ {
jsdisp_t *args; jsdisp_t *args;
@ -128,14 +109,14 @@ static HRESULT create_arguments(script_ctx_t *ctx, IDispatch *calee, DISPPARAMS
return hres; return hres;
} }
for(i=0; i < arg_cnt(dp); i++) { for(i=0; i < argc; i++) {
hres = jsdisp_propput_idx(args, i, get_arg(dp,i), ei); hres = jsdisp_propput_idx(args, i, argv+i, ei);
if(FAILED(hres)) if(FAILED(hres))
break; break;
} }
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
num_set_int(&var, arg_cnt(dp)); num_set_int(&var, argc);
hres = jsdisp_propput_name(args, lengthW, &var, ei); hres = jsdisp_propput_name(args, lengthW, &var, ei);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
@ -155,7 +136,7 @@ static HRESULT create_arguments(script_ctx_t *ctx, IDispatch *calee, DISPPARAMS
} }
static HRESULT create_var_disp(script_ctx_t *ctx, FunctionInstance *function, jsdisp_t *arg_disp, static HRESULT create_var_disp(script_ctx_t *ctx, FunctionInstance *function, jsdisp_t *arg_disp,
DISPPARAMS *dp, jsexcept_t *ei, jsdisp_t **ret) unsigned argc, VARIANT *argv, jsexcept_t *ei, jsdisp_t **ret)
{ {
jsdisp_t *var_disp; jsdisp_t *var_disp;
VARIANT var; VARIANT var;
@ -168,7 +149,7 @@ static HRESULT create_var_disp(script_ctx_t *ctx, FunctionInstance *function, js
var_set_jsdisp(&var, arg_disp); var_set_jsdisp(&var, arg_disp);
hres = jsdisp_propput_name(var_disp, argumentsW, &var, ei); hres = jsdisp_propput_name(var_disp, argumentsW, &var, ei);
if(SUCCEEDED(hres)) if(SUCCEEDED(hres))
hres = init_parameters(var_disp, function, dp, ei); hres = init_parameters(var_disp, function, argc, argv, ei);
if(FAILED(hres)) { if(FAILED(hres)) {
jsdisp_release(var_disp); jsdisp_release(var_disp);
return hres; return hres;
@ -178,7 +159,7 @@ static HRESULT create_var_disp(script_ctx_t *ctx, FunctionInstance *function, js
return S_OK; return S_OK;
} }
static HRESULT invoke_source(script_ctx_t *ctx, FunctionInstance *function, IDispatch *this_obj, DISPPARAMS *dp, static HRESULT invoke_source(script_ctx_t *ctx, FunctionInstance *function, IDispatch *this_obj, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
jsdisp_t *var_disp, *arg_disp; jsdisp_t *var_disp, *arg_disp;
@ -191,11 +172,11 @@ static HRESULT invoke_source(script_ctx_t *ctx, FunctionInstance *function, IDis
return E_FAIL; return E_FAIL;
} }
hres = create_arguments(ctx, to_disp(&function->dispex), dp, ei, &arg_disp); hres = create_arguments(ctx, to_disp(&function->dispex), argc, argv, ei, &arg_disp);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
hres = create_var_disp(ctx, function, arg_disp, dp, ei, &var_disp); hres = create_var_disp(ctx, function, arg_disp, argc, argv, ei, &var_disp);
if(FAILED(hres)) { if(FAILED(hres)) {
jsdisp_release(arg_disp); jsdisp_release(arg_disp);
return hres; return hres;
@ -222,7 +203,7 @@ static HRESULT invoke_source(script_ctx_t *ctx, FunctionInstance *function, IDis
return hres; return hres;
} }
static HRESULT invoke_constructor(script_ctx_t *ctx, FunctionInstance *function, DISPPARAMS *dp, static HRESULT invoke_constructor(script_ctx_t *ctx, FunctionInstance *function, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
jsdisp_t *this_obj; jsdisp_t *this_obj;
@ -233,7 +214,7 @@ static HRESULT invoke_constructor(script_ctx_t *ctx, FunctionInstance *function,
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
hres = invoke_source(ctx, function, to_disp(this_obj), dp, &var, ei); hres = invoke_source(ctx, function, to_disp(this_obj), argc, argv, &var, ei);
if(FAILED(hres)) { if(FAILED(hres)) {
jsdisp_release(this_obj); jsdisp_release(this_obj);
return hres; return hres;
@ -250,7 +231,7 @@ static HRESULT invoke_constructor(script_ctx_t *ctx, FunctionInstance *function,
return S_OK; return S_OK;
} }
static HRESULT invoke_value_proc(script_ctx_t *ctx, FunctionInstance *function, IDispatch *this_disp, WORD flags, DISPPARAMS *dp, static HRESULT invoke_value_proc(script_ctx_t *ctx, FunctionInstance *function, IDispatch *this_disp, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
vdisp_t vthis; vdisp_t vthis;
@ -263,19 +244,19 @@ static HRESULT invoke_value_proc(script_ctx_t *ctx, FunctionInstance *function,
else else
set_jsdisp(&vthis, ctx->global); set_jsdisp(&vthis, ctx->global);
hres = function->value_proc(ctx, &vthis, flags, dp, retv, ei); hres = function->value_proc(ctx, &vthis, flags, argc, argv, retv, ei);
vdisp_release(&vthis); vdisp_release(&vthis);
return hres; return hres;
} }
static HRESULT call_function(script_ctx_t *ctx, FunctionInstance *function, IDispatch *this_obj, DISPPARAMS *args, static HRESULT call_function(script_ctx_t *ctx, FunctionInstance *function, IDispatch *this_obj,
VARIANT *retv, jsexcept_t *ei) unsigned argc, VARIANT *argv, VARIANT *retv, jsexcept_t *ei)
{ {
if(function->value_proc) if(function->value_proc)
return invoke_value_proc(ctx, function, this_obj, DISPATCH_METHOD, args, retv, ei); return invoke_value_proc(ctx, function, this_obj, DISPATCH_METHOD, argc, argv, retv, ei);
return invoke_source(ctx, function, this_obj, args, retv, ei); return invoke_source(ctx, function, this_obj, argc, argv, retv, ei);
} }
static HRESULT function_to_string(FunctionInstance *function, BSTR *ret) static HRESULT function_to_string(FunctionInstance *function, BSTR *ret)
@ -307,7 +288,7 @@ static HRESULT function_to_string(FunctionInstance *function, BSTR *ret)
return S_OK; return S_OK;
} }
HRESULT Function_invoke(jsdisp_t *func_this, IDispatch *jsthis, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei) HRESULT Function_invoke(jsdisp_t *func_this, IDispatch *jsthis, WORD flags, unsigned argc, VARIANT *argv, VARIANT *retv, jsexcept_t *ei)
{ {
FunctionInstance *function; FunctionInstance *function;
@ -317,16 +298,16 @@ HRESULT Function_invoke(jsdisp_t *func_this, IDispatch *jsthis, WORD flags, DISP
function = (FunctionInstance*)func_this; function = (FunctionInstance*)func_this;
if(function->value_proc) if(function->value_proc)
return invoke_value_proc(function->dispex.ctx, function, jsthis, flags, dp, retv, ei); return invoke_value_proc(function->dispex.ctx, function, jsthis, flags, argc, argv, retv, ei);
if(flags == DISPATCH_CONSTRUCT) if(flags == DISPATCH_CONSTRUCT)
return invoke_constructor(function->dispex.ctx, function, dp, retv, ei); return invoke_constructor(function->dispex.ctx, function, argc, argv, retv, ei);
assert(flags == DISPATCH_METHOD); assert(flags == DISPATCH_METHOD);
return invoke_source(function->dispex.ctx, function, jsthis, dp, retv, ei); return invoke_source(function->dispex.ctx, function, jsthis, argc, argv, retv, ei);
} }
static HRESULT Function_length(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Function_length(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
FunctionInstance *This = function_from_vdisp(jsthis); FunctionInstance *This = function_from_vdisp(jsthis);
@ -345,7 +326,7 @@ static HRESULT Function_length(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, D
return S_OK; return S_OK;
} }
static HRESULT Function_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Function_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
FunctionInstance *function; FunctionInstance *function;
@ -370,7 +351,7 @@ static HRESULT Function_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
return S_OK; return S_OK;
} }
static HRESULT array_to_args(script_ctx_t *ctx, jsdisp_t *arg_array, jsexcept_t *ei, DISPPARAMS *args) static HRESULT array_to_args(script_ctx_t *ctx, jsdisp_t *arg_array, jsexcept_t *ei, unsigned *argc, VARIANT **ret)
{ {
VARIANT var, *argv; VARIANT var, *argv;
DWORD length, i; DWORD length, i;
@ -401,17 +382,17 @@ static HRESULT array_to_args(script_ctx_t *ctx, jsdisp_t *arg_array, jsexcept_t
} }
} }
args->cArgs = length; *argc = length;
args->rgvarg = argv; *ret = argv;
return S_OK; return S_OK;
} }
static HRESULT Function_apply(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Function_apply(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
FunctionInstance *function; FunctionInstance *function;
DISPPARAMS args = {NULL,NULL,0,0}; VARIANT *args = NULL;
DWORD argc, i; unsigned i, cnt = 0;
IDispatch *this_obj = NULL; IDispatch *this_obj = NULL;
HRESULT hres = S_OK; HRESULT hres = S_OK;
@ -420,12 +401,9 @@ static HRESULT Function_apply(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI
if(!(function = function_this(jsthis))) if(!(function = function_this(jsthis)))
return throw_type_error(ctx, ei, JS_E_FUNCTION_EXPECTED, NULL); return throw_type_error(ctx, ei, JS_E_FUNCTION_EXPECTED, NULL);
argc = arg_cnt(dp);
if(argc) { if(argc) {
VARIANT *v = get_arg(dp,0); if(V_VT(argv) != VT_EMPTY && V_VT(argv) != VT_NULL) {
hres = to_object(ctx, argv, &this_obj);
if(V_VT(v) != VT_EMPTY && V_VT(v) != VT_NULL) {
hres = to_object(ctx, v, &this_obj);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
} }
@ -434,8 +412,8 @@ static HRESULT Function_apply(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI
if(argc >= 2) { if(argc >= 2) {
jsdisp_t *arg_array = NULL; jsdisp_t *arg_array = NULL;
if(V_VT(get_arg(dp,1)) == VT_DISPATCH) { if(V_VT(argv+1) == VT_DISPATCH) {
arg_array = iface_to_jsdisp((IUnknown*)V_DISPATCH(get_arg(dp,1))); arg_array = iface_to_jsdisp((IUnknown*)V_DISPATCH(argv+1));
if(arg_array && if(arg_array &&
(!is_class(arg_array, JSCLASS_ARRAY) && !is_class(arg_array, JSCLASS_ARGUMENTS) )) { (!is_class(arg_array, JSCLASS_ARRAY) && !is_class(arg_array, JSCLASS_ARGUMENTS) )) {
jsdisp_release(arg_array); jsdisp_release(arg_array);
@ -444,7 +422,7 @@ static HRESULT Function_apply(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI
} }
if(arg_array) { if(arg_array) {
hres = array_to_args(ctx, arg_array, ei, &args); hres = array_to_args(ctx, arg_array, ei, &cnt, &args);
jsdisp_release(arg_array); jsdisp_release(arg_array);
}else { }else {
FIXME("throw TypeError\n"); FIXME("throw TypeError\n");
@ -453,23 +431,22 @@ static HRESULT Function_apply(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI
} }
if(SUCCEEDED(hres)) if(SUCCEEDED(hres))
hres = call_function(ctx, function, this_obj, &args, retv, ei); hres = call_function(ctx, function, this_obj, cnt, args, retv, ei);
if(this_obj) if(this_obj)
IDispatch_Release(this_obj); IDispatch_Release(this_obj);
for(i=0; i<args.cArgs; i++) for(i=0; i < cnt; i++)
VariantClear(args.rgvarg+i); VariantClear(args+i);
heap_free(args.rgvarg); heap_free(args);
return hres; return hres;
} }
static HRESULT Function_call(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Function_call(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
FunctionInstance *function; FunctionInstance *function;
DISPPARAMS args = {NULL,NULL,0,0};
IDispatch *this_obj = NULL; IDispatch *this_obj = NULL;
DWORD argc; unsigned cnt = 0;
HRESULT hres; HRESULT hres;
TRACE("\n"); TRACE("\n");
@ -477,30 +454,24 @@ static HRESULT Function_call(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DIS
if(!(function = function_this(jsthis))) if(!(function = function_this(jsthis)))
return throw_type_error(ctx, ei, JS_E_FUNCTION_EXPECTED, NULL); return throw_type_error(ctx, ei, JS_E_FUNCTION_EXPECTED, NULL);
argc = arg_cnt(dp);
if(argc) { if(argc) {
VARIANT *v = get_arg(dp,0); if(V_VT(argv) != VT_EMPTY && V_VT(argv) != VT_NULL) {
hres = to_object(ctx, argv, &this_obj);
if(V_VT(v) != VT_EMPTY && V_VT(v) != VT_NULL) {
hres = to_object(ctx, v, &this_obj);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
} }
args.cArgs = argc-1; cnt = argc-1;
} }
if(args.cArgs) hres = call_function(ctx, function, this_obj, cnt, argv+1, retv, ei);
args.rgvarg = dp->rgvarg + dp->cArgs - args.cArgs-1;
hres = call_function(ctx, function, this_obj, &args, retv, ei);
if(this_obj) if(this_obj)
IDispatch_Release(this_obj); IDispatch_Release(this_obj);
return hres; return hres;
} }
HRESULT Function_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, HRESULT Function_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
FunctionInstance *function; FunctionInstance *function;
@ -516,10 +487,8 @@ HRESULT Function_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAM
switch(flags) { switch(flags) {
case DISPATCH_METHOD: case DISPATCH_METHOD:
if(function->value_proc) assert(function->value_proc != NULL);
return invoke_value_proc(ctx, function, get_this(dp), flags, dp, retv, ei); return invoke_value_proc(ctx, function, NULL, flags, argc, argv, retv, ei);
return invoke_source(ctx, function, get_this(dp), dp, retv, ei);
case DISPATCH_PROPERTYGET: { case DISPATCH_PROPERTYGET: {
HRESULT hres; HRESULT hres;
@ -535,10 +504,8 @@ HRESULT Function_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAM
} }
case DISPATCH_CONSTRUCT: case DISPATCH_CONSTRUCT:
if(function->value_proc) assert(function->value_proc != NULL);
return invoke_value_proc(ctx, function, get_this(dp), flags, dp, retv, ei); return invoke_value_proc(ctx, function, NULL, flags, argc, argv, retv, ei);
return invoke_constructor(ctx, function, dp, retv, ei);
default: default:
FIXME("not implemented flags %x\n", flags); FIXME("not implemented flags %x\n", flags);
@ -549,7 +516,7 @@ HRESULT Function_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAM
} }
static HRESULT Function_arguments(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, static HRESULT Function_arguments(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei) unsigned argc, VARIANT *argv, VARIANT *retv, jsexcept_t *ei)
{ {
FunctionInstance *function = (FunctionInstance*)jsthis->u.jsdisp; FunctionInstance *function = (FunctionInstance*)jsthis->u.jsdisp;
HRESULT hres = S_OK; HRESULT hres = S_OK;
@ -707,10 +674,10 @@ HRESULT create_source_function(script_ctx_t *ctx, bytecode_t *code, function_cod
return S_OK; return S_OK;
} }
static HRESULT construct_function(script_ctx_t *ctx, DISPPARAMS *dp, jsexcept_t *ei, IDispatch **ret) static HRESULT construct_function(script_ctx_t *ctx, unsigned argc, VARIANT *argv, jsexcept_t *ei, IDispatch **ret)
{ {
WCHAR *str = NULL, *ptr; WCHAR *str = NULL, *ptr;
DWORD argc, len = 0, l; DWORD len = 0, l;
bytecode_t *code; bytecode_t *code;
jsdisp_t *function; jsdisp_t *function;
BSTR *params = NULL; BSTR *params = NULL;
@ -721,7 +688,6 @@ static HRESULT construct_function(script_ctx_t *ctx, DISPPARAMS *dp, jsexcept_t
static const WCHAR function_beginW[] = {')',' ','{','\n'}; static const WCHAR function_beginW[] = {')',' ','{','\n'};
static const WCHAR function_endW[] = {'\n','}',0}; static const WCHAR function_endW[] = {'\n','}',0};
argc = arg_cnt(dp);
if(argc) { if(argc) {
params = heap_alloc(argc*sizeof(BSTR)); params = heap_alloc(argc*sizeof(BSTR));
if(!params) if(!params)
@ -730,7 +696,7 @@ static HRESULT construct_function(script_ctx_t *ctx, DISPPARAMS *dp, jsexcept_t
if(argc > 2) if(argc > 2)
len = (argc-2)*2; /* separating commas */ len = (argc-2)*2; /* separating commas */
for(i=0; i < argc; i++) { for(i=0; i < argc; i++) {
hres = to_string(ctx, get_arg(dp,i), ei, params+i); hres = to_string(ctx, argv+i, ei, params+i);
if(FAILED(hres)) if(FAILED(hres))
break; break;
len += SysStringLen(params[i]); len += SysStringLen(params[i]);
@ -795,7 +761,7 @@ static HRESULT construct_function(script_ctx_t *ctx, DISPPARAMS *dp, jsexcept_t
return S_OK; return S_OK;
} }
static HRESULT FunctionConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT FunctionConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
HRESULT hres; HRESULT hres;
@ -806,7 +772,7 @@ static HRESULT FunctionConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD fla
case DISPATCH_CONSTRUCT: { case DISPATCH_CONSTRUCT: {
IDispatch *ret; IDispatch *ret;
hres = construct_function(ctx, dp, ei, &ret); hres = construct_function(ctx, argc, argv, ei, &ret);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -822,7 +788,7 @@ static HRESULT FunctionConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD fla
return S_OK; return S_OK;
} }
static HRESULT FunctionProt_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT FunctionProt_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
FIXME("\n"); FIXME("\n");

View File

@ -113,161 +113,161 @@ static WCHAR int_to_char(int i)
return 'A'+i-10; return 'A'+i-10;
} }
static HRESULT constructor_call(jsdisp_t *constr, WORD flags, DISPPARAMS *dp, static HRESULT constructor_call(jsdisp_t *constr, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
if(flags != DISPATCH_PROPERTYGET) if(flags != DISPATCH_PROPERTYGET)
return jsdisp_call_value(constr, NULL, flags, dp, retv, ei); return jsdisp_call_value(constr, NULL, flags, argc, argv, retv, ei);
jsdisp_addref(constr); jsdisp_addref(constr);
var_set_jsdisp(retv, constr); var_set_jsdisp(retv, constr);
return S_OK; return S_OK;
} }
static HRESULT JSGlobal_Array(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT JSGlobal_Array(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
return constructor_call(ctx->array_constr, flags, dp, retv, ei); return constructor_call(ctx->array_constr, flags, argc, argv, retv, ei);
} }
static HRESULT JSGlobal_Boolean(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT JSGlobal_Boolean(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
return constructor_call(ctx->bool_constr, flags, dp, retv, ei); return constructor_call(ctx->bool_constr, flags, argc, argv, retv, ei);
} }
static HRESULT JSGlobal_Date(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT JSGlobal_Date(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
return constructor_call(ctx->date_constr, flags, dp, retv, ei); return constructor_call(ctx->date_constr, flags, argc, argv, retv, ei);
} }
static HRESULT JSGlobal_Error(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT JSGlobal_Error(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
return constructor_call(ctx->error_constr, flags, dp, retv, ei); return constructor_call(ctx->error_constr, flags, argc, argv, retv, ei);
} }
static HRESULT JSGlobal_EvalError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT JSGlobal_EvalError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
return constructor_call(ctx->eval_error_constr, flags, dp, retv, ei); return constructor_call(ctx->eval_error_constr, flags, argc, argv, retv, ei);
} }
static HRESULT JSGlobal_RangeError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT JSGlobal_RangeError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
return constructor_call(ctx->range_error_constr, flags, dp, retv, ei); return constructor_call(ctx->range_error_constr, flags, argc, argv, retv, ei);
} }
static HRESULT JSGlobal_ReferenceError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT JSGlobal_ReferenceError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
return constructor_call(ctx->reference_error_constr, flags, dp, retv, ei); return constructor_call(ctx->reference_error_constr, flags, argc, argv, retv, ei);
} }
static HRESULT JSGlobal_SyntaxError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT JSGlobal_SyntaxError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
return constructor_call(ctx->syntax_error_constr, flags, dp, retv, ei); return constructor_call(ctx->syntax_error_constr, flags, argc, argv, retv, ei);
} }
static HRESULT JSGlobal_TypeError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT JSGlobal_TypeError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
return constructor_call(ctx->type_error_constr, flags, dp, retv, ei); return constructor_call(ctx->type_error_constr, flags, argc, argv, retv, ei);
} }
static HRESULT JSGlobal_URIError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT JSGlobal_URIError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
return constructor_call(ctx->uri_error_constr, flags, dp, retv, ei); return constructor_call(ctx->uri_error_constr, flags, argc, argv, retv, ei);
} }
static HRESULT JSGlobal_Function(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT JSGlobal_Function(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
return constructor_call(ctx->function_constr, flags, dp, retv, ei); return constructor_call(ctx->function_constr, flags, argc, argv, retv, ei);
} }
static HRESULT JSGlobal_Number(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT JSGlobal_Number(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
return constructor_call(ctx->number_constr, flags, dp, retv, ei); return constructor_call(ctx->number_constr, flags, argc, argv, retv, ei);
} }
static HRESULT JSGlobal_Object(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT JSGlobal_Object(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
return constructor_call(ctx->object_constr, flags, dp, retv, ei); return constructor_call(ctx->object_constr, flags, argc, argv, retv, ei);
} }
static HRESULT JSGlobal_String(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT JSGlobal_String(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
return constructor_call(ctx->string_constr, flags, dp, retv, ei); return constructor_call(ctx->string_constr, flags, argc, argv, retv, ei);
} }
static HRESULT JSGlobal_RegExp(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT JSGlobal_RegExp(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
return constructor_call(ctx->regexp_constr, flags, dp, retv, ei); return constructor_call(ctx->regexp_constr, flags, argc, argv, retv, ei);
} }
static HRESULT JSGlobal_ActiveXObject(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT JSGlobal_ActiveXObject(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
return constructor_call(ctx->activex_constr, flags, dp, retv, ei); return constructor_call(ctx->activex_constr, flags, argc, argv, retv, ei);
} }
static HRESULT JSGlobal_VBArray(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT JSGlobal_VBArray(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
return constructor_call(ctx->vbarray_constr, flags, dp, retv, ei); return constructor_call(ctx->vbarray_constr, flags, argc, argv, retv, ei);
} }
static HRESULT JSGlobal_Enumerator(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT JSGlobal_Enumerator(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
FIXME("\n"); FIXME("\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT JSGlobal_escape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT JSGlobal_escape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
BSTR ret, str; BSTR ret, str;
@ -277,7 +277,7 @@ static HRESULT JSGlobal_escape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, D
TRACE("\n"); TRACE("\n");
if(!arg_cnt(dp)) { if(!argc) {
if(retv) { if(retv) {
ret = SysAllocString(undefinedW); ret = SysAllocString(undefinedW);
if(!ret) if(!ret)
@ -290,7 +290,7 @@ static HRESULT JSGlobal_escape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, D
return S_OK; return S_OK;
} }
hres = to_string(ctx, get_arg(dp, 0), ei, &str); hres = to_string(ctx, argv, ei, &str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -341,26 +341,24 @@ static HRESULT JSGlobal_escape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, D
} }
/* ECMA-262 3rd Edition 15.1.2.1 */ /* ECMA-262 3rd Edition 15.1.2.1 */
static HRESULT JSGlobal_eval(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT JSGlobal_eval(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
bytecode_t *code; bytecode_t *code;
VARIANT *arg;
HRESULT hres; HRESULT hres;
TRACE("\n"); TRACE("\n");
if(!arg_cnt(dp)) { if(!argc) {
if(retv) if(retv)
V_VT(retv) = VT_EMPTY; V_VT(retv) = VT_EMPTY;
return S_OK; return S_OK;
} }
arg = get_arg(dp, 0); if(V_VT(argv) != VT_BSTR) {
if(V_VT(arg) != VT_BSTR) {
if(retv) { if(retv) {
V_VT(retv) = VT_EMPTY; V_VT(retv) = VT_EMPTY;
return VariantCopy(retv, arg); return VariantCopy(retv, argv);
} }
return S_OK; return S_OK;
} }
@ -370,10 +368,10 @@ static HRESULT JSGlobal_eval(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DIS
return E_UNEXPECTED; return E_UNEXPECTED;
} }
TRACE("parsing %s\n", debugstr_w(V_BSTR(arg))); TRACE("parsing %s\n", debugstr_w(V_BSTR(argv)));
hres = compile_script(ctx, V_BSTR(arg), NULL, TRUE, FALSE, &code); hres = compile_script(ctx, V_BSTR(argv), NULL, TRUE, FALSE, &code);
if(FAILED(hres)) { if(FAILED(hres)) {
WARN("parse (%s) failed: %08x\n", debugstr_w(V_BSTR(arg)), hres); WARN("parse (%s) failed: %08x\n", debugstr_w(V_BSTR(argv)), hres);
return throw_syntax_error(ctx, ei, hres, NULL); return throw_syntax_error(ctx, ei, hres, NULL);
} }
@ -383,7 +381,7 @@ static HRESULT JSGlobal_eval(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DIS
return hres; return hres;
} }
static HRESULT JSGlobal_isNaN(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT JSGlobal_isNaN(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
VARIANT_BOOL ret = VARIANT_TRUE; VARIANT_BOOL ret = VARIANT_TRUE;
@ -392,8 +390,8 @@ static HRESULT JSGlobal_isNaN(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI
TRACE("\n"); TRACE("\n");
if(arg_cnt(dp)) { if(argc) {
hres = to_number(ctx, get_arg(dp,0), ei, &n); hres = to_number(ctx, argv, ei, &n);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -408,7 +406,7 @@ static HRESULT JSGlobal_isNaN(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI
return S_OK; return S_OK;
} }
static HRESULT JSGlobal_isFinite(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT JSGlobal_isFinite(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
VARIANT_BOOL ret = VARIANT_FALSE; VARIANT_BOOL ret = VARIANT_FALSE;
@ -416,10 +414,10 @@ static HRESULT JSGlobal_isFinite(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
TRACE("\n"); TRACE("\n");
if(arg_cnt(dp)) { if(argc) {
double n; double n;
hres = to_number(ctx, get_arg(dp,0), ei, &n); hres = to_number(ctx, argv, ei, &n);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -445,7 +443,7 @@ static INT char_to_int(WCHAR c)
return 100; return 100;
} }
static HRESULT JSGlobal_parseInt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT JSGlobal_parseInt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
BOOL neg = FALSE, empty = TRUE; BOOL neg = FALSE, empty = TRUE;
@ -455,13 +453,13 @@ static HRESULT JSGlobal_parseInt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
BSTR str; BSTR str;
HRESULT hres; HRESULT hres;
if(!arg_cnt(dp)) { if(!argc) {
if(retv) num_set_val(retv, NAN); if(retv) num_set_val(retv, NAN);
return S_OK; return S_OK;
} }
if(arg_cnt(dp) >= 2) { if(argc >= 2) {
hres = to_int32(ctx, get_arg(dp, 1), ei, &radix); hres = to_int32(ctx, argv+1, ei, &radix);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -473,7 +471,7 @@ static HRESULT JSGlobal_parseInt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
} }
} }
hres = to_string(ctx, get_arg(dp, 0), ei, &str); hres = to_string(ctx, argv, ei, &str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -524,25 +522,23 @@ static HRESULT JSGlobal_parseInt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
return S_OK; return S_OK;
} }
static HRESULT JSGlobal_parseFloat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT JSGlobal_parseFloat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
LONGLONG d = 0, hlp; LONGLONG d = 0, hlp;
int exp = 0; int exp = 0;
VARIANT *arg;
WCHAR *str; WCHAR *str;
BSTR val_str = NULL; BSTR val_str = NULL;
BOOL ret_nan = TRUE, positive = TRUE; BOOL ret_nan = TRUE, positive = TRUE;
HRESULT hres; HRESULT hres;
if(!arg_cnt(dp)) { if(!argc) {
if(retv) if(retv)
num_set_val(retv, NAN); num_set_val(retv, NAN);
return S_OK; return S_OK;
} }
arg = get_arg(dp, 0); hres = to_string(ctx, argv, ei, &val_str);
hres = to_string(ctx, arg, ei, &val_str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -633,7 +629,7 @@ static inline int hex_to_int(const WCHAR wch) {
return -1; return -1;
} }
static HRESULT JSGlobal_unescape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT JSGlobal_unescape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
BSTR ret, str; BSTR ret, str;
@ -643,7 +639,7 @@ static HRESULT JSGlobal_unescape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
TRACE("\n"); TRACE("\n");
if(!arg_cnt(dp)) { if(!argc) {
if(retv) { if(retv) {
ret = SysAllocString(undefinedW); ret = SysAllocString(undefinedW);
if(!ret) if(!ret)
@ -656,7 +652,7 @@ static HRESULT JSGlobal_unescape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
return S_OK; return S_OK;
} }
hres = to_string(ctx, get_arg(dp, 0), ei, &str); hres = to_string(ctx, argv, ei, &str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -712,14 +708,14 @@ static HRESULT JSGlobal_unescape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
return S_OK; return S_OK;
} }
static HRESULT JSGlobal_GetObject(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT JSGlobal_GetObject(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
FIXME("\n"); FIXME("\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT JSGlobal_ScriptEngine(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT JSGlobal_ScriptEngine(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
static const WCHAR JScriptW[] = {'J','S','c','r','i','p','t',0}; static const WCHAR JScriptW[] = {'J','S','c','r','i','p','t',0};
@ -740,7 +736,7 @@ static HRESULT JSGlobal_ScriptEngine(script_ctx_t *ctx, vdisp_t *jsthis, WORD fl
return S_OK; return S_OK;
} }
static HRESULT JSGlobal_ScriptEngineMajorVersion(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT JSGlobal_ScriptEngineMajorVersion(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
@ -750,7 +746,7 @@ static HRESULT JSGlobal_ScriptEngineMajorVersion(script_ctx_t *ctx, vdisp_t *jst
return S_OK; return S_OK;
} }
static HRESULT JSGlobal_ScriptEngineMinorVersion(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT JSGlobal_ScriptEngineMinorVersion(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
@ -760,7 +756,7 @@ static HRESULT JSGlobal_ScriptEngineMinorVersion(script_ctx_t *ctx, vdisp_t *jst
return S_OK; return S_OK;
} }
static HRESULT JSGlobal_ScriptEngineBuildVersion(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT JSGlobal_ScriptEngineBuildVersion(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
@ -770,14 +766,14 @@ static HRESULT JSGlobal_ScriptEngineBuildVersion(script_ctx_t *ctx, vdisp_t *jst
return S_OK; return S_OK;
} }
static HRESULT JSGlobal_CollectGarbage(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT JSGlobal_CollectGarbage(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
FIXME("\n"); FIXME("\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
const WCHAR *ptr; const WCHAR *ptr;
@ -789,7 +785,7 @@ static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
TRACE("\n"); TRACE("\n");
if(!arg_cnt(dp)) { if(!argc) {
if(retv) { if(retv) {
ret = SysAllocString(undefinedW); ret = SysAllocString(undefinedW);
if(!ret) if(!ret)
@ -802,7 +798,7 @@ static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
return S_OK; return S_OK;
} }
hres = to_string(ctx, get_arg(dp,0), ei, &str); hres = to_string(ctx, argv, ei, &str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -851,7 +847,7 @@ static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
return S_OK; return S_OK;
} }
static HRESULT JSGlobal_decodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT JSGlobal_decodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
BSTR str, ret; BSTR str, ret;
@ -863,7 +859,7 @@ static HRESULT JSGlobal_decodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
TRACE("\n"); TRACE("\n");
if(!arg_cnt(dp)) { if(!argc) {
if(retv) { if(retv) {
ret = SysAllocString(undefinedW); ret = SysAllocString(undefinedW);
if(!ret) if(!ret)
@ -876,7 +872,7 @@ static HRESULT JSGlobal_decodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
return S_OK; return S_OK;
} }
hres = to_string(ctx, get_arg(dp,0), ei, &str); hres = to_string(ctx, argv, ei, &str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -947,7 +943,7 @@ static HRESULT JSGlobal_decodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
return S_OK; return S_OK;
} }
static HRESULT JSGlobal_encodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT JSGlobal_encodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
BSTR str, ret; BSTR str, ret;
@ -958,7 +954,7 @@ static HRESULT JSGlobal_encodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, W
TRACE("\n"); TRACE("\n");
if(!arg_cnt(dp)) { if(!argc) {
if(retv) { if(retv) {
ret = SysAllocString(undefinedW); ret = SysAllocString(undefinedW);
if(!ret) if(!ret)
@ -971,7 +967,7 @@ static HRESULT JSGlobal_encodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, W
return S_OK; return S_OK;
} }
hres = to_string(ctx, get_arg(dp, 0), ei, &str); hres = to_string(ctx, argv, ei, &str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -1021,7 +1017,7 @@ static HRESULT JSGlobal_encodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, W
} }
/* ECMA-262 3rd Edition 15.1.3.2 */ /* ECMA-262 3rd Edition 15.1.3.2 */
static HRESULT JSGlobal_decodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT JSGlobal_decodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
BSTR str, ret; BSTR str, ret;
@ -1032,7 +1028,7 @@ static HRESULT JSGlobal_decodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, W
TRACE("\n"); TRACE("\n");
if(!arg_cnt(dp)) { if(!argc) {
if(retv) { if(retv) {
ret = SysAllocString(undefinedW); ret = SysAllocString(undefinedW);
if(!ret) if(!ret)
@ -1045,7 +1041,7 @@ static HRESULT JSGlobal_decodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, W
return S_OK; return S_OK;
} }
hres = to_string(ctx, get_arg(dp, 0), ei, &str); hres = to_string(ctx, argv, ei, &str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;

View File

@ -152,7 +152,7 @@ static inline jsdisp_t *get_jsdisp(vdisp_t *vdisp)
return is_jsdisp(vdisp) ? vdisp->u.jsdisp : NULL; return is_jsdisp(vdisp) ? vdisp->u.jsdisp : NULL;
} }
typedef HRESULT (*builtin_invoke_t)(script_ctx_t*,vdisp_t*,WORD,DISPPARAMS*,VARIANT*,jsexcept_t*); typedef HRESULT (*builtin_invoke_t)(script_ctx_t*,vdisp_t*,WORD,unsigned,VARIANT*,VARIANT*,jsexcept_t*);
typedef struct { typedef struct {
const WCHAR *name; const WCHAR *name;
@ -206,11 +206,11 @@ 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(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 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,DISPPARAMS*,VARIANT*,jsexcept_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,DISPPARAMS*,VARIANT*,jsexcept_t*) DECLSPEC_HIDDEN; HRESULT disp_call_value(script_ctx_t*,IDispatch*,IDispatch*,WORD,unsigned,VARIANT*,VARIANT*,jsexcept_t*) DECLSPEC_HIDDEN;
HRESULT jsdisp_call_value(jsdisp_t*,IDispatch*,WORD,DISPPARAMS*,VARIANT*,jsexcept_t*) DECLSPEC_HIDDEN; HRESULT jsdisp_call_value(jsdisp_t*,IDispatch*,WORD,unsigned,VARIANT*,VARIANT*,jsexcept_t*) DECLSPEC_HIDDEN;
HRESULT jsdisp_call(jsdisp_t*,DISPID,WORD,DISPPARAMS*,VARIANT*,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,DISPPARAMS*,VARIANT*,jsexcept_t*) DECLSPEC_HIDDEN; HRESULT jsdisp_call_name(jsdisp_t*,const WCHAR*,WORD,unsigned,VARIANT*,VARIANT*,jsexcept_t*) DECLSPEC_HIDDEN;
HRESULT disp_propget(script_ctx_t*,IDispatch*,DISPID,VARIANT*,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 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_propget(jsdisp_t*,DISPID,VARIANT*,jsexcept_t*) DECLSPEC_HIDDEN;
@ -225,8 +225,8 @@ VARIANT_BOOL jsdisp_is_own_prop(jsdisp_t *obj, BSTR name) DECLSPEC_HIDDEN;
HRESULT create_builtin_function(script_ctx_t*,builtin_invoke_t,const WCHAR*,const builtin_info_t*,DWORD, HRESULT create_builtin_function(script_ctx_t*,builtin_invoke_t,const WCHAR*,const builtin_info_t*,DWORD,
jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN; jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
HRESULT Function_value(script_ctx_t*,vdisp_t*,WORD,DISPPARAMS*,VARIANT*,jsexcept_t*) DECLSPEC_HIDDEN; HRESULT Function_value(script_ctx_t*,vdisp_t*,WORD,unsigned,VARIANT*,VARIANT*,jsexcept_t*) DECLSPEC_HIDDEN;
HRESULT Function_invoke(jsdisp_t*,IDispatch*,WORD,DISPPARAMS*,VARIANT*,jsexcept_t*); HRESULT Function_invoke(jsdisp_t*,IDispatch*,WORD,unsigned,VARIANT*,VARIANT*,jsexcept_t*);
HRESULT throw_eval_error(script_ctx_t*,jsexcept_t*,HRESULT,const WCHAR*) 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; HRESULT throw_generic_error(script_ctx_t*,jsexcept_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;

View File

@ -203,7 +203,6 @@ HRESULT to_primitive(script_ctx_t *ctx, VARIANT *v, jsexcept_t *ei, VARIANT *ret
case VT_DISPATCH: { case VT_DISPATCH: {
jsdisp_t *jsdisp; jsdisp_t *jsdisp;
DISPID id; DISPID id;
DISPPARAMS dp = {NULL, NULL, 0, 0};
HRESULT hres; HRESULT hres;
static const WCHAR toStringW[] = {'t','o','S','t','r','i','n','g',0}; static const WCHAR toStringW[] = {'t','o','S','t','r','i','n','g',0};
@ -227,7 +226,7 @@ HRESULT to_primitive(script_ctx_t *ctx, VARIANT *v, jsexcept_t *ei, VARIANT *ret
hres = jsdisp_get_id(jsdisp, hint == HINT_STRING ? toStringW : valueOfW, 0, &id); hres = jsdisp_get_id(jsdisp, hint == HINT_STRING ? toStringW : valueOfW, 0, &id);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
hres = jsdisp_call(jsdisp, id, DISPATCH_METHOD, &dp, ret, ei); hres = jsdisp_call(jsdisp, id, DISPATCH_METHOD, 0, NULL, ret, ei);
if(FAILED(hres)) { if(FAILED(hres)) {
WARN("call error - forwarding exception\n"); WARN("call error - forwarding exception\n");
jsdisp_release(jsdisp); jsdisp_release(jsdisp);
@ -243,7 +242,7 @@ HRESULT to_primitive(script_ctx_t *ctx, VARIANT *v, jsexcept_t *ei, VARIANT *ret
hres = jsdisp_get_id(jsdisp, hint == HINT_STRING ? valueOfW : toStringW, 0, &id); hres = jsdisp_get_id(jsdisp, hint == HINT_STRING ? valueOfW : toStringW, 0, &id);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
hres = jsdisp_call(jsdisp, id, DISPATCH_METHOD, &dp, ret, ei); hres = jsdisp_call(jsdisp, id, DISPATCH_METHOD, 0, NULL, ret, ei);
if(FAILED(hres)) { if(FAILED(hres)) {
WARN("call error - forwarding exception\n"); WARN("call error - forwarding exception\n");
jsdisp_release(jsdisp); jsdisp_release(jsdisp);

View File

@ -58,7 +58,7 @@ static const WCHAR sqrtW[] = {'s','q','r','t',0};
static const WCHAR tanW[] = {'t','a','n',0}; static const WCHAR tanW[] = {'t','a','n',0};
/* ECMA-262 3rd Edition 15.8.2.12 */ /* ECMA-262 3rd Edition 15.8.2.12 */
static HRESULT Math_abs(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Math_abs(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
double d; double d;
@ -66,13 +66,13 @@ static HRESULT Math_abs(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARA
TRACE("\n"); TRACE("\n");
if(!arg_cnt(dp)) { if(!argc) {
if(retv) if(retv)
num_set_val(retv, NAN); num_set_val(retv, NAN);
return S_OK; return S_OK;
} }
hres = to_number(ctx, get_arg(dp, 0), ei, &d); hres = to_number(ctx, argv, ei, &d);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -81,7 +81,7 @@ static HRESULT Math_abs(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARA
return S_OK; return S_OK;
} }
static HRESULT Math_acos(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Math_acos(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
double x; double x;
@ -89,12 +89,12 @@ static HRESULT Math_acos(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPAR
TRACE("\n"); TRACE("\n");
if(!arg_cnt(dp)) { if(!argc) {
if(retv) num_set_val(retv, NAN); if(retv) num_set_val(retv, NAN);
return S_OK; return S_OK;
} }
hres = to_number(ctx, get_arg(dp, 0), ei, &x); hres = to_number(ctx, argv, ei, &x);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -103,7 +103,7 @@ static HRESULT Math_acos(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPAR
return S_OK; return S_OK;
} }
static HRESULT Math_asin(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Math_asin(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
double x; double x;
@ -111,12 +111,12 @@ static HRESULT Math_asin(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPAR
TRACE("\n"); TRACE("\n");
if(!arg_cnt(dp)) { if(!argc) {
if(retv) num_set_val(retv, NAN); if(retv) num_set_val(retv, NAN);
return S_OK; return S_OK;
} }
hres = to_number(ctx, get_arg(dp, 0), ei, &x); hres = to_number(ctx, argv, ei, &x);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -125,7 +125,7 @@ static HRESULT Math_asin(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPAR
return S_OK; return S_OK;
} }
static HRESULT Math_atan(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Math_atan(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
double x; double x;
@ -133,12 +133,12 @@ static HRESULT Math_atan(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPAR
TRACE("\n"); TRACE("\n");
if(!arg_cnt(dp)) { if(!argc) {
if(retv) num_set_val(retv, NAN); if(retv) num_set_val(retv, NAN);
return S_OK; return S_OK;
} }
hres = to_number(ctx, get_arg(dp, 0), ei, &x); hres = to_number(ctx, argv, ei, &x);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -146,7 +146,7 @@ static HRESULT Math_atan(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPAR
return S_OK; return S_OK;
} }
static HRESULT Math_atan2(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Math_atan2(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
double x, y; double x, y;
@ -154,16 +154,16 @@ static HRESULT Math_atan2(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPA
TRACE("\n"); TRACE("\n");
if(arg_cnt(dp)<2) { if(argc<2) {
if(retv) num_set_val(retv, NAN); if(retv) num_set_val(retv, NAN);
return S_OK; return S_OK;
} }
hres = to_number(ctx, get_arg(dp, 0), ei, &y); hres = to_number(ctx, argv, ei, &y);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
hres = to_number(ctx, get_arg(dp, 1), ei, &x); hres = to_number(ctx, argv+1, ei, &x);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -172,7 +172,7 @@ static HRESULT Math_atan2(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPA
} }
/* ECMA-262 3rd Edition 15.8.2.6 */ /* ECMA-262 3rd Edition 15.8.2.6 */
static HRESULT Math_ceil(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Math_ceil(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
double x; double x;
@ -180,13 +180,13 @@ static HRESULT Math_ceil(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPAR
TRACE("\n"); TRACE("\n");
if(!arg_cnt(dp)) { if(!argc) {
if(retv) if(retv)
num_set_val(retv, NAN); num_set_val(retv, NAN);
return S_OK; return S_OK;
} }
hres = to_number(ctx, get_arg(dp, 0), ei, &x); hres = to_number(ctx, argv, ei, &x);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -195,7 +195,7 @@ static HRESULT Math_ceil(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPAR
return S_OK; return S_OK;
} }
static HRESULT Math_cos(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Math_cos(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
double x; double x;
@ -203,12 +203,12 @@ static HRESULT Math_cos(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARA
TRACE("\n"); TRACE("\n");
if(!arg_cnt(dp)) { if(!argc) {
if(retv) num_set_val(retv, NAN); if(retv) num_set_val(retv, NAN);
return S_OK; return S_OK;
} }
hres = to_number(ctx, get_arg(dp, 0), ei, &x); hres = to_number(ctx, argv, ei, &x);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -216,7 +216,7 @@ static HRESULT Math_cos(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARA
return S_OK; return S_OK;
} }
static HRESULT Math_exp(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Math_exp(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
double x; double x;
@ -224,12 +224,12 @@ static HRESULT Math_exp(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARA
TRACE("\n"); TRACE("\n");
if(!arg_cnt(dp)) { if(!argc) {
if(retv) num_set_val(retv, NAN); if(retv) num_set_val(retv, NAN);
return S_OK; return S_OK;
} }
hres = to_number(ctx, get_arg(dp, 0), ei, &x); hres = to_number(ctx, argv, ei, &x);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -237,7 +237,7 @@ static HRESULT Math_exp(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARA
return S_OK; return S_OK;
} }
static HRESULT Math_floor(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Math_floor(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
double x; double x;
@ -245,13 +245,13 @@ static HRESULT Math_floor(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPA
TRACE("\n"); TRACE("\n");
if(!arg_cnt(dp)) { if(!argc) {
if(retv) if(retv)
num_set_val(retv, NAN); num_set_val(retv, NAN);
return S_OK; return S_OK;
} }
hres = to_number(ctx, get_arg(dp, 0), ei, &x); hres = to_number(ctx, argv, ei, &x);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -260,7 +260,7 @@ static HRESULT Math_floor(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPA
return S_OK; return S_OK;
} }
static HRESULT Math_log(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Math_log(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
double x; double x;
@ -268,13 +268,13 @@ static HRESULT Math_log(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARA
TRACE("\n"); TRACE("\n");
if(!arg_cnt(dp)) { if(!argc) {
if(retv) if(retv)
num_set_val(retv, NAN); num_set_val(retv, NAN);
return S_OK; return S_OK;
} }
hres = to_number(ctx, get_arg(dp, 0), ei, &x); hres = to_number(ctx, argv, ei, &x);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -284,7 +284,7 @@ static HRESULT Math_log(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARA
} }
/* ECMA-262 3rd Edition 15.8.2.11 */ /* ECMA-262 3rd Edition 15.8.2.11 */
static HRESULT Math_max(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Math_max(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DOUBLE max, d; DOUBLE max, d;
@ -293,18 +293,18 @@ static HRESULT Math_max(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARA
TRACE("\n"); TRACE("\n");
if(!arg_cnt(dp)) { if(!argc) {
if(retv) if(retv)
num_set_val(retv, -INFINITY); num_set_val(retv, -INFINITY);
return S_OK; return S_OK;
} }
hres = to_number(ctx, get_arg(dp, 0), ei, &max); hres = to_number(ctx, argv, ei, &max);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
for(i=1; i < arg_cnt(dp); i++) { for(i=1; i < argc; i++) {
hres = to_number(ctx, get_arg(dp, i), ei, &d); hres = to_number(ctx, argv+i, ei, &d);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -318,7 +318,7 @@ static HRESULT Math_max(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARA
} }
/* ECMA-262 3rd Edition 15.8.2.12 */ /* ECMA-262 3rd Edition 15.8.2.12 */
static HRESULT Math_min(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Math_min(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DOUBLE min, d; DOUBLE min, d;
@ -327,18 +327,18 @@ static HRESULT Math_min(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARA
TRACE("\n"); TRACE("\n");
if(!arg_cnt(dp)) { if(!argc) {
if(retv) if(retv)
num_set_val(retv, INFINITY); num_set_val(retv, INFINITY);
return S_OK; return S_OK;
} }
hres = to_number(ctx, get_arg(dp, 0), ei, &min); hres = to_number(ctx, argv, ei, &min);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
for(i=1; i < arg_cnt(dp); i++) { for(i=1; i < argc; i++) {
hres = to_number(ctx, get_arg(dp, i), ei, &d); hres = to_number(ctx, argv+i, ei, &d);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -352,7 +352,7 @@ static HRESULT Math_min(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARA
} }
/* ECMA-262 3rd Edition 15.8.2.13 */ /* ECMA-262 3rd Edition 15.8.2.13 */
static HRESULT Math_pow(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Math_pow(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
double x, y; double x, y;
@ -360,16 +360,16 @@ static HRESULT Math_pow(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARA
TRACE("\n"); TRACE("\n");
if(arg_cnt(dp) < 2) { if(argc < 2) {
if(retv) num_set_val(retv, NAN); if(retv) num_set_val(retv, NAN);
return S_OK; return S_OK;
} }
hres = to_number(ctx, get_arg(dp, 0), ei, &x); hres = to_number(ctx, argv, ei, &x);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
hres = to_number(ctx, get_arg(dp, 1), ei, &y); hres = to_number(ctx, argv+1, ei, &y);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -379,7 +379,7 @@ static HRESULT Math_pow(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARA
} }
/* ECMA-262 3rd Edition 15.8.2.14 */ /* ECMA-262 3rd Edition 15.8.2.14 */
static HRESULT Math_random(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Math_random(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
UINT r; UINT r;
@ -396,7 +396,7 @@ static HRESULT Math_random(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPP
} }
/* ECMA-262 3rd Edition 15.8.2.15 */ /* ECMA-262 3rd Edition 15.8.2.15 */
static HRESULT Math_round(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Math_round(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
double x; double x;
@ -404,13 +404,13 @@ static HRESULT Math_round(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPA
TRACE("\n"); TRACE("\n");
if(!arg_cnt(dp)) { if(!argc) {
if(retv) if(retv)
num_set_val(retv, NAN); num_set_val(retv, NAN);
return S_OK; return S_OK;
} }
hres = to_number(ctx, get_arg(dp, 0), ei, &x); hres = to_number(ctx, argv, ei, &x);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -419,7 +419,7 @@ static HRESULT Math_round(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPA
return S_OK; return S_OK;
} }
static HRESULT Math_sin(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Math_sin(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
double x; double x;
@ -427,12 +427,12 @@ static HRESULT Math_sin(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARA
TRACE("\n"); TRACE("\n");
if(!arg_cnt(dp)) { if(!argc) {
if(retv) num_set_val(retv, NAN); if(retv) num_set_val(retv, NAN);
return S_OK; return S_OK;
} }
hres = to_number(ctx, get_arg(dp, 0), ei, &x); hres = to_number(ctx, argv, ei, &x);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -440,7 +440,7 @@ static HRESULT Math_sin(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARA
return S_OK; return S_OK;
} }
static HRESULT Math_sqrt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Math_sqrt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
double x; double x;
@ -448,12 +448,12 @@ static HRESULT Math_sqrt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPAR
TRACE("\n"); TRACE("\n");
if(!arg_cnt(dp)) { if(!argc) {
if(retv) num_set_val(retv, NAN); if(retv) num_set_val(retv, NAN);
return S_OK; return S_OK;
} }
hres = to_number(ctx, get_arg(dp, 0), ei, &x); hres = to_number(ctx, argv, ei, &x);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -461,7 +461,7 @@ static HRESULT Math_sqrt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPAR
return S_OK; return S_OK;
} }
static HRESULT Math_tan(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Math_tan(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
double x; double x;
@ -469,12 +469,12 @@ static HRESULT Math_tan(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARA
TRACE("\n"); TRACE("\n");
if(!arg_cnt(dp)) { if(!argc) {
if(retv) num_set_val(retv, NAN); if(retv) num_set_val(retv, NAN);
return S_OK; return S_OK;
} }
hres = to_number(ctx, get_arg(dp, 0), ei, &x); hres = to_number(ctx, argv, ei, &x);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;

View File

@ -218,7 +218,7 @@ static inline void number_to_exponential(double val, int prec, BSTR *out)
} }
/* ECMA-262 3rd Edition 15.7.4.2 */ /* ECMA-262 3rd Edition 15.7.4.2 */
static HRESULT Number_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Number_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
NumberInstance *number; NumberInstance *number;
@ -232,8 +232,8 @@ static HRESULT Number_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, D
if(!(number = number_this(jsthis))) if(!(number = number_this(jsthis)))
return throw_type_error(ctx, ei, JS_E_NUMBER_EXPECTED, NULL); return throw_type_error(ctx, ei, JS_E_NUMBER_EXPECTED, NULL);
if(arg_cnt(dp)) { if(argc) {
hres = to_int32(ctx, get_arg(dp, 0), ei, &radix); hres = to_int32(ctx, argv, ei, &radix);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -343,14 +343,14 @@ static HRESULT Number_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, D
return S_OK; return S_OK;
} }
static HRESULT Number_toLocaleString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Number_toLocaleString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
FIXME("\n"); FIXME("\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT Number_toFixed(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Number_toFixed(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
NumberInstance *number; NumberInstance *number;
@ -364,8 +364,8 @@ static HRESULT Number_toFixed(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI
if(!(number = number_this(jsthis))) if(!(number = number_this(jsthis)))
return throw_type_error(ctx, ei, JS_E_NUMBER_EXPECTED, NULL); return throw_type_error(ctx, ei, JS_E_NUMBER_EXPECTED, NULL);
if(arg_cnt(dp)) { if(argc) {
hres = to_int32(ctx, get_arg(dp, 0), ei, &prec); hres = to_int32(ctx, argv, ei, &prec);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -394,7 +394,7 @@ static HRESULT Number_toFixed(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI
return S_OK; return S_OK;
} }
static HRESULT Number_toExponential(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Number_toExponential(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
NumberInstance *number; NumberInstance *number;
@ -408,8 +408,8 @@ static HRESULT Number_toExponential(script_ctx_t *ctx, vdisp_t *jsthis, WORD fla
if(!(number = number_this(jsthis))) if(!(number = number_this(jsthis)))
return throw_type_error(ctx, ei, JS_E_NUMBER_EXPECTED, NULL); return throw_type_error(ctx, ei, JS_E_NUMBER_EXPECTED, NULL);
if(arg_cnt(dp)) { if(argc) {
hres = to_int32(ctx, get_arg(dp, 0), ei, &prec); hres = to_int32(ctx, argv, ei, &prec);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -440,7 +440,7 @@ static HRESULT Number_toExponential(script_ctx_t *ctx, vdisp_t *jsthis, WORD fla
return S_OK; return S_OK;
} }
static HRESULT Number_toPrecision(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Number_toPrecision(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
NumberInstance *number; NumberInstance *number;
@ -452,8 +452,8 @@ static HRESULT Number_toPrecision(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
if(!(number = number_this(jsthis))) if(!(number = number_this(jsthis)))
return throw_type_error(ctx, ei, JS_E_NUMBER_EXPECTED, NULL); return throw_type_error(ctx, ei, JS_E_NUMBER_EXPECTED, NULL);
if(arg_cnt(dp)) { if(argc) {
hres = to_int32(ctx, get_arg(dp, 0), ei, &prec); hres = to_int32(ctx, argv, ei, &prec);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -490,7 +490,7 @@ static HRESULT Number_toPrecision(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
return S_OK; return S_OK;
} }
static HRESULT Number_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Number_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
NumberInstance *number; NumberInstance *number;
@ -505,7 +505,7 @@ static HRESULT Number_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI
return S_OK; return S_OK;
} }
static HRESULT Number_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Number_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
NumberInstance *number = number_from_vdisp(jsthis); NumberInstance *number = number_from_vdisp(jsthis);
@ -543,7 +543,7 @@ static const builtin_info_t Number_info = {
NULL NULL
}; };
static HRESULT NumberConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT NumberConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
double n; double n;
@ -553,13 +553,13 @@ static HRESULT NumberConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
switch(flags) { switch(flags) {
case INVOKE_FUNC: case INVOKE_FUNC:
if(!arg_cnt(dp)) { if(!argc) {
if(retv) if(retv)
num_set_int(retv, 0); num_set_int(retv, 0);
return S_OK; return S_OK;
} }
hres = to_number(ctx, get_arg(dp, 0), ei, &n); hres = to_number(ctx, argv, ei, &n);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -570,8 +570,8 @@ static HRESULT NumberConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
case DISPATCH_CONSTRUCT: { case DISPATCH_CONSTRUCT: {
jsdisp_t *obj; jsdisp_t *obj;
if(arg_cnt(dp)) { if(argc) {
hres = to_number(ctx, get_arg(dp, 0), ei, &n); hres = to_number(ctx, argv, ei, &n);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
}else { }else {

View File

@ -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 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, DISPPARAMS *dp, static HRESULT Object_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
jsdisp_t *jsdisp; jsdisp_t *jsdisp;
@ -78,11 +78,9 @@ static HRESULT Object_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, D
return S_OK; return S_OK;
} }
static HRESULT Object_toLocaleString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Object_toLocaleString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DISPPARAMS params = {NULL, NULL, 0, 0};
TRACE("\n"); TRACE("\n");
if(!is_jsdisp(jsthis)) { if(!is_jsdisp(jsthis)) {
@ -90,10 +88,10 @@ static HRESULT Object_toLocaleString(script_ctx_t *ctx, vdisp_t *jsthis, WORD fl
return E_FAIL; return E_FAIL;
} }
return jsdisp_call_name(jsthis->u.jsdisp, toStringW, DISPATCH_METHOD, &params, retv, ei); return jsdisp_call_name(jsthis->u.jsdisp, toStringW, DISPATCH_METHOD, 0, NULL, retv, ei);
} }
static HRESULT Object_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Object_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
@ -108,7 +106,7 @@ static HRESULT Object_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI
return S_OK; return S_OK;
} }
static HRESULT Object_hasOwnProperty(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Object_hasOwnProperty(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
BSTR name; BSTR name;
@ -118,7 +116,7 @@ static HRESULT Object_hasOwnProperty(script_ctx_t *ctx, vdisp_t *jsthis, WORD fl
TRACE("\n"); TRACE("\n");
if(!arg_cnt(dp)) { if(!argc) {
if(retv) { if(retv) {
V_VT(retv) = VT_BOOL; V_VT(retv) = VT_BOOL;
V_BOOL(retv) = VARIANT_FALSE; V_BOOL(retv) = VARIANT_FALSE;
@ -127,7 +125,7 @@ static HRESULT Object_hasOwnProperty(script_ctx_t *ctx, vdisp_t *jsthis, WORD fl
return S_OK; return S_OK;
} }
hres = to_string(ctx, get_arg(dp, 0), ei, &name); hres = to_string(ctx, argv, ei, &name);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -154,21 +152,21 @@ static HRESULT Object_hasOwnProperty(script_ctx_t *ctx, vdisp_t *jsthis, WORD fl
return S_OK; return S_OK;
} }
static HRESULT Object_propertyIsEnumerable(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Object_propertyIsEnumerable(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
FIXME("\n"); FIXME("\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT Object_isPrototypeOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Object_isPrototypeOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
FIXME("\n"); FIXME("\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT Object_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT Object_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
@ -213,7 +211,7 @@ static const builtin_info_t Object_info = {
NULL NULL
}; };
static HRESULT ObjectConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT ObjectConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
HRESULT hres; HRESULT hres;
@ -222,13 +220,11 @@ static HRESULT ObjectConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
switch(flags) { switch(flags) {
case DISPATCH_METHOD: case DISPATCH_METHOD:
if(arg_cnt(dp)) { if(argc) {
VARIANT *arg = get_arg(dp,0); if(V_VT(argv) != VT_EMPTY && V_VT(argv) != VT_NULL && (V_VT(argv) != VT_DISPATCH || V_DISPATCH(argv))) {
if(V_VT(arg) != VT_EMPTY && V_VT(arg) != VT_NULL && (V_VT(arg) != VT_DISPATCH || V_DISPATCH(arg))) {
IDispatch *disp; IDispatch *disp;
hres = to_object(ctx, arg, &disp); hres = to_object(ctx, argv, &disp);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;

View File

@ -3473,7 +3473,7 @@ HRESULT regexp_match(script_ctx_t *ctx, jsdisp_t *dispex, const WCHAR *str, DWOR
return S_OK; return S_OK;
} }
static HRESULT RegExp_source(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT RegExp_source(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
@ -3496,21 +3496,21 @@ static HRESULT RegExp_source(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DIS
return S_OK; return S_OK;
} }
static HRESULT RegExp_global(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT RegExp_global(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
FIXME("\n"); FIXME("\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT RegExp_ignoreCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT RegExp_ignoreCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
FIXME("\n"); FIXME("\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT RegExp_multiline(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT RegExp_multiline(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
FIXME("\n"); FIXME("\n");
@ -3534,7 +3534,7 @@ static INT index_from_var(script_ctx_t *ctx, VARIANT *v)
return is_int32(n) ? n : 0; return is_int32(n) ? n : 0;
} }
static HRESULT RegExp_lastIndex(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT RegExp_lastIndex(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
@ -3548,15 +3548,13 @@ static HRESULT RegExp_lastIndex(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
} }
case DISPATCH_PROPERTYPUT: { case DISPATCH_PROPERTYPUT: {
RegExpInstance *regexp = regexp_from_vdisp(jsthis); RegExpInstance *regexp = regexp_from_vdisp(jsthis);
VARIANT *arg;
HRESULT hres; HRESULT hres;
arg = get_arg(dp,0); hres = VariantCopy(&regexp->last_index_var, argv);
hres = VariantCopy(&regexp->last_index_var, arg);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
regexp->last_index = index_from_var(ctx, arg); regexp->last_index = index_from_var(ctx, argv);
break; break;
} }
default: default:
@ -3567,7 +3565,7 @@ static HRESULT RegExp_lastIndex(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
return S_OK; return S_OK;
} }
static HRESULT RegExp_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT RegExp_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
FIXME("\n"); FIXME("\n");
@ -3698,7 +3696,7 @@ static HRESULT run_exec(script_ctx_t *ctx, vdisp_t *jsthis, VARIANT *arg, jsexce
return S_OK; return S_OK;
} }
static HRESULT RegExp_exec(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT RegExp_exec(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
match_result_t *parens = NULL, match; match_result_t *parens = NULL, match;
@ -3709,7 +3707,7 @@ static HRESULT RegExp_exec(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPP
TRACE("\n"); TRACE("\n");
hres = run_exec(ctx, jsthis, arg_cnt(dp) ? get_arg(dp,0) : NULL, ei, &string, &match, &parens, &parens_cnt, &b); hres = run_exec(ctx, jsthis, argc ? argv : NULL, ei, &string, &match, &parens, &parens_cnt, &b);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -3732,18 +3730,16 @@ static HRESULT RegExp_exec(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPP
return hres; return hres;
} }
static HRESULT RegExp_test(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT RegExp_test(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
match_result_t match; match_result_t match;
VARIANT undef_var; VARIANT undef_var;
VARIANT_BOOL b; VARIANT_BOOL b;
DWORD argc;
HRESULT hres; HRESULT hres;
TRACE("\n"); TRACE("\n");
argc = arg_cnt(dp);
if(!argc) { if(!argc) {
V_VT(&undef_var) = VT_BSTR; V_VT(&undef_var) = VT_BSTR;
V_BSTR(&undef_var) = SysAllocString(undefinedW); V_BSTR(&undef_var) = SysAllocString(undefinedW);
@ -3751,7 +3747,7 @@ static HRESULT RegExp_test(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPP
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
hres = run_exec(ctx, jsthis, argc ? get_arg(dp,0) : &undef_var, ei, NULL, &match, NULL, NULL, &b); hres = run_exec(ctx, jsthis, argc ? argv : &undef_var, ei, NULL, &match, NULL, NULL, &b);
if(!argc) if(!argc)
SysFreeString(V_BSTR(&undef_var)); SysFreeString(V_BSTR(&undef_var));
if(FAILED(hres)) if(FAILED(hres))
@ -3764,7 +3760,7 @@ static HRESULT RegExp_test(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPP
return S_OK; return S_OK;
} }
static HRESULT RegExp_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT RegExp_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
@ -4014,7 +4010,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, static HRESULT RegExpConstr_leftContext(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei) unsigned argc, VARIANT *argv, VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
@ -4041,7 +4037,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, static HRESULT RegExpConstr_rightContext(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei) unsigned argc, VARIANT *argv, VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
@ -4067,20 +4063,19 @@ static HRESULT RegExpConstr_rightContext(script_ctx_t *ctx, vdisp_t *jsthis, WOR
return S_OK; return S_OK;
} }
static HRESULT RegExpConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT RegExpConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
switch(flags) { switch(flags) {
case DISPATCH_METHOD: case DISPATCH_METHOD:
if(arg_cnt(dp)) { if(argc) {
VARIANT *arg = get_arg(dp,0); if(V_VT(argv) == VT_DISPATCH) {
if(V_VT(arg) == VT_DISPATCH) { jsdisp_t *jsdisp = iface_to_jsdisp((IUnknown*)V_DISPATCH(argv));
jsdisp_t *jsdisp = iface_to_jsdisp((IUnknown*)V_DISPATCH(arg));
if(jsdisp) { if(jsdisp) {
if(is_class(jsdisp, JSCLASS_REGEXP)) { if(is_class(jsdisp, JSCLASS_REGEXP)) {
if(arg_cnt(dp) > 1 && V_VT(get_arg(dp,1)) != VT_EMPTY) { if(argc > 1 && V_VT(argv+1) != VT_EMPTY) {
jsdisp_release(jsdisp); jsdisp_release(jsdisp);
return throw_regexp_error(ctx, ei, JS_E_REGEXP_SYNTAX, NULL); return throw_regexp_error(ctx, ei, JS_E_REGEXP_SYNTAX, NULL);
} }
@ -4100,12 +4095,12 @@ static HRESULT RegExpConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
jsdisp_t *ret; jsdisp_t *ret;
HRESULT hres; HRESULT hres;
if(!arg_cnt(dp)) { if(!argc) {
FIXME("no args\n"); FIXME("no args\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
hres = create_regexp_var(ctx, get_arg(dp,0), arg_cnt(dp) > 1 ? get_arg(dp,1) : NULL, &ret); hres = create_regexp_var(ctx, argv, argc > 1 ? argv+1 : NULL, &ret);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;

View File

@ -102,7 +102,7 @@ static HRESULT get_string_val(script_ctx_t *ctx, vdisp_t *jsthis, jsexcept_t *ei
return S_OK; return S_OK;
} }
static HRESULT String_length(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT String_length(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("%p\n", jsthis); TRACE("%p\n", jsthis);
@ -143,7 +143,7 @@ static HRESULT stringobj_to_string(vdisp_t *jsthis, VARIANT *retv)
} }
/* ECMA-262 3rd Edition 15.5.4.2 */ /* ECMA-262 3rd Edition 15.5.4.2 */
static HRESULT String_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT String_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
@ -152,7 +152,7 @@ static HRESULT String_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, D
} }
/* ECMA-262 3rd Edition 15.5.4.2 */ /* ECMA-262 3rd Edition 15.5.4.2 */
static HRESULT String_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT String_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
TRACE("\n"); TRACE("\n");
@ -191,7 +191,7 @@ static HRESULT do_attributeless_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, V
return S_OK; return S_OK;
} }
static HRESULT do_attribute_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, DISPPARAMS *dp, VARIANT *retv, static HRESULT do_attribute_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, unsigned argc, VARIANT *argv, VARIANT *retv,
jsexcept_t *ei, const WCHAR *tagname, const WCHAR *attr) jsexcept_t *ei, const WCHAR *tagname, const WCHAR *attr)
{ {
static const WCHAR tagfmtW[] static const WCHAR tagfmtW[]
@ -222,8 +222,8 @@ static HRESULT do_attribute_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, DISPP
length = string->length; length = string->length;
} }
if(arg_cnt(dp)) { if(argc) {
hres = to_string(ctx, get_arg(dp, 0), ei, &attr_value); hres = to_string(ctx, argv, ei, &attr_value);
if(FAILED(hres)) { if(FAILED(hres)) {
SysFreeString(val_str); SysFreeString(val_str);
return hres; return hres;
@ -257,30 +257,30 @@ static HRESULT do_attribute_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, DISPP
return S_OK; return S_OK;
} }
static HRESULT String_anchor(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT String_anchor(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
static const WCHAR fontW[] = {'A',0}; static const WCHAR fontW[] = {'A',0};
static const WCHAR colorW[] = {'N','A','M','E',0}; static const WCHAR colorW[] = {'N','A','M','E',0};
return do_attribute_tag_format(ctx, jsthis, dp, retv, ei, fontW, colorW); return do_attribute_tag_format(ctx, jsthis, argc, argv, retv, ei, fontW, colorW);
} }
static HRESULT String_big(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT String_big(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
static const WCHAR bigtagW[] = {'B','I','G',0}; static const WCHAR bigtagW[] = {'B','I','G',0};
return do_attributeless_tag_format(ctx, jsthis, retv, ei, bigtagW); return do_attributeless_tag_format(ctx, jsthis, retv, ei, bigtagW);
} }
static HRESULT String_blink(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT String_blink(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
static const WCHAR blinktagW[] = {'B','L','I','N','K',0}; static const WCHAR blinktagW[] = {'B','L','I','N','K',0};
return do_attributeless_tag_format(ctx, jsthis, retv, ei, blinktagW); return do_attributeless_tag_format(ctx, jsthis, retv, ei, blinktagW);
} }
static HRESULT String_bold(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT String_bold(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
static const WCHAR boldtagW[] = {'B',0}; static const WCHAR boldtagW[] = {'B',0};
@ -288,7 +288,7 @@ static HRESULT String_bold(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPP
} }
/* ECMA-262 3rd Edition 15.5.4.5 */ /* ECMA-262 3rd Edition 15.5.4.5 */
static HRESULT String_charAt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT String_charAt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
const WCHAR *str; const WCHAR *str;
@ -303,10 +303,10 @@ static HRESULT String_charAt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DIS
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(arg_cnt(dp)) { if(argc) {
double d; double d;
hres = to_integer(ctx, get_arg(dp, 0), ei, &d); hres = to_integer(ctx, argv, ei, &d);
if(FAILED(hres)) { if(FAILED(hres)) {
SysFreeString(val_str); SysFreeString(val_str);
return hres; return hres;
@ -334,7 +334,7 @@ static HRESULT String_charAt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DIS
} }
/* ECMA-262 3rd Edition 15.5.4.5 */ /* ECMA-262 3rd Edition 15.5.4.5 */
static HRESULT String_charCodeAt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT String_charCodeAt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
const WCHAR *str; const WCHAR *str;
@ -348,10 +348,10 @@ static HRESULT String_charCodeAt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(arg_cnt(dp) > 0) { if(argc > 0) {
double d; double d;
hres = to_integer(ctx, get_arg(dp, 0), ei, &d); hres = to_integer(ctx, argv, ei, &d);
if(FAILED(hres)) { if(FAILED(hres)) {
SysFreeString(val_str); SysFreeString(val_str);
return hres; return hres;
@ -375,7 +375,7 @@ static HRESULT String_charCodeAt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
} }
/* ECMA-262 3rd Edition 15.5.4.6 */ /* ECMA-262 3rd Edition 15.5.4.6 */
static HRESULT String_concat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT String_concat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
BSTR *strs = NULL, ret = NULL; BSTR *strs = NULL, ret = NULL;
@ -386,7 +386,7 @@ static HRESULT String_concat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DIS
TRACE("\n"); TRACE("\n");
str_cnt = arg_cnt(dp)+1; str_cnt = argc+1;
strs = heap_alloc_zero(str_cnt * sizeof(BSTR)); strs = heap_alloc_zero(str_cnt * sizeof(BSTR));
if(!strs) if(!strs)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
@ -396,8 +396,8 @@ static HRESULT String_concat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DIS
hres = to_string(ctx, &var, ei, strs); hres = to_string(ctx, &var, ei, strs);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
for(i=0; i < arg_cnt(dp); i++) { for(i=0; i < argc; i++) {
hres = to_string(ctx, get_arg(dp, i), ei, strs+i+1); hres = to_string(ctx, argv+i, ei, strs+i+1);
if(FAILED(hres)) if(FAILED(hres))
break; break;
} }
@ -432,32 +432,32 @@ static HRESULT String_concat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DIS
return S_OK; return S_OK;
} }
static HRESULT String_fixed(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT String_fixed(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
static const WCHAR fixedtagW[] = {'T','T',0}; static const WCHAR fixedtagW[] = {'T','T',0};
return do_attributeless_tag_format(ctx, jsthis, retv, ei, fixedtagW); return do_attributeless_tag_format(ctx, jsthis, retv, ei, fixedtagW);
} }
static HRESULT String_fontcolor(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT String_fontcolor(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
static const WCHAR fontW[] = {'F','O','N','T',0}; static const WCHAR fontW[] = {'F','O','N','T',0};
static const WCHAR colorW[] = {'C','O','L','O','R',0}; static const WCHAR colorW[] = {'C','O','L','O','R',0};
return do_attribute_tag_format(ctx, jsthis, dp, retv, ei, fontW, colorW); return do_attribute_tag_format(ctx, jsthis, argc, argv, retv, ei, fontW, colorW);
} }
static HRESULT String_fontsize(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT String_fontsize(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
static const WCHAR fontW[] = {'F','O','N','T',0}; static const WCHAR fontW[] = {'F','O','N','T',0};
static const WCHAR colorW[] = {'S','I','Z','E',0}; static const WCHAR colorW[] = {'S','I','Z','E',0};
return do_attribute_tag_format(ctx, jsthis, dp, retv, ei, fontW, colorW); return do_attribute_tag_format(ctx, jsthis, argc, argv, retv, ei, fontW, colorW);
} }
static HRESULT String_indexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT String_indexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
DWORD length, pos = 0; DWORD length, pos = 0;
@ -472,23 +472,23 @@ static HRESULT String_indexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(!arg_cnt(dp)) { if(!argc) {
if(retv) if(retv)
num_set_int(retv, -1); num_set_int(retv, -1);
SysFreeString(val_str); SysFreeString(val_str);
return S_OK; return S_OK;
} }
hres = to_string(ctx, get_arg(dp,0), ei, &search_str); hres = to_string(ctx, argv, ei, &search_str);
if(FAILED(hres)) { if(FAILED(hres)) {
SysFreeString(val_str); SysFreeString(val_str);
return hres; return hres;
} }
if(arg_cnt(dp) >= 2) { if(argc >= 2) {
double d; double d;
hres = to_integer(ctx, get_arg(dp,1), ei, &d); hres = to_integer(ctx, argv+1, ei, &d);
if(SUCCEEDED(hres) && d > 0.0) if(SUCCEEDED(hres) && d > 0.0)
pos = is_int32(d) ? min(length, d) : length; pos = is_int32(d) ? min(length, d) : length;
} }
@ -513,7 +513,7 @@ static HRESULT String_indexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI
return S_OK; return S_OK;
} }
static HRESULT String_italics(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT String_italics(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
static const WCHAR italicstagW[] = {'I',0}; static const WCHAR italicstagW[] = {'I',0};
@ -521,7 +521,7 @@ static HRESULT String_italics(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI
} }
/* ECMA-262 3rd Edition 15.5.4.8 */ /* ECMA-262 3rd Edition 15.5.4.8 */
static HRESULT String_lastIndexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT String_lastIndexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
BSTR search_str, val_str; BSTR search_str, val_str;
@ -536,14 +536,14 @@ static HRESULT String_lastIndexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(!arg_cnt(dp)) { if(!argc) {
if(retv) if(retv)
num_set_int(retv, -1); num_set_int(retv, -1);
SysFreeString(val_str); SysFreeString(val_str);
return S_OK; return S_OK;
} }
hres = to_string(ctx, get_arg(dp,0), ei, &search_str); hres = to_string(ctx, argv, ei, &search_str);
if(FAILED(hres)) { if(FAILED(hres)) {
SysFreeString(val_str); SysFreeString(val_str);
return hres; return hres;
@ -551,10 +551,10 @@ static HRESULT String_lastIndexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
search_len = SysStringLen(search_str); search_len = SysStringLen(search_str);
if(arg_cnt(dp) >= 2) { if(argc >= 2) {
double d; double d;
hres = to_integer(ctx, get_arg(dp,1), ei, &d); hres = to_integer(ctx, argv+1, ei, &d);
if(SUCCEEDED(hres) && d > 0) if(SUCCEEDED(hres) && d > 0)
pos = is_int32(d) ? min(length, d) : length; pos = is_int32(d) ? min(length, d) : length;
}else { }else {
@ -582,29 +582,28 @@ static HRESULT String_lastIndexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
return S_OK; return S_OK;
} }
static HRESULT String_link(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT String_link(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
static const WCHAR fontW[] = {'A',0}; static const WCHAR fontW[] = {'A',0};
static const WCHAR colorW[] = {'H','R','E','F',0}; static const WCHAR colorW[] = {'H','R','E','F',0};
return do_attribute_tag_format(ctx, jsthis, dp, retv, ei, fontW, colorW); return do_attribute_tag_format(ctx, jsthis, argc, argv, retv, ei, fontW, colorW);
} }
/* ECMA-262 3rd Edition 15.5.4.10 */ /* ECMA-262 3rd Edition 15.5.4.10 */
static HRESULT String_match(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT String_match(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
const WCHAR *str; const WCHAR *str;
jsdisp_t *regexp; jsdisp_t *regexp;
VARIANT *arg_var;
DWORD length; DWORD length;
BSTR val_str = NULL; BSTR val_str = NULL;
HRESULT hres = S_OK; HRESULT hres = S_OK;
TRACE("\n"); TRACE("\n");
if(!arg_cnt(dp)) { if(!argc) {
if(retv) { if(retv) {
V_VT(retv) = VT_NULL; V_VT(retv) = VT_NULL;
} }
@ -612,10 +611,9 @@ static HRESULT String_match(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP
return S_OK; return S_OK;
} }
arg_var = get_arg(dp, 0); switch(V_VT(argv)) {
switch(V_VT(arg_var)) {
case VT_DISPATCH: case VT_DISPATCH:
regexp = iface_to_jsdisp((IUnknown*)V_DISPATCH(arg_var)); regexp = iface_to_jsdisp((IUnknown*)V_DISPATCH(argv));
if(regexp) { if(regexp) {
if(is_class(regexp, JSCLASS_REGEXP)) if(is_class(regexp, JSCLASS_REGEXP))
break; break;
@ -624,7 +622,7 @@ static HRESULT String_match(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP
default: { default: {
BSTR match_str; BSTR match_str;
hres = to_string(ctx, arg_var, ei, &match_str); hres = to_string(ctx, argv, ei, &match_str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -687,29 +685,27 @@ 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, 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) match_result_t *parens, DWORD parens_cnt, BSTR *ret, jsexcept_t *ei)
{ {
DISPPARAMS dp = {NULL, NULL, 0, 0}; VARIANT *argv;
VARIANTARG *args, *arg; unsigned argc;
VARIANT var; VARIANT var;
DWORD i; DWORD i;
HRESULT hres = S_OK; HRESULT hres = S_OK;
dp.cArgs = parens_cnt+3; argc = parens_cnt+3;
dp.rgvarg = args = heap_alloc_zero(sizeof(VARIANT)*dp.cArgs); argv = heap_alloc_zero(sizeof(VARIANT)*argc);
if(!args) if(!argv)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
arg = get_arg(&dp,0); V_VT(argv) = VT_BSTR;
V_VT(arg) = VT_BSTR; V_BSTR(argv) = SysAllocStringLen(match->str, match->len);
V_BSTR(arg) = SysAllocStringLen(match->str, match->len); if(!V_BSTR(argv))
if(!V_BSTR(arg))
hres = E_OUTOFMEMORY; hres = E_OUTOFMEMORY;
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
for(i=0; i < parens_cnt; i++) { for(i=0; i < parens_cnt; i++) {
arg = get_arg(&dp,i+1); V_VT(argv+i+1) = VT_BSTR;
V_VT(arg) = VT_BSTR; V_BSTR(argv+i+1) = SysAllocStringLen(parens[i].str, parens[i].len);
V_BSTR(arg) = SysAllocStringLen(parens[i].str, parens[i].len); if(!V_BSTR(argv+i+1)) {
if(!V_BSTR(arg)) {
hres = E_OUTOFMEMORY; hres = E_OUTOFMEMORY;
break; break;
} }
@ -717,24 +713,22 @@ static HRESULT rep_call(script_ctx_t *ctx, jsdisp_t *func, const WCHAR *str, mat
} }
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
arg = get_arg(&dp,parens_cnt+1); num_set_int(argv+parens_cnt+1, match->str - str);
num_set_int(arg, match->str - str);
arg = get_arg(&dp,parens_cnt+2); V_VT(argv+parens_cnt+2) = VT_BSTR;
V_VT(arg) = VT_BSTR; V_BSTR(argv+parens_cnt+2) = SysAllocString(str);
V_BSTR(arg) = SysAllocString(str); if(!V_BSTR(argv+parens_cnt+2))
if(!V_BSTR(arg))
hres = E_OUTOFMEMORY; hres = E_OUTOFMEMORY;
} }
if(SUCCEEDED(hres)) if(SUCCEEDED(hres))
hres = jsdisp_call_value(func, NULL, DISPATCH_METHOD, &dp, &var, ei); hres = jsdisp_call_value(func, NULL, DISPATCH_METHOD, argc, argv, &var, ei);
for(i=0; i < parens_cnt+3; i++) { for(i=0; i < parens_cnt+3; i++) {
if(i != parens_cnt+1) if(i != parens_cnt+1)
SysFreeString(V_BSTR(get_arg(&dp,i))); SysFreeString(V_BSTR(argv+i));
} }
heap_free(args); heap_free(argv);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -745,7 +739,7 @@ static HRESULT rep_call(script_ctx_t *ctx, jsdisp_t *func, const WCHAR *str, mat
} }
/* ECMA-262 3rd Edition 15.5.4.11 */ /* ECMA-262 3rd Edition 15.5.4.11 */
static HRESULT String_replace(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT String_replace(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
const WCHAR *str; const WCHAR *str;
@ -755,7 +749,6 @@ static HRESULT String_replace(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI
match_result_t *parens = NULL, match = {NULL,0}, **parens_ptr = &parens; match_result_t *parens = NULL, match = {NULL,0}, **parens_ptr = &parens;
strbuf_t ret = {NULL,0,0}; strbuf_t ret = {NULL,0,0};
DWORD re_flags = REM_NO_CTX_UPDATE; DWORD re_flags = REM_NO_CTX_UPDATE;
VARIANT *arg_var;
HRESULT hres = S_OK; HRESULT hres = S_OK;
TRACE("\n"); TRACE("\n");
@ -764,7 +757,7 @@ static HRESULT String_replace(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(!arg_cnt(dp)) { if(!argc) {
if(retv) { if(retv) {
if(!val_str) { if(!val_str) {
val_str = SysAllocStringLen(str, length); val_str = SysAllocStringLen(str, length);
@ -778,10 +771,9 @@ static HRESULT String_replace(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI
return S_OK; return S_OK;
} }
arg_var = get_arg(dp, 0); switch(V_VT(argv)) {
switch(V_VT(arg_var)) {
case VT_DISPATCH: case VT_DISPATCH:
regexp = iface_to_jsdisp((IUnknown*)V_DISPATCH(arg_var)); regexp = iface_to_jsdisp((IUnknown*)V_DISPATCH(argv));
if(regexp) { if(regexp) {
if(is_class(regexp, JSCLASS_REGEXP)) { if(is_class(regexp, JSCLASS_REGEXP)) {
break; break;
@ -792,18 +784,17 @@ static HRESULT String_replace(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI
} }
default: default:
hres = to_string(ctx, arg_var, ei, &match_str); hres = to_string(ctx, argv, ei, &match_str);
if(FAILED(hres)) { if(FAILED(hres)) {
SysFreeString(val_str); SysFreeString(val_str);
return hres; return hres;
} }
} }
if(arg_cnt(dp) >= 2) { if(argc >= 2) {
arg_var = get_arg(dp,1); switch(V_VT(argv+1)) {
switch(V_VT(arg_var)) {
case VT_DISPATCH: case VT_DISPATCH:
rep_func = iface_to_jsdisp((IUnknown*)V_DISPATCH(arg_var)); rep_func = iface_to_jsdisp((IUnknown*)V_DISPATCH(argv+1));
if(rep_func) { if(rep_func) {
if(is_class(rep_func, JSCLASS_FUNCTION)) { if(is_class(rep_func, JSCLASS_FUNCTION)) {
break; break;
@ -814,7 +805,7 @@ static HRESULT String_replace(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI
} }
default: default:
hres = to_string(ctx, arg_var, ei, &rep_str); hres = to_string(ctx, argv+1, ei, &rep_str);
if(FAILED(hres)) if(FAILED(hres))
break; break;
@ -984,13 +975,12 @@ static HRESULT String_replace(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI
return hres; return hres;
} }
static HRESULT String_search(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT String_search(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
jsdisp_t *regexp = NULL; jsdisp_t *regexp = NULL;
const WCHAR *str, *cp; const WCHAR *str, *cp;
match_result_t match; match_result_t match;
VARIANT *arg;
DWORD length; DWORD length;
BSTR val_str; BSTR val_str;
HRESULT hres; HRESULT hres;
@ -1001,16 +991,15 @@ static HRESULT String_search(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DIS
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(!arg_cnt(dp)) { if(!argc) {
if(retv) if(retv)
V_VT(retv) = VT_NULL; V_VT(retv) = VT_NULL;
SysFreeString(val_str); SysFreeString(val_str);
return S_OK; return S_OK;
} }
arg = get_arg(dp,0); if(V_VT(argv) == VT_DISPATCH) {
if(V_VT(arg) == VT_DISPATCH) { regexp = iface_to_jsdisp((IUnknown*)V_DISPATCH(argv));
regexp = iface_to_jsdisp((IUnknown*)V_DISPATCH(arg));
if(regexp) { if(regexp) {
if(!is_class(regexp, JSCLASS_REGEXP)) { if(!is_class(regexp, JSCLASS_REGEXP)) {
jsdisp_release(regexp); jsdisp_release(regexp);
@ -1020,7 +1009,7 @@ static HRESULT String_search(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DIS
} }
if(!regexp) { if(!regexp) {
hres = create_regexp_var(ctx, arg, NULL, &regexp); hres = create_regexp_var(ctx, argv, NULL, &regexp);
if(FAILED(hres)) { if(FAILED(hres)) {
SysFreeString(val_str); SysFreeString(val_str);
return hres; return hres;
@ -1040,7 +1029,7 @@ static HRESULT String_search(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DIS
} }
/* ECMA-262 3rd Edition 15.5.4.13 */ /* ECMA-262 3rd Edition 15.5.4.13 */
static HRESULT String_slice(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT String_slice(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
const WCHAR *str; const WCHAR *str;
@ -1056,8 +1045,8 @@ static HRESULT String_slice(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(arg_cnt(dp)) { if(argc) {
hres = to_integer(ctx, get_arg(dp,0), ei, &d); hres = to_integer(ctx, argv, ei, &d);
if(FAILED(hres)) { if(FAILED(hres)) {
SysFreeString(val_str); SysFreeString(val_str);
return hres; return hres;
@ -1077,8 +1066,8 @@ static HRESULT String_slice(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP
} }
} }
if(arg_cnt(dp) >= 2) { if(argc >= 2) {
hres = to_integer(ctx, get_arg(dp,1), ei, &d); hres = to_integer(ctx, argv+1, ei, &d);
if(FAILED(hres)) { if(FAILED(hres)) {
SysFreeString(val_str); SysFreeString(val_str);
return hres; return hres;
@ -1118,28 +1107,28 @@ static HRESULT String_slice(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP
return S_OK; return S_OK;
} }
static HRESULT String_small(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT String_small(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
static const WCHAR smalltagW[] = {'S','M','A','L','L',0}; static const WCHAR smalltagW[] = {'S','M','A','L','L',0};
return do_attributeless_tag_format(ctx, jsthis, retv, ei, smalltagW); return do_attributeless_tag_format(ctx, jsthis, retv, ei, smalltagW);
} }
static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
match_result_t *match_result = NULL; match_result_t *match_result = NULL;
DWORD length, match_cnt, i, match_len = 0; DWORD length, match_cnt, i, match_len = 0;
const WCHAR *str, *ptr, *ptr2; const WCHAR *str, *ptr, *ptr2;
BOOL use_regexp = FALSE; BOOL use_regexp = FALSE;
VARIANT *arg, var; VARIANT var;
jsdisp_t *array; jsdisp_t *array;
BSTR val_str, match_str = NULL; BSTR val_str, match_str = NULL;
HRESULT hres; HRESULT hres;
TRACE("\n"); TRACE("\n");
if(arg_cnt(dp) != 1) { if(argc != 1) {
FIXME("unsupported args\n"); FIXME("unsupported args\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
@ -1148,12 +1137,11 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
arg = get_arg(dp, 0); switch(V_VT(argv)) {
switch(V_VT(arg)) {
case VT_DISPATCH: { case VT_DISPATCH: {
jsdisp_t *regexp; jsdisp_t *regexp;
regexp = iface_to_jsdisp((IUnknown*)V_DISPATCH(arg)); regexp = iface_to_jsdisp((IUnknown*)V_DISPATCH(argv));
if(regexp) { if(regexp) {
if(is_class(regexp, JSCLASS_REGEXP)) { if(is_class(regexp, JSCLASS_REGEXP)) {
use_regexp = TRUE; use_regexp = TRUE;
@ -1169,7 +1157,7 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP
} }
} }
default: default:
hres = to_string(ctx, arg, ei, &match_str); hres = to_string(ctx, argv, ei, &match_str);
if(FAILED(hres)) { if(FAILED(hres)) {
SysFreeString(val_str); SysFreeString(val_str);
return hres; return hres;
@ -1250,14 +1238,14 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP
return hres; return hres;
} }
static HRESULT String_strike(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT String_strike(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
static const WCHAR striketagW[] = {'S','T','R','I','K','E',0}; static const WCHAR striketagW[] = {'S','T','R','I','K','E',0};
return do_attributeless_tag_format(ctx, jsthis, retv, ei, striketagW); return do_attributeless_tag_format(ctx, jsthis, retv, ei, striketagW);
} }
static HRESULT String_sub(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT String_sub(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
static const WCHAR subtagW[] = {'S','U','B',0}; static const WCHAR subtagW[] = {'S','U','B',0};
@ -1265,7 +1253,7 @@ static HRESULT String_sub(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPA
} }
/* ECMA-262 3rd Edition 15.5.4.15 */ /* ECMA-262 3rd Edition 15.5.4.15 */
static HRESULT String_substring(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT String_substring(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
const WCHAR *str; const WCHAR *str;
@ -1281,8 +1269,8 @@ static HRESULT String_substring(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(arg_cnt(dp) >= 1) { if(argc >= 1) {
hres = to_integer(ctx, get_arg(dp,0), ei, &d); hres = to_integer(ctx, argv, ei, &d);
if(FAILED(hres)) { if(FAILED(hres)) {
SysFreeString(val_str); SysFreeString(val_str);
return hres; return hres;
@ -1292,8 +1280,8 @@ static HRESULT String_substring(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
start = is_int32(d) ? min(length, d) : length; start = is_int32(d) ? min(length, d) : length;
} }
if(arg_cnt(dp) >= 2) { if(argc >= 2) {
hres = to_integer(ctx, get_arg(dp,1), ei, &d); hres = to_integer(ctx, argv+1, ei, &d);
if(FAILED(hres)) { if(FAILED(hres)) {
SysFreeString(val_str); SysFreeString(val_str);
return hres; return hres;
@ -1326,7 +1314,7 @@ static HRESULT String_substring(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
} }
/* ECMA-262 3rd Edition B.2.3 */ /* ECMA-262 3rd Edition B.2.3 */
static HRESULT String_substr(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT String_substr(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
BSTR val_str; BSTR val_str;
@ -1342,8 +1330,8 @@ static HRESULT String_substr(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DIS
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(arg_cnt(dp) >= 1) { if(argc >= 1) {
hres = to_integer(ctx, get_arg(dp,0), ei, &d); hres = to_integer(ctx, argv, ei, &d);
if(FAILED(hres)) { if(FAILED(hres)) {
SysFreeString(val_str); SysFreeString(val_str);
return hres; return hres;
@ -1353,8 +1341,8 @@ static HRESULT String_substr(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DIS
start = is_int32(d) ? min(length, d) : length; start = is_int32(d) ? min(length, d) : length;
} }
if(arg_cnt(dp) >= 2) { if(argc >= 2) {
hres = to_integer(ctx, get_arg(dp,1), ei, &d); hres = to_integer(ctx, argv+1, ei, &d);
if(FAILED(hres)) { if(FAILED(hres)) {
SysFreeString(val_str); SysFreeString(val_str);
return hres; return hres;
@ -1380,14 +1368,14 @@ static HRESULT String_substr(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DIS
return hres; return hres;
} }
static HRESULT String_sup(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT String_sup(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
static const WCHAR suptagW[] = {'S','U','P',0}; static const WCHAR suptagW[] = {'S','U','P',0};
return do_attributeless_tag_format(ctx, jsthis, retv, ei, suptagW); return do_attributeless_tag_format(ctx, jsthis, retv, ei, suptagW);
} }
static HRESULT String_toLowerCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT String_toLowerCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
const WCHAR* str; const WCHAR* str;
@ -1417,7 +1405,7 @@ static HRESULT String_toLowerCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
return S_OK; return S_OK;
} }
static HRESULT String_toUpperCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT String_toUpperCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
const WCHAR* str; const WCHAR* str;
@ -1447,28 +1435,28 @@ static HRESULT String_toUpperCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
return S_OK; return S_OK;
} }
static HRESULT String_toLocaleLowerCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT String_toLocaleLowerCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
FIXME("\n"); FIXME("\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT String_toLocaleUpperCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT String_toLocaleUpperCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
FIXME("\n"); FIXME("\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT String_localeCompare(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT String_localeCompare(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
FIXME("\n"); FIXME("\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT String_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT String_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
StringInstance *This = string_from_vdisp(jsthis); StringInstance *This = string_from_vdisp(jsthis);
@ -1550,18 +1538,18 @@ static const builtin_info_t String_info = {
/* ECMA-262 3rd Edition 15.5.3.2 */ /* ECMA-262 3rd Edition 15.5.3.2 */
static HRESULT StringConstr_fromCharCode(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, static HRESULT StringConstr_fromCharCode(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei) unsigned argc, VARIANT *argv, VARIANT *retv, jsexcept_t *ei)
{ {
DWORD i, code; DWORD i, code;
BSTR ret; BSTR ret;
HRESULT hres; HRESULT hres;
ret = SysAllocStringLen(NULL, arg_cnt(dp)); ret = SysAllocStringLen(NULL, argc);
if(!ret) if(!ret)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
for(i=0; i<arg_cnt(dp); i++) { for(i=0; i<argc; i++) {
hres = to_uint32(ctx, get_arg(dp, i), ei, &code); hres = to_uint32(ctx, argv+i, ei, &code);
if(FAILED(hres)) { if(FAILED(hres)) {
SysFreeString(ret); SysFreeString(ret);
return hres; return hres;
@ -1579,7 +1567,7 @@ static HRESULT StringConstr_fromCharCode(script_ctx_t *ctx, vdisp_t *jsthis, WOR
return S_OK; return S_OK;
} }
static HRESULT StringConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT StringConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
HRESULT hres; HRESULT hres;
@ -1590,8 +1578,8 @@ static HRESULT StringConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
case INVOKE_FUNC: { case INVOKE_FUNC: {
BSTR str; BSTR str;
if(arg_cnt(dp)) { if(argc) {
hres = to_string(ctx, get_arg(dp, 0), ei, &str); hres = to_string(ctx, argv, ei, &str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
}else { }else {
@ -1607,10 +1595,10 @@ static HRESULT StringConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
case DISPATCH_CONSTRUCT: { case DISPATCH_CONSTRUCT: {
jsdisp_t *ret; jsdisp_t *ret;
if(arg_cnt(dp)) { if(argc) {
BSTR str; BSTR str;
hres = to_string(ctx, get_arg(dp, 0), ei, &str); hres = to_string(ctx, argv, ei, &str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;

View File

@ -44,7 +44,7 @@ static inline VBArrayInstance *vbarray_this(vdisp_t *jsthis)
return is_vclass(jsthis, JSCLASS_VBARRAY) ? vbarray_from_vdisp(jsthis) : NULL; return is_vclass(jsthis, JSCLASS_VBARRAY) ? vbarray_from_vdisp(jsthis) : NULL;
} }
static HRESULT VBArray_dimensions(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPARAMS *dp, static HRESULT VBArray_dimensions(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
VBArrayInstance *vbarray; VBArrayInstance *vbarray;
@ -60,11 +60,11 @@ static HRESULT VBArray_dimensions(script_ctx_t *ctx, vdisp_t *vthis, WORD flags,
return S_OK; return S_OK;
} }
static HRESULT VBArray_getItem(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPARAMS *dp, static HRESULT VBArray_getItem(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
VBArrayInstance *vbarray; VBArrayInstance *vbarray;
int i, *indexes, size; int i, *indexes;
VARIANT out; VARIANT out;
HRESULT hres; HRESULT hres;
@ -74,16 +74,15 @@ static HRESULT VBArray_getItem(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DI
if(!vbarray) if(!vbarray)
return throw_type_error(ctx, ei, JS_E_VBARRAY_EXPECTED, NULL); return throw_type_error(ctx, ei, JS_E_VBARRAY_EXPECTED, NULL);
size = arg_cnt(dp); if(argc < SafeArrayGetDim(vbarray->safearray))
if(size < SafeArrayGetDim(vbarray->safearray))
return throw_range_error(ctx, ei, JS_E_SUBSCRIPT_OUT_OF_RANGE, NULL); return throw_range_error(ctx, ei, JS_E_SUBSCRIPT_OUT_OF_RANGE, NULL);
indexes = heap_alloc(sizeof(int)*size); indexes = heap_alloc(sizeof(int)*argc);
if(!indexes) if(!indexes)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
for(i=0; i<size; i++) { for(i=0; i<argc; i++) {
hres = to_int32(ctx, get_arg(dp, i), ei, indexes+i); hres = to_int32(ctx, argv+i, ei, indexes+i);
if(FAILED(hres)) { if(FAILED(hres)) {
heap_free(indexes); heap_free(indexes);
return hres; return hres;
@ -103,7 +102,7 @@ static HRESULT VBArray_getItem(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DI
return hres; return hres;
} }
static HRESULT VBArray_lbound(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPARAMS *dp, static HRESULT VBArray_lbound(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
VBArrayInstance *vbarray; VBArrayInstance *vbarray;
@ -116,8 +115,8 @@ static HRESULT VBArray_lbound(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DIS
if(!vbarray) if(!vbarray)
return throw_type_error(ctx, ei, JS_E_VBARRAY_EXPECTED, NULL); return throw_type_error(ctx, ei, JS_E_VBARRAY_EXPECTED, NULL);
if(arg_cnt(dp)) { if(argc) {
hres = to_int32(ctx, get_arg(dp, 0), ei, &dim); hres = to_int32(ctx, argv, ei, &dim);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
} else } else
@ -134,7 +133,7 @@ static HRESULT VBArray_lbound(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DIS
return S_OK; return S_OK;
} }
static HRESULT VBArray_toArray(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPARAMS *dp, static HRESULT VBArray_toArray(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
VBArrayInstance *vbarray; VBArrayInstance *vbarray;
@ -182,7 +181,7 @@ static HRESULT VBArray_toArray(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DI
return S_OK; return S_OK;
} }
static HRESULT VBArray_ubound(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPARAMS *dp, static HRESULT VBArray_ubound(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
VBArrayInstance *vbarray; VBArrayInstance *vbarray;
@ -195,8 +194,8 @@ static HRESULT VBArray_ubound(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DIS
if(!vbarray) if(!vbarray)
return throw_type_error(ctx, ei, JS_E_VBARRAY_EXPECTED, NULL); return throw_type_error(ctx, ei, JS_E_VBARRAY_EXPECTED, NULL);
if(arg_cnt(dp)) { if(argc) {
hres = to_int32(ctx, get_arg(dp, 0), ei, &dim); hres = to_int32(ctx, argv, ei, &dim);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
} else } else
@ -213,7 +212,7 @@ static HRESULT VBArray_ubound(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DIS
return S_OK; return S_OK;
} }
static HRESULT VBArray_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, static HRESULT VBArray_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
FIXME("\n"); FIXME("\n");
@ -275,10 +274,9 @@ static HRESULT alloc_vbarray(script_ctx_t *ctx, jsdisp_t *object_prototype, VBAr
return S_OK; return S_OK;
} }
static HRESULT VBArrayConstr_value(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPARAMS *dp, static HRESULT VBArrayConstr_value(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, VARIANT *argv,
VARIANT *retv, jsexcept_t *ei) VARIANT *retv, jsexcept_t *ei)
{ {
VARIANT *arg;
VBArrayInstance *vbarray; VBArrayInstance *vbarray;
HRESULT hres; HRESULT hres;
@ -286,21 +284,21 @@ static HRESULT VBArrayConstr_value(script_ctx_t *ctx, vdisp_t *vthis, WORD flags
switch(flags) { switch(flags) {
case DISPATCH_METHOD: case DISPATCH_METHOD:
if(arg_cnt(dp)<1 || V_VT((arg = get_arg(dp, 0)))!=(VT_ARRAY|VT_VARIANT)) if(argc<1 || V_VT(argv) != (VT_ARRAY|VT_VARIANT))
return throw_type_error(ctx, ei, JS_E_VBARRAY_EXPECTED, NULL); return throw_type_error(ctx, ei, JS_E_VBARRAY_EXPECTED, NULL);
hres = VariantCopy(retv, arg); hres = VariantCopy(retv, argv);
return hres; return hres;
case DISPATCH_CONSTRUCT: case DISPATCH_CONSTRUCT:
if(arg_cnt(dp)<1 || V_VT((arg = get_arg(dp, 0)))!=(VT_ARRAY|VT_VARIANT)) if(argc<1 || V_VT(argv) != (VT_ARRAY|VT_VARIANT))
return throw_type_error(ctx, ei, JS_E_VBARRAY_EXPECTED, NULL); return throw_type_error(ctx, ei, JS_E_VBARRAY_EXPECTED, NULL);
hres = alloc_vbarray(ctx, NULL, &vbarray); hres = alloc_vbarray(ctx, NULL, &vbarray);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
hres = SafeArrayCopy(V_ARRAY(arg), &vbarray->safearray); hres = SafeArrayCopy(V_ARRAY(argv), &vbarray->safearray);
if(FAILED(hres)) { if(FAILED(hres)) {
jsdisp_release(&vbarray->dispex); jsdisp_release(&vbarray->dispex);
return hres; return hres;