jscript: Store exception value in script_ctx_t instead of passing it everywhere.

This commit is contained in:
Jacek Caban 2012-09-18 19:01:49 +02:00 committed by Alexandre Julliard
parent 19f951e86a
commit 6f5475dd26
19 changed files with 885 additions and 908 deletions

View File

@ -139,7 +139,7 @@ static IUnknown *create_activex_object(script_ctx_t *ctx, const WCHAR *progid)
} }
static HRESULT ActiveXObject_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT ActiveXObject_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
IDispatch *disp; IDispatch *disp;
IUnknown *obj; IUnknown *obj;
@ -164,14 +164,14 @@ static HRESULT ActiveXObject_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flag
return E_NOTIMPL; return E_NOTIMPL;
} }
hres = to_string(ctx, argv[0], ei, &progid); hres = to_string(ctx, argv[0], &progid);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
obj = create_activex_object(ctx, progid); obj = create_activex_object(ctx, progid);
SysFreeString(progid); SysFreeString(progid);
if(!obj) if(!obj)
return throw_generic_error(ctx, ei, JS_E_CANNOT_CREATE_OBJ, NULL); return throw_generic_error(ctx, JS_E_CANNOT_CREATE_OBJ, NULL);
hres = IUnknown_QueryInterface(obj, &IID_IDispatch, (void**)&disp); hres = IUnknown_QueryInterface(obj, &IID_IDispatch, (void**)&disp);
IUnknown_Release(obj); IUnknown_Release(obj);

View File

@ -59,7 +59,7 @@ static inline ArrayInstance *array_this(vdisp_t *jsthis)
return is_vclass(jsthis, JSCLASS_ARRAY) ? array_from_vdisp(jsthis) : NULL; return is_vclass(jsthis, JSCLASS_ARRAY) ? array_from_vdisp(jsthis) : NULL;
} }
static HRESULT get_length(script_ctx_t *ctx, vdisp_t *vdisp, jsexcept_t *ei, jsdisp_t **jsthis, DWORD *ret) static HRESULT get_length(script_ctx_t *ctx, vdisp_t *vdisp, jsdisp_t **jsthis, DWORD *ret)
{ {
ArrayInstance *array; ArrayInstance *array;
jsval_t val; jsval_t val;
@ -73,13 +73,13 @@ static HRESULT get_length(script_ctx_t *ctx, vdisp_t *vdisp, jsexcept_t *ei, jsd
} }
if(!is_jsdisp(vdisp)) if(!is_jsdisp(vdisp))
return throw_type_error(ctx, ei, JS_E_JSCRIPT_EXPECTED, NULL); return throw_type_error(ctx, JS_E_JSCRIPT_EXPECTED, NULL);
hres = jsdisp_propget_name(vdisp->u.jsdisp, lengthW, &val, ei); hres = jsdisp_propget_name(vdisp->u.jsdisp, lengthW, &val);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
hres = to_uint32(ctx, val, ei, ret); hres = to_uint32(ctx, val, ret);
jsval_release(val); jsval_release(val);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -88,14 +88,14 @@ static HRESULT get_length(script_ctx_t *ctx, vdisp_t *vdisp, jsexcept_t *ei, jsd
return S_OK; return S_OK;
} }
static HRESULT set_length(jsdisp_t *obj, jsexcept_t *ei, DWORD length) static HRESULT set_length(jsdisp_t *obj, DWORD length)
{ {
if(is_class(obj, JSCLASS_ARRAY)) { if(is_class(obj, JSCLASS_ARRAY)) {
((ArrayInstance*)obj)->length = length; ((ArrayInstance*)obj)->length = length;
return S_OK; return S_OK;
} }
return jsdisp_propput_name(obj, lengthW, jsval_number(length), ei); return jsdisp_propput_name(obj, lengthW, jsval_number(length));
} }
static WCHAR *idx_to_str(DWORD idx, WCHAR *ptr) static WCHAR *idx_to_str(DWORD idx, WCHAR *ptr)
@ -114,7 +114,7 @@ static WCHAR *idx_to_str(DWORD idx, WCHAR *ptr)
} }
static HRESULT Array_length(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Array_length(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
ArrayInstance *This = array_from_vdisp(jsthis); ArrayInstance *This = array_from_vdisp(jsthis);
@ -129,13 +129,13 @@ static HRESULT Array_length(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi
DWORD i; DWORD i;
HRESULT hres; HRESULT hres;
hres = to_number(ctx, argv[0], ei, &len); hres = to_number(ctx, argv[0], &len);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
len = floor(len); len = floor(len);
if(len!=(DWORD)len) if(len!=(DWORD)len)
return throw_range_error(ctx, ei, JS_E_INVALID_LENGTH, NULL); return throw_range_error(ctx, JS_E_INVALID_LENGTH, NULL);
for(i=len; i<This->length; i++) { for(i=len; i<This->length; i++) {
hres = jsdisp_delete_idx(&This->dispex, i); hres = jsdisp_delete_idx(&This->dispex, i);
@ -154,20 +154,20 @@ static HRESULT Array_length(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi
return S_OK; return S_OK;
} }
static HRESULT concat_array(jsdisp_t *array, ArrayInstance *obj, DWORD *len, jsexcept_t *ei) static HRESULT concat_array(jsdisp_t *array, ArrayInstance *obj, DWORD *len)
{ {
jsval_t val; jsval_t val;
DWORD i; DWORD i;
HRESULT hres; HRESULT hres;
for(i=0; i < obj->length; i++) { for(i=0; i < obj->length; i++) {
hres = jsdisp_get_idx(&obj->dispex, i, &val, ei); hres = jsdisp_get_idx(&obj->dispex, i, &val);
if(hres == DISP_E_UNKNOWNNAME) if(hres == DISP_E_UNKNOWNNAME)
continue; continue;
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
hres = jsdisp_propput_idx(array, *len+i, val, ei); hres = jsdisp_propput_idx(array, *len+i, val);
jsval_release(val); jsval_release(val);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -177,7 +177,7 @@ static HRESULT concat_array(jsdisp_t *array, ArrayInstance *obj, DWORD *len, jse
return S_OK; return S_OK;
} }
static HRESULT concat_obj(jsdisp_t *array, IDispatch *obj, DWORD *len, jsexcept_t *ei) static HRESULT concat_obj(jsdisp_t *array, IDispatch *obj, DWORD *len)
{ {
jsdisp_t *jsobj; jsdisp_t *jsobj;
HRESULT hres; HRESULT hres;
@ -185,18 +185,18 @@ static HRESULT concat_obj(jsdisp_t *array, IDispatch *obj, DWORD *len, jsexcept_
jsobj = iface_to_jsdisp((IUnknown*)obj); jsobj = iface_to_jsdisp((IUnknown*)obj);
if(jsobj) { if(jsobj) {
if(is_class(jsobj, JSCLASS_ARRAY)) { if(is_class(jsobj, JSCLASS_ARRAY)) {
hres = concat_array(array, (ArrayInstance*)jsobj, len, ei); hres = concat_array(array, (ArrayInstance*)jsobj, len);
jsdisp_release(jsobj); jsdisp_release(jsobj);
return hres; return hres;
} }
jsdisp_release(jsobj); jsdisp_release(jsobj);
} }
return jsdisp_propput_idx(array, (*len)++, jsval_disp(obj), ei); return jsdisp_propput_idx(array, (*len)++, jsval_disp(obj));
} }
static HRESULT Array_concat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Array_concat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
jsdisp_t *ret; jsdisp_t *ret;
DWORD len = 0; DWORD len = 0;
@ -208,15 +208,15 @@ static HRESULT Array_concat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
hres = concat_obj(ret, jsthis->u.disp, &len, ei); hres = concat_obj(ret, jsthis->u.disp, &len);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
DWORD i; DWORD i;
for(i=0; i < argc; i++) { for(i=0; i < argc; i++) {
if(is_object_instance(argv[i])) if(is_object_instance(argv[i]))
hres = concat_obj(ret, get_object(argv[i]), &len, ei); hres = concat_obj(ret, get_object(argv[i]), &len);
else else
hres = jsdisp_propput_idx(ret, len++, argv[i], ei); hres = jsdisp_propput_idx(ret, len++, argv[i]);
if(FAILED(hres)) if(FAILED(hres))
break; break;
} }
@ -232,7 +232,7 @@ static HRESULT Array_concat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi
return S_OK; return S_OK;
} }
static HRESULT array_join(script_ctx_t *ctx, jsdisp_t *array, DWORD length, const WCHAR *sep, jsval_t *r, jsexcept_t *ei) static HRESULT array_join(script_ctx_t *ctx, jsdisp_t *array, DWORD length, const WCHAR *sep, jsval_t *r)
{ {
BSTR *str_tab, ret = NULL; BSTR *str_tab, ret = NULL;
jsval_t val; jsval_t val;
@ -254,7 +254,7 @@ static HRESULT array_join(script_ctx_t *ctx, jsdisp_t *array, DWORD length, cons
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
for(i=0; i < length; i++) { for(i=0; i < length; i++) {
hres = jsdisp_get_idx(array, i, &val, ei); hres = jsdisp_get_idx(array, i, &val);
if(hres == DISP_E_UNKNOWNNAME) { if(hres == DISP_E_UNKNOWNNAME) {
hres = S_OK; hres = S_OK;
continue; continue;
@ -262,7 +262,7 @@ static HRESULT array_join(script_ctx_t *ctx, jsdisp_t *array, DWORD length, cons
break; break;
if(!is_undefined(val) && !is_null(val)) { if(!is_undefined(val) && !is_null(val)) {
hres = to_string(ctx, val, ei, str_tab+i); hres = to_string(ctx, val, str_tab+i);
jsval_release(val); jsval_release(val);
if(FAILED(hres)) if(FAILED(hres))
break; break;
@ -333,7 +333,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, unsigned argc, jsval_t *argv, static HRESULT Array_join(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
jsdisp_t *jsthis; jsdisp_t *jsthis;
DWORD length; DWORD length;
@ -341,29 +341,29 @@ static HRESULT Array_join(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigne
TRACE("\n"); TRACE("\n");
hres = get_length(ctx, vthis, ei, &jsthis, &length); hres = get_length(ctx, vthis, &jsthis, &length);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(argc) { if(argc) {
BSTR sep; BSTR sep;
hres = to_string(ctx, argv[0], ei, &sep); hres = to_string(ctx, argv[0], &sep);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
hres = array_join(ctx, jsthis, length, sep, r, ei); hres = array_join(ctx, jsthis, length, sep, r);
SysFreeString(sep); SysFreeString(sep);
}else { }else {
hres = array_join(ctx, jsthis, length, default_separatorW, r, ei); hres = array_join(ctx, jsthis, length, default_separatorW, r);
} }
return hres; return hres;
} }
static HRESULT Array_pop(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Array_pop(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
jsdisp_t *jsthis; jsdisp_t *jsthis;
jsval_t val; jsval_t val;
@ -372,12 +372,12 @@ static HRESULT Array_pop(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned
TRACE("\n"); TRACE("\n");
hres = get_length(ctx, vthis, ei, &jsthis, &length); hres = get_length(ctx, vthis, &jsthis, &length);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(!length) { if(!length) {
hres = set_length(jsthis, ei, 0); hres = set_length(jsthis, 0);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -387,7 +387,7 @@ static HRESULT Array_pop(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned
} }
length--; length--;
hres = jsdisp_get_idx(jsthis, length, &val, ei); hres = jsdisp_get_idx(jsthis, length, &val);
if(SUCCEEDED(hres)) if(SUCCEEDED(hres))
hres = jsdisp_delete_idx(jsthis, length); hres = jsdisp_delete_idx(jsthis, length);
else if(hres == DISP_E_UNKNOWNNAME) else if(hres == DISP_E_UNKNOWNNAME)
@ -396,7 +396,7 @@ static HRESULT Array_pop(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned
return hres; return hres;
if(SUCCEEDED(hres)) if(SUCCEEDED(hres))
hres = set_length(jsthis, ei, length); hres = set_length(jsthis, length);
if(FAILED(hres)) { if(FAILED(hres)) {
jsval_release(val); jsval_release(val);
@ -412,7 +412,7 @@ static HRESULT Array_pop(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned
/* 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, unsigned argc, jsval_t *argv, static HRESULT Array_push(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
jsdisp_t *jsthis; jsdisp_t *jsthis;
DWORD length = 0; DWORD length = 0;
@ -421,17 +421,17 @@ static HRESULT Array_push(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigne
TRACE("\n"); TRACE("\n");
hres = get_length(ctx, vthis, ei, &jsthis, &length); hres = get_length(ctx, vthis, &jsthis, &length);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
for(i=0; i < argc; i++) { for(i=0; i < argc; i++) {
hres = jsdisp_propput_idx(jsthis, length+i, argv[i], ei); hres = jsdisp_propput_idx(jsthis, length+i, argv[i]);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
} }
hres = set_length(jsthis, ei, length+argc); hres = set_length(jsthis, length+argc);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -441,7 +441,7 @@ static HRESULT Array_push(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigne
} }
static HRESULT Array_reverse(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Array_reverse(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
jsdisp_t *jsthis; jsdisp_t *jsthis;
DWORD length, k, l; DWORD length, k, l;
@ -450,18 +450,18 @@ static HRESULT Array_reverse(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsi
TRACE("\n"); TRACE("\n");
hres1 = get_length(ctx, vthis, ei, &jsthis, &length); hres1 = get_length(ctx, vthis, &jsthis, &length);
if(FAILED(hres1)) if(FAILED(hres1))
return hres1; return hres1;
for(k=0; k<length/2; k++) { for(k=0; k<length/2; k++) {
l = length-k-1; l = length-k-1;
hres1 = jsdisp_get_idx(jsthis, k, &v1, ei); hres1 = jsdisp_get_idx(jsthis, k, &v1);
if(FAILED(hres1) && hres1!=DISP_E_UNKNOWNNAME) if(FAILED(hres1) && hres1!=DISP_E_UNKNOWNNAME)
return hres1; return hres1;
hres2 = jsdisp_get_idx(jsthis, l, &v2, ei); hres2 = jsdisp_get_idx(jsthis, l, &v2);
if(FAILED(hres2) && hres2!=DISP_E_UNKNOWNNAME) { if(FAILED(hres2) && hres2!=DISP_E_UNKNOWNNAME) {
jsval_release(v1); jsval_release(v1);
return hres2; return hres2;
@ -470,7 +470,7 @@ static HRESULT Array_reverse(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsi
if(hres1 == DISP_E_UNKNOWNNAME) if(hres1 == DISP_E_UNKNOWNNAME)
hres1 = jsdisp_delete_idx(jsthis, l); hres1 = jsdisp_delete_idx(jsthis, l);
else else
hres1 = jsdisp_propput_idx(jsthis, l, v1, ei); hres1 = jsdisp_propput_idx(jsthis, l, v1);
if(FAILED(hres1)) { if(FAILED(hres1)) {
jsval_release(v1); jsval_release(v1);
@ -481,7 +481,7 @@ static HRESULT Array_reverse(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsi
if(hres2 == DISP_E_UNKNOWNNAME) if(hres2 == DISP_E_UNKNOWNNAME)
hres2 = jsdisp_delete_idx(jsthis, k); hres2 = jsdisp_delete_idx(jsthis, k);
else else
hres2 = jsdisp_propput_idx(jsthis, k, v2, ei); hres2 = jsdisp_propput_idx(jsthis, k, v2);
if(FAILED(hres2)) { if(FAILED(hres2)) {
jsval_release(v2); jsval_release(v2);
@ -496,7 +496,7 @@ static HRESULT Array_reverse(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsi
/* 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, unsigned argc, jsval_t *argv, static HRESULT Array_shift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
jsdisp_t *jsthis; jsdisp_t *jsthis;
DWORD length = 0, i; DWORD length = 0, i;
@ -505,12 +505,12 @@ static HRESULT Array_shift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsign
TRACE("\n"); TRACE("\n");
hres = get_length(ctx, vthis, ei, &jsthis, &length); hres = get_length(ctx, vthis, &jsthis, &length);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(!length) { if(!length) {
hres = set_length(jsthis, ei, 0); hres = set_length(jsthis, 0);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
} }
@ -521,24 +521,24 @@ static HRESULT Array_shift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsign
return S_OK; return S_OK;
} }
hres = jsdisp_get_idx(jsthis, 0, &ret, ei); hres = jsdisp_get_idx(jsthis, 0, &ret);
if(hres == DISP_E_UNKNOWNNAME) { if(hres == DISP_E_UNKNOWNNAME) {
ret = jsval_undefined(); ret = jsval_undefined();
hres = S_OK; hres = S_OK;
} }
for(i=1; SUCCEEDED(hres) && i<length; i++) { for(i=1; SUCCEEDED(hres) && i<length; i++) {
hres = jsdisp_get_idx(jsthis, i, &v, ei); hres = jsdisp_get_idx(jsthis, i, &v);
if(hres == DISP_E_UNKNOWNNAME) if(hres == DISP_E_UNKNOWNNAME)
hres = jsdisp_delete_idx(jsthis, i-1); hres = jsdisp_delete_idx(jsthis, i-1);
else if(SUCCEEDED(hres)) else if(SUCCEEDED(hres))
hres = jsdisp_propput_idx(jsthis, i-1, v, ei); hres = jsdisp_propput_idx(jsthis, i-1, v);
} }
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
hres = jsdisp_delete_idx(jsthis, length-1); hres = jsdisp_delete_idx(jsthis, length-1);
if(SUCCEEDED(hres)) if(SUCCEEDED(hres))
hres = set_length(jsthis, ei, length-1); hres = set_length(jsthis, length-1);
} }
if(FAILED(hres)) if(FAILED(hres))
@ -552,8 +552,7 @@ static HRESULT Array_shift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsign
} }
/* 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, unsigned argc, jsval_t *argv, static HRESULT Array_slice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
jsval_t *r, jsexcept_t *ei)
{ {
jsdisp_t *arr, *jsthis; jsdisp_t *arr, *jsthis;
DOUBLE range; DOUBLE range;
@ -562,12 +561,12 @@ static HRESULT Array_slice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsign
TRACE("\n"); TRACE("\n");
hres = get_length(ctx, vthis, ei, &jsthis, &length); hres = get_length(ctx, vthis, &jsthis, &length);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(argc) { if(argc) {
hres = to_number(ctx, argv[0], ei, &range); hres = to_number(ctx, argv[0], &range);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -580,7 +579,7 @@ static HRESULT Array_slice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsign
else start = 0; else start = 0;
if(argc > 1) { if(argc > 1) {
hres = to_number(ctx, argv[1], ei, &range); hres = to_number(ctx, argv[1], &range);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -599,12 +598,12 @@ static HRESULT Array_slice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsign
for(idx=start; idx<end; idx++) { for(idx=start; idx<end; idx++) {
jsval_t v; jsval_t v;
hres = jsdisp_get_idx(jsthis, idx, &v, ei); hres = jsdisp_get_idx(jsthis, idx, &v);
if(hres == DISP_E_UNKNOWNNAME) if(hres == DISP_E_UNKNOWNNAME)
continue; continue;
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
hres = jsdisp_propput_idx(arr, idx-start, v, ei); hres = jsdisp_propput_idx(arr, idx-start, v);
jsval_release(v); jsval_release(v);
} }
@ -622,7 +621,7 @@ static HRESULT Array_slice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsign
return S_OK; return S_OK;
} }
static HRESULT sort_cmp(script_ctx_t *ctx, jsdisp_t *cmp_func, jsval_t v1, jsval_t v2, jsexcept_t *ei, INT *cmp) static HRESULT sort_cmp(script_ctx_t *ctx, jsdisp_t *cmp_func, jsval_t v1, jsval_t v2, INT *cmp)
{ {
HRESULT hres; HRESULT hres;
@ -631,11 +630,11 @@ static HRESULT sort_cmp(script_ctx_t *ctx, jsdisp_t *cmp_func, jsval_t v1, jsval
jsval_t res; jsval_t res;
double n; double n;
hres = jsdisp_call_value(cmp_func, NULL, DISPATCH_METHOD, 2, args, &res, ei); hres = jsdisp_call_value(cmp_func, NULL, DISPATCH_METHOD, 2, args, &res);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
hres = to_number(ctx, res, ei, &n); hres = to_number(ctx, res, &n);
jsval_release(res); jsval_release(res);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -656,11 +655,11 @@ static HRESULT sort_cmp(script_ctx_t *ctx, jsdisp_t *cmp_func, jsval_t v1, jsval
}else { }else {
BSTR x, y; BSTR x, y;
hres = to_string(ctx, v1, ei, &x); hres = to_string(ctx, v1, &x);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
hres = to_string(ctx, v2, ei, &y); hres = to_string(ctx, v2, &y);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
*cmp = strcmpW(x, y); *cmp = strcmpW(x, y);
SysFreeString(y); SysFreeString(y);
@ -675,7 +674,7 @@ static HRESULT sort_cmp(script_ctx_t *ctx, jsdisp_t *cmp_func, jsval_t v1, jsval
/* 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, unsigned argc, jsval_t *argv, static HRESULT Array_sort(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
jsdisp_t *jsthis, *cmp_func = NULL; jsdisp_t *jsthis, *cmp_func = NULL;
jsval_t *vtab, **sorttab = NULL; jsval_t *vtab, **sorttab = NULL;
@ -685,7 +684,7 @@ static HRESULT Array_sort(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigne
TRACE("\n"); TRACE("\n");
hres = get_length(ctx, vthis, ei, &jsthis, &length); hres = get_length(ctx, vthis, &jsthis, &length);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -720,7 +719,7 @@ static HRESULT Array_sort(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigne
vtab = heap_alloc_zero(length * sizeof(*vtab)); vtab = heap_alloc_zero(length * sizeof(*vtab));
if(vtab) { if(vtab) {
for(i=0; i<length; i++) { for(i=0; i<length; i++) {
hres = jsdisp_get_idx(jsthis, i, vtab+i, ei); hres = jsdisp_get_idx(jsthis, i, vtab+i);
if(hres == DISP_E_UNKNOWNNAME) { if(hres == DISP_E_UNKNOWNNAME) {
vtab[i] = jsval_undefined(); vtab[i] = jsval_undefined();
hres = S_OK; hres = S_OK;
@ -749,7 +748,7 @@ static HRESULT Array_sort(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigne
sorttab[i] = vtab+i; sorttab[i] = vtab+i;
for(i=0; i < length/2; i++) { for(i=0; i < length/2; i++) {
hres = sort_cmp(ctx, cmp_func, *sorttab[2*i+1], *sorttab[2*i], ei, &cmp); hres = sort_cmp(ctx, cmp_func, *sorttab[2*i+1], *sorttab[2*i], &cmp);
if(FAILED(hres)) if(FAILED(hres))
break; break;
@ -774,7 +773,7 @@ static HRESULT Array_sort(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigne
memcpy(tmpbuf, sorttab+i, k*sizeof(jsval_t*)); memcpy(tmpbuf, sorttab+i, k*sizeof(jsval_t*));
while(a < k && b < bend) { while(a < k && b < bend) {
hres = sort_cmp(ctx, cmp_func, *tmpbuf[a], *sorttab[i+k+b], ei, &cmp); hres = sort_cmp(ctx, cmp_func, *tmpbuf[a], *sorttab[i+k+b], &cmp);
if(FAILED(hres)) if(FAILED(hres))
break; break;
@ -800,7 +799,7 @@ static HRESULT Array_sort(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigne
} }
for(i=0; SUCCEEDED(hres) && i < length; i++) for(i=0; SUCCEEDED(hres) && i < length; i++)
hres = jsdisp_propput_idx(jsthis, i, *sorttab[i], ei); hres = jsdisp_propput_idx(jsthis, i, *sorttab[i]);
} }
if(vtab) { if(vtab) {
@ -822,7 +821,7 @@ static HRESULT Array_sort(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigne
/* 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, unsigned argc, jsval_t *argv, static HRESULT Array_splice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
DWORD length, start=0, delete_cnt=0, 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;
@ -833,12 +832,12 @@ static HRESULT Array_splice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsig
TRACE("\n"); TRACE("\n");
hres = get_length(ctx, vthis, ei, &jsthis, &length); hres = get_length(ctx, vthis, &jsthis, &length);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(argc) { if(argc) {
hres = to_integer(ctx, argv[0], ei, &d); hres = to_integer(ctx, argv[0], &d);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -853,7 +852,7 @@ static HRESULT Array_splice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsig
} }
if(argc >= 2) { if(argc >= 2) {
hres = to_integer(ctx, argv[1], ei, &d); hres = to_integer(ctx, argv[1], &d);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -873,26 +872,26 @@ static HRESULT Array_splice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsig
return hres; return hres;
for(i=0; SUCCEEDED(hres) && i < delete_cnt; i++) { for(i=0; SUCCEEDED(hres) && i < delete_cnt; i++) {
hres = jsdisp_get_idx(jsthis, start+i, &val, ei); hres = jsdisp_get_idx(jsthis, start+i, &val);
if(hres == DISP_E_UNKNOWNNAME) { if(hres == DISP_E_UNKNOWNNAME) {
hres = S_OK; hres = S_OK;
}else if(SUCCEEDED(hres)) { }else if(SUCCEEDED(hres)) {
hres = jsdisp_propput_idx(ret_array, i, val, ei); hres = jsdisp_propput_idx(ret_array, i, val);
jsval_release(val); jsval_release(val);
} }
} }
if(SUCCEEDED(hres)) if(SUCCEEDED(hres))
hres = jsdisp_propput_name(ret_array, lengthW, jsval_number(delete_cnt), ei); hres = jsdisp_propput_name(ret_array, lengthW, jsval_number(delete_cnt));
} }
if(add_args < delete_cnt) { if(add_args < delete_cnt) {
for(i = start; SUCCEEDED(hres) && i < length-delete_cnt; i++) { for(i = start; SUCCEEDED(hres) && i < length-delete_cnt; i++) {
hres = jsdisp_get_idx(jsthis, i+delete_cnt, &val, ei); hres = jsdisp_get_idx(jsthis, i+delete_cnt, &val);
if(hres == DISP_E_UNKNOWNNAME) { if(hres == DISP_E_UNKNOWNNAME) {
hres = jsdisp_delete_idx(jsthis, i+add_args); hres = jsdisp_delete_idx(jsthis, i+add_args);
}else if(SUCCEEDED(hres)) { }else if(SUCCEEDED(hres)) {
hres = jsdisp_propput_idx(jsthis, i+add_args, val, ei); hres = jsdisp_propput_idx(jsthis, i+add_args, val);
jsval_release(val); jsval_release(val);
} }
} }
@ -901,21 +900,21 @@ static HRESULT Array_splice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsig
hres = jsdisp_delete_idx(jsthis, i-1); hres = jsdisp_delete_idx(jsthis, i-1);
}else if(add_args > delete_cnt) { }else if(add_args > delete_cnt) {
for(i=length-delete_cnt; SUCCEEDED(hres) && i != start; i--) { for(i=length-delete_cnt; SUCCEEDED(hres) && i != start; i--) {
hres = jsdisp_get_idx(jsthis, i+delete_cnt-1, &val, ei); hres = jsdisp_get_idx(jsthis, i+delete_cnt-1, &val);
if(hres == DISP_E_UNKNOWNNAME) { if(hres == DISP_E_UNKNOWNNAME) {
hres = jsdisp_delete_idx(jsthis, i+add_args-1); hres = jsdisp_delete_idx(jsthis, i+add_args-1);
}else if(SUCCEEDED(hres)) { }else if(SUCCEEDED(hres)) {
hres = jsdisp_propput_idx(jsthis, i+add_args-1, val, ei); hres = jsdisp_propput_idx(jsthis, i+add_args-1, val);
jsval_release(val); jsval_release(val);
} }
} }
} }
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, argv[i+2], ei); hres = jsdisp_propput_idx(jsthis, start+i, argv[i+2]);
if(SUCCEEDED(hres)) if(SUCCEEDED(hres))
hres = jsdisp_propput_name(jsthis, lengthW, jsval_number(length-delete_cnt+add_args), ei); hres = jsdisp_propput_name(jsthis, lengthW, jsval_number(length-delete_cnt+add_args));
if(FAILED(hres)) { if(FAILED(hres)) {
if(ret_array) if(ret_array)
@ -930,7 +929,7 @@ static HRESULT Array_splice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsig
/* ECMA-262 3rd Edition 15.4.4.2 */ /* ECMA-262 3rd Edition 15.4.4.2 */
static HRESULT Array_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Array_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
ArrayInstance *array; ArrayInstance *array;
@ -938,13 +937,13 @@ static HRESULT Array_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
array = array_this(jsthis); array = array_this(jsthis);
if(!array) if(!array)
return throw_type_error(ctx, ei, JS_E_ARRAY_EXPECTED, NULL); return throw_type_error(ctx, JS_E_ARRAY_EXPECTED, NULL);
return array_join(ctx, &array->dispex, array->length, default_separatorW, r, ei); return array_join(ctx, &array->dispex, array->length, default_separatorW, r);
} }
static HRESULT Array_toLocaleString(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Array_toLocaleString(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
FIXME("\n"); FIXME("\n");
return E_NOTIMPL; return E_NOTIMPL;
@ -952,7 +951,7 @@ 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, unsigned argc, jsval_t *argv, static HRESULT Array_unshift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
jsdisp_t *jsthis; jsdisp_t *jsthis;
WCHAR buf[14], *buf_end, *str; WCHAR buf[14], *buf_end, *str;
@ -963,7 +962,7 @@ static HRESULT Array_unshift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsi
TRACE("\n"); TRACE("\n");
hres = get_length(ctx, vthis, ei, &jsthis, &length); hres = get_length(ctx, vthis, &jsthis, &length);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -977,11 +976,11 @@ static HRESULT Array_unshift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsi
hres = jsdisp_get_id(jsthis, str, 0, &id); hres = jsdisp_get_id(jsthis, str, 0, &id);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
hres = jsdisp_propget(jsthis, id, &val, ei); hres = jsdisp_propget(jsthis, id, &val);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
hres = jsdisp_propput_idx(jsthis, i+argc, val, ei); hres = jsdisp_propput_idx(jsthis, i+argc, val);
jsval_release(val); jsval_release(val);
}else if(hres == DISP_E_UNKNOWNNAME) { }else if(hres == DISP_E_UNKNOWNNAME) {
hres = IDispatchEx_DeleteMemberByDispID(vthis->u.dispex, id); hres = IDispatchEx_DeleteMemberByDispID(vthis->u.dispex, id);
@ -993,14 +992,14 @@ static HRESULT Array_unshift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsi
} }
for(i=0; i<argc; i++) { for(i=0; i<argc; i++) {
hres = jsdisp_propput_idx(jsthis, i, argv[i], ei); hres = jsdisp_propput_idx(jsthis, i, argv[i]);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
} }
if(argc) { if(argc) {
length += argc; length += argc;
hres = set_length(jsthis, ei, length); hres = set_length(jsthis, length);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
} }
@ -1011,15 +1010,15 @@ static HRESULT Array_unshift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsi
} }
static HRESULT Array_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Array_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
switch(flags) { switch(flags) {
case INVOKE_FUNC: case INVOKE_FUNC:
return throw_type_error(ctx, ei, JS_E_FUNCTION_EXPECTED, NULL); return throw_type_error(ctx, JS_E_FUNCTION_EXPECTED, NULL);
case INVOKE_PROPERTYGET: case INVOKE_PROPERTYGET:
return array_join(ctx, jsthis->u.jsdisp, array_from_vdisp(jsthis)->length, default_separatorW, r, ei); return array_join(ctx, jsthis->u.jsdisp, array_from_vdisp(jsthis)->length, default_separatorW, r);
default: default:
FIXME("unimplemented flags %x\n", flags); FIXME("unimplemented flags %x\n", flags);
return E_NOTIMPL; return E_NOTIMPL;
@ -1093,7 +1092,7 @@ static const builtin_info_t ArrayInst_info = {
}; };
static HRESULT ArrayConstr_value(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT ArrayConstr_value(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
jsdisp_t *obj; jsdisp_t *obj;
DWORD i; DWORD i;
@ -1108,7 +1107,7 @@ static HRESULT ArrayConstr_value(script_ctx_t *ctx, vdisp_t *vthis, WORD flags,
double n = get_number(argv[0]); double n = get_number(argv[0]);
if(n < 0 || !is_int32(n)) if(n < 0 || !is_int32(n))
return throw_range_error(ctx, ei, JS_E_INVALID_LENGTH, NULL); return throw_range_error(ctx, JS_E_INVALID_LENGTH, NULL);
hres = create_array(ctx, n, &obj); hres = create_array(ctx, n, &obj);
if(FAILED(hres)) if(FAILED(hres))
@ -1123,7 +1122,7 @@ static HRESULT ArrayConstr_value(script_ctx_t *ctx, vdisp_t *vthis, WORD flags,
return hres; return hres;
for(i=0; i < argc; i++) { for(i=0; i < argc; i++) {
hres = jsdisp_propput_idx(obj, i, argv[i], ei); hres = jsdisp_propput_idx(obj, i, argv[i]);
if(FAILED(hres)) if(FAILED(hres))
break; break;
} }

View File

@ -38,8 +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, unsigned argc, jsval_t *argv, static HRESULT Bool_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
jsval_t *r, jsexcept_t *ei)
{ {
BoolInstance *bool; BoolInstance *bool;
@ -49,7 +48,7 @@ static HRESULT Bool_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns
TRACE("\n"); TRACE("\n");
if(!(bool = bool_this(jsthis))) if(!(bool = bool_this(jsthis)))
return throw_type_error(ctx, ei, JS_E_BOOLEAN_EXPECTED, NULL); return throw_type_error(ctx, JS_E_BOOLEAN_EXPECTED, NULL);
if(r) { if(r) {
BSTR val; BSTR val;
@ -67,15 +66,14 @@ static HRESULT Bool_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns
} }
/* 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, unsigned argc, jsval_t *argv, static HRESULT Bool_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
jsval_t *r, jsexcept_t *ei)
{ {
BoolInstance *bool; BoolInstance *bool;
TRACE("\n"); TRACE("\n");
if(!(bool = bool_this(jsthis))) if(!(bool = bool_this(jsthis)))
return throw_type_error(ctx, ei, JS_E_BOOLEAN_EXPECTED, NULL); return throw_type_error(ctx, JS_E_BOOLEAN_EXPECTED, NULL);
if(r) if(r)
*r = jsval_bool(bool->val); *r = jsval_bool(bool->val);
@ -83,13 +81,13 @@ static HRESULT Bool_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi
} }
static HRESULT Bool_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Bool_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
switch(flags) { switch(flags) {
case INVOKE_FUNC: case INVOKE_FUNC:
return throw_type_error(ctx, ei, JS_E_FUNCTION_EXPECTED, NULL); return throw_type_error(ctx, JS_E_FUNCTION_EXPECTED, NULL);
default: default:
FIXME("unimplemented flags %x\n", flags); FIXME("unimplemented flags %x\n", flags);
return E_NOTIMPL; return E_NOTIMPL;
@ -122,7 +120,7 @@ static const builtin_info_t BoolInst_info = {
}; };
static HRESULT BoolConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT BoolConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
BOOL value = FALSE; BOOL value = FALSE;
HRESULT hres; HRESULT hres;

File diff suppressed because it is too large Load Diff

View File

@ -344,7 +344,7 @@ static HRESULT convert_params(const DISPPARAMS *dp, jsval_t *buf, unsigned *argc
} }
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,
unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei, IServiceProvider *caller) unsigned argc, jsval_t *argv, jsval_t *r, IServiceProvider *caller)
{ {
HRESULT hres; HRESULT hres;
@ -362,17 +362,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, argc, argv, r, ei); hres = prop->u.p->invoke(This->ctx, &vthis, flags, argc, argv, r);
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, argc, argv, r, ei); hres = Function_invoke(This, jsthis, flags, argc, argv, r);
} }
return hres; return hres;
} }
case PROP_PROTREF: case PROP_PROTREF:
return invoke_prop_func(This->prototype, jsthis, This->prototype->props+prop->u.ref, return invoke_prop_func(This->prototype, jsthis, This->prototype->props+prop->u.ref,
flags, argc, argv, r, ei, caller); flags, argc, argv, r, caller);
case PROP_JSVAL: { case PROP_JSVAL: {
if(!is_object_instance(prop->u.val)) { if(!is_object_instance(prop->u.val)) {
FIXME("invoke %s\n", debugstr_jsval(prop->u.val)); FIXME("invoke %s\n", debugstr_jsval(prop->u.val));
@ -381,7 +381,7 @@ static HRESULT invoke_prop_func(jsdisp_t *This, IDispatch *jsthis, dispex_prop_t
TRACE("call %s %p\n", debugstr_w(prop->name), get_object(prop->u.val)); TRACE("call %s %p\n", debugstr_w(prop->name), get_object(prop->u.val));
return disp_call_value(This->ctx, get_object(prop->u.val), jsthis, flags, argc, argv, r, ei); return disp_call_value(This->ctx, get_object(prop->u.val), jsthis, flags, argc, argv, r);
} }
default: default:
ERR("type %d\n", prop->type); ERR("type %d\n", prop->type);
@ -391,7 +391,7 @@ static HRESULT invoke_prop_func(jsdisp_t *This, IDispatch *jsthis, dispex_prop_t
} }
static HRESULT prop_get(jsdisp_t *This, dispex_prop_t *prop, DISPPARAMS *dp, static HRESULT prop_get(jsdisp_t *This, dispex_prop_t *prop, DISPPARAMS *dp,
jsval_t *r, jsexcept_t *ei, IServiceProvider *caller) jsval_t *r, IServiceProvider *caller)
{ {
HRESULT hres; HRESULT hres;
@ -413,12 +413,12 @@ 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, 0, NULL, r, ei); hres = prop->u.p->invoke(This->ctx, &vthis, DISPATCH_PROPERTYGET, 0, NULL, r);
vdisp_release(&vthis); vdisp_release(&vthis);
} }
break; break;
case PROP_PROTREF: case PROP_PROTREF:
hres = prop_get(This->prototype, This->prototype->props+prop->u.ref, dp, r, ei, caller); hres = prop_get(This->prototype, This->prototype->props+prop->u.ref, dp, r, caller);
break; break;
case PROP_JSVAL: case PROP_JSVAL:
hres = jsval_copy(prop->u.val, r); hres = jsval_copy(prop->u.val, r);
@ -437,8 +437,7 @@ static HRESULT prop_get(jsdisp_t *This, dispex_prop_t *prop, DISPPARAMS *dp,
return hres; return hres;
} }
static HRESULT prop_put(jsdisp_t *This, dispex_prop_t *prop, jsval_t val, static HRESULT prop_put(jsdisp_t *This, dispex_prop_t *prop, jsval_t val, IServiceProvider *caller)
jsexcept_t *ei, IServiceProvider *caller)
{ {
HRESULT hres; HRESULT hres;
@ -451,7 +450,7 @@ static HRESULT prop_put(jsdisp_t *This, dispex_prop_t *prop, jsval_t val,
vdisp_t vthis; vdisp_t vthis;
set_jsdisp(&vthis, This); set_jsdisp(&vthis, This);
hres = prop->u.p->invoke(This->ctx, &vthis, DISPATCH_PROPERTYPUT, 1, &val, NULL, ei); hres = prop->u.p->invoke(This->ctx, &vthis, DISPATCH_PROPERTYPUT, 1, &val, NULL);
vdisp_release(&vthis); vdisp_release(&vthis);
return hres; return hres;
} }
@ -655,7 +654,6 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc
{ {
jsdisp_t *This = impl_from_IDispatchEx(iface); jsdisp_t *This = impl_from_IDispatchEx(iface);
dispex_prop_t *prop; dispex_prop_t *prop;
jsexcept_t jsexcept;
HRESULT hres; HRESULT hres;
TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller); TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
@ -669,7 +667,7 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc
return DISP_E_MEMBERNOTFOUND; return DISP_E_MEMBERNOTFOUND;
} }
memset(&jsexcept, 0, sizeof(jsexcept)); clear_ei(This->ctx);
switch(wFlags) { switch(wFlags) {
case DISPATCH_METHOD|DISPATCH_PROPERTYGET: case DISPATCH_METHOD|DISPATCH_PROPERTYGET:
@ -684,7 +682,7 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
hres = invoke_prop_func(This, get_this(pdp), prop, wFlags, argc, argv, pvarRes ? &r : NULL, &jsexcept, pspCaller); hres = invoke_prop_func(This, get_this(pdp), prop, wFlags, argc, argv, pvarRes ? &r : NULL, pspCaller);
if(argv != buf) if(argv != buf)
heap_free(argv); heap_free(argv);
if(SUCCEEDED(hres) && pvarRes) { if(SUCCEEDED(hres) && pvarRes) {
@ -696,7 +694,7 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc
case DISPATCH_PROPERTYGET: { case DISPATCH_PROPERTYGET: {
jsval_t r; jsval_t r;
hres = prop_get(This, prop, pdp, &r, &jsexcept, pspCaller); hres = prop_get(This, prop, pdp, &r, pspCaller);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
hres = jsval_to_variant(r, pvarRes); hres = jsval_to_variant(r, pvarRes);
jsval_release(r); jsval_release(r);
@ -721,7 +719,7 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
hres = prop_put(This, prop, val, &jsexcept, pspCaller); hres = prop_put(This, prop, val, pspCaller);
jsval_release(val); jsval_release(val);
break; break;
} }
@ -731,8 +729,7 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc
} }
if(pei) if(pei)
*pei = jsexcept.ei; *pei = This->ctx->ei.ei;
return hres; return hres;
} }
@ -942,11 +939,9 @@ HRESULT init_dispex_from_constr(jsdisp_t *dispex, script_ctx_t *ctx, const built
hres = find_prop_name_prot(constr, string_hash(prototypeW), prototypeW, &prop); hres = find_prop_name_prot(constr, string_hash(prototypeW), prototypeW, &prop);
if(SUCCEEDED(hres) && prop && prop->type!=PROP_DELETED) { if(SUCCEEDED(hres) && prop && prop->type!=PROP_DELETED) {
jsexcept_t jsexcept;
jsval_t val; jsval_t val;
memset(&jsexcept, 0, sizeof(jsexcept)); hres = prop_get(constr, prop, NULL, &val, NULL);
hres = prop_get(constr, prop, NULL, &val, &jsexcept, NULL/*FIXME*/);
if(FAILED(hres)) { if(FAILED(hres)) {
ERR("Could not get prototype\n"); ERR("Could not get prototype\n");
return hres; return hres;
@ -997,24 +992,23 @@ 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, unsigned argc, jsval_t *argv, jsval_t *r, HRESULT jsdisp_call_value(jsdisp_t *jsfunc, IDispatch *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
jsexcept_t *ei)
{ {
HRESULT hres; HRESULT hres;
if(is_class(jsfunc, JSCLASS_FUNCTION)) { if(is_class(jsfunc, JSCLASS_FUNCTION)) {
hres = Function_invoke(jsfunc, jsthis, flags, argc, argv, r, ei); hres = Function_invoke(jsfunc, jsthis, flags, argc, argv, r);
}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, argc, argv, r, ei); hres = jsfunc->builtin_info->value_prop.invoke(jsfunc->ctx, &vdisp, flags, argc, argv, r);
vdisp_release(&vdisp); vdisp_release(&vdisp);
} }
return hres; return hres;
} }
HRESULT jsdisp_call(jsdisp_t *disp, DISPID id, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) HRESULT jsdisp_call(jsdisp_t *disp, DISPID id, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
{ {
dispex_prop_t *prop; dispex_prop_t *prop;
@ -1022,12 +1016,10 @@ HRESULT jsdisp_call(jsdisp_t *disp, DISPID id, WORD flags, unsigned argc, jsval_
if(!prop) if(!prop)
return DISP_E_MEMBERNOTFOUND; return DISP_E_MEMBERNOTFOUND;
memset(ei, 0, sizeof(*ei)); return invoke_prop_func(disp, to_disp(disp), prop, flags, argc, argv, r, NULL);
return invoke_prop_func(disp, to_disp(disp), prop, flags, argc, argv, r, ei, NULL);
} }
HRESULT jsdisp_call_name(jsdisp_t *disp, const WCHAR *name, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r, HRESULT jsdisp_call_name(jsdisp_t *disp, const WCHAR *name, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
jsexcept_t *ei)
{ {
dispex_prop_t *prop; dispex_prop_t *prop;
HRESULT hres; HRESULT hres;
@ -1036,12 +1028,10 @@ HRESULT jsdisp_call_name(jsdisp_t *disp, const WCHAR *name, WORD flags, unsigned
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
memset(ei, 0, sizeof(*ei)); return invoke_prop_func(disp, to_disp(disp), prop, flags, argc, argv, r, NULL);
return invoke_prop_func(disp, to_disp(disp), prop, flags, argc, argv, r, ei, NULL);
} }
HRESULT disp_call(script_ctx_t *ctx, IDispatch *disp, DISPID id, WORD flags, unsigned argc, jsval_t *argv, HRESULT disp_call(script_ctx_t *ctx, IDispatch *disp, DISPID id, WORD flags, unsigned argc, jsval_t *argv, jsval_t *ret)
jsval_t *ret, jsexcept_t *ei)
{ {
IDispatchEx *dispex; IDispatchEx *dispex;
jsdisp_t *jsdisp; jsdisp_t *jsdisp;
@ -1057,12 +1047,11 @@ HRESULT disp_call(script_ctx_t *ctx, IDispatch *disp, DISPID id, WORD flags, uns
return E_FAIL; return E_FAIL;
} }
hres = jsdisp_call(jsdisp, id, flags, argc, argv, ret, ei); hres = jsdisp_call(jsdisp, id, flags, argc, argv, ret);
jsdisp_release(jsdisp); jsdisp_release(jsdisp);
return hres; return hres;
} }
memset(ei, 0, sizeof(*ei));
if(ret && argc) if(ret && argc)
flags |= DISPATCH_PROPERTYGET; flags |= DISPATCH_PROPERTYGET;
@ -1098,9 +1087,10 @@ HRESULT disp_call(script_ctx_t *ctx, IDispatch *disp, DISPID id, WORD flags, uns
} }
V_VT(&retv) = VT_EMPTY; V_VT(&retv) = VT_EMPTY;
clear_ei(ctx);
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, ret ? &retv : NULL, &ei->ei, hres = IDispatchEx_InvokeEx(dispex, id, ctx->lcid, flags, &dp, ret ? &retv : NULL, &ctx->ei.ei,
&ctx->jscaller->IServiceProvider_iface); &ctx->jscaller->IServiceProvider_iface);
IDispatchEx_Release(dispex); IDispatchEx_Release(dispex);
}else { }else {
@ -1112,7 +1102,7 @@ HRESULT disp_call(script_ctx_t *ctx, IDispatch *disp, DISPID id, WORD flags, uns
} }
TRACE("using IDispatch\n"); TRACE("using IDispatch\n");
hres = IDispatch_Invoke(disp, id, &IID_NULL, ctx->lcid, flags, &dp, ret ? &retv : NULL, &ei->ei, &err); hres = IDispatch_Invoke(disp, id, &IID_NULL, ctx->lcid, flags, &dp, ret ? &retv : NULL, &ctx->ei.ei, &err);
} }
for(i=0; i<argc; i++) for(i=0; i<argc; i++)
@ -1130,7 +1120,7 @@ HRESULT disp_call(script_ctx_t *ctx, IDispatch *disp, DISPID id, WORD flags, uns
} }
HRESULT disp_call_value(script_ctx_t *ctx, IDispatch *disp, IDispatch *jsthis, WORD flags, unsigned argc, jsval_t *argv, HRESULT disp_call_value(script_ctx_t *ctx, IDispatch *disp, IDispatch *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
jsdisp_t *jsdisp; jsdisp_t *jsdisp;
IDispatchEx *dispex; IDispatchEx *dispex;
@ -1146,12 +1136,11 @@ 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, argc, argv, r, ei); hres = jsdisp_call_value(jsdisp, jsthis, flags, argc, argv, r);
jsdisp_release(jsdisp); jsdisp_release(jsdisp);
return hres; return hres;
} }
memset(ei, 0, sizeof(*ei));
if(r && argc) if(r && argc)
flags |= DISPATCH_PROPERTYGET; flags |= DISPATCH_PROPERTYGET;
@ -1192,9 +1181,10 @@ HRESULT disp_call_value(script_ctx_t *ctx, IDispatch *disp, IDispatch *jsthis, W
} }
V_VT(&retv) = VT_EMPTY; V_VT(&retv) = VT_EMPTY;
clear_ei(ctx);
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, &dp, r ? &retv : NULL, &ei->ei, hres = IDispatchEx_InvokeEx(dispex, DISPID_VALUE, ctx->lcid, flags, &dp, r ? &retv : NULL, &ctx->ei.ei,
&ctx->jscaller->IServiceProvider_iface); &ctx->jscaller->IServiceProvider_iface);
IDispatchEx_Release(dispex); IDispatchEx_Release(dispex);
}else { }else {
@ -1206,7 +1196,7 @@ 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, &dp, r ? &retv : NULL, &ei->ei, &err); hres = IDispatch_Invoke(disp, DISPID_VALUE, &IID_NULL, ctx->lcid, flags, &dp, r ? &retv : NULL, &ctx->ei.ei, &err);
} }
for(i=0; i<argc; i++) for(i=0; i<argc; i++)
@ -1224,7 +1214,7 @@ HRESULT disp_call_value(script_ctx_t *ctx, IDispatch *disp, IDispatch *jsthis, W
return hres; return hres;
} }
HRESULT jsdisp_propput_name(jsdisp_t *obj, const WCHAR *name, jsval_t val, jsexcept_t *ei) HRESULT jsdisp_propput_name(jsdisp_t *obj, const WCHAR *name, jsval_t val)
{ {
dispex_prop_t *prop; dispex_prop_t *prop;
HRESULT hres; HRESULT hres;
@ -1233,7 +1223,7 @@ HRESULT jsdisp_propput_name(jsdisp_t *obj, const WCHAR *name, jsval_t val, jsexc
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
return prop_put(obj, prop, val, ei, NULL); return prop_put(obj, prop, val, NULL);
} }
HRESULT jsdisp_propput_const(jsdisp_t *obj, const WCHAR *name, jsval_t val) HRESULT jsdisp_propput_const(jsdisp_t *obj, const WCHAR *name, jsval_t val)
@ -1260,17 +1250,17 @@ HRESULT jsdisp_propput_dontenum(jsdisp_t *obj, const WCHAR *name, jsval_t val)
return jsval_copy(val, &prop->u.val); return jsval_copy(val, &prop->u.val);
} }
HRESULT jsdisp_propput_idx(jsdisp_t *obj, DWORD idx, jsval_t val, jsexcept_t *ei) HRESULT jsdisp_propput_idx(jsdisp_t *obj, DWORD idx, jsval_t val)
{ {
WCHAR buf[12]; WCHAR buf[12];
static const WCHAR formatW[] = {'%','d',0}; static const WCHAR formatW[] = {'%','d',0};
sprintfW(buf, formatW, idx); sprintfW(buf, formatW, idx);
return jsdisp_propput_name(obj, buf, val, ei); return jsdisp_propput_name(obj, buf, val);
} }
HRESULT disp_propput(script_ctx_t *ctx, IDispatch *disp, DISPID id, jsval_t val, jsexcept_t *ei) HRESULT disp_propput(script_ctx_t *ctx, IDispatch *disp, DISPID id, jsval_t val)
{ {
jsdisp_t *jsdisp; jsdisp_t *jsdisp;
HRESULT hres; HRESULT hres;
@ -1281,7 +1271,7 @@ HRESULT disp_propput(script_ctx_t *ctx, IDispatch *disp, DISPID id, jsval_t val,
prop = get_prop(jsdisp, id); prop = get_prop(jsdisp, id);
if(prop) if(prop)
hres = prop_put(jsdisp, prop, val, ei, NULL); hres = prop_put(jsdisp, prop, val, NULL);
else else
hres = DISP_E_MEMBERNOTFOUND; hres = DISP_E_MEMBERNOTFOUND;
@ -1296,16 +1286,17 @@ HRESULT disp_propput(script_ctx_t *ctx, IDispatch *disp, DISPID id, jsval_t val,
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
clear_ei(ctx);
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, DISPATCH_PROPERTYPUT, &dp, NULL, &ei->ei, hres = IDispatchEx_InvokeEx(dispex, id, ctx->lcid, DISPATCH_PROPERTYPUT, &dp, NULL, &ctx->ei.ei,
&ctx->jscaller->IServiceProvider_iface); &ctx->jscaller->IServiceProvider_iface);
IDispatchEx_Release(dispex); IDispatchEx_Release(dispex);
}else { }else {
ULONG err = 0; ULONG err = 0;
TRACE("using IDispatch\n"); TRACE("using IDispatch\n");
hres = IDispatch_Invoke(disp, id, &IID_NULL, ctx->lcid, DISPATCH_PROPERTYPUT, &dp, NULL, &ei->ei, &err); hres = IDispatch_Invoke(disp, id, &IID_NULL, ctx->lcid, DISPATCH_PROPERTYPUT, &dp, NULL, &ctx->ei.ei, &err);
} }
VariantClear(&var); VariantClear(&var);
@ -1314,7 +1305,7 @@ HRESULT disp_propput(script_ctx_t *ctx, IDispatch *disp, DISPID id, jsval_t val,
return hres; return hres;
} }
HRESULT jsdisp_propget_name(jsdisp_t *obj, const WCHAR *name, jsval_t *val, jsexcept_t *ei) HRESULT jsdisp_propget_name(jsdisp_t *obj, const WCHAR *name, jsval_t *val)
{ {
DISPPARAMS dp = {NULL, NULL, 0, 0}; DISPPARAMS dp = {NULL, NULL, 0, 0};
dispex_prop_t *prop; dispex_prop_t *prop;
@ -1329,10 +1320,10 @@ HRESULT jsdisp_propget_name(jsdisp_t *obj, const WCHAR *name, jsval_t *val, jsex
return S_OK; return S_OK;
} }
return prop_get(obj, prop, &dp, val, ei, NULL); return prop_get(obj, prop, &dp, val, NULL);
} }
HRESULT jsdisp_get_idx(jsdisp_t *obj, DWORD idx, jsval_t *r, jsexcept_t *ei) HRESULT jsdisp_get_idx(jsdisp_t *obj, DWORD idx, jsval_t *r)
{ {
WCHAR name[12]; WCHAR name[12];
DISPPARAMS dp = {NULL, NULL, 0, 0}; DISPPARAMS dp = {NULL, NULL, 0, 0};
@ -1352,10 +1343,10 @@ HRESULT jsdisp_get_idx(jsdisp_t *obj, DWORD idx, jsval_t *r, jsexcept_t *ei)
return DISP_E_UNKNOWNNAME; return DISP_E_UNKNOWNNAME;
} }
return prop_get(obj, prop, &dp, r, ei, NULL); return prop_get(obj, prop, &dp, r, NULL);
} }
HRESULT jsdisp_propget(jsdisp_t *jsdisp, DISPID id, jsval_t *val, jsexcept_t *ei) HRESULT jsdisp_propget(jsdisp_t *jsdisp, DISPID id, jsval_t *val)
{ {
DISPPARAMS dp = {NULL,NULL,0,0}; DISPPARAMS dp = {NULL,NULL,0,0};
dispex_prop_t *prop; dispex_prop_t *prop;
@ -1364,10 +1355,10 @@ HRESULT jsdisp_propget(jsdisp_t *jsdisp, DISPID id, jsval_t *val, jsexcept_t *ei
if(!prop) if(!prop)
return DISP_E_MEMBERNOTFOUND; return DISP_E_MEMBERNOTFOUND;
return prop_get(jsdisp, prop, &dp, val, ei, NULL); return prop_get(jsdisp, prop, &dp, val, NULL);
} }
HRESULT disp_propget(script_ctx_t *ctx, IDispatch *disp, DISPID id, jsval_t *val, jsexcept_t *ei) HRESULT disp_propget(script_ctx_t *ctx, IDispatch *disp, DISPID id, jsval_t *val)
{ {
DISPPARAMS dp = {NULL,NULL,0,0}; DISPPARAMS dp = {NULL,NULL,0,0};
IDispatchEx *dispex; IDispatchEx *dispex;
@ -1377,22 +1368,23 @@ HRESULT disp_propget(script_ctx_t *ctx, IDispatch *disp, DISPID id, jsval_t *val
jsdisp = iface_to_jsdisp((IUnknown*)disp); jsdisp = iface_to_jsdisp((IUnknown*)disp);
if(jsdisp) { if(jsdisp) {
hres = jsdisp_propget(jsdisp, id, val, ei); hres = jsdisp_propget(jsdisp, id, val);
jsdisp_release(jsdisp); jsdisp_release(jsdisp);
return hres; return hres;
} }
V_VT(&var) = VT_EMPTY; V_VT(&var) = VT_EMPTY;
clear_ei(ctx);
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, INVOKE_PROPERTYGET, &dp, &var, &ei->ei, hres = IDispatchEx_InvokeEx(dispex, id, ctx->lcid, INVOKE_PROPERTYGET, &dp, &var, &ctx->ei.ei,
&ctx->jscaller->IServiceProvider_iface); &ctx->jscaller->IServiceProvider_iface);
IDispatchEx_Release(dispex); IDispatchEx_Release(dispex);
}else { }else {
ULONG err = 0; ULONG err = 0;
TRACE("using IDispatch\n"); TRACE("using IDispatch\n");
hres = IDispatch_Invoke(disp, id, &IID_NULL, ctx->lcid, INVOKE_PROPERTYGET, &dp, &var, &ei->ei, &err); hres = IDispatch_Invoke(disp, id, &IID_NULL, ctx->lcid, INVOKE_PROPERTYGET, &dp, &var, &ctx->ei.ei, &err);
} }
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;

View File

@ -130,7 +130,7 @@ static HRESULT stack_pop_number(exec_ctx_t *ctx, double *r)
HRESULT hres; HRESULT hres;
v = stack_pop(ctx); v = stack_pop(ctx);
hres = to_number(ctx->script, v, ctx->ei, r); hres = to_number(ctx->script, v, r);
jsval_release(v); jsval_release(v);
return hres; return hres;
} }
@ -143,7 +143,7 @@ static HRESULT stack_pop_object(exec_ctx_t *ctx, IDispatch **r)
v = stack_pop(ctx); v = stack_pop(ctx);
if(is_object_instance(v)) { if(is_object_instance(v)) {
if(!get_object(v)) if(!get_object(v))
return throw_type_error(ctx->script, ctx->ei, JS_E_OBJECT_REQUIRED, NULL); return throw_type_error(ctx->script, JS_E_OBJECT_REQUIRED, NULL);
*r = get_object(v); *r = get_object(v);
return S_OK; return S_OK;
} }
@ -155,12 +155,12 @@ static HRESULT stack_pop_object(exec_ctx_t *ctx, IDispatch **r)
static inline HRESULT stack_pop_int(exec_ctx_t *ctx, INT *r) static inline HRESULT stack_pop_int(exec_ctx_t *ctx, INT *r)
{ {
return to_int32(ctx->script, stack_pop(ctx), ctx->ei, r); return to_int32(ctx->script, stack_pop(ctx), r);
} }
static inline HRESULT stack_pop_uint(exec_ctx_t *ctx, DWORD *r) static inline HRESULT stack_pop_uint(exec_ctx_t *ctx, DWORD *r)
{ {
return to_uint32(ctx->script, stack_pop(ctx), ctx->ei, r); return to_uint32(ctx->script, stack_pop(ctx), r);
} }
static inline IDispatch *stack_pop_objid(exec_ctx_t *ctx, DISPID *id) static inline IDispatch *stack_pop_objid(exec_ctx_t *ctx, DISPID *id)
@ -195,7 +195,7 @@ static void exprval_release(exprval_t *val)
} }
/* ECMA-262 3rd Edition 8.7.1 */ /* ECMA-262 3rd Edition 8.7.1 */
static HRESULT exprval_to_value(script_ctx_t *ctx, exprval_t *val, jsexcept_t *ei, jsval_t *ret) static HRESULT exprval_to_value(script_ctx_t *ctx, exprval_t *val, jsval_t *ret)
{ {
switch(val->type) { switch(val->type) {
case EXPRVAL_JSVAL: case EXPRVAL_JSVAL:
@ -208,7 +208,7 @@ static HRESULT exprval_to_value(script_ctx_t *ctx, exprval_t *val, jsexcept_t *e
return E_FAIL; return E_FAIL;
} }
return disp_propget(ctx, val->u.idref.disp, val->u.idref.id, ret, ei); return disp_propget(ctx, val->u.idref.disp, val->u.idref.id, ret);
case EXPRVAL_INVALID: case EXPRVAL_INVALID:
assert(0); assert(0);
} }
@ -261,6 +261,13 @@ static void scope_pop(scope_chain_t **scope)
scope_release(tmp); scope_release(tmp);
} }
void clear_ei(script_ctx_t *ctx)
{
memset(&ctx->ei.ei, 0, sizeof(ctx->ei.ei));
jsval_release(ctx->ei.val);
ctx->ei.val = jsval_undefined();
}
void scope_release(scope_chain_t *scope) void scope_release(scope_chain_t *scope)
{ {
if(--scope->ref) if(--scope->ref)
@ -551,7 +558,7 @@ static HRESULT interp_var_set(exec_ctx_t *ctx)
TRACE("%s\n", debugstr_w(name)); TRACE("%s\n", debugstr_w(name));
val = stack_pop(ctx); val = stack_pop(ctx);
hres = jsdisp_propput_name(ctx->var_disp, name, val, ctx->ei); hres = jsdisp_propput_name(ctx->var_disp, name, val);
jsval_release(val); jsval_release(val);
return hres; return hres;
} }
@ -605,7 +612,7 @@ static HRESULT interp_forin(exec_ctx_t *ctx)
stack_pop(ctx); stack_pop(ctx);
stack_push(ctx, jsval_number(id)); /* safe, just after pop() */ stack_push(ctx, jsval_number(id)); /* safe, just after pop() */
hres = disp_propput(ctx->script, var_obj, var_id, jsval_string(name), ctx->ei); hres = disp_propput(ctx->script, var_obj, var_id, jsval_string(name));
SysFreeString(name); SysFreeString(name);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -678,6 +685,7 @@ static HRESULT interp_throw(exec_ctx_t *ctx)
{ {
TRACE("\n"); TRACE("\n");
jsval_release(ctx->ei->val);
ctx->ei->val = stack_pop(ctx); ctx->ei->val = stack_pop(ctx);
return DISP_E_EXCEPTION; return DISP_E_EXCEPTION;
} }
@ -688,7 +696,7 @@ static HRESULT interp_throw_ref(exec_ctx_t *ctx)
TRACE("%08x\n", arg); TRACE("%08x\n", arg);
return throw_reference_error(ctx->script, ctx->ei, arg, NULL); return throw_reference_error(ctx->script, arg, NULL);
} }
static HRESULT interp_throw_type(exec_ctx_t *ctx) static HRESULT interp_throw_type(exec_ctx_t *ctx)
@ -698,7 +706,7 @@ static HRESULT interp_throw_type(exec_ctx_t *ctx)
TRACE("%08x %s\n", hres, debugstr_w(str)); TRACE("%08x %s\n", hres, debugstr_w(str));
return throw_type_error(ctx->script, ctx->ei, hres, str); return throw_type_error(ctx->script, hres, str);
} }
/* ECMA-262 3rd Edition 12.14 */ /* ECMA-262 3rd Edition 12.14 */
@ -814,7 +822,7 @@ static HRESULT interp_array(exec_ctx_t *ctx)
return hres; return hres;
} }
hres = to_string(ctx->script, namev, ctx->ei, &name); hres = to_string(ctx->script, namev, &name);
jsval_release(namev); jsval_release(namev);
if(FAILED(hres)) { if(FAILED(hres)) {
IDispatch_Release(obj); IDispatch_Release(obj);
@ -824,7 +832,7 @@ static HRESULT interp_array(exec_ctx_t *ctx)
hres = disp_get_id(ctx->script, obj, name, 0, &id); hres = disp_get_id(ctx->script, obj, name, 0, &id);
SysFreeString(name); SysFreeString(name);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
hres = disp_propget(ctx->script, obj, id, &v, ctx->ei); hres = disp_propget(ctx->script, obj, id, &v);
}else if(hres == DISP_E_UNKNOWNNAME) { }else if(hres == DISP_E_UNKNOWNNAME) {
v = jsval_undefined(); v = jsval_undefined();
hres = S_OK; hres = S_OK;
@ -853,7 +861,7 @@ static HRESULT interp_member(exec_ctx_t *ctx)
hres = disp_get_id(ctx->script, obj, arg, 0, &id); hres = disp_get_id(ctx->script, obj, arg, 0, &id);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
hres = disp_propget(ctx->script, obj, id, &v, ctx->ei); hres = disp_propget(ctx->script, obj, id, &v);
}else if(hres == DISP_E_UNKNOWNNAME) { }else if(hres == DISP_E_UNKNOWNNAME) {
v = jsval_undefined(); v = jsval_undefined();
hres = S_OK; hres = S_OK;
@ -883,7 +891,7 @@ static HRESULT interp_memberid(exec_ctx_t *ctx)
hres = to_object(ctx->script, objv, &obj); hres = to_object(ctx->script, objv, &obj);
jsval_release(objv); jsval_release(objv);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
hres = to_string(ctx->script, namev, ctx->ei, &name); hres = to_string(ctx->script, namev, &name);
if(FAILED(hres)) if(FAILED(hres))
IDispatch_Release(obj); IDispatch_Release(obj);
} }
@ -919,9 +927,9 @@ static HRESULT interp_refval(exec_ctx_t *ctx)
disp = stack_topn_objid(ctx, 0, &id); disp = stack_topn_objid(ctx, 0, &id);
if(!disp) if(!disp)
return throw_reference_error(ctx->script, ctx->ei, JS_E_ILLEGAL_ASSIGN, NULL); return throw_reference_error(ctx->script, JS_E_ILLEGAL_ASSIGN, NULL);
hres = disp_propget(ctx->script, disp, id, &v, ctx->ei); hres = disp_propget(ctx->script, disp, id, &v);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -942,13 +950,13 @@ static HRESULT interp_new(exec_ctx_t *ctx)
/* NOTE: Should use to_object here */ /* NOTE: Should use to_object here */
if(is_null(constr)) if(is_null(constr))
return throw_type_error(ctx->script, ctx->ei, JS_E_OBJECT_EXPECTED, NULL); return throw_type_error(ctx->script, JS_E_OBJECT_EXPECTED, NULL);
else if(!is_object_instance(constr)) else if(!is_object_instance(constr))
return throw_type_error(ctx->script, ctx->ei, JS_E_INVALID_ACTION, NULL); return throw_type_error(ctx->script, JS_E_INVALID_ACTION, NULL);
else if(!get_object(constr)) else if(!get_object(constr))
return throw_type_error(ctx->script, ctx->ei, JS_E_INVALID_PROPERTY, NULL); return throw_type_error(ctx->script, JS_E_INVALID_PROPERTY, NULL);
hres = disp_call_value(ctx->script, get_object(constr), NULL, DISPATCH_CONSTRUCT, argc, stack_args(ctx, argc), &r, ctx->ei); hres = disp_call_value(ctx->script, get_object(constr), NULL, DISPATCH_CONSTRUCT, argc, stack_args(ctx, argc), &r);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -968,10 +976,10 @@ static HRESULT interp_call(exec_ctx_t *ctx)
obj = stack_topn(ctx, argn); obj = stack_topn(ctx, argn);
if(!is_object_instance(obj)) if(!is_object_instance(obj))
return throw_type_error(ctx->script, ctx->ei, JS_E_INVALID_PROPERTY, NULL); return throw_type_error(ctx->script, JS_E_INVALID_PROPERTY, NULL);
hres = disp_call_value(ctx->script, get_object(obj), NULL, DISPATCH_METHOD, argn, stack_args(ctx, argn), hres = disp_call_value(ctx->script, get_object(obj), NULL, DISPATCH_METHOD, argn, stack_args(ctx, argn),
do_ret ? &r : NULL, ctx->ei); do_ret ? &r : NULL);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -993,9 +1001,9 @@ static HRESULT interp_call_member(exec_ctx_t *ctx)
obj = stack_topn_objid(ctx, argn, &id); obj = stack_topn_objid(ctx, argn, &id);
if(!obj) if(!obj)
return throw_type_error(ctx->script, ctx->ei, id, NULL); return throw_type_error(ctx->script, id, NULL);
hres = disp_call(ctx->script, obj, id, DISPATCH_METHOD, argn, stack_args(ctx, argn), do_ret ? &r : NULL, ctx->ei); hres = disp_call(ctx->script, obj, id, DISPATCH_METHOD, argn, stack_args(ctx, argn), do_ret ? &r : NULL);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -1028,9 +1036,9 @@ static HRESULT interp_ident(exec_ctx_t *ctx)
return hres; return hres;
if(exprval.type == EXPRVAL_INVALID) if(exprval.type == EXPRVAL_INVALID)
return throw_type_error(ctx->script, ctx->ei, JS_E_UNDEFINED_VARIABLE, arg); return throw_type_error(ctx->script, JS_E_UNDEFINED_VARIABLE, arg);
hres = exprval_to_value(ctx->script, &exprval, ctx->ei, &v); hres = exprval_to_value(ctx->script, &exprval, &v);
exprval_release(&exprval); exprval_release(&exprval);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -1159,7 +1167,7 @@ static HRESULT interp_carray(exec_ctx_t *ctx)
i = arg; i = arg;
while(i--) { while(i--) {
val = stack_pop(ctx); val = stack_pop(ctx);
hres = jsdisp_propput_idx(array, i, val, ctx->ei); hres = jsdisp_propput_idx(array, i, val);
jsval_release(val); jsval_release(val);
if(FAILED(hres)) { if(FAILED(hres)) {
jsdisp_release(array); jsdisp_release(array);
@ -1200,7 +1208,7 @@ static HRESULT interp_obj_prop(exec_ctx_t *ctx)
assert(is_object_instance(stack_top(ctx))); assert(is_object_instance(stack_top(ctx)));
obj = as_jsdisp(get_object(stack_top(ctx))); obj = as_jsdisp(get_object(stack_top(ctx)));
hres = jsdisp_propput_name(obj, name, val, ctx->ei); hres = jsdisp_propput_name(obj, name, val);
jsval_release(val); jsval_release(val);
return hres; return hres;
} }
@ -1319,7 +1327,7 @@ static HRESULT interp_instanceof(exec_ctx_t *ctx)
v = stack_pop(ctx); v = stack_pop(ctx);
if(!is_object_instance(v) || !get_object(v)) { if(!is_object_instance(v) || !get_object(v)) {
jsval_release(v); jsval_release(v);
return throw_type_error(ctx->script, ctx->ei, JS_E_FUNCTION_EXPECTED, NULL); return throw_type_error(ctx->script, JS_E_FUNCTION_EXPECTED, NULL);
} }
obj = iface_to_jsdisp((IUnknown*)get_object(v)); obj = iface_to_jsdisp((IUnknown*)get_object(v));
@ -1330,9 +1338,9 @@ static HRESULT interp_instanceof(exec_ctx_t *ctx)
} }
if(is_class(obj, JSCLASS_FUNCTION)) { if(is_class(obj, JSCLASS_FUNCTION)) {
hres = jsdisp_propget_name(obj, prototypeW, &prot, ctx->ei); hres = jsdisp_propget_name(obj, prototypeW, &prot);
}else { }else {
hres = throw_type_error(ctx->script, ctx->ei, JS_E_FUNCTION_EXPECTED, NULL); hres = throw_type_error(ctx->script, JS_E_FUNCTION_EXPECTED, NULL);
} }
jsdisp_release(obj); jsdisp_release(obj);
if(FAILED(hres)) if(FAILED(hres))
@ -1378,11 +1386,11 @@ static HRESULT interp_in(exec_ctx_t *ctx)
obj = stack_pop(ctx); obj = stack_pop(ctx);
if(!is_object_instance(obj) || !get_object(obj)) { if(!is_object_instance(obj) || !get_object(obj)) {
jsval_release(obj); jsval_release(obj);
return throw_type_error(ctx->script, ctx->ei, JS_E_OBJECT_EXPECTED, NULL); return throw_type_error(ctx->script, JS_E_OBJECT_EXPECTED, NULL);
} }
v = stack_pop(ctx); v = stack_pop(ctx);
hres = to_string(ctx->script, v, ctx->ei, &str); hres = to_string(ctx->script, v, &str);
jsval_release(v); jsval_release(v);
if(FAILED(hres)) { if(FAILED(hres)) {
IDispatch_Release(get_object(obj)); IDispatch_Release(get_object(obj));
@ -1403,16 +1411,16 @@ static HRESULT interp_in(exec_ctx_t *ctx)
} }
/* ECMA-262 3rd Edition 11.6.1 */ /* ECMA-262 3rd Edition 11.6.1 */
static HRESULT add_eval(script_ctx_t *ctx, jsval_t lval, jsval_t rval, jsexcept_t *ei, jsval_t *ret) static HRESULT add_eval(script_ctx_t *ctx, jsval_t lval, jsval_t rval, jsval_t *ret)
{ {
jsval_t r, l; jsval_t r, l;
HRESULT hres; HRESULT hres;
hres = to_primitive(ctx, lval, ei, &l, NO_HINT); hres = to_primitive(ctx, lval, &l, NO_HINT);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
hres = to_primitive(ctx, rval, ei, &r, NO_HINT); hres = to_primitive(ctx, rval, &r, NO_HINT);
if(FAILED(hres)) { if(FAILED(hres)) {
jsval_release(l); jsval_release(l);
return hres; return hres;
@ -1424,13 +1432,13 @@ static HRESULT add_eval(script_ctx_t *ctx, jsval_t lval, jsval_t rval, jsexcept_
if(is_string(l)) if(is_string(l))
lstr = get_string(l); lstr = get_string(l);
else else
hres = to_string(ctx, l, ei, &lstr); hres = to_string(ctx, l, &lstr);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
if(is_string(r)) if(is_string(r))
rstr = get_string(r); rstr = get_string(r);
else else
hres = to_string(ctx, r, ei, &rstr); hres = to_string(ctx, r, &rstr);
} }
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
@ -1456,9 +1464,9 @@ static HRESULT add_eval(script_ctx_t *ctx, jsval_t lval, jsval_t rval, jsexcept_
}else { }else {
double nl, nr; double nl, nr;
hres = to_number(ctx, l, ei, &nl); hres = to_number(ctx, l, &nl);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
hres = to_number(ctx, r, ei, &nr); hres = to_number(ctx, r, &nr);
if(SUCCEEDED(hres)) if(SUCCEEDED(hres))
*ret = jsval_number(nl+nr); *ret = jsval_number(nl+nr);
} }
@ -1480,7 +1488,7 @@ static HRESULT interp_add(exec_ctx_t *ctx)
TRACE("%s + %s\n", debugstr_jsval(l), debugstr_jsval(r)); TRACE("%s + %s\n", debugstr_jsval(l), debugstr_jsval(r));
hres = add_eval(ctx->script, l, r, ctx->ei, &ret); hres = add_eval(ctx->script, l, r, &ret);
jsval_release(l); jsval_release(l);
jsval_release(r); jsval_release(r);
if(FAILED(hres)) if(FAILED(hres))
@ -1587,7 +1595,7 @@ static HRESULT interp_delete(exec_ctx_t *ctx)
return hres; return hres;
} }
hres = to_string(ctx->script, namev, ctx->ei, &name); hres = to_string(ctx->script, namev, &name);
jsval_release(namev); jsval_release(namev);
if(FAILED(hres)) { if(FAILED(hres)) {
IDispatch_Release(obj); IDispatch_Release(obj);
@ -1711,7 +1719,7 @@ static HRESULT interp_typeofid(exec_ctx_t *ctx)
if(!obj) if(!obj)
return stack_push_string(ctx, undefinedW); return stack_push_string(ctx, undefinedW);
hres = disp_propget(ctx->script, obj, id, &v, ctx->ei); hres = disp_propget(ctx->script, obj, id, &v);
IDispatch_Release(obj); IDispatch_Release(obj);
if(FAILED(hres)) if(FAILED(hres))
return stack_push_string(ctx, unknownW); return stack_push_string(ctx, unknownW);
@ -1745,7 +1753,7 @@ static HRESULT interp_typeofident(exec_ctx_t *ctx)
return hres; return hres;
} }
hres = exprval_to_value(ctx->script, &exprval, ctx->ei, &v); hres = exprval_to_value(ctx->script, &exprval, &v);
exprval_release(&exprval); exprval_release(&exprval);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -1801,7 +1809,7 @@ static HRESULT interp_tonum(exec_ctx_t *ctx)
TRACE("\n"); TRACE("\n");
v = stack_pop(ctx); v = stack_pop(ctx);
hres = to_number(ctx->script, v, ctx->ei, &n); hres = to_number(ctx->script, v, &n);
jsval_release(v); jsval_release(v);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -1822,15 +1830,15 @@ static HRESULT interp_postinc(exec_ctx_t *ctx)
obj = stack_pop_objid(ctx, &id); obj = stack_pop_objid(ctx, &id);
if(!obj) if(!obj)
return throw_type_error(ctx->script, ctx->ei, JS_E_OBJECT_EXPECTED, NULL); return throw_type_error(ctx->script, JS_E_OBJECT_EXPECTED, NULL);
hres = disp_propget(ctx->script, obj, id, &v, ctx->ei); hres = disp_propget(ctx->script, obj, id, &v);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
double n; double n;
hres = to_number(ctx->script, v, ctx->ei, &n); hres = to_number(ctx->script, v, &n);
if(SUCCEEDED(hres)) if(SUCCEEDED(hres))
hres = disp_propput(ctx->script, obj, id, jsval_number(n+(double)arg), ctx->ei); hres = disp_propput(ctx->script, obj, id, jsval_number(n+(double)arg));
if(FAILED(hres)) if(FAILED(hres))
jsval_release(v); jsval_release(v);
} }
@ -1855,17 +1863,17 @@ static HRESULT interp_preinc(exec_ctx_t *ctx)
obj = stack_pop_objid(ctx, &id); obj = stack_pop_objid(ctx, &id);
if(!obj) if(!obj)
return throw_type_error(ctx->script, ctx->ei, JS_E_OBJECT_EXPECTED, NULL); return throw_type_error(ctx->script, JS_E_OBJECT_EXPECTED, NULL);
hres = disp_propget(ctx->script, obj, id, &v, ctx->ei); hres = disp_propget(ctx->script, obj, id, &v);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
double n; double n;
hres = to_number(ctx->script, v, ctx->ei, &n); hres = to_number(ctx->script, v, &n);
jsval_release(v); jsval_release(v);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
ret = n+(double)arg; ret = n+(double)arg;
hres = disp_propput(ctx->script, obj, id, jsval_number(ret), ctx->ei); hres = disp_propput(ctx->script, obj, id, jsval_number(ret));
} }
} }
IDispatch_Release(obj); IDispatch_Release(obj);
@ -1876,16 +1884,16 @@ static HRESULT interp_preinc(exec_ctx_t *ctx)
} }
/* ECMA-262 3rd Edition 11.9.3 */ /* ECMA-262 3rd Edition 11.9.3 */
static HRESULT equal_values(script_ctx_t *ctx, jsval_t lval, jsval_t rval, jsexcept_t *ei, BOOL *ret) static HRESULT equal_values(script_ctx_t *ctx, jsval_t lval, jsval_t rval, BOOL *ret)
{ {
if(jsval_type(lval) == jsval_type(rval) || (is_number(lval) && is_number(rval))) if(jsval_type(lval) == jsval_type(rval) || (is_number(lval) && is_number(rval)))
return equal2_values(lval, rval, ret); return equal2_values(lval, rval, ret);
/* FIXME: NULL disps should be handled in more general way */ /* FIXME: NULL disps should be handled in more general way */
if(is_object_instance(lval) && !get_object(lval)) if(is_object_instance(lval) && !get_object(lval))
return equal_values(ctx, jsval_null(), rval, ei, ret); return equal_values(ctx, jsval_null(), rval, ret);
if(is_object_instance(rval) && !get_object(rval)) if(is_object_instance(rval) && !get_object(rval))
return equal_values(ctx, lval, jsval_null(), ei, ret); return equal_values(ctx, lval, jsval_null(), ret);
if((is_null(lval) && is_undefined(rval)) || (is_undefined(lval) && is_null(rval))) { if((is_null(lval) && is_undefined(rval)) || (is_undefined(lval) && is_null(rval))) {
*ret = TRUE; *ret = TRUE;
@ -1896,42 +1904,42 @@ static HRESULT equal_values(script_ctx_t *ctx, jsval_t lval, jsval_t rval, jsexc
double n; double n;
HRESULT hres; HRESULT hres;
hres = to_number(ctx, lval, ei, &n); hres = to_number(ctx, lval, &n);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
/* FIXME: optimize */ /* FIXME: optimize */
return equal_values(ctx, jsval_number(n), rval, ei, ret); return equal_values(ctx, jsval_number(n), rval, ret);
} }
if(is_string(rval) && is_number(lval)) { if(is_string(rval) && is_number(lval)) {
double n; double n;
HRESULT hres; HRESULT hres;
hres = to_number(ctx, rval, ei, &n); hres = to_number(ctx, rval, &n);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
/* FIXME: optimize */ /* FIXME: optimize */
return equal_values(ctx, lval, jsval_number(n), ei, ret); return equal_values(ctx, lval, jsval_number(n), ret);
} }
if(is_bool(rval)) if(is_bool(rval))
return equal_values(ctx, lval, jsval_number(get_bool(rval) ? 1 : 0), ei, ret); return equal_values(ctx, lval, jsval_number(get_bool(rval) ? 1 : 0), ret);
if(is_bool(lval)) if(is_bool(lval))
return equal_values(ctx, jsval_number(get_bool(lval) ? 1 : 0), rval, ei, ret); return equal_values(ctx, jsval_number(get_bool(lval) ? 1 : 0), rval, ret);
if(is_object_instance(rval) && (is_string(lval) || is_number(lval))) { if(is_object_instance(rval) && (is_string(lval) || is_number(lval))) {
jsval_t prim; jsval_t prim;
HRESULT hres; HRESULT hres;
hres = to_primitive(ctx, rval, ei, &prim, NO_HINT); hres = to_primitive(ctx, rval, &prim, NO_HINT);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
hres = equal_values(ctx, lval, prim, ei, ret); hres = equal_values(ctx, lval, prim, ret);
jsval_release(prim); jsval_release(prim);
return hres; return hres;
} }
@ -1941,11 +1949,11 @@ static HRESULT equal_values(script_ctx_t *ctx, jsval_t lval, jsval_t rval, jsexc
jsval_t prim; jsval_t prim;
HRESULT hres; HRESULT hres;
hres = to_primitive(ctx, lval, ei, &prim, NO_HINT); hres = to_primitive(ctx, lval, &prim, NO_HINT);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
hres = equal_values(ctx, prim, rval, ei, ret); hres = equal_values(ctx, prim, rval, ret);
jsval_release(prim); jsval_release(prim);
return hres; return hres;
} }
@ -1967,7 +1975,7 @@ static HRESULT interp_eq(exec_ctx_t *ctx)
TRACE("%s == %s\n", debugstr_jsval(l), debugstr_jsval(r)); TRACE("%s == %s\n", debugstr_jsval(l), debugstr_jsval(r));
hres = equal_values(ctx->script, l, r, ctx->ei, &b); hres = equal_values(ctx->script, l, r, &b);
jsval_release(l); jsval_release(l);
jsval_release(r); jsval_release(r);
if(FAILED(hres)) if(FAILED(hres))
@ -1988,7 +1996,7 @@ static HRESULT interp_neq(exec_ctx_t *ctx)
TRACE("%s != %s\n", debugstr_jsval(l), debugstr_jsval(r)); TRACE("%s != %s\n", debugstr_jsval(l), debugstr_jsval(r));
hres = equal_values(ctx->script, l, r, ctx->ei, &b); hres = equal_values(ctx->script, l, r, &b);
jsval_release(l); jsval_release(l);
jsval_release(r); jsval_release(r);
if(FAILED(hres)) if(FAILED(hres))
@ -2040,17 +2048,17 @@ static HRESULT interp_neq2(exec_ctx_t *ctx)
} }
/* ECMA-262 3rd Edition 11.8.5 */ /* ECMA-262 3rd Edition 11.8.5 */
static HRESULT less_eval(script_ctx_t *ctx, jsval_t lval, jsval_t rval, BOOL greater, jsexcept_t *ei, BOOL *ret) static HRESULT less_eval(script_ctx_t *ctx, jsval_t lval, jsval_t rval, BOOL greater, BOOL *ret)
{ {
double ln, rn; double ln, rn;
jsval_t l, r; jsval_t l, r;
HRESULT hres; HRESULT hres;
hres = to_primitive(ctx, lval, ei, &l, NO_HINT); hres = to_primitive(ctx, lval, &l, NO_HINT);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
hres = to_primitive(ctx, rval, ei, &r, NO_HINT); hres = to_primitive(ctx, rval, &r, NO_HINT);
if(FAILED(hres)) { if(FAILED(hres)) {
jsval_release(l); jsval_release(l);
return hres; return hres;
@ -2063,10 +2071,10 @@ static HRESULT less_eval(script_ctx_t *ctx, jsval_t lval, jsval_t rval, BOOL gre
return S_OK; return S_OK;
} }
hres = to_number(ctx, l, ei, &ln); hres = to_number(ctx, l, &ln);
jsval_release(l); jsval_release(l);
if(SUCCEEDED(hres)) if(SUCCEEDED(hres))
hres = to_number(ctx, r, ei, &rn); hres = to_number(ctx, r, &rn);
jsval_release(r); jsval_release(r);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -2087,7 +2095,7 @@ static HRESULT interp_lt(exec_ctx_t *ctx)
TRACE("%s < %s\n", debugstr_jsval(l), debugstr_jsval(r)); TRACE("%s < %s\n", debugstr_jsval(l), debugstr_jsval(r));
hres = less_eval(ctx->script, l, r, FALSE, ctx->ei, &b); hres = less_eval(ctx->script, l, r, FALSE, &b);
jsval_release(l); jsval_release(l);
jsval_release(r); jsval_release(r);
if(FAILED(hres)) if(FAILED(hres))
@ -2108,7 +2116,7 @@ static HRESULT interp_lteq(exec_ctx_t *ctx)
TRACE("%s <= %s\n", debugstr_jsval(l), debugstr_jsval(r)); TRACE("%s <= %s\n", debugstr_jsval(l), debugstr_jsval(r));
hres = less_eval(ctx->script, r, l, TRUE, ctx->ei, &b); hres = less_eval(ctx->script, r, l, TRUE, &b);
jsval_release(l); jsval_release(l);
jsval_release(r); jsval_release(r);
if(FAILED(hres)) if(FAILED(hres))
@ -2129,7 +2137,7 @@ static HRESULT interp_gt(exec_ctx_t *ctx)
TRACE("%s > %s\n", debugstr_jsval(l), debugstr_jsval(r)); TRACE("%s > %s\n", debugstr_jsval(l), debugstr_jsval(r));
hres = less_eval(ctx->script, r, l, FALSE, ctx->ei, &b); hres = less_eval(ctx->script, r, l, FALSE, &b);
jsval_release(l); jsval_release(l);
jsval_release(r); jsval_release(r);
if(FAILED(hres)) if(FAILED(hres))
@ -2150,7 +2158,7 @@ static HRESULT interp_gteq(exec_ctx_t *ctx)
TRACE("%s >= %s\n", debugstr_jsval(l), debugstr_jsval(r)); TRACE("%s >= %s\n", debugstr_jsval(l), debugstr_jsval(r));
hres = less_eval(ctx->script, l, r, TRUE, ctx->ei, &b); hres = less_eval(ctx->script, l, r, TRUE, &b);
jsval_release(l); jsval_release(l);
jsval_release(r); jsval_release(r);
if(FAILED(hres)) if(FAILED(hres))
@ -2169,7 +2177,7 @@ static HRESULT interp_bneg(exec_ctx_t *ctx)
TRACE("\n"); TRACE("\n");
v = stack_pop(ctx); v = stack_pop(ctx);
hres = to_int32(ctx->script, v, ctx->ei, &i); hres = to_int32(ctx->script, v, &i);
jsval_release(v); jsval_release(v);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -2263,10 +2271,10 @@ static HRESULT interp_assign(exec_ctx_t *ctx)
disp = stack_pop_objid(ctx, &id); disp = stack_pop_objid(ctx, &id);
if(!disp) { if(!disp) {
jsval_release(v); jsval_release(v);
return throw_reference_error(ctx->script, ctx->ei, JS_E_ILLEGAL_ASSIGN, NULL); return throw_reference_error(ctx->script, JS_E_ILLEGAL_ASSIGN, NULL);
} }
hres = disp_propput(ctx->script, disp, id, v, ctx->ei); hres = disp_propput(ctx->script, disp, id, v);
IDispatch_Release(disp); IDispatch_Release(disp);
if(FAILED(hres)) { if(FAILED(hres)) {
jsval_release(v); jsval_release(v);
@ -2289,9 +2297,9 @@ static HRESULT interp_assign_call(exec_ctx_t *ctx)
disp = stack_topn_objid(ctx, argc+1, &id); disp = stack_topn_objid(ctx, argc+1, &id);
if(!disp) if(!disp)
return throw_reference_error(ctx->script, ctx->ei, JS_E_ILLEGAL_ASSIGN, NULL); return throw_reference_error(ctx->script, JS_E_ILLEGAL_ASSIGN, NULL);
hres = disp_call(ctx->script, disp, id, DISPATCH_PROPERTYPUT, argc+1, stack_args(ctx, argc+1), NULL, ctx->ei); hres = disp_call(ctx->script, disp, id, DISPATCH_PROPERTYPUT, argc+1, stack_args(ctx, argc+1), NULL);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -2398,7 +2406,7 @@ static HRESULT unwind_exception(exec_ctx_t *ctx)
hres = create_dispex(ctx->script, NULL, NULL, &scope_obj); hres = create_dispex(ctx->script, NULL, NULL, &scope_obj);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
hres = jsdisp_propput_name(scope_obj, ident, except_val, ctx->ei); hres = jsdisp_propput_name(scope_obj, ident, except_val);
if(FAILED(hres)) if(FAILED(hres))
jsdisp_release(scope_obj); jsdisp_release(scope_obj);
} }
@ -2491,8 +2499,7 @@ static HRESULT enter_bytecode(script_ctx_t *ctx, bytecode_t *code, function_code
return S_OK; return S_OK;
} }
HRESULT exec_source(exec_ctx_t *ctx, bytecode_t *code, function_code_t *func, BOOL from_eval, HRESULT exec_source(exec_ctx_t *ctx, bytecode_t *code, function_code_t *func, BOOL from_eval, jsval_t *ret)
jsexcept_t *ei, jsval_t *ret)
{ {
exec_ctx_t *prev_ctx; exec_ctx_t *prev_ctx;
jsval_t val; jsval_t val;
@ -2509,7 +2516,7 @@ HRESULT exec_source(exec_ctx_t *ctx, bytecode_t *code, function_code_t *func, BO
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
hres = jsdisp_propput_name(ctx->var_disp, func->funcs[i].name, jsval_obj(func_obj), ei); hres = jsdisp_propput_name(ctx->var_disp, func->funcs[i].name, jsval_obj(func_obj));
jsdisp_release(func_obj); jsdisp_release(func_obj);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -2528,7 +2535,7 @@ HRESULT exec_source(exec_ctx_t *ctx, bytecode_t *code, function_code_t *func, BO
prev_ctx = ctx->script->exec_ctx; prev_ctx = ctx->script->exec_ctx;
ctx->script->exec_ctx = ctx; ctx->script->exec_ctx = ctx;
hres = enter_bytecode(ctx->script, code, func, ei, &val); hres = enter_bytecode(ctx->script, code, func, &ctx->script->ei, &val);
assert(ctx->script->exec_ctx == ctx); assert(ctx->script->exec_ctx == ctx);
ctx->script->exec_ctx = prev_ctx; ctx->script->exec_ctx = prev_ctx;
if(FAILED(hres)) if(FAILED(hres))

View File

@ -246,7 +246,7 @@ static inline void exec_addref(exec_ctx_t *ctx)
void exec_release(exec_ctx_t*) DECLSPEC_HIDDEN; void exec_release(exec_ctx_t*) DECLSPEC_HIDDEN;
HRESULT create_exec_ctx(script_ctx_t*,IDispatch*,jsdisp_t*,scope_chain_t*,BOOL,exec_ctx_t**) DECLSPEC_HIDDEN; HRESULT create_exec_ctx(script_ctx_t*,IDispatch*,jsdisp_t*,scope_chain_t*,BOOL,exec_ctx_t**) DECLSPEC_HIDDEN;
HRESULT exec_source(exec_ctx_t*,bytecode_t*,function_code_t*,BOOL,jsexcept_t*,jsval_t*) DECLSPEC_HIDDEN; HRESULT exec_source(exec_ctx_t*,bytecode_t*,function_code_t*,BOOL,jsval_t*) DECLSPEC_HIDDEN;
HRESULT create_source_function(script_ctx_t*,bytecode_t*,function_code_t*,scope_chain_t*,jsdisp_t**) DECLSPEC_HIDDEN; HRESULT create_source_function(script_ctx_t*,bytecode_t*,function_code_t*,scope_chain_t*,jsdisp_t**) DECLSPEC_HIDDEN;
typedef enum { typedef enum {

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,
unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) unsigned argc, jsval_t *argv, jsval_t *r)
{ {
jsdisp_t *jsthis; jsdisp_t *jsthis;
BSTR name = NULL, msg = NULL, ret = NULL; BSTR name = NULL, msg = NULL, ret = NULL;
@ -57,12 +57,12 @@ static HRESULT Error_toString(script_ctx_t *ctx, vdisp_t *vthis, WORD flags,
return S_OK; return S_OK;
} }
hres = jsdisp_propget_name(jsthis, nameW, &v, ei); hres = jsdisp_propget_name(jsthis, nameW, &v);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(!is_undefined(v)) { if(!is_undefined(v)) {
hres = to_string(ctx, v, ei, &name); hres = to_string(ctx, v, &name);
jsval_release(v); jsval_release(v);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -72,10 +72,10 @@ static HRESULT Error_toString(script_ctx_t *ctx, vdisp_t *vthis, WORD flags,
} }
} }
hres = jsdisp_propget_name(jsthis, messageW, &v, ei); hres = jsdisp_propget_name(jsthis, messageW, &v);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
if(!is_undefined(v)) { if(!is_undefined(v)) {
hres = to_string(ctx, v, ei, &msg); hres = to_string(ctx, v, &msg);
jsval_release(v); jsval_release(v);
if(SUCCEEDED(hres) && !*msg) { if(SUCCEEDED(hres) && !*msg) {
SysFreeString(msg); SysFreeString(msg);
@ -124,13 +124,13 @@ 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,
unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) unsigned argc, jsval_t *argv, jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
switch(flags) { switch(flags) {
case INVOKE_FUNC: case INVOKE_FUNC:
return throw_type_error(ctx, ei, JS_E_FUNCTION_EXPECTED, NULL); return throw_type_error(ctx, JS_E_FUNCTION_EXPECTED, NULL);
default: default:
FIXME("unimplemented flags %x\n", flags); FIXME("unimplemented flags %x\n", flags);
return E_NOTIMPL; return E_NOTIMPL;
@ -196,7 +196,7 @@ static HRESULT create_error(script_ctx_t *ctx, jsdisp_t *constr,
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
hres = jsdisp_propput_name(err, numberW, jsval_number((INT)number), NULL/*FIXME*/); hres = jsdisp_propput_name(err, numberW, jsval_number((INT)number));
if(FAILED(hres)) { if(FAILED(hres)) {
jsdisp_release(err); jsdisp_release(err);
return hres; return hres;
@ -205,9 +205,9 @@ static HRESULT create_error(script_ctx_t *ctx, jsdisp_t *constr,
if(msg) str = SysAllocString(msg); if(msg) str = SysAllocString(msg);
else str = SysAllocStringLen(NULL, 0); else str = SysAllocStringLen(NULL, 0);
if(str) { if(str) {
hres = jsdisp_propput_name(err, messageW, jsval_string(str), NULL/*FIXME*/); hres = jsdisp_propput_name(err, messageW, jsval_string(str));
if(SUCCEEDED(hres)) if(SUCCEEDED(hres))
hres = jsdisp_propput_name(err, descriptionW, jsval_string(str), NULL/*FIXME*/); hres = jsdisp_propput_name(err, descriptionW, jsval_string(str));
SysFreeString(str); SysFreeString(str);
}else { }else {
hres = E_OUTOFMEMORY; hres = E_OUTOFMEMORY;
@ -222,7 +222,7 @@ static HRESULT create_error(script_ctx_t *ctx, jsdisp_t *constr,
} }
static HRESULT error_constr(script_ctx_t *ctx, WORD flags, unsigned argc, jsval_t *argv, static HRESULT error_constr(script_ctx_t *ctx, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei, jsdisp_t *constr) { jsval_t *r, jsdisp_t *constr) {
jsdisp_t *err; jsdisp_t *err;
UINT num = 0; UINT num = 0;
BSTR msg = NULL; BSTR msg = NULL;
@ -231,18 +231,18 @@ static HRESULT error_constr(script_ctx_t *ctx, WORD flags, unsigned argc, jsval_
if(argc) { if(argc) {
double n; double n;
hres = to_number(ctx, argv[0], ei, &n); hres = to_number(ctx, argv[0], &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, argv[0], ei, &msg); hres = to_string(ctx, argv[0], &msg);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
num = n; num = n;
} }
if(argc>1 && !msg) { if(argc>1 && !msg) {
hres = to_string(ctx, argv[1], ei, &msg); hres = to_string(ctx, argv[1], &msg);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
} }
@ -269,59 +269,59 @@ static HRESULT error_constr(script_ctx_t *ctx, WORD flags, unsigned argc, jsval_
} }
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,
unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) unsigned argc, jsval_t *argv, jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
return error_constr(ctx, flags, argc, argv, r, ei, ctx->error_constr); return error_constr(ctx, flags, argc, argv, r, 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,
unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) unsigned argc, jsval_t *argv, jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
return error_constr(ctx, flags, argc, argv, r, ei, ctx->eval_error_constr); return error_constr(ctx, flags, argc, argv, r, 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,
unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) unsigned argc, jsval_t *argv, jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
return error_constr(ctx, flags, argc, argv, r, ei, ctx->range_error_constr); return error_constr(ctx, flags, argc, argv, r, 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,
unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) unsigned argc, jsval_t *argv, jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
return error_constr(ctx, flags, argc, argv, r, ei, ctx->reference_error_constr); return error_constr(ctx, flags, argc, argv, r, 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,
unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) unsigned argc, jsval_t *argv, jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
return error_constr(ctx, flags, argc, argv, r, ei, ctx->regexp_error_constr); return error_constr(ctx, flags, argc, argv, r, 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,
unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) unsigned argc, jsval_t *argv, jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
return error_constr(ctx, flags, argc, argv, r, ei, ctx->syntax_error_constr); return error_constr(ctx, flags, argc, argv, r, 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,
unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) unsigned argc, jsval_t *argv, jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
return error_constr(ctx, flags, argc, argv, r, ei, ctx->type_error_constr); return error_constr(ctx, flags, argc, argv, r, 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,
unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) unsigned argc, jsval_t *argv, jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
return error_constr(ctx, flags, argc, argv, r, ei, ctx->uri_error_constr); return error_constr(ctx, flags, argc, argv, r, 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)
@ -360,7 +360,7 @@ HRESULT init_error_constr(script_ctx_t *ctx, jsdisp_t *object_prototype)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
hres = jsdisp_propput_name(err, nameW, jsval_string(str), NULL/*FIXME*/); hres = jsdisp_propput_name(err, nameW, jsval_string(str));
SysFreeString(str); SysFreeString(str);
if(SUCCEEDED(hres)) if(SUCCEEDED(hres))
hres = create_builtin_constructor(ctx, constr_val[i], names[i], NULL, hres = create_builtin_constructor(ctx, constr_val[i], names[i], NULL,
@ -374,7 +374,7 @@ HRESULT init_error_constr(script_ctx_t *ctx, jsdisp_t *object_prototype)
return S_OK; return S_OK;
} }
static HRESULT throw_error(script_ctx_t *ctx, jsexcept_t *ei, HRESULT error, const WCHAR *str, jsdisp_t *constr) static HRESULT throw_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str, jsdisp_t *constr)
{ {
WCHAR buf[1024], *pos = NULL; WCHAR buf[1024], *pos = NULL;
jsdisp_t *err; jsdisp_t *err;
@ -399,42 +399,42 @@ static HRESULT throw_error(script_ctx_t *ctx, jsexcept_t *ei, HRESULT error, con
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(ei) jsval_release(ctx->ei.val);
ei->val = jsval_obj(err); ctx->ei.val = jsval_obj(err);
return error; return error;
} }
HRESULT throw_generic_error(script_ctx_t *ctx, jsexcept_t *ei, HRESULT error, const WCHAR *str) HRESULT throw_generic_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
{ {
return throw_error(ctx, ei, error, str, ctx->error_constr); return throw_error(ctx, error, str, ctx->error_constr);
} }
HRESULT throw_range_error(script_ctx_t *ctx, jsexcept_t *ei, HRESULT error, const WCHAR *str) HRESULT throw_range_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
{ {
return throw_error(ctx, ei, error, str, ctx->range_error_constr); return throw_error(ctx, error, str, ctx->range_error_constr);
} }
HRESULT throw_reference_error(script_ctx_t *ctx, jsexcept_t *ei, HRESULT error, const WCHAR *str) HRESULT throw_reference_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
{ {
return throw_error(ctx, ei, error, str, ctx->reference_error_constr); return throw_error(ctx, error, str, ctx->reference_error_constr);
} }
HRESULT throw_regexp_error(script_ctx_t *ctx, jsexcept_t *ei, HRESULT error, const WCHAR *str) HRESULT throw_regexp_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
{ {
return throw_error(ctx, ei, error, str, ctx->regexp_error_constr); return throw_error(ctx, error, str, ctx->regexp_error_constr);
} }
HRESULT throw_syntax_error(script_ctx_t *ctx, jsexcept_t *ei, HRESULT error, const WCHAR *str) HRESULT throw_syntax_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
{ {
return throw_error(ctx, ei, error, str, ctx->syntax_error_constr); return throw_error(ctx, error, str, ctx->syntax_error_constr);
} }
HRESULT throw_type_error(script_ctx_t *ctx, jsexcept_t *ei, HRESULT error, const WCHAR *str) HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
{ {
return throw_error(ctx, ei, error, str, ctx->type_error_constr); return throw_error(ctx, error, str, ctx->type_error_constr);
} }
HRESULT throw_uri_error(script_ctx_t *ctx, jsexcept_t *ei, HRESULT error, const WCHAR *str) HRESULT throw_uri_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
{ {
return throw_error(ctx, ei, error, str, ctx->uri_error_constr); return throw_error(ctx, error, str, ctx->uri_error_constr);
} }

View File

@ -55,15 +55,14 @@ 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 HRESULT init_parameters(jsdisp_t *var_disp, FunctionInstance *function, unsigned argc, jsval_t *argv, static HRESULT init_parameters(jsdisp_t *var_disp, FunctionInstance *function, unsigned argc, jsval_t *argv)
jsexcept_t *ei)
{ {
DWORD i=0; DWORD i=0;
HRESULT hres; HRESULT hres;
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 < argc ? argv[i] : jsval_undefined(), ei); i < argc ? argv[i] : jsval_undefined());
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
} }
@ -72,7 +71,7 @@ static HRESULT init_parameters(jsdisp_t *var_disp, FunctionInstance *function, u
} }
static HRESULT Arguments_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Arguments_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
FIXME("\n"); FIXME("\n");
return E_NOTIMPL; return E_NOTIMPL;
@ -86,8 +85,7 @@ static const builtin_info_t Arguments_info = {
NULL NULL
}; };
static HRESULT create_arguments(script_ctx_t *ctx, IDispatch *calee, unsigned argc, jsval_t *argv, static HRESULT create_arguments(script_ctx_t *ctx, IDispatch *calee, unsigned argc, jsval_t *argv, jsdisp_t **ret)
jsexcept_t *ei, jsdisp_t **ret)
{ {
jsdisp_t *args; jsdisp_t *args;
DWORD i; DWORD i;
@ -106,16 +104,16 @@ static HRESULT create_arguments(script_ctx_t *ctx, IDispatch *calee, unsigned ar
} }
for(i=0; i < argc; i++) { for(i=0; i < argc; i++) {
hres = jsdisp_propput_idx(args, i, argv[i], ei); hres = jsdisp_propput_idx(args, i, argv[i]);
if(FAILED(hres)) if(FAILED(hres))
break; break;
} }
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
hres = jsdisp_propput_name(args, lengthW, jsval_number(argc), ei); hres = jsdisp_propput_name(args, lengthW, jsval_number(argc));
if(SUCCEEDED(hres)) if(SUCCEEDED(hres))
hres = jsdisp_propput_name(args, caleeW, jsval_disp(calee), ei); hres = jsdisp_propput_name(args, caleeW, jsval_disp(calee));
} }
if(FAILED(hres)) { if(FAILED(hres)) {
@ -128,7 +126,7 @@ static HRESULT create_arguments(script_ctx_t *ctx, IDispatch *calee, unsigned ar
} }
static HRESULT create_var_disp(script_ctx_t *ctx, FunctionInstance *function, jsdisp_t *arg_disp, static HRESULT create_var_disp(script_ctx_t *ctx, FunctionInstance *function, jsdisp_t *arg_disp,
unsigned argc, jsval_t *argv, jsexcept_t *ei, jsdisp_t **ret) unsigned argc, jsval_t *argv, jsdisp_t **ret)
{ {
jsdisp_t *var_disp; jsdisp_t *var_disp;
HRESULT hres; HRESULT hres;
@ -137,9 +135,9 @@ static HRESULT create_var_disp(script_ctx_t *ctx, FunctionInstance *function, js
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
hres = jsdisp_propput_name(var_disp, argumentsW, jsval_obj(arg_disp), ei); hres = jsdisp_propput_name(var_disp, argumentsW, jsval_obj(arg_disp));
if(SUCCEEDED(hres)) if(SUCCEEDED(hres))
hres = init_parameters(var_disp, function, argc, argv, ei); hres = init_parameters(var_disp, function, argc, argv);
if(FAILED(hres)) { if(FAILED(hres)) {
jsdisp_release(var_disp); jsdisp_release(var_disp);
return hres; return hres;
@ -150,7 +148,7 @@ static HRESULT create_var_disp(script_ctx_t *ctx, FunctionInstance *function, js
} }
static HRESULT invoke_source(script_ctx_t *ctx, FunctionInstance *function, IDispatch *this_obj, unsigned argc, jsval_t *argv, static HRESULT invoke_source(script_ctx_t *ctx, FunctionInstance *function, IDispatch *this_obj, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
jsdisp_t *var_disp, *arg_disp; jsdisp_t *var_disp, *arg_disp;
exec_ctx_t *exec_ctx; exec_ctx_t *exec_ctx;
@ -162,11 +160,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), argc, argv, ei, &arg_disp); hres = create_arguments(ctx, to_disp(&function->dispex), argc, argv, &arg_disp);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
hres = create_var_disp(ctx, function, arg_disp, argc, argv, ei, &var_disp); hres = create_var_disp(ctx, function, arg_disp, argc, argv, &var_disp);
if(FAILED(hres)) { if(FAILED(hres)) {
jsdisp_release(arg_disp); jsdisp_release(arg_disp);
return hres; return hres;
@ -183,7 +181,7 @@ static HRESULT invoke_source(script_ctx_t *ctx, FunctionInstance *function, IDis
prev_args = function->arguments; prev_args = function->arguments;
function->arguments = arg_disp; function->arguments = arg_disp;
hres = exec_source(exec_ctx, function->code, function->func_code, FALSE, ei, r); hres = exec_source(exec_ctx, function->code, function->func_code, FALSE, r);
function->arguments = prev_args; function->arguments = prev_args;
} }
@ -193,7 +191,7 @@ static HRESULT invoke_source(script_ctx_t *ctx, FunctionInstance *function, IDis
} }
static HRESULT invoke_constructor(script_ctx_t *ctx, FunctionInstance *function, unsigned argc, jsval_t *argv, static HRESULT invoke_constructor(script_ctx_t *ctx, FunctionInstance *function, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
jsdisp_t *this_obj; jsdisp_t *this_obj;
jsval_t var; jsval_t var;
@ -203,7 +201,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), argc, argv, &var, ei); hres = invoke_source(ctx, function, to_disp(this_obj), argc, argv, &var);
if(FAILED(hres)) { if(FAILED(hres)) {
jsdisp_release(this_obj); jsdisp_release(this_obj);
return hres; return hres;
@ -219,8 +217,8 @@ 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, unsigned argc, jsval_t *argv, static HRESULT invoke_value_proc(script_ctx_t *ctx, FunctionInstance *function, IDispatch *this_disp, WORD flags,
jsval_t *r, jsexcept_t *ei) unsigned argc, jsval_t *argv, jsval_t *r)
{ {
vdisp_t vthis; vdisp_t vthis;
HRESULT hres; HRESULT hres;
@ -232,19 +230,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, argc, argv, r, ei); hres = function->value_proc(ctx, &vthis, flags, argc, argv, r);
vdisp_release(&vthis); vdisp_release(&vthis);
return hres; return hres;
} }
static HRESULT call_function(script_ctx_t *ctx, FunctionInstance *function, IDispatch *this_obj, static HRESULT call_function(script_ctx_t *ctx, FunctionInstance *function, IDispatch *this_obj,
unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) unsigned argc, jsval_t *argv, jsval_t *r)
{ {
if(function->value_proc) if(function->value_proc)
return invoke_value_proc(ctx, function, this_obj, DISPATCH_METHOD, argc, argv, r, ei); return invoke_value_proc(ctx, function, this_obj, DISPATCH_METHOD, argc, argv, r);
return invoke_source(ctx, function, this_obj, argc, argv, r, ei); return invoke_source(ctx, function, this_obj, argc, argv, r);
} }
static HRESULT function_to_string(FunctionInstance *function, BSTR *ret) static HRESULT function_to_string(FunctionInstance *function, BSTR *ret)
@ -276,7 +274,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, unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) HRESULT Function_invoke(jsdisp_t *func_this, IDispatch *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
{ {
FunctionInstance *function; FunctionInstance *function;
@ -286,17 +284,17 @@ HRESULT Function_invoke(jsdisp_t *func_this, IDispatch *jsthis, WORD flags, unsi
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, argc, argv, r, ei); return invoke_value_proc(function->dispex.ctx, function, jsthis, flags, argc, argv, r);
if(flags == DISPATCH_CONSTRUCT) if(flags == DISPATCH_CONSTRUCT)
return invoke_constructor(function->dispex.ctx, function, argc, argv, r, ei); return invoke_constructor(function->dispex.ctx, function, argc, argv, r);
assert(flags == DISPATCH_METHOD); assert(flags == DISPATCH_METHOD);
return invoke_source(function->dispex.ctx, function, jsthis, argc, argv, r, ei); return invoke_source(function->dispex.ctx, function, jsthis, argc, argv, r);
} }
static HRESULT Function_length(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Function_length(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
FunctionInstance *This = function_from_vdisp(jsthis); FunctionInstance *This = function_from_vdisp(jsthis);
@ -315,7 +313,7 @@ static HRESULT Function_length(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u
} }
static HRESULT Function_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Function_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
FunctionInstance *function; FunctionInstance *function;
BSTR str; BSTR str;
@ -324,7 +322,7 @@ static HRESULT Function_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
TRACE("\n"); TRACE("\n");
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, JS_E_FUNCTION_EXPECTED, NULL);
hres = function_to_string(function, &str); hres = function_to_string(function, &str);
if(FAILED(hres)) if(FAILED(hres))
@ -337,17 +335,17 @@ 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, unsigned *argc, jsval_t **ret) static HRESULT array_to_args(script_ctx_t *ctx, jsdisp_t *arg_array, unsigned *argc, jsval_t **ret)
{ {
jsval_t *argv, val; jsval_t *argv, val;
DWORD length, i; DWORD length, i;
HRESULT hres; HRESULT hres;
hres = jsdisp_propget_name(arg_array, lengthW, &val, ei); hres = jsdisp_propget_name(arg_array, lengthW, &val);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
hres = to_uint32(ctx, val, ei, &length); hres = to_uint32(ctx, val, &length);
jsval_release(val); jsval_release(val);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -357,7 +355,7 @@ static HRESULT array_to_args(script_ctx_t *ctx, jsdisp_t *arg_array, jsexcept_t
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
for(i=0; i<length; i++) { for(i=0; i<length; i++) {
hres = jsdisp_get_idx(arg_array, i, argv+i, ei); hres = jsdisp_get_idx(arg_array, i, argv+i);
if(hres == DISP_E_UNKNOWNNAME) { if(hres == DISP_E_UNKNOWNNAME) {
argv[i] = jsval_undefined(); argv[i] = jsval_undefined();
}else if(FAILED(hres)) { }else if(FAILED(hres)) {
@ -373,8 +371,7 @@ static HRESULT array_to_args(script_ctx_t *ctx, jsdisp_t *arg_array, jsexcept_t
return S_OK; return S_OK;
} }
static HRESULT Function_apply(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Function_apply(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
jsval_t *r, jsexcept_t *ei)
{ {
FunctionInstance *function; FunctionInstance *function;
jsval_t *args = NULL; jsval_t *args = NULL;
@ -385,7 +382,7 @@ static HRESULT Function_apply(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
TRACE("\n"); TRACE("\n");
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, JS_E_FUNCTION_EXPECTED, NULL);
if(argc) { if(argc) {
if(!is_undefined(argv[0]) && !is_null(argv[0])) { if(!is_undefined(argv[0]) && !is_null(argv[0])) {
@ -408,7 +405,7 @@ static HRESULT Function_apply(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
} }
if(arg_array) { if(arg_array) {
hres = array_to_args(ctx, arg_array, ei, &cnt, &args); hres = array_to_args(ctx, arg_array, &cnt, &args);
jsdisp_release(arg_array); jsdisp_release(arg_array);
}else { }else {
FIXME("throw TypeError\n"); FIXME("throw TypeError\n");
@ -417,7 +414,7 @@ static HRESULT Function_apply(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
} }
if(SUCCEEDED(hres)) if(SUCCEEDED(hres))
hres = call_function(ctx, function, this_obj, cnt, args, r, ei); hres = call_function(ctx, function, this_obj, cnt, args, r);
if(this_obj) if(this_obj)
IDispatch_Release(this_obj); IDispatch_Release(this_obj);
@ -428,7 +425,7 @@ static HRESULT Function_apply(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
} }
static HRESULT Function_call(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Function_call(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
FunctionInstance *function; FunctionInstance *function;
IDispatch *this_obj = NULL; IDispatch *this_obj = NULL;
@ -438,7 +435,7 @@ static HRESULT Function_call(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns
TRACE("\n"); TRACE("\n");
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, JS_E_FUNCTION_EXPECTED, NULL);
if(argc) { if(argc) {
if(!is_undefined(argv[0]) && !is_null(argv[0])) { if(!is_undefined(argv[0]) && !is_null(argv[0])) {
@ -450,7 +447,7 @@ static HRESULT Function_call(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns
cnt = argc-1; cnt = argc-1;
} }
hres = call_function(ctx, function, this_obj, cnt, argv+1, r, ei); hres = call_function(ctx, function, this_obj, cnt, argv+1, r);
if(this_obj) if(this_obj)
IDispatch_Release(this_obj); IDispatch_Release(this_obj);
@ -458,7 +455,7 @@ static HRESULT Function_call(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns
} }
HRESULT Function_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, HRESULT Function_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
FunctionInstance *function; FunctionInstance *function;
@ -474,7 +471,7 @@ HRESULT Function_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned
switch(flags) { switch(flags) {
case DISPATCH_METHOD: case DISPATCH_METHOD:
assert(function->value_proc != NULL); assert(function->value_proc != NULL);
return invoke_value_proc(ctx, function, NULL, flags, argc, argv, r, ei); return invoke_value_proc(ctx, function, NULL, flags, argc, argv, r);
case DISPATCH_PROPERTYGET: { case DISPATCH_PROPERTYGET: {
HRESULT hres; HRESULT hres;
@ -490,7 +487,7 @@ HRESULT Function_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned
case DISPATCH_CONSTRUCT: case DISPATCH_CONSTRUCT:
assert(function->value_proc != NULL); assert(function->value_proc != NULL);
return invoke_value_proc(ctx, function, NULL, flags, argc, argv, r, ei); return invoke_value_proc(ctx, function, NULL, flags, argc, argv, r);
default: default:
FIXME("not implemented flags %x\n", flags); FIXME("not implemented flags %x\n", flags);
@ -501,7 +498,7 @@ HRESULT Function_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned
} }
static HRESULT Function_arguments(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, static HRESULT Function_arguments(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) unsigned argc, jsval_t *argv, jsval_t *r)
{ {
FunctionInstance *function = (FunctionInstance*)jsthis->u.jsdisp; FunctionInstance *function = (FunctionInstance*)jsthis->u.jsdisp;
HRESULT hres = S_OK; HRESULT hres = S_OK;
@ -591,12 +588,9 @@ static HRESULT create_function(script_ctx_t *ctx, const builtin_info_t *builtin_
return S_OK; return S_OK;
} }
static HRESULT set_prototype(script_ctx_t *ctx, jsdisp_t *dispex, jsdisp_t *prototype) static inline HRESULT set_prototype(script_ctx_t *ctx, jsdisp_t *dispex, jsdisp_t *prototype)
{ {
jsexcept_t jsexcept; return jsdisp_propput_name(dispex, prototypeW, jsval_obj(prototype));
memset(&jsexcept, 0, sizeof(jsexcept));
return jsdisp_propput_name(dispex, prototypeW, jsval_obj(prototype), &jsexcept);
} }
HRESULT create_builtin_function(script_ctx_t *ctx, builtin_invoke_t value_proc, const WCHAR *name, HRESULT create_builtin_function(script_ctx_t *ctx, builtin_invoke_t value_proc, const WCHAR *name,
@ -689,7 +683,7 @@ 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, unsigned argc, jsval_t *argv, jsexcept_t *ei, IDispatch **ret) static HRESULT construct_function(script_ctx_t *ctx, unsigned argc, jsval_t *argv, IDispatch **ret)
{ {
WCHAR *str = NULL, *ptr; WCHAR *str = NULL, *ptr;
DWORD len = 0, l; DWORD len = 0, l;
@ -711,7 +705,7 @@ static HRESULT construct_function(script_ctx_t *ctx, unsigned argc, jsval_t *arg
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, argv[i], ei, params+i); hres = to_string(ctx, argv[i], params+i);
if(FAILED(hres)) if(FAILED(hres))
break; break;
len += SysStringLen(params[i]); len += SysStringLen(params[i]);
@ -777,7 +771,7 @@ static HRESULT construct_function(script_ctx_t *ctx, unsigned argc, jsval_t *arg
} }
static HRESULT FunctionConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT FunctionConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
HRESULT hres; HRESULT hres;
@ -787,7 +781,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, argc, argv, ei, &ret); hres = construct_function(ctx, argc, argv, &ret);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -803,7 +797,7 @@ static HRESULT FunctionConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD fla
} }
static HRESULT FunctionProt_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT FunctionProt_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
FIXME("\n"); FIXME("\n");
return E_NOTIMPL; return E_NOTIMPL;

View File

@ -114,169 +114,168 @@ static WCHAR int_to_char(int i)
return 'A'+i-10; return 'A'+i-10;
} }
static HRESULT constructor_call(jsdisp_t *constr, WORD flags, unsigned argc, jsval_t *argv, static HRESULT constructor_call(jsdisp_t *constr, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
jsval_t *r, jsexcept_t *ei)
{ {
if(flags != DISPATCH_PROPERTYGET) if(flags != DISPATCH_PROPERTYGET)
return jsdisp_call_value(constr, NULL, flags, argc, argv, r, ei); return jsdisp_call_value(constr, NULL, flags, argc, argv, r);
*r = jsval_obj(jsdisp_addref(constr)); *r = jsval_obj(jsdisp_addref(constr));
return S_OK; return S_OK;
} }
static HRESULT JSGlobal_Array(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_Array(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
return constructor_call(ctx->array_constr, flags, argc, argv, r, ei); return constructor_call(ctx->array_constr, flags, argc, argv, r);
} }
static HRESULT JSGlobal_Boolean(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_Boolean(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
return constructor_call(ctx->bool_constr, flags, argc, argv, r, ei); return constructor_call(ctx->bool_constr, flags, argc, argv, r);
} }
static HRESULT JSGlobal_Date(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_Date(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
return constructor_call(ctx->date_constr, flags, argc, argv, r, ei); return constructor_call(ctx->date_constr, flags, argc, argv, r);
} }
static HRESULT JSGlobal_Error(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_Error(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
return constructor_call(ctx->error_constr, flags, argc, argv, r, ei); return constructor_call(ctx->error_constr, flags, argc, argv, r);
} }
static HRESULT JSGlobal_EvalError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_EvalError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
return constructor_call(ctx->eval_error_constr, flags, argc, argv, r, ei); return constructor_call(ctx->eval_error_constr, flags, argc, argv, r);
} }
static HRESULT JSGlobal_RangeError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_RangeError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
return constructor_call(ctx->range_error_constr, flags, argc, argv, r, ei); return constructor_call(ctx->range_error_constr, flags, argc, argv, r);
} }
static HRESULT JSGlobal_RegExpError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_RegExpError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
return constructor_call(ctx->regexp_error_constr, flags, argc, argv, r, ei); return constructor_call(ctx->regexp_error_constr, flags, argc, argv, r);
} }
static HRESULT JSGlobal_ReferenceError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_ReferenceError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
return constructor_call(ctx->reference_error_constr, flags, argc, argv, r, ei); return constructor_call(ctx->reference_error_constr, flags, argc, argv, r);
} }
static HRESULT JSGlobal_SyntaxError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_SyntaxError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
return constructor_call(ctx->syntax_error_constr, flags, argc, argv, r, ei); return constructor_call(ctx->syntax_error_constr, flags, argc, argv, r);
} }
static HRESULT JSGlobal_TypeError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_TypeError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
return constructor_call(ctx->type_error_constr, flags, argc, argv, r, ei); return constructor_call(ctx->type_error_constr, flags, argc, argv, r);
} }
static HRESULT JSGlobal_URIError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_URIError(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
return constructor_call(ctx->uri_error_constr, flags, argc, argv, r, ei); return constructor_call(ctx->uri_error_constr, flags, argc, argv, r);
} }
static HRESULT JSGlobal_Function(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_Function(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
return constructor_call(ctx->function_constr, flags, argc, argv, r, ei); return constructor_call(ctx->function_constr, flags, argc, argv, r);
} }
static HRESULT JSGlobal_Number(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_Number(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
return constructor_call(ctx->number_constr, flags, argc, argv, r, ei); return constructor_call(ctx->number_constr, flags, argc, argv, r);
} }
static HRESULT JSGlobal_Object(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_Object(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
return constructor_call(ctx->object_constr, flags, argc, argv, r, ei); return constructor_call(ctx->object_constr, flags, argc, argv, r);
} }
static HRESULT JSGlobal_String(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_String(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
return constructor_call(ctx->string_constr, flags, argc, argv, r, ei); return constructor_call(ctx->string_constr, flags, argc, argv, r);
} }
static HRESULT JSGlobal_RegExp(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_RegExp(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
return constructor_call(ctx->regexp_constr, flags, argc, argv, r, ei); return constructor_call(ctx->regexp_constr, flags, argc, argv, r);
} }
static HRESULT JSGlobal_ActiveXObject(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_ActiveXObject(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
return constructor_call(ctx->activex_constr, flags, argc, argv, r, ei); return constructor_call(ctx->activex_constr, flags, argc, argv, r);
} }
static HRESULT JSGlobal_VBArray(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_VBArray(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
return constructor_call(ctx->vbarray_constr, flags, argc, argv, r, ei); return constructor_call(ctx->vbarray_constr, flags, argc, argv, r);
} }
static HRESULT JSGlobal_Enumerator(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_Enumerator(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
FIXME("\n"); FIXME("\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT JSGlobal_escape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_escape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
BSTR ret, str; BSTR ret, str;
const WCHAR *ptr; const WCHAR *ptr;
@ -297,7 +296,7 @@ static HRESULT JSGlobal_escape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u
return S_OK; return S_OK;
} }
hres = to_string(ctx, argv[0], ei, &str); hres = to_string(ctx, argv[0], &str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -346,7 +345,7 @@ static HRESULT JSGlobal_escape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u
/* ECMA-262 3rd Edition 15.1.2.1 */ /* ECMA-262 3rd Edition 15.1.2.1 */
static HRESULT JSGlobal_eval(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_eval(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
bytecode_t *code; bytecode_t *code;
HRESULT hres; HRESULT hres;
@ -374,16 +373,16 @@ static HRESULT JSGlobal_eval(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns
hres = compile_script(ctx, get_string(argv[0]), NULL, TRUE, FALSE, &code); hres = compile_script(ctx, get_string(argv[0]), NULL, TRUE, FALSE, &code);
if(FAILED(hres)) { if(FAILED(hres)) {
WARN("parse (%s) failed: %08x\n", debugstr_jsval(argv[0]), hres); WARN("parse (%s) failed: %08x\n", debugstr_jsval(argv[0]), hres);
return throw_syntax_error(ctx, ei, hres, NULL); return throw_syntax_error(ctx, hres, NULL);
} }
hres = exec_source(ctx->exec_ctx, code, &code->global_code, TRUE, ei, r); hres = exec_source(ctx->exec_ctx, code, &code->global_code, TRUE, r);
release_bytecode(code); release_bytecode(code);
return hres; return hres;
} }
static HRESULT JSGlobal_isNaN(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_isNaN(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
BOOL ret = TRUE; BOOL ret = TRUE;
double n; double n;
@ -392,7 +391,7 @@ static HRESULT JSGlobal_isNaN(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
TRACE("\n"); TRACE("\n");
if(argc) { if(argc) {
hres = to_number(ctx, argv[0], ei, &n); hres = to_number(ctx, argv[0], &n);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -406,7 +405,7 @@ static HRESULT JSGlobal_isNaN(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
} }
static HRESULT JSGlobal_isFinite(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_isFinite(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
BOOL ret = FALSE; BOOL ret = FALSE;
HRESULT hres; HRESULT hres;
@ -416,7 +415,7 @@ static HRESULT JSGlobal_isFinite(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
if(argc) { if(argc) {
double n; double n;
hres = to_number(ctx, argv[0], ei, &n); hres = to_number(ctx, argv[0], &n);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -441,7 +440,7 @@ static INT char_to_int(WCHAR c)
} }
static HRESULT JSGlobal_parseInt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_parseInt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
BOOL neg = FALSE, empty = TRUE; BOOL neg = FALSE, empty = TRUE;
DOUBLE ret = 0.0; DOUBLE ret = 0.0;
@ -457,7 +456,7 @@ static HRESULT JSGlobal_parseInt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
} }
if(argc >= 2) { if(argc >= 2) {
hres = to_int32(ctx, argv[1], ei, &radix); hres = to_int32(ctx, argv[1], &radix);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -469,7 +468,7 @@ static HRESULT JSGlobal_parseInt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
} }
} }
hres = to_string(ctx, argv[0], ei, &str); hres = to_string(ctx, argv[0], &str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -521,7 +520,7 @@ static HRESULT JSGlobal_parseInt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
} }
static HRESULT JSGlobal_parseFloat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_parseFloat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
LONGLONG d = 0, hlp; LONGLONG d = 0, hlp;
int exp = 0; int exp = 0;
@ -536,7 +535,7 @@ static HRESULT JSGlobal_parseFloat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flag
return S_OK; return S_OK;
} }
hres = to_string(ctx, argv[0], ei, &val_str); hres = to_string(ctx, argv[0], &val_str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -628,7 +627,7 @@ static inline int hex_to_int(const WCHAR wch) {
} }
static HRESULT JSGlobal_unescape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_unescape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
BSTR ret, str; BSTR ret, str;
const WCHAR *ptr; const WCHAR *ptr;
@ -648,7 +647,7 @@ static HRESULT JSGlobal_unescape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
return S_OK; return S_OK;
} }
hres = to_string(ctx, argv[0], ei, &str); hres = to_string(ctx, argv[0], &str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -702,14 +701,14 @@ static HRESULT JSGlobal_unescape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
} }
static HRESULT JSGlobal_GetObject(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_GetObject(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
FIXME("\n"); FIXME("\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT JSGlobal_ScriptEngine(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_ScriptEngine(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
static const WCHAR JScriptW[] = {'J','S','c','r','i','p','t',0}; static const WCHAR JScriptW[] = {'J','S','c','r','i','p','t',0};
@ -729,7 +728,7 @@ static HRESULT JSGlobal_ScriptEngine(script_ctx_t *ctx, vdisp_t *jsthis, WORD fl
} }
static HRESULT JSGlobal_ScriptEngineMajorVersion(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_ScriptEngineMajorVersion(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
@ -739,7 +738,7 @@ static HRESULT JSGlobal_ScriptEngineMajorVersion(script_ctx_t *ctx, vdisp_t *jst
} }
static HRESULT JSGlobal_ScriptEngineMinorVersion(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_ScriptEngineMinorVersion(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
@ -749,7 +748,7 @@ static HRESULT JSGlobal_ScriptEngineMinorVersion(script_ctx_t *ctx, vdisp_t *jst
} }
static HRESULT JSGlobal_ScriptEngineBuildVersion(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_ScriptEngineBuildVersion(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
@ -759,14 +758,14 @@ static HRESULT JSGlobal_ScriptEngineBuildVersion(script_ctx_t *ctx, vdisp_t *jst
} }
static HRESULT JSGlobal_CollectGarbage(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_CollectGarbage(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
FIXME("\n"); FIXME("\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
const WCHAR *ptr; const WCHAR *ptr;
DWORD len = 0, i; DWORD len = 0, i;
@ -789,7 +788,7 @@ static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
return S_OK; return S_OK;
} }
hres = to_string(ctx, argv[0], ei, &str); hres = to_string(ctx, argv[0], &str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -800,7 +799,7 @@ static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
i = WideCharToMultiByte(CP_UTF8, 0, ptr, 1, NULL, 0, NULL, NULL)*3; i = WideCharToMultiByte(CP_UTF8, 0, ptr, 1, NULL, 0, NULL, NULL)*3;
if(!i) { if(!i) {
SysFreeString(str); SysFreeString(str);
return throw_uri_error(ctx, ei, JS_E_INVALID_URI_CHAR, NULL); return throw_uri_error(ctx, JS_E_INVALID_URI_CHAR, NULL);
} }
len += i; len += i;
@ -837,7 +836,7 @@ static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
} }
static HRESULT JSGlobal_decodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_decodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
BSTR str, ret; BSTR str, ret;
WCHAR *ptr; WCHAR *ptr;
@ -860,7 +859,7 @@ static HRESULT JSGlobal_decodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
return S_OK; return S_OK;
} }
hres = to_string(ctx, argv[0], ei, &str); hres = to_string(ctx, argv[0], &str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -882,7 +881,7 @@ static HRESULT JSGlobal_decodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
if(!res) { if(!res) {
SysFreeString(str); SysFreeString(str);
return throw_uri_error(ctx, ei, JS_E_INVALID_URI_CODING, NULL); return throw_uri_error(ctx, JS_E_INVALID_URI_CODING, NULL);
} }
ptr += i*3+2; ptr += i*3+2;
@ -929,7 +928,7 @@ static HRESULT JSGlobal_decodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
} }
static HRESULT JSGlobal_encodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_encodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
BSTR str, ret; BSTR str, ret;
char buf[4]; char buf[4];
@ -951,7 +950,7 @@ static HRESULT JSGlobal_encodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, W
return S_OK; return S_OK;
} }
hres = to_string(ctx, argv[0], ei, &str); hres = to_string(ctx, argv[0], &str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -962,7 +961,7 @@ static HRESULT JSGlobal_encodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, W
size = WideCharToMultiByte(CP_UTF8, 0, ptr, 1, NULL, 0, NULL, NULL); size = WideCharToMultiByte(CP_UTF8, 0, ptr, 1, NULL, 0, NULL, NULL);
if(!size) { if(!size) {
SysFreeString(str); SysFreeString(str);
return throw_uri_error(ctx, ei, JS_E_INVALID_URI_CHAR, NULL); return throw_uri_error(ctx, JS_E_INVALID_URI_CHAR, NULL);
} }
len += size*3; len += size*3;
} }
@ -999,7 +998,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, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_decodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
BSTR str, ret; BSTR str, ret;
const WCHAR *ptr; const WCHAR *ptr;
@ -1021,7 +1020,7 @@ static HRESULT JSGlobal_decodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, W
return S_OK; return S_OK;
} }
hres = to_string(ctx, argv[0], ei, &str); hres = to_string(ctx, argv[0], &str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -1240,19 +1239,19 @@ HRESULT init_global(script_ctx_t *ctx)
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
hres = jsdisp_propput_name(ctx->global, MathW, jsval_obj(math), NULL/*FIXME*/); hres = jsdisp_propput_name(ctx->global, MathW, jsval_obj(math));
jsdisp_release(math); jsdisp_release(math);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
hres = jsdisp_propput_name(ctx->global, undefinedW, jsval_undefined(), NULL/*FIXME*/); hres = jsdisp_propput_name(ctx->global, undefinedW, jsval_undefined());
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
hres = jsdisp_propput_name(ctx->global, NaNW, jsval_number(NAN), NULL/*FIXME*/); hres = jsdisp_propput_name(ctx->global, NaNW, jsval_number(NAN));
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
hres = jsdisp_propput_name(ctx->global, InfinityW, jsval_number(INFINITY), NULL/*FIXME*/); hres = jsdisp_propput_name(ctx->global, InfinityW, jsval_number(INFINITY));
return hres; return hres;
} }

View File

@ -68,6 +68,7 @@ void script_release(script_ctx_t *ctx)
if(--ctx->ref) if(--ctx->ref)
return; return;
clear_ei(ctx);
if(ctx->cc) if(ctx->cc)
release_cc(ctx->cc); release_cc(ctx->cc);
jsheap_free(&ctx->tmp_heap); jsheap_free(&ctx->tmp_heap);
@ -99,7 +100,6 @@ static inline BOOL is_started(script_ctx_t *ctx)
static HRESULT exec_global_code(JScript *This, bytecode_t *code) static HRESULT exec_global_code(JScript *This, bytecode_t *code)
{ {
exec_ctx_t *exec_ctx; exec_ctx_t *exec_ctx;
jsexcept_t jsexcept;
HRESULT hres; HRESULT hres;
hres = create_exec_ctx(This->ctx, NULL, This->ctx->global, NULL, TRUE, &exec_ctx); hres = create_exec_ctx(This->ctx, NULL, This->ctx->global, NULL, TRUE, &exec_ctx);
@ -108,9 +108,8 @@ static HRESULT exec_global_code(JScript *This, bytecode_t *code)
IActiveScriptSite_OnEnterScript(This->site); IActiveScriptSite_OnEnterScript(This->site);
memset(&jsexcept, 0, sizeof(jsexcept)); clear_ei(This->ctx);
hres = exec_source(exec_ctx, code, &code->global_code, FALSE, &jsexcept, NULL); hres = exec_source(exec_ctx, code, &code->global_code, FALSE, NULL);
jsval_release(jsexcept.val);
exec_release(exec_ctx); exec_release(exec_ctx);
IActiveScriptSite_OnLeaveScript(This->site); IActiveScriptSite_OnLeaveScript(This->site);
@ -716,6 +715,7 @@ static HRESULT WINAPI JScriptParse_InitNew(IActiveScriptParse *iface)
ctx->active_script = &This->IActiveScript_iface; ctx->active_script = &This->IActiveScript_iface;
ctx->safeopt = This->safeopt; ctx->safeopt = This->safeopt;
ctx->version = This->version; ctx->version = This->version;
ctx->ei.val = jsval_undefined();
jsheap_init(&ctx->tmp_heap); jsheap_init(&ctx->tmp_heap);
hres = create_jscaller(ctx); hres = create_jscaller(ctx);

View File

@ -149,7 +149,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,unsigned,jsval_t*,jsval_t*,jsexcept_t*); typedef HRESULT (*builtin_invoke_t)(script_ctx_t*,vdisp_t*,WORD,unsigned,jsval_t*,jsval_t*);
typedef struct { typedef struct {
const WCHAR *name; const WCHAR *name;
@ -204,20 +204,20 @@ HRESULT create_dispex(script_ctx_t*,const builtin_info_t*,jsdisp_t*,jsdisp_t**)
HRESULT init_dispex(jsdisp_t*,script_ctx_t*,const builtin_info_t*,jsdisp_t*) DECLSPEC_HIDDEN; HRESULT init_dispex(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,unsigned,jsval_t*,jsval_t*,jsexcept_t*) DECLSPEC_HIDDEN; HRESULT disp_call(script_ctx_t*,IDispatch*,DISPID,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
HRESULT disp_call_value(script_ctx_t*,IDispatch*,IDispatch*,WORD,unsigned,jsval_t*,jsval_t*,jsexcept_t*) DECLSPEC_HIDDEN; HRESULT disp_call_value(script_ctx_t*,IDispatch*,IDispatch*,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
HRESULT jsdisp_call_value(jsdisp_t*,IDispatch*,WORD,unsigned,jsval_t*,jsval_t*,jsexcept_t*) DECLSPEC_HIDDEN; HRESULT jsdisp_call_value(jsdisp_t*,IDispatch*,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
HRESULT jsdisp_call(jsdisp_t*,DISPID,WORD,unsigned,jsval_t*,jsval_t*,jsexcept_t*) DECLSPEC_HIDDEN; HRESULT jsdisp_call(jsdisp_t*,DISPID,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
HRESULT jsdisp_call_name(jsdisp_t*,const WCHAR*,WORD,unsigned,jsval_t*,jsval_t*,jsexcept_t*) DECLSPEC_HIDDEN; HRESULT jsdisp_call_name(jsdisp_t*,const WCHAR*,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
HRESULT disp_propget(script_ctx_t*,IDispatch*,DISPID,jsval_t*,jsexcept_t*) DECLSPEC_HIDDEN; HRESULT disp_propget(script_ctx_t*,IDispatch*,DISPID,jsval_t*) DECLSPEC_HIDDEN;
HRESULT disp_propput(script_ctx_t*,IDispatch*,DISPID,jsval_t,jsexcept_t*) DECLSPEC_HIDDEN; HRESULT disp_propput(script_ctx_t*,IDispatch*,DISPID,jsval_t) DECLSPEC_HIDDEN;
HRESULT jsdisp_propget(jsdisp_t*,DISPID,jsval_t*,jsexcept_t*) DECLSPEC_HIDDEN; HRESULT jsdisp_propget(jsdisp_t*,DISPID,jsval_t*) DECLSPEC_HIDDEN;
HRESULT jsdisp_propput_name(jsdisp_t*,const WCHAR*,jsval_t,jsexcept_t*) DECLSPEC_HIDDEN; HRESULT jsdisp_propput_name(jsdisp_t*,const WCHAR*,jsval_t) DECLSPEC_HIDDEN;
HRESULT jsdisp_propput_const(jsdisp_t*,const WCHAR*,jsval_t) DECLSPEC_HIDDEN; HRESULT jsdisp_propput_const(jsdisp_t*,const WCHAR*,jsval_t) DECLSPEC_HIDDEN;
HRESULT jsdisp_propput_dontenum(jsdisp_t*,const WCHAR*,jsval_t) DECLSPEC_HIDDEN; HRESULT jsdisp_propput_dontenum(jsdisp_t*,const WCHAR*,jsval_t) DECLSPEC_HIDDEN;
HRESULT jsdisp_propput_idx(jsdisp_t*,DWORD,jsval_t,jsexcept_t*) DECLSPEC_HIDDEN; HRESULT jsdisp_propput_idx(jsdisp_t*,DWORD,jsval_t) DECLSPEC_HIDDEN;
HRESULT jsdisp_propget_name(jsdisp_t*,LPCWSTR,jsval_t*,jsexcept_t*) DECLSPEC_HIDDEN; HRESULT jsdisp_propget_name(jsdisp_t*,LPCWSTR,jsval_t*) DECLSPEC_HIDDEN;
HRESULT jsdisp_get_idx(jsdisp_t*,DWORD,jsval_t*,jsexcept_t*) DECLSPEC_HIDDEN; HRESULT jsdisp_get_idx(jsdisp_t*,DWORD,jsval_t*) DECLSPEC_HIDDEN;
HRESULT jsdisp_get_id(jsdisp_t*,const WCHAR*,DWORD,DISPID*) DECLSPEC_HIDDEN; HRESULT jsdisp_get_id(jsdisp_t*,const WCHAR*,DWORD,DISPID*) DECLSPEC_HIDDEN;
HRESULT jsdisp_delete_idx(jsdisp_t*,DWORD) DECLSPEC_HIDDEN; HRESULT jsdisp_delete_idx(jsdisp_t*,DWORD) DECLSPEC_HIDDEN;
HRESULT jsdisp_is_own_prop(jsdisp_t*,BSTR,BOOL*) DECLSPEC_HIDDEN; HRESULT jsdisp_is_own_prop(jsdisp_t*,BSTR,BOOL*) DECLSPEC_HIDDEN;
@ -226,17 +226,17 @@ HRESULT create_builtin_function(script_ctx_t*,builtin_invoke_t,const WCHAR*,cons
jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN; jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
HRESULT create_builtin_constructor(script_ctx_t*,builtin_invoke_t,const WCHAR*,const builtin_info_t*,DWORD, HRESULT create_builtin_constructor(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,unsigned,jsval_t*,jsval_t*,jsexcept_t*) DECLSPEC_HIDDEN; HRESULT Function_value(script_ctx_t*,vdisp_t*,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
HRESULT Function_invoke(jsdisp_t*,IDispatch*,WORD,unsigned,jsval_t*,jsval_t*,jsexcept_t*) DECLSPEC_HIDDEN; HRESULT Function_invoke(jsdisp_t*,IDispatch*,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
HRESULT throw_eval_error(script_ctx_t*,jsexcept_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN; HRESULT throw_eval_error(script_ctx_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*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
HRESULT throw_range_error(script_ctx_t*,jsexcept_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN; HRESULT throw_range_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
HRESULT throw_reference_error(script_ctx_t*,jsexcept_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN; HRESULT throw_reference_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
HRESULT throw_regexp_error(script_ctx_t*,jsexcept_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN; HRESULT throw_regexp_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
HRESULT throw_syntax_error(script_ctx_t*,jsexcept_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN; HRESULT throw_syntax_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
HRESULT throw_type_error(script_ctx_t*,jsexcept_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN; HRESULT throw_type_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
HRESULT throw_uri_error(script_ctx_t*,jsexcept_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN; HRESULT throw_uri_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
HRESULT create_object(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN; HRESULT create_object(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
HRESULT create_math(script_ctx_t*,jsdisp_t**) DECLSPEC_HIDDEN; HRESULT create_math(script_ctx_t*,jsdisp_t**) DECLSPEC_HIDDEN;
@ -254,13 +254,13 @@ typedef enum {
HINT_NUMBER HINT_NUMBER
} hint_t; } hint_t;
HRESULT to_primitive(script_ctx_t*,jsval_t,jsexcept_t*,jsval_t*, hint_t) DECLSPEC_HIDDEN; HRESULT to_primitive(script_ctx_t*,jsval_t,jsval_t*, hint_t) DECLSPEC_HIDDEN;
HRESULT to_boolean(jsval_t,BOOL*) DECLSPEC_HIDDEN; HRESULT to_boolean(jsval_t,BOOL*) DECLSPEC_HIDDEN;
HRESULT to_number(script_ctx_t*,jsval_t,jsexcept_t*,double*) DECLSPEC_HIDDEN; HRESULT to_number(script_ctx_t*,jsval_t,double*) DECLSPEC_HIDDEN;
HRESULT to_integer(script_ctx_t*,jsval_t,jsexcept_t*,double*) DECLSPEC_HIDDEN; HRESULT to_integer(script_ctx_t*,jsval_t,double*) DECLSPEC_HIDDEN;
HRESULT to_int32(script_ctx_t*,jsval_t,jsexcept_t*,INT*) DECLSPEC_HIDDEN; HRESULT to_int32(script_ctx_t*,jsval_t,INT*) DECLSPEC_HIDDEN;
HRESULT to_uint32(script_ctx_t*,jsval_t,jsexcept_t*,DWORD*) DECLSPEC_HIDDEN; HRESULT to_uint32(script_ctx_t*,jsval_t,DWORD*) DECLSPEC_HIDDEN;
HRESULT to_string(script_ctx_t*,jsval_t,jsexcept_t*,BSTR*) DECLSPEC_HIDDEN; HRESULT to_string(script_ctx_t*,jsval_t,BSTR*) DECLSPEC_HIDDEN;
HRESULT to_object(script_ctx_t*,jsval_t,IDispatch**) DECLSPEC_HIDDEN; HRESULT to_object(script_ctx_t*,jsval_t,IDispatch**) DECLSPEC_HIDDEN;
HRESULT variant_change_type(script_ctx_t*,VARIANT*,VARIANT*,VARTYPE) DECLSPEC_HIDDEN; HRESULT variant_change_type(script_ctx_t*,VARIANT*,VARIANT*,VARTYPE) DECLSPEC_HIDDEN;
@ -293,6 +293,13 @@ typedef struct {
script_ctx_t *ctx; script_ctx_t *ctx;
} JSCaller; } JSCaller;
#include "jsval.h"
struct _jsexcept_t {
EXCEPINFO ei;
jsval_t val;
};
struct _script_ctx_t { struct _script_ctx_t {
LONG ref; LONG ref;
@ -308,6 +315,7 @@ struct _script_ctx_t {
LCID lcid; LCID lcid;
cc_ctx_t *cc; cc_ctx_t *cc;
JSCaller *jscaller; JSCaller *jscaller;
jsexcept_t ei;
jsheap_t tmp_heap; jsheap_t tmp_heap;
@ -339,6 +347,7 @@ struct _script_ctx_t {
}; };
void script_release(script_ctx_t*) DECLSPEC_HIDDEN; void script_release(script_ctx_t*) DECLSPEC_HIDDEN;
void clear_ei(script_ctx_t*) DECLSPEC_HIDDEN;
static inline void script_addref(script_ctx_t *ctx) static inline void script_addref(script_ctx_t *ctx)
{ {
@ -375,7 +384,7 @@ HRESULT regexp_match_next(script_ctx_t*,jsdisp_t*,DWORD,const WCHAR*,DWORD,const
DWORD*,DWORD*,match_result_t*) DECLSPEC_HIDDEN; DWORD*,DWORD*,match_result_t*) DECLSPEC_HIDDEN;
HRESULT regexp_match(script_ctx_t*,jsdisp_t*,const WCHAR*,DWORD,BOOL,match_result_t**,DWORD*) DECLSPEC_HIDDEN; HRESULT regexp_match(script_ctx_t*,jsdisp_t*,const WCHAR*,DWORD,BOOL,match_result_t**,DWORD*) DECLSPEC_HIDDEN;
HRESULT parse_regexp_flags(const WCHAR*,DWORD,DWORD*) DECLSPEC_HIDDEN; HRESULT parse_regexp_flags(const WCHAR*,DWORD,DWORD*) DECLSPEC_HIDDEN;
HRESULT regexp_string_match(script_ctx_t*,jsdisp_t*,BSTR,jsval_t*,jsexcept_t*) DECLSPEC_HIDDEN; HRESULT regexp_string_match(script_ctx_t*,jsdisp_t*,BSTR,jsval_t*) DECLSPEC_HIDDEN;
static inline BOOL is_class(jsdisp_t *jsdisp, jsclass_t class) static inline BOOL is_class(jsdisp_t *jsdisp, jsclass_t class)
{ {
@ -502,10 +511,3 @@ static inline LPWSTR heap_strdupW(LPCWSTR str)
return ret; return ret;
} }
#include "jsval.h"
struct _jsexcept_t {
EXCEPINFO ei;
jsval_t val;
};

View File

@ -380,7 +380,7 @@ HRESULT jsval_to_variant(jsval_t val, VARIANT *retv)
} }
/* ECMA-262 3rd Edition 9.1 */ /* ECMA-262 3rd Edition 9.1 */
HRESULT to_primitive(script_ctx_t *ctx, jsval_t val, jsexcept_t *ei, jsval_t *ret, hint_t hint) HRESULT to_primitive(script_ctx_t *ctx, jsval_t val, jsval_t *ret, hint_t hint)
{ {
if(is_object_instance(val)) { if(is_object_instance(val)) {
jsdisp_t *jsdisp; jsdisp_t *jsdisp;
@ -398,7 +398,7 @@ HRESULT to_primitive(script_ctx_t *ctx, jsval_t val, jsexcept_t *ei, jsval_t *re
jsdisp = iface_to_jsdisp((IUnknown*)get_object(val)); jsdisp = iface_to_jsdisp((IUnknown*)get_object(val));
if(!jsdisp) if(!jsdisp)
return disp_propget(ctx, get_object(val), DISPID_VALUE, ret, ei); return disp_propget(ctx, get_object(val), DISPID_VALUE, ret);
if(hint == NO_HINT) if(hint == NO_HINT)
hint = is_class(jsdisp, JSCLASS_DATE) ? HINT_STRING : HINT_NUMBER; hint = is_class(jsdisp, JSCLASS_DATE) ? HINT_STRING : HINT_NUMBER;
@ -407,7 +407,7 @@ HRESULT to_primitive(script_ctx_t *ctx, jsval_t val, jsexcept_t *ei, jsval_t *re
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, 0, NULL, &prim, ei); hres = jsdisp_call(jsdisp, id, DISPATCH_METHOD, 0, NULL, &prim);
if(FAILED(hres)) { if(FAILED(hres)) {
WARN("call error - forwarding exception\n"); WARN("call error - forwarding exception\n");
jsdisp_release(jsdisp); jsdisp_release(jsdisp);
@ -423,7 +423,7 @@ HRESULT to_primitive(script_ctx_t *ctx, jsval_t val, jsexcept_t *ei, jsval_t *re
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, 0, NULL, &prim, ei); hres = jsdisp_call(jsdisp, id, DISPATCH_METHOD, 0, NULL, &prim);
if(FAILED(hres)) { if(FAILED(hres)) {
WARN("call error - forwarding exception\n"); WARN("call error - forwarding exception\n");
jsdisp_release(jsdisp); jsdisp_release(jsdisp);
@ -440,7 +440,7 @@ HRESULT to_primitive(script_ctx_t *ctx, jsval_t val, jsexcept_t *ei, jsval_t *re
jsdisp_release(jsdisp); jsdisp_release(jsdisp);
WARN("failed\n"); WARN("failed\n");
return throw_type_error(ctx, ei, JS_E_TO_PRIMITIVE, NULL); return throw_type_error(ctx, JS_E_TO_PRIMITIVE, NULL);
} }
return jsval_copy(val, ret); return jsval_copy(val, ret);
@ -586,7 +586,7 @@ static HRESULT str_to_number(BSTR str, double *ret)
} }
/* ECMA-262 3rd Edition 9.3 */ /* ECMA-262 3rd Edition 9.3 */
HRESULT to_number(script_ctx_t *ctx, jsval_t val, jsexcept_t *ei, double *ret) HRESULT to_number(script_ctx_t *ctx, jsval_t val, double *ret)
{ {
switch(jsval_type(val)) { switch(jsval_type(val)) {
case JSV_UNDEFINED: case JSV_UNDEFINED:
@ -604,11 +604,11 @@ HRESULT to_number(script_ctx_t *ctx, jsval_t val, jsexcept_t *ei, double *ret)
jsval_t prim; jsval_t prim;
HRESULT hres; HRESULT hres;
hres = to_primitive(ctx, val, ei, &prim, HINT_NUMBER); hres = to_primitive(ctx, val, &prim, HINT_NUMBER);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
hres = to_number(ctx, prim, ei, ret); hres = to_number(ctx, prim, ret);
jsval_release(prim); jsval_release(prim);
return hres; return hres;
} }
@ -625,12 +625,12 @@ HRESULT to_number(script_ctx_t *ctx, jsval_t val, jsexcept_t *ei, double *ret)
} }
/* ECMA-262 3rd Edition 9.4 */ /* ECMA-262 3rd Edition 9.4 */
HRESULT to_integer(script_ctx_t *ctx, jsval_t v, jsexcept_t *ei, double *ret) HRESULT to_integer(script_ctx_t *ctx, jsval_t v, double *ret)
{ {
double n; double n;
HRESULT hres; HRESULT hres;
hres = to_number(ctx, v, ei, &n); hres = to_number(ctx, v, &n);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -642,12 +642,12 @@ HRESULT to_integer(script_ctx_t *ctx, jsval_t v, jsexcept_t *ei, double *ret)
} }
/* ECMA-262 3rd Edition 9.5 */ /* ECMA-262 3rd Edition 9.5 */
HRESULT to_int32(script_ctx_t *ctx, jsval_t v, jsexcept_t *ei, INT *ret) HRESULT to_int32(script_ctx_t *ctx, jsval_t v, INT *ret)
{ {
double n; double n;
HRESULT hres; HRESULT hres;
hres = to_number(ctx, v, ei, &n); hres = to_number(ctx, v, &n);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -656,12 +656,12 @@ HRESULT to_int32(script_ctx_t *ctx, jsval_t v, jsexcept_t *ei, INT *ret)
} }
/* ECMA-262 3rd Edition 9.6 */ /* ECMA-262 3rd Edition 9.6 */
HRESULT to_uint32(script_ctx_t *ctx, jsval_t val, jsexcept_t *ei, DWORD *ret) HRESULT to_uint32(script_ctx_t *ctx, jsval_t val, DWORD *ret)
{ {
double n; double n;
HRESULT hres; HRESULT hres;
hres = to_number(ctx, val, ei, &n); hres = to_number(ctx, val, &n);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -728,7 +728,7 @@ HRESULT double_to_bstr(double n, BSTR *str)
} }
/* ECMA-262 3rd Edition 9.8 */ /* ECMA-262 3rd Edition 9.8 */
HRESULT to_string(script_ctx_t *ctx, jsval_t val, jsexcept_t *ei, BSTR *str) HRESULT to_string(script_ctx_t *ctx, jsval_t val, BSTR *str)
{ {
const WCHAR undefinedW[] = {'u','n','d','e','f','i','n','e','d',0}; const WCHAR undefinedW[] = {'u','n','d','e','f','i','n','e','d',0};
const WCHAR nullW[] = {'n','u','l','l',0}; const WCHAR nullW[] = {'n','u','l','l',0};
@ -751,11 +751,11 @@ HRESULT to_string(script_ctx_t *ctx, jsval_t val, jsexcept_t *ei, BSTR *str)
jsval_t prim; jsval_t prim;
HRESULT hres; HRESULT hres;
hres = to_primitive(ctx, val, ei, &prim, HINT_STRING); hres = to_primitive(ctx, val, &prim, HINT_STRING);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
hres = to_string(ctx, prim, ei, str); hres = to_string(ctx, prim, str);
jsval_release(prim); jsval_release(prim);
return hres; return hres;
} }
@ -837,22 +837,20 @@ HRESULT to_object(script_ctx_t *ctx, jsval_t val, IDispatch **disp)
HRESULT variant_change_type(script_ctx_t *ctx, VARIANT *dst, VARIANT *src, VARTYPE vt) HRESULT variant_change_type(script_ctx_t *ctx, VARIANT *dst, VARIANT *src, VARTYPE vt)
{ {
jsexcept_t ei;
jsval_t val; jsval_t val;
HRESULT hres; HRESULT hres;
clear_ei(ctx);
hres = variant_to_jsval(src, &val); hres = variant_to_jsval(src, &val);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
memset(&ei, 0, sizeof(ei));
switch(vt) { switch(vt) {
case VT_I2: case VT_I2:
case VT_I4: { case VT_I4: {
INT i; INT i;
hres = to_int32(ctx, val, &ei, &i); hres = to_int32(ctx, val, &i);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
if(vt == VT_I4) if(vt == VT_I4)
V_I4(dst) = i; V_I4(dst) = i;
@ -863,7 +861,7 @@ HRESULT variant_change_type(script_ctx_t *ctx, VARIANT *dst, VARIANT *src, VARTY
} }
case VT_R8: { case VT_R8: {
double n; double n;
hres = to_number(ctx, val, &ei, &n); hres = to_number(ctx, val, &n);
if(SUCCEEDED(hres)) if(SUCCEEDED(hres))
V_R8(dst) = n; V_R8(dst) = n;
break; break;
@ -871,7 +869,7 @@ HRESULT variant_change_type(script_ctx_t *ctx, VARIANT *dst, VARIANT *src, VARTY
case VT_R4: { case VT_R4: {
double n; double n;
hres = to_number(ctx, val, &ei, &n); hres = to_number(ctx, val, &n);
if(SUCCEEDED(hres)) if(SUCCEEDED(hres))
V_R4(dst) = n; V_R4(dst) = n;
break; break;
@ -887,7 +885,7 @@ HRESULT variant_change_type(script_ctx_t *ctx, VARIANT *dst, VARIANT *src, VARTY
case VT_BSTR: { case VT_BSTR: {
BSTR str; BSTR str;
hres = to_string(ctx, val, &ei, &str); hres = to_string(ctx, val, &str);
if(SUCCEEDED(hres)) if(SUCCEEDED(hres))
V_BSTR(dst) = str; V_BSTR(dst) = str;
break; break;
@ -904,10 +902,8 @@ HRESULT variant_change_type(script_ctx_t *ctx, VARIANT *dst, VARIANT *src, VARTY
} }
jsval_release(val); jsval_release(val);
if(FAILED(hres)) { if(FAILED(hres))
jsval_release(ei.val);
return hres; return hres;
}
V_VT(dst) = vt; V_VT(dst) = vt;
return S_OK; return S_OK;

View File

@ -59,7 +59,7 @@ 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, unsigned argc, jsval_t *argv, static HRESULT Math_abs(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
double d; double d;
HRESULT hres; HRESULT hres;
@ -72,7 +72,7 @@ static HRESULT Math_abs(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned
return S_OK; return S_OK;
} }
hres = to_number(ctx, argv[0], ei, &d); hres = to_number(ctx, argv[0], &d);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -82,7 +82,7 @@ static HRESULT Math_abs(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned
} }
static HRESULT Math_acos(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Math_acos(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
double x; double x;
HRESULT hres; HRESULT hres;
@ -95,7 +95,7 @@ static HRESULT Math_acos(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigne
return S_OK; return S_OK;
} }
hres = to_number(ctx, argv[0], ei, &x); hres = to_number(ctx, argv[0], &x);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -105,7 +105,7 @@ static HRESULT Math_acos(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigne
} }
static HRESULT Math_asin(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Math_asin(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
double x; double x;
HRESULT hres; HRESULT hres;
@ -118,7 +118,7 @@ static HRESULT Math_asin(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigne
return S_OK; return S_OK;
} }
hres = to_number(ctx, argv[0], ei, &x); hres = to_number(ctx, argv[0], &x);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -128,7 +128,7 @@ static HRESULT Math_asin(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigne
} }
static HRESULT Math_atan(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Math_atan(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
double x; double x;
HRESULT hres; HRESULT hres;
@ -141,7 +141,7 @@ static HRESULT Math_atan(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigne
return S_OK; return S_OK;
} }
hres = to_number(ctx, argv[0], ei, &x); hres = to_number(ctx, argv[0], &x);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -151,7 +151,7 @@ static HRESULT Math_atan(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigne
} }
static HRESULT Math_atan2(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Math_atan2(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
double x, y; double x, y;
HRESULT hres; HRESULT hres;
@ -164,11 +164,11 @@ static HRESULT Math_atan2(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsign
return S_OK; return S_OK;
} }
hres = to_number(ctx, argv[0], ei, &y); hres = to_number(ctx, argv[0], &y);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
hres = to_number(ctx, argv[1], ei, &x); hres = to_number(ctx, argv[1], &x);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -179,7 +179,7 @@ static HRESULT Math_atan2(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsign
/* 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, unsigned argc, jsval_t *argv, static HRESULT Math_ceil(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
double x; double x;
HRESULT hres; HRESULT hres;
@ -192,7 +192,7 @@ static HRESULT Math_ceil(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigne
return S_OK; return S_OK;
} }
hres = to_number(ctx, argv[0], ei, &x); hres = to_number(ctx, argv[0], &x);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -202,7 +202,7 @@ static HRESULT Math_ceil(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigne
} }
static HRESULT Math_cos(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Math_cos(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
double x; double x;
HRESULT hres; HRESULT hres;
@ -215,7 +215,7 @@ static HRESULT Math_cos(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned
return S_OK; return S_OK;
} }
hres = to_number(ctx, argv[0], ei, &x); hres = to_number(ctx, argv[0], &x);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -225,7 +225,7 @@ static HRESULT Math_cos(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned
} }
static HRESULT Math_exp(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Math_exp(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
double x; double x;
HRESULT hres; HRESULT hres;
@ -238,7 +238,7 @@ static HRESULT Math_exp(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned
return S_OK; return S_OK;
} }
hres = to_number(ctx, argv[0], ei, &x); hres = to_number(ctx, argv[0], &x);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -248,7 +248,7 @@ static HRESULT Math_exp(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned
} }
static HRESULT Math_floor(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Math_floor(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
double x; double x;
HRESULT hres; HRESULT hres;
@ -261,7 +261,7 @@ static HRESULT Math_floor(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsign
return S_OK; return S_OK;
} }
hres = to_number(ctx, argv[0], ei, &x); hres = to_number(ctx, argv[0], &x);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -271,7 +271,7 @@ static HRESULT Math_floor(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsign
} }
static HRESULT Math_log(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Math_log(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
double x; double x;
HRESULT hres; HRESULT hres;
@ -284,7 +284,7 @@ static HRESULT Math_log(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned
return S_OK; return S_OK;
} }
hres = to_number(ctx, argv[0], ei, &x); hres = to_number(ctx, argv[0], &x);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -295,7 +295,7 @@ static HRESULT Math_log(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned
/* 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, unsigned argc, jsval_t *argv, static HRESULT Math_max(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
DOUBLE max, d; DOUBLE max, d;
DWORD i; DWORD i;
@ -309,12 +309,12 @@ static HRESULT Math_max(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned
return S_OK; return S_OK;
} }
hres = to_number(ctx, argv[0], ei, &max); hres = to_number(ctx, argv[0], &max);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
for(i=1; i < argc; i++) { for(i=1; i < argc; i++) {
hres = to_number(ctx, argv[i], ei, &d); hres = to_number(ctx, argv[i], &d);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -329,7 +329,7 @@ static HRESULT Math_max(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned
/* 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, unsigned argc, jsval_t *argv, static HRESULT Math_min(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
DOUBLE min, d; DOUBLE min, d;
DWORD i; DWORD i;
@ -343,12 +343,12 @@ static HRESULT Math_min(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned
return S_OK; return S_OK;
} }
hres = to_number(ctx, argv[0], ei, &min); hres = to_number(ctx, argv[0], &min);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
for(i=1; i < argc; i++) { for(i=1; i < argc; i++) {
hres = to_number(ctx, argv[i], ei, &d); hres = to_number(ctx, argv[i], &d);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -363,7 +363,7 @@ static HRESULT Math_min(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned
/* 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, unsigned argc, jsval_t *argv, static HRESULT Math_pow(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
double x, y; double x, y;
HRESULT hres; HRESULT hres;
@ -376,11 +376,11 @@ static HRESULT Math_pow(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned
return S_OK; return S_OK;
} }
hres = to_number(ctx, argv[0], ei, &x); hres = to_number(ctx, argv[0], &x);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
hres = to_number(ctx, argv[1], ei, &y); hres = to_number(ctx, argv[1], &y);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -391,7 +391,7 @@ static HRESULT Math_pow(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned
/* 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, unsigned argc, jsval_t *argv, static HRESULT Math_random(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
UINT x; UINT x;
@ -407,7 +407,7 @@ static HRESULT Math_random(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsig
/* 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, unsigned argc, jsval_t *argv, static HRESULT Math_round(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
double x; double x;
HRESULT hres; HRESULT hres;
@ -420,7 +420,7 @@ static HRESULT Math_round(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsign
return S_OK; return S_OK;
} }
hres = to_number(ctx, argv[0], ei, &x); hres = to_number(ctx, argv[0], &x);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -430,7 +430,7 @@ static HRESULT Math_round(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsign
} }
static HRESULT Math_sin(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Math_sin(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
double x; double x;
HRESULT hres; HRESULT hres;
@ -443,7 +443,7 @@ static HRESULT Math_sin(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned
return S_OK; return S_OK;
} }
hres = to_number(ctx, argv[0], ei, &x); hres = to_number(ctx, argv[0], &x);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -453,7 +453,7 @@ static HRESULT Math_sin(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned
} }
static HRESULT Math_sqrt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Math_sqrt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
double x; double x;
HRESULT hres; HRESULT hres;
@ -466,7 +466,7 @@ static HRESULT Math_sqrt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigne
return S_OK; return S_OK;
} }
hres = to_number(ctx, argv[0], ei, &x); hres = to_number(ctx, argv[0], &x);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -476,7 +476,7 @@ static HRESULT Math_sqrt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigne
} }
static HRESULT Math_tan(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Math_tan(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
double x; double x;
HRESULT hres; HRESULT hres;
@ -489,7 +489,7 @@ static HRESULT Math_tan(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned
return S_OK; return S_OK;
} }
hres = to_number(ctx, argv[0], ei, &x); hres = to_number(ctx, argv[0], &x);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;

View File

@ -219,7 +219,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, unsigned argc, jsval_t *argv, static HRESULT Number_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
NumberInstance *number; NumberInstance *number;
INT radix = 10; INT radix = 10;
@ -230,21 +230,21 @@ static HRESULT Number_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u
TRACE("\n"); TRACE("\n");
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, JS_E_NUMBER_EXPECTED, NULL);
if(argc) { if(argc) {
hres = to_int32(ctx, argv[0], ei, &radix); hres = to_int32(ctx, argv[0], &radix);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(radix<2 || radix>36) if(radix<2 || radix>36)
return throw_type_error(ctx, ei, JS_E_INVALIDARG, NULL); return throw_type_error(ctx, JS_E_INVALIDARG, NULL);
} }
val = number->value; val = number->value;
if(radix==10 || isnan(val) || isinf(val)) { if(radix==10 || isnan(val) || isinf(val)) {
hres = to_string(ctx, jsval_number(val), ei, &str); hres = to_string(ctx, jsval_number(val), &str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
}else { }else {
@ -339,14 +339,14 @@ static HRESULT Number_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u
} }
static HRESULT Number_toLocaleString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Number_toLocaleString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
FIXME("\n"); FIXME("\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT Number_toFixed(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Number_toFixed(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
NumberInstance *number; NumberInstance *number;
DOUBLE val; DOUBLE val;
@ -357,20 +357,20 @@ static HRESULT Number_toFixed(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
TRACE("\n"); TRACE("\n");
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, JS_E_NUMBER_EXPECTED, NULL);
if(argc) { if(argc) {
hres = to_int32(ctx, argv[0], ei, &prec); hres = to_int32(ctx, argv[0], &prec);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(prec<0 || prec>20) if(prec<0 || prec>20)
return throw_range_error(ctx, ei, JS_E_FRACTION_DIGITS_OUT_OF_RANGE, NULL); return throw_range_error(ctx, JS_E_FRACTION_DIGITS_OUT_OF_RANGE, NULL);
} }
val = number->value; val = number->value;
if(isinf(val) || isnan(val)) { if(isinf(val) || isnan(val)) {
hres = to_string(ctx, jsval_number(val), ei, &str); hres = to_string(ctx, jsval_number(val), &str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
}else { }else {
@ -385,7 +385,7 @@ static HRESULT Number_toFixed(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
} }
static HRESULT Number_toExponential(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Number_toExponential(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
NumberInstance *number; NumberInstance *number;
DOUBLE val; DOUBLE val;
@ -396,20 +396,20 @@ static HRESULT Number_toExponential(script_ctx_t *ctx, vdisp_t *jsthis, WORD fla
TRACE("\n"); TRACE("\n");
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, JS_E_NUMBER_EXPECTED, NULL);
if(argc) { if(argc) {
hres = to_int32(ctx, argv[0], ei, &prec); hres = to_int32(ctx, argv[0], &prec);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(prec<0 || prec>20) if(prec<0 || prec>20)
return throw_range_error(ctx, ei, JS_E_FRACTION_DIGITS_OUT_OF_RANGE, NULL); return throw_range_error(ctx, JS_E_FRACTION_DIGITS_OUT_OF_RANGE, NULL);
} }
val = number->value; val = number->value;
if(isinf(val) || isnan(val)) { if(isinf(val) || isnan(val)) {
hres = to_string(ctx, jsval_number(val), ei, &str); hres = to_string(ctx, jsval_number(val), &str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
}else { }else {
@ -426,7 +426,7 @@ static HRESULT Number_toExponential(script_ctx_t *ctx, vdisp_t *jsthis, WORD fla
} }
static HRESULT Number_toPrecision(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Number_toPrecision(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
NumberInstance *number; NumberInstance *number;
INT prec = 0, size; INT prec = 0, size;
@ -435,20 +435,20 @@ static HRESULT Number_toPrecision(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
HRESULT hres; HRESULT hres;
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, JS_E_NUMBER_EXPECTED, NULL);
if(argc) { if(argc) {
hres = to_int32(ctx, argv[0], ei, &prec); hres = to_int32(ctx, argv[0], &prec);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(prec<1 || prec>21) if(prec<1 || prec>21)
return throw_range_error(ctx, ei, JS_E_PRECISION_OUT_OF_RANGE, NULL); return throw_range_error(ctx, JS_E_PRECISION_OUT_OF_RANGE, NULL);
} }
val = number->value; val = number->value;
if(isinf(val) || isnan(val) || !prec) { if(isinf(val) || isnan(val) || !prec) {
hres = to_string(ctx, jsval_number(val), ei, &str); hres = to_string(ctx, jsval_number(val), &str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
}else { }else {
@ -471,14 +471,14 @@ static HRESULT Number_toPrecision(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
} }
static HRESULT Number_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Number_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
NumberInstance *number; NumberInstance *number;
TRACE("\n"); TRACE("\n");
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, JS_E_NUMBER_EXPECTED, NULL);
if(r) if(r)
*r = jsval_number(number->value); *r = jsval_number(number->value);
@ -486,13 +486,13 @@ static HRESULT Number_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
} }
static HRESULT Number_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Number_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
NumberInstance *number = number_from_vdisp(jsthis); NumberInstance *number = number_from_vdisp(jsthis);
switch(flags) { switch(flags) {
case INVOKE_FUNC: case INVOKE_FUNC:
return throw_type_error(ctx, ei, JS_E_FUNCTION_EXPECTED, NULL); return throw_type_error(ctx, JS_E_FUNCTION_EXPECTED, NULL);
case DISPATCH_PROPERTYGET: case DISPATCH_PROPERTYGET:
*r = jsval_number(number->value); *r = jsval_number(number->value);
break; break;
@ -532,7 +532,7 @@ static const builtin_info_t NumberInst_info = {
}; };
static HRESULT NumberConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT NumberConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
double n; double n;
HRESULT hres; HRESULT hres;
@ -547,7 +547,7 @@ static HRESULT NumberConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
return S_OK; return S_OK;
} }
hres = to_number(ctx, argv[0], ei, &n); hres = to_number(ctx, argv[0], &n);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -559,7 +559,7 @@ static HRESULT NumberConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
jsdisp_t *obj; jsdisp_t *obj;
if(argc) { if(argc) {
hres = to_number(ctx, argv[0], ei, &n); hres = to_number(ctx, argv[0], &n);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
}else { }else {

View File

@ -33,7 +33,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, unsigned argc, jsval_t *argv, static HRESULT Object_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
jsdisp_t *jsdisp; jsdisp_t *jsdisp;
const WCHAR *str; const WCHAR *str;
@ -79,7 +79,7 @@ static HRESULT Object_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u
} }
static HRESULT Object_toLocaleString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Object_toLocaleString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
@ -88,11 +88,11 @@ 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, 0, NULL, r, ei); return jsdisp_call_name(jsthis->u.jsdisp, toStringW, DISPATCH_METHOD, 0, NULL, r);
} }
static HRESULT Object_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Object_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
@ -104,7 +104,7 @@ static HRESULT Object_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
} }
static HRESULT Object_hasOwnProperty(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Object_hasOwnProperty(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
BSTR name; BSTR name;
DISPID id; DISPID id;
@ -118,7 +118,7 @@ static HRESULT Object_hasOwnProperty(script_ctx_t *ctx, vdisp_t *jsthis, WORD fl
return S_OK; return S_OK;
} }
hres = to_string(ctx, argv[0], ei, &name); hres = to_string(ctx, argv[0], &name);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -148,27 +148,27 @@ static HRESULT Object_hasOwnProperty(script_ctx_t *ctx, vdisp_t *jsthis, WORD fl
} }
static HRESULT Object_propertyIsEnumerable(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Object_propertyIsEnumerable(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
FIXME("\n"); FIXME("\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT Object_isPrototypeOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Object_isPrototypeOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
FIXME("\n"); FIXME("\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT Object_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Object_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
switch(flags) { switch(flags) {
case INVOKE_FUNC: case INVOKE_FUNC:
return throw_type_error(ctx, ei, JS_E_FUNCTION_EXPECTED, NULL); return throw_type_error(ctx, JS_E_FUNCTION_EXPECTED, NULL);
case DISPATCH_PROPERTYGET: { case DISPATCH_PROPERTYGET: {
BSTR ret = SysAllocString(default_valueW); BSTR ret = SysAllocString(default_valueW);
if(!ret) if(!ret)
@ -216,7 +216,7 @@ static const builtin_info_t ObjectInst_info = {
}; };
static HRESULT ObjectConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT ObjectConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
HRESULT hres; HRESULT hres;

View File

@ -3474,7 +3474,7 @@ HRESULT regexp_match(script_ctx_t *ctx, jsdisp_t *dispex, const WCHAR *str, DWOR
} }
static HRESULT RegExp_source(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT RegExp_source(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
@ -3496,21 +3496,21 @@ static HRESULT RegExp_source(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns
} }
static HRESULT RegExp_global(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT RegExp_global(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
FIXME("\n"); FIXME("\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT RegExp_ignoreCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT RegExp_ignoreCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
FIXME("\n"); FIXME("\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT RegExp_multiline(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT RegExp_multiline(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
FIXME("\n"); FIXME("\n");
return E_NOTIMPL; return E_NOTIMPL;
@ -3518,14 +3518,12 @@ static HRESULT RegExp_multiline(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
static INT index_from_val(script_ctx_t *ctx, jsval_t v) static INT index_from_val(script_ctx_t *ctx, jsval_t v)
{ {
jsexcept_t ei;
double n; double n;
HRESULT hres; HRESULT hres;
memset(&ei, 0, sizeof(ei)); hres = to_number(ctx, v, &n);
hres = to_number(ctx, v, &ei, &n); if(FAILED(hres)) {
if(FAILED(hres)) { /* FIXME: Move ignoring exceptions to to_primitive */ clear_ei(ctx); /* FIXME: Move ignoring exceptions to to_primitive */
jsval_release(ei.val);
return 0; return 0;
} }
@ -3534,7 +3532,7 @@ static INT index_from_val(script_ctx_t *ctx, jsval_t v)
} }
static HRESULT RegExp_lastIndex(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT RegExp_lastIndex(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
@ -3564,14 +3562,14 @@ static HRESULT RegExp_lastIndex(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
} }
static HRESULT RegExp_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT RegExp_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
FIXME("\n"); FIXME("\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT create_match_array(script_ctx_t *ctx, BSTR input, const match_result_t *result, static HRESULT create_match_array(script_ctx_t *ctx, BSTR input, const match_result_t *result,
const match_result_t *parens, DWORD parens_cnt, jsexcept_t *ei, IDispatch **ret) const match_result_t *parens, DWORD parens_cnt, IDispatch **ret)
{ {
jsdisp_t *array; jsdisp_t *array;
BSTR str; BSTR str;
@ -3594,22 +3592,22 @@ static HRESULT create_match_array(script_ctx_t *ctx, BSTR input, const match_res
break; break;
} }
hres = jsdisp_propput_idx(array, i+1, jsval_string(str), ei); hres = jsdisp_propput_idx(array, i+1, jsval_string(str));
SysFreeString(str); SysFreeString(str);
if(FAILED(hres)) if(FAILED(hres))
break; break;
} }
while(SUCCEEDED(hres)) { while(SUCCEEDED(hres)) {
hres = jsdisp_propput_name(array, indexW, jsval_number(result->str-input), ei); hres = jsdisp_propput_name(array, indexW, jsval_number(result->str-input));
if(FAILED(hres)) if(FAILED(hres))
break; break;
hres = jsdisp_propput_name(array, lastIndexW, jsval_number(result->str-input+result->len), ei); hres = jsdisp_propput_name(array, lastIndexW, jsval_number(result->str-input+result->len));
if(FAILED(hres)) if(FAILED(hres))
break; break;
hres = jsdisp_propput_name(array, inputW, jsval_string(input), ei); hres = jsdisp_propput_name(array, inputW, jsval_string(input));
if(FAILED(hres)) if(FAILED(hres))
break; break;
@ -3618,7 +3616,7 @@ static HRESULT create_match_array(script_ctx_t *ctx, BSTR input, const match_res
hres = E_OUTOFMEMORY; hres = E_OUTOFMEMORY;
break; break;
} }
hres = jsdisp_propput_name(array, zeroW, jsval_string(str), ei); hres = jsdisp_propput_name(array, zeroW, jsval_string(str));
SysFreeString(str); SysFreeString(str);
break; break;
} }
@ -3632,7 +3630,7 @@ static HRESULT create_match_array(script_ctx_t *ctx, BSTR input, const match_res
return S_OK; return S_OK;
} }
static HRESULT run_exec(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t arg, jsexcept_t *ei, BSTR *input, static HRESULT run_exec(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t arg, BSTR *input,
match_result_t *match, match_result_t **parens, DWORD *parens_cnt, BOOL *ret) match_result_t *match, match_result_t **parens, DWORD *parens_cnt, BOOL *ret)
{ {
RegExpInstance *regexp; RegExpInstance *regexp;
@ -3648,7 +3646,7 @@ static HRESULT run_exec(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t arg, jsexcep
regexp = regexp_from_vdisp(jsthis); regexp = regexp_from_vdisp(jsthis);
hres = to_string(ctx, arg, ei, &string); hres = to_string(ctx, arg, &string);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
length = SysStringLen(string); length = SysStringLen(string);
@ -3685,7 +3683,7 @@ static HRESULT run_exec(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t arg, jsexcep
} }
static HRESULT RegExp_exec(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT RegExp_exec(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
match_result_t *parens = NULL, match; match_result_t *parens = NULL, match;
DWORD parens_cnt = 0; DWORD parens_cnt = 0;
@ -3695,7 +3693,7 @@ static HRESULT RegExp_exec(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsig
TRACE("\n"); TRACE("\n");
hres = run_exec(ctx, jsthis, argc ? argv[0] : jsval_string(NULL), ei, &string, &match, &parens, &parens_cnt, &b); hres = run_exec(ctx, jsthis, argc ? argv[0] : jsval_string(NULL), &string, &match, &parens, &parens_cnt, &b);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -3703,7 +3701,7 @@ static HRESULT RegExp_exec(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsig
if(b) { if(b) {
IDispatch *ret; IDispatch *ret;
hres = create_match_array(ctx, string, &match, parens, parens_cnt, ei, &ret); hres = create_match_array(ctx, string, &match, parens, parens_cnt, &ret);
if(SUCCEEDED(hres)) if(SUCCEEDED(hres))
*r = jsval_disp(ret); *r = jsval_disp(ret);
}else { }else {
@ -3717,7 +3715,7 @@ static HRESULT RegExp_exec(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsig
} }
static HRESULT RegExp_test(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT RegExp_test(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
match_result_t match; match_result_t match;
BSTR undef_str; BSTR undef_str;
@ -3732,7 +3730,7 @@ static HRESULT RegExp_test(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsig
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
hres = run_exec(ctx, jsthis, argc ? argv[0] : jsval_string(undef_str), ei, NULL, &match, NULL, NULL, &b); hres = run_exec(ctx, jsthis, argc ? argv[0] : jsval_string(undef_str), NULL, &match, NULL, NULL, &b);
if(!argc) if(!argc)
SysFreeString(undef_str); SysFreeString(undef_str);
if(FAILED(hres)) if(FAILED(hres))
@ -3744,13 +3742,13 @@ static HRESULT RegExp_test(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsig
} }
static HRESULT RegExp_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT RegExp_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
switch(flags) { switch(flags) {
case INVOKE_FUNC: case INVOKE_FUNC:
return throw_type_error(ctx, ei, JS_E_FUNCTION_EXPECTED, NULL); return throw_type_error(ctx, JS_E_FUNCTION_EXPECTED, NULL);
default: default:
FIXME("unimplemented flags %x\n", flags); FIXME("unimplemented flags %x\n", flags);
return E_NOTIMPL; return E_NOTIMPL;
@ -3909,8 +3907,7 @@ HRESULT create_regexp_var(script_ctx_t *ctx, jsval_t src_arg, jsval_t *flags_arg
return create_regexp(ctx, src, -1, flags, ret); return create_regexp(ctx, src, -1, flags, ret);
} }
HRESULT regexp_string_match(script_ctx_t *ctx, jsdisp_t *re, BSTR str, HRESULT regexp_string_match(script_ctx_t *ctx, jsdisp_t *re, BSTR str, jsval_t *r)
jsval_t *r, jsexcept_t *ei)
{ {
static const WCHAR indexW[] = {'i','n','d','e','x',0}; static const WCHAR indexW[] = {'i','n','d','e','x',0};
static const WCHAR inputW[] = {'i','n','p','u','t',0}; static const WCHAR inputW[] = {'i','n','p','u','t',0};
@ -3937,7 +3934,7 @@ HRESULT regexp_string_match(script_ctx_t *ctx, jsdisp_t *re, BSTR str,
if(hres == S_OK) { if(hres == S_OK) {
IDispatch *ret; IDispatch *ret;
hres = create_match_array(ctx, str, &match, parens, parens_cnt, ei, &ret); hres = create_match_array(ctx, str, &match, parens, parens_cnt, &ret);
if(SUCCEEDED(hres)) if(SUCCEEDED(hres))
*r = jsval_disp(ret); *r = jsval_disp(ret);
}else { }else {
@ -3974,23 +3971,23 @@ HRESULT regexp_string_match(script_ctx_t *ctx, jsdisp_t *re, BSTR str,
break; break;
} }
hres = jsdisp_propput_idx(array, i, jsval_string(tmp_str), ei); hres = jsdisp_propput_idx(array, i, jsval_string(tmp_str));
SysFreeString(tmp_str); SysFreeString(tmp_str);
if(FAILED(hres)) if(FAILED(hres))
break; break;
} }
while(SUCCEEDED(hres)) { while(SUCCEEDED(hres)) {
hres = jsdisp_propput_name(array, indexW, jsval_number(match_result[match_cnt-1].str-str), ei); hres = jsdisp_propput_name(array, indexW, jsval_number(match_result[match_cnt-1].str-str));
if(FAILED(hres)) if(FAILED(hres))
break; break;
hres = jsdisp_propput_name(array, lastIndexW, hres = jsdisp_propput_name(array, lastIndexW,
jsval_number(match_result[match_cnt-1].str-str+match_result[match_cnt-1].len), ei); jsval_number(match_result[match_cnt-1].str-str+match_result[match_cnt-1].len));
if(FAILED(hres)) if(FAILED(hres))
break; break;
hres = jsdisp_propput_name(array, inputW, jsval_string(str), ei); hres = jsdisp_propput_name(array, inputW, jsval_string(str));
break; break;
} }
@ -4004,7 +4001,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,
unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) unsigned argc, jsval_t *argv, jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
@ -4030,7 +4027,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,
unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) unsigned argc, jsval_t *argv, jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
@ -4056,7 +4053,7 @@ static HRESULT RegExpConstr_rightContext(script_ctx_t *ctx, vdisp_t *jsthis, WOR
} }
static HRESULT RegExpConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT RegExpConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
@ -4069,7 +4066,7 @@ static HRESULT RegExpConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
if(is_class(jsdisp, JSCLASS_REGEXP)) { if(is_class(jsdisp, JSCLASS_REGEXP)) {
if(argc > 1 && !is_undefined(argv[1])) { if(argc > 1 && !is_undefined(argv[1])) {
jsdisp_release(jsdisp); jsdisp_release(jsdisp);
return throw_regexp_error(ctx, ei, JS_E_REGEXP_SYNTAX, NULL); return throw_regexp_error(ctx, JS_E_REGEXP_SYNTAX, NULL);
} }
if(r) if(r)

View File

@ -77,8 +77,7 @@ static inline StringInstance *string_this(vdisp_t *jsthis)
return is_vclass(jsthis, JSCLASS_STRING) ? string_from_vdisp(jsthis) : NULL; return is_vclass(jsthis, JSCLASS_STRING) ? string_from_vdisp(jsthis) : NULL;
} }
static HRESULT get_string_val(script_ctx_t *ctx, vdisp_t *jsthis, jsexcept_t *ei, static HRESULT get_string_val(script_ctx_t *ctx, vdisp_t *jsthis, const WCHAR **str, DWORD *len, BSTR *val_str)
const WCHAR **str, DWORD *len, BSTR *val_str)
{ {
StringInstance *string; StringInstance *string;
HRESULT hres; HRESULT hres;
@ -90,7 +89,7 @@ static HRESULT get_string_val(script_ctx_t *ctx, vdisp_t *jsthis, jsexcept_t *ei
return S_OK; return S_OK;
} }
hres = to_string(ctx, jsval_disp(jsthis->u.disp), ei, val_str); hres = to_string(ctx, jsval_disp(jsthis->u.disp), val_str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -100,7 +99,7 @@ static HRESULT get_string_val(script_ctx_t *ctx, vdisp_t *jsthis, jsexcept_t *ei
} }
static HRESULT String_length(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT String_length(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
TRACE("%p\n", jsthis); TRACE("%p\n", jsthis);
@ -140,7 +139,7 @@ static HRESULT stringobj_to_string(vdisp_t *jsthis, jsval_t *r)
/* 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, unsigned argc, jsval_t *argv, static HRESULT String_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
@ -149,15 +148,14 @@ static HRESULT String_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u
/* 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, unsigned argc, jsval_t *argv, static HRESULT String_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
return stringobj_to_string(jsthis, r); return stringobj_to_string(jsthis, r);
} }
static HRESULT do_attributeless_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t *r, static HRESULT do_attributeless_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t *r, const WCHAR *tagname)
jsexcept_t *ei, const WCHAR *tagname)
{ {
const WCHAR *str; const WCHAR *str;
DWORD length; DWORD length;
@ -166,7 +164,7 @@ static HRESULT do_attributeless_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, j
static const WCHAR tagfmt[] = {'<','%','s','>','%','s','<','/','%','s','>',0}; static const WCHAR tagfmt[] = {'<','%','s','>','%','s','<','/','%','s','>',0};
hres = get_string_val(ctx, jsthis, ei, &str, &length, &val_str); hres = get_string_val(ctx, jsthis, &str, &length, &val_str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -186,7 +184,7 @@ static HRESULT do_attributeless_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, j
} }
static HRESULT do_attribute_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, unsigned argc, jsval_t *argv, jsval_t *r, static HRESULT do_attribute_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, unsigned argc, jsval_t *argv, jsval_t *r,
jsexcept_t *ei, const WCHAR *tagname, const WCHAR *attr) const WCHAR *tagname, const WCHAR *attr)
{ {
static const WCHAR tagfmtW[] static const WCHAR tagfmtW[]
= {'<','%','s',' ','%','s','=','\"','%','s','\"','>','%','s','<','/','%','s','>',0}; = {'<','%','s',' ','%','s','=','\"','%','s','\"','>','%','s','<','/','%','s','>',0};
@ -199,7 +197,7 @@ static HRESULT do_attribute_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, unsig
HRESULT hres; HRESULT hres;
if(!(string = string_this(jsthis))) { if(!(string = string_this(jsthis))) {
hres = to_string(ctx, jsval_disp(jsthis->u.disp), ei, &val_str); hres = to_string(ctx, jsval_disp(jsthis->u.disp), &val_str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -212,7 +210,7 @@ static HRESULT do_attribute_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, unsig
} }
if(argc) { if(argc) {
hres = to_string(ctx, argv[0], ei, &attr_value); hres = to_string(ctx, argv[0], &attr_value);
if(FAILED(hres)) { if(FAILED(hres)) {
SysFreeString(val_str); SysFreeString(val_str);
return hres; return hres;
@ -245,38 +243,38 @@ static HRESULT do_attribute_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, unsig
} }
static HRESULT String_anchor(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT String_anchor(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
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, argc, argv, r, ei, fontW, colorW); return do_attribute_tag_format(ctx, jsthis, argc, argv, r, fontW, colorW);
} }
static HRESULT String_big(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT String_big(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
static const WCHAR bigtagW[] = {'B','I','G',0}; static const WCHAR bigtagW[] = {'B','I','G',0};
return do_attributeless_tag_format(ctx, jsthis, r, ei, bigtagW); return do_attributeless_tag_format(ctx, jsthis, r, bigtagW);
} }
static HRESULT String_blink(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT String_blink(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
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, r, ei, blinktagW); return do_attributeless_tag_format(ctx, jsthis, r, blinktagW);
} }
static HRESULT String_bold(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT String_bold(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
static const WCHAR boldtagW[] = {'B',0}; static const WCHAR boldtagW[] = {'B',0};
return do_attributeless_tag_format(ctx, jsthis, r, ei, boldtagW); return do_attributeless_tag_format(ctx, jsthis, r, boldtagW);
} }
/* 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, unsigned argc, jsval_t *argv, static HRESULT String_charAt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
const WCHAR *str; const WCHAR *str;
DWORD length; DWORD length;
@ -286,14 +284,14 @@ static HRESULT String_charAt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns
TRACE("\n"); TRACE("\n");
hres = get_string_val(ctx, jsthis, ei, &str, &length, &val_str); hres = get_string_val(ctx, jsthis, &str, &length, &val_str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(argc) { if(argc) {
double d; double d;
hres = to_integer(ctx, argv[0], ei, &d); hres = to_integer(ctx, argv[0], &d);
if(FAILED(hres)) { if(FAILED(hres)) {
SysFreeString(val_str); SysFreeString(val_str);
return hres; return hres;
@ -321,7 +319,7 @@ static HRESULT String_charAt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns
/* 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, unsigned argc, jsval_t *argv, static HRESULT String_charCodeAt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
const WCHAR *str; const WCHAR *str;
BSTR val_str; BSTR val_str;
@ -330,14 +328,14 @@ static HRESULT String_charCodeAt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
TRACE("\n"); TRACE("\n");
hres = get_string_val(ctx, jsthis, ei, &str, &length, &val_str); hres = get_string_val(ctx, jsthis, &str, &length, &val_str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(argc > 0) { if(argc > 0) {
double d; double d;
hres = to_integer(ctx, argv[0], ei, &d); hres = to_integer(ctx, argv[0], &d);
if(FAILED(hres)) { if(FAILED(hres)) {
SysFreeString(val_str); SysFreeString(val_str);
return hres; return hres;
@ -362,7 +360,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, unsigned argc, jsval_t *argv, static HRESULT String_concat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
BSTR *strs = NULL, ret = NULL; BSTR *strs = NULL, ret = NULL;
DWORD len = 0, i, l, str_cnt; DWORD len = 0, i, l, str_cnt;
@ -376,10 +374,10 @@ static HRESULT String_concat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns
if(!strs) if(!strs)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
hres = to_string(ctx, jsval_disp(jsthis->u.disp), ei, strs); hres = to_string(ctx, jsval_disp(jsthis->u.disp), strs);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
for(i=0; i < argc; i++) { for(i=0; i < argc; i++) {
hres = to_string(ctx, argv[i], ei, strs+i+1); hres = to_string(ctx, argv[i], strs+i+1);
if(FAILED(hres)) if(FAILED(hres))
break; break;
} }
@ -413,32 +411,32 @@ static HRESULT String_concat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns
} }
static HRESULT String_fixed(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT String_fixed(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
static const WCHAR fixedtagW[] = {'T','T',0}; static const WCHAR fixedtagW[] = {'T','T',0};
return do_attributeless_tag_format(ctx, jsthis, r, ei, fixedtagW); return do_attributeless_tag_format(ctx, jsthis, r, fixedtagW);
} }
static HRESULT String_fontcolor(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT String_fontcolor(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
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, argc, argv, r, ei, fontW, colorW); return do_attribute_tag_format(ctx, jsthis, argc, argv, r, fontW, colorW);
} }
static HRESULT String_fontsize(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT String_fontsize(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
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, argc, argv, r, ei, fontW, colorW); return do_attribute_tag_format(ctx, jsthis, argc, argv, r, fontW, colorW);
} }
static HRESULT String_indexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT String_indexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
DWORD length, pos = 0; DWORD length, pos = 0;
const WCHAR *str; const WCHAR *str;
@ -448,7 +446,7 @@ static HRESULT String_indexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
TRACE("\n"); TRACE("\n");
hres = get_string_val(ctx, jsthis, ei, &str, &length, &val_str); hres = get_string_val(ctx, jsthis, &str, &length, &val_str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -459,7 +457,7 @@ static HRESULT String_indexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
return S_OK; return S_OK;
} }
hres = to_string(ctx, argv[0], ei, &search_str); hres = to_string(ctx, argv[0], &search_str);
if(FAILED(hres)) { if(FAILED(hres)) {
SysFreeString(val_str); SysFreeString(val_str);
return hres; return hres;
@ -468,7 +466,7 @@ static HRESULT String_indexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
if(argc >= 2) { if(argc >= 2) {
double d; double d;
hres = to_integer(ctx, argv[1], ei, &d); hres = to_integer(ctx, argv[1], &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;
} }
@ -494,15 +492,15 @@ static HRESULT String_indexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
} }
static HRESULT String_italics(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT String_italics(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
static const WCHAR italicstagW[] = {'I',0}; static const WCHAR italicstagW[] = {'I',0};
return do_attributeless_tag_format(ctx, jsthis, r, ei, italicstagW); return do_attributeless_tag_format(ctx, jsthis, r, italicstagW);
} }
/* 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, unsigned argc, jsval_t *argv, static HRESULT String_lastIndexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
BSTR search_str, val_str; BSTR search_str, val_str;
DWORD length, pos = 0, search_len; DWORD length, pos = 0, search_len;
@ -512,7 +510,7 @@ static HRESULT String_lastIndexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
TRACE("\n"); TRACE("\n");
hres = get_string_val(ctx, jsthis, ei, &str, &length, &val_str); hres = get_string_val(ctx, jsthis, &str, &length, &val_str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -523,7 +521,7 @@ static HRESULT String_lastIndexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
return S_OK; return S_OK;
} }
hres = to_string(ctx, argv[0], ei, &search_str); hres = to_string(ctx, argv[0], &search_str);
if(FAILED(hres)) { if(FAILED(hres)) {
SysFreeString(val_str); SysFreeString(val_str);
return hres; return hres;
@ -534,7 +532,7 @@ static HRESULT String_lastIndexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
if(argc >= 2) { if(argc >= 2) {
double d; double d;
hres = to_integer(ctx, argv[1], ei, &d); hres = to_integer(ctx, argv[1], &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 {
@ -563,17 +561,17 @@ static HRESULT String_lastIndexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
} }
static HRESULT String_link(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT String_link(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
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, argc, argv, r, ei, fontW, colorW); return do_attribute_tag_format(ctx, jsthis, argc, argv, r, 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, unsigned argc, jsval_t *argv, static HRESULT String_match(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
jsdisp_t *regexp = NULL; jsdisp_t *regexp = NULL;
const WCHAR *str; const WCHAR *str;
@ -600,7 +598,7 @@ static HRESULT String_match(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi
if(!regexp) { if(!regexp) {
BSTR match_str; BSTR match_str;
hres = to_string(ctx, argv[0], ei, &match_str); hres = to_string(ctx, argv[0], &match_str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -610,12 +608,12 @@ static HRESULT String_match(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi
return hres; return hres;
} }
hres = get_string_val(ctx, jsthis, ei, &str, &length, &val_str); hres = get_string_val(ctx, jsthis, &str, &length, &val_str);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
if(!val_str) if(!val_str)
val_str = SysAllocStringLen(str, length); val_str = SysAllocStringLen(str, length);
if(val_str) if(val_str)
hres = regexp_string_match(ctx, regexp, val_str, r, ei); hres = regexp_string_match(ctx, regexp, val_str, r);
else else
hres = E_OUTOFMEMORY; hres = E_OUTOFMEMORY;
} }
@ -660,7 +658,7 @@ 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)
{ {
jsval_t *argv; jsval_t *argv;
unsigned argc; unsigned argc;
@ -700,7 +698,7 @@ static HRESULT rep_call(script_ctx_t *ctx, jsdisp_t *func, const WCHAR *str, mat
} }
if(SUCCEEDED(hres)) if(SUCCEEDED(hres))
hres = jsdisp_call_value(func, NULL, DISPATCH_METHOD, argc, argv, &val, ei); hres = jsdisp_call_value(func, NULL, DISPATCH_METHOD, argc, argv, &val);
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)
@ -711,14 +709,14 @@ static HRESULT rep_call(script_ctx_t *ctx, jsdisp_t *func, const WCHAR *str, mat
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
hres = to_string(ctx, val, ei, ret); hres = to_string(ctx, val, ret);
jsval_release(val); jsval_release(val);
return hres; return hres;
} }
/* 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, unsigned argc, jsval_t *argv, static HRESULT String_replace(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
const WCHAR *str; const WCHAR *str;
DWORD parens_cnt = 0, parens_size=0, rep_len=0, length; DWORD parens_cnt = 0, parens_size=0, rep_len=0, length;
@ -731,7 +729,7 @@ static HRESULT String_replace(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
TRACE("\n"); TRACE("\n");
hres = get_string_val(ctx, jsthis, ei, &str, &length, &val_str); hres = get_string_val(ctx, jsthis, &str, &length, &val_str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -757,7 +755,7 @@ static HRESULT String_replace(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
} }
if(!regexp) { if(!regexp) {
hres = to_string(ctx, argv[0], ei, &match_str); hres = to_string(ctx, argv[0], &match_str);
if(FAILED(hres)) { if(FAILED(hres)) {
SysFreeString(val_str); SysFreeString(val_str);
return hres; return hres;
@ -774,7 +772,7 @@ static HRESULT String_replace(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
} }
if(!rep_func) { if(!rep_func) {
hres = to_string(ctx, argv[1], ei, &rep_str); hres = to_string(ctx, argv[1], &rep_str);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
rep_len = SysStringLen(rep_str); rep_len = SysStringLen(rep_str);
if(!strchrW(rep_str, '$')) if(!strchrW(rep_str, '$'))
@ -819,7 +817,7 @@ static HRESULT String_replace(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
if(rep_func) { if(rep_func) {
BSTR cstr; BSTR cstr;
hres = rep_call(ctx, rep_func, str, &match, parens, parens_cnt, &cstr, ei); hres = rep_call(ctx, rep_func, str, &match, parens, parens_cnt, &cstr);
if(FAILED(hres)) if(FAILED(hres))
break; break;
@ -943,7 +941,7 @@ static HRESULT String_replace(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
} }
static HRESULT String_search(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT String_search(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
jsdisp_t *regexp = NULL; jsdisp_t *regexp = NULL;
const WCHAR *str, *cp; const WCHAR *str, *cp;
@ -954,7 +952,7 @@ static HRESULT String_search(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns
TRACE("\n"); TRACE("\n");
hres = get_string_val(ctx, jsthis, ei, &str, &length, &val_str); hres = get_string_val(ctx, jsthis, &str, &length, &val_str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -995,7 +993,7 @@ static HRESULT String_search(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns
/* 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, unsigned argc, jsval_t *argv, static HRESULT String_slice(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
const WCHAR *str; const WCHAR *str;
BSTR val_str; BSTR val_str;
@ -1006,12 +1004,12 @@ static HRESULT String_slice(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi
TRACE("\n"); TRACE("\n");
hres = get_string_val(ctx, jsthis, ei, &str, &length, &val_str); hres = get_string_val(ctx, jsthis, &str, &length, &val_str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(argc) { if(argc) {
hres = to_integer(ctx, argv[0], ei, &d); hres = to_integer(ctx, argv[0], &d);
if(FAILED(hres)) { if(FAILED(hres)) {
SysFreeString(val_str); SysFreeString(val_str);
return hres; return hres;
@ -1032,7 +1030,7 @@ static HRESULT String_slice(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi
} }
if(argc >= 2) { if(argc >= 2) {
hres = to_integer(ctx, argv[1], ei, &d); hres = to_integer(ctx, argv[1], &d);
if(FAILED(hres)) { if(FAILED(hres)) {
SysFreeString(val_str); SysFreeString(val_str);
return hres; return hres;
@ -1072,14 +1070,14 @@ static HRESULT String_slice(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi
} }
static HRESULT String_small(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT String_small(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
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, r, ei, smalltagW); return do_attributeless_tag_format(ctx, jsthis, r, smalltagW);
} }
static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
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;
@ -1096,7 +1094,7 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi
return E_NOTIMPL; return E_NOTIMPL;
} }
hres = get_string_val(ctx, jsthis, ei, &str, &length, &val_str); hres = get_string_val(ctx, jsthis, &str, &length, &val_str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -1118,7 +1116,7 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi
} }
if(!use_regexp) { if(!use_regexp) {
hres = to_string(ctx, argv[0], ei, &match_str); hres = to_string(ctx, argv[0], &match_str);
if(FAILED(hres)) { if(FAILED(hres)) {
SysFreeString(val_str); SysFreeString(val_str);
return hres; return hres;
@ -1156,7 +1154,7 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi
break; break;
} }
hres = jsdisp_propput_idx(array, i, jsval_string(tmp_str), ei); hres = jsdisp_propput_idx(array, i, jsval_string(tmp_str));
SysFreeString(tmp_str); SysFreeString(tmp_str);
if(FAILED(hres)) if(FAILED(hres))
break; break;
@ -1177,7 +1175,7 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi
tmp_str = SysAllocStringLen(ptr, len); tmp_str = SysAllocStringLen(ptr, len);
if(tmp_str) { if(tmp_str) {
hres = jsdisp_propput_idx(array, i, jsval_string(tmp_str), ei); hres = jsdisp_propput_idx(array, i, jsval_string(tmp_str));
SysFreeString(tmp_str); SysFreeString(tmp_str);
}else { }else {
hres = E_OUTOFMEMORY; hres = E_OUTOFMEMORY;
@ -1198,22 +1196,22 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi
} }
static HRESULT String_strike(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT String_strike(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
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, r, ei, striketagW); return do_attributeless_tag_format(ctx, jsthis, r, striketagW);
} }
static HRESULT String_sub(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT String_sub(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
static const WCHAR subtagW[] = {'S','U','B',0}; static const WCHAR subtagW[] = {'S','U','B',0};
return do_attributeless_tag_format(ctx, jsthis, r, ei, subtagW); return do_attributeless_tag_format(ctx, jsthis, r, subtagW);
} }
/* 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, unsigned argc, jsval_t *argv, static HRESULT String_substring(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
const WCHAR *str; const WCHAR *str;
BSTR val_str; BSTR val_str;
@ -1224,12 +1222,12 @@ static HRESULT String_substring(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
TRACE("\n"); TRACE("\n");
hres = get_string_val(ctx, jsthis, ei, &str, &length, &val_str); hres = get_string_val(ctx, jsthis, &str, &length, &val_str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(argc >= 1) { if(argc >= 1) {
hres = to_integer(ctx, argv[0], ei, &d); hres = to_integer(ctx, argv[0], &d);
if(FAILED(hres)) { if(FAILED(hres)) {
SysFreeString(val_str); SysFreeString(val_str);
return hres; return hres;
@ -1240,7 +1238,7 @@ static HRESULT String_substring(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
} }
if(argc >= 2) { if(argc >= 2) {
hres = to_integer(ctx, argv[1], ei, &d); hres = to_integer(ctx, argv[1], &d);
if(FAILED(hres)) { if(FAILED(hres)) {
SysFreeString(val_str); SysFreeString(val_str);
return hres; return hres;
@ -1274,7 +1272,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, unsigned argc, jsval_t *argv, static HRESULT String_substr(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
BSTR val_str; BSTR val_str;
const WCHAR *str; const WCHAR *str;
@ -1285,12 +1283,12 @@ static HRESULT String_substr(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns
TRACE("\n"); TRACE("\n");
hres = get_string_val(ctx, jsthis, ei, &str, &length, &val_str); hres = get_string_val(ctx, jsthis, &str, &length, &val_str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(argc >= 1) { if(argc >= 1) {
hres = to_integer(ctx, argv[0], ei, &d); hres = to_integer(ctx, argv[0], &d);
if(FAILED(hres)) { if(FAILED(hres)) {
SysFreeString(val_str); SysFreeString(val_str);
return hres; return hres;
@ -1301,7 +1299,7 @@ static HRESULT String_substr(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns
} }
if(argc >= 2) { if(argc >= 2) {
hres = to_integer(ctx, argv[1], ei, &d); hres = to_integer(ctx, argv[1], &d);
if(FAILED(hres)) { if(FAILED(hres)) {
SysFreeString(val_str); SysFreeString(val_str);
return hres; return hres;
@ -1329,14 +1327,14 @@ static HRESULT String_substr(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns
} }
static HRESULT String_sup(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT String_sup(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
static const WCHAR suptagW[] = {'S','U','P',0}; static const WCHAR suptagW[] = {'S','U','P',0};
return do_attributeless_tag_format(ctx, jsthis, r, ei, suptagW); return do_attributeless_tag_format(ctx, jsthis, r, suptagW);
} }
static HRESULT String_toLowerCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT String_toLowerCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
const WCHAR* str; const WCHAR* str;
DWORD length; DWORD length;
@ -1345,7 +1343,7 @@ static HRESULT String_toLowerCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
TRACE("\n"); TRACE("\n");
hres = get_string_val(ctx, jsthis, ei, &str, &length, &val_str); hres = get_string_val(ctx, jsthis, &str, &length, &val_str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -1364,7 +1362,7 @@ static HRESULT String_toLowerCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
} }
static HRESULT String_toUpperCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT String_toUpperCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
const WCHAR* str; const WCHAR* str;
DWORD length; DWORD length;
@ -1373,7 +1371,7 @@ static HRESULT String_toUpperCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
TRACE("\n"); TRACE("\n");
hres = get_string_val(ctx, jsthis, ei, &str, &length, &val_str); hres = get_string_val(ctx, jsthis, &str, &length, &val_str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
@ -1392,28 +1390,28 @@ static HRESULT String_toUpperCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
} }
static HRESULT String_toLocaleLowerCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT String_toLocaleLowerCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
FIXME("\n"); FIXME("\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT String_toLocaleUpperCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT String_toLocaleUpperCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
FIXME("\n"); FIXME("\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT String_localeCompare(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT String_localeCompare(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
FIXME("\n"); FIXME("\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT String_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT String_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
StringInstance *This = string_from_vdisp(jsthis); StringInstance *This = string_from_vdisp(jsthis);
@ -1421,7 +1419,7 @@ static HRESULT String_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi
switch(flags) { switch(flags) {
case INVOKE_FUNC: case INVOKE_FUNC:
return throw_type_error(ctx, ei, JS_E_FUNCTION_EXPECTED, NULL); return throw_type_error(ctx, JS_E_FUNCTION_EXPECTED, NULL);
case DISPATCH_PROPERTYGET: { case DISPATCH_PROPERTYGET: {
BSTR str = SysAllocString(This->str); BSTR str = SysAllocString(This->str);
if(!str) if(!str)
@ -1506,7 +1504,7 @@ static const builtin_info_t StringInst_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,
unsigned argc, jsval_t *argv, jsval_t *r, jsexcept_t *ei) unsigned argc, jsval_t *argv, jsval_t *r)
{ {
DWORD i, code; DWORD i, code;
BSTR ret; BSTR ret;
@ -1519,7 +1517,7 @@ static HRESULT StringConstr_fromCharCode(script_ctx_t *ctx, vdisp_t *jsthis, WOR
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
for(i=0; i<argc; i++) { for(i=0; i<argc; i++) {
hres = to_uint32(ctx, argv[i], ei, &code); hres = to_uint32(ctx, argv[i], &code);
if(FAILED(hres)) { if(FAILED(hres)) {
SysFreeString(ret); SysFreeString(ret);
return hres; return hres;
@ -1536,7 +1534,7 @@ static HRESULT StringConstr_fromCharCode(script_ctx_t *ctx, vdisp_t *jsthis, WOR
} }
static HRESULT StringConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT StringConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
HRESULT hres; HRESULT hres;
@ -1547,7 +1545,7 @@ static HRESULT StringConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
BSTR str; BSTR str;
if(argc) { if(argc) {
hres = to_string(ctx, argv[0], ei, &str); hres = to_string(ctx, argv[0], &str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
}else { }else {
@ -1565,7 +1563,7 @@ static HRESULT StringConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
if(argc) { if(argc) {
BSTR str; BSTR str;
hres = to_string(ctx, argv[0], ei, &str); hres = to_string(ctx, argv[0], &str);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;

View File

@ -45,7 +45,7 @@ static inline VBArrayInstance *vbarray_this(vdisp_t *jsthis)
} }
static HRESULT VBArray_dimensions(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT VBArray_dimensions(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
VBArrayInstance *vbarray; VBArrayInstance *vbarray;
@ -53,7 +53,7 @@ static HRESULT VBArray_dimensions(script_ctx_t *ctx, vdisp_t *vthis, WORD flags,
vbarray = vbarray_this(vthis); vbarray = vbarray_this(vthis);
if(!vbarray) if(!vbarray)
return throw_type_error(ctx, ei, JS_E_VBARRAY_EXPECTED, NULL); return throw_type_error(ctx, JS_E_VBARRAY_EXPECTED, NULL);
if(r) if(r)
*r = jsval_number(SafeArrayGetDim(vbarray->safearray)); *r = jsval_number(SafeArrayGetDim(vbarray->safearray));
@ -61,7 +61,7 @@ static HRESULT VBArray_dimensions(script_ctx_t *ctx, vdisp_t *vthis, WORD flags,
} }
static HRESULT VBArray_getItem(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT VBArray_getItem(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
VBArrayInstance *vbarray; VBArrayInstance *vbarray;
int i, *indexes; int i, *indexes;
@ -72,17 +72,17 @@ static HRESULT VBArray_getItem(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, un
vbarray = vbarray_this(vthis); vbarray = vbarray_this(vthis);
if(!vbarray) if(!vbarray)
return throw_type_error(ctx, ei, JS_E_VBARRAY_EXPECTED, NULL); return throw_type_error(ctx, JS_E_VBARRAY_EXPECTED, NULL);
if(argc < SafeArrayGetDim(vbarray->safearray)) if(argc < SafeArrayGetDim(vbarray->safearray))
return throw_range_error(ctx, ei, JS_E_SUBSCRIPT_OUT_OF_RANGE, NULL); return throw_range_error(ctx, JS_E_SUBSCRIPT_OUT_OF_RANGE, NULL);
indexes = heap_alloc(sizeof(int)*argc); indexes = heap_alloc(sizeof(int)*argc);
if(!indexes) if(!indexes)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
for(i=0; i<argc; i++) { for(i=0; i<argc; i++) {
hres = to_int32(ctx, argv[i], ei, indexes+i); hres = to_int32(ctx, argv[i], indexes+i);
if(FAILED(hres)) { if(FAILED(hres)) {
heap_free(indexes); heap_free(indexes);
return hres; return hres;
@ -92,7 +92,7 @@ static HRESULT VBArray_getItem(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, un
hres = SafeArrayGetElement(vbarray->safearray, indexes, (void*)&out); hres = SafeArrayGetElement(vbarray->safearray, indexes, (void*)&out);
heap_free(indexes); heap_free(indexes);
if(hres == DISP_E_BADINDEX) if(hres == DISP_E_BADINDEX)
return throw_range_error(ctx, ei, JS_E_SUBSCRIPT_OUT_OF_RANGE, NULL); return throw_range_error(ctx, JS_E_SUBSCRIPT_OUT_OF_RANGE, NULL);
else if(FAILED(hres)) else if(FAILED(hres))
return hres; return hres;
@ -104,7 +104,7 @@ static HRESULT VBArray_getItem(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, un
} }
static HRESULT VBArray_lbound(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT VBArray_lbound(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
VBArrayInstance *vbarray; VBArrayInstance *vbarray;
int dim; int dim;
@ -114,10 +114,10 @@ static HRESULT VBArray_lbound(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, uns
vbarray = vbarray_this(vthis); vbarray = vbarray_this(vthis);
if(!vbarray) if(!vbarray)
return throw_type_error(ctx, ei, JS_E_VBARRAY_EXPECTED, NULL); return throw_type_error(ctx, JS_E_VBARRAY_EXPECTED, NULL);
if(argc) { if(argc) {
hres = to_int32(ctx, argv[0], ei, &dim); hres = to_int32(ctx, argv[0], &dim);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
} else } else
@ -125,7 +125,7 @@ static HRESULT VBArray_lbound(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, uns
hres = SafeArrayGetLBound(vbarray->safearray, dim, &dim); hres = SafeArrayGetLBound(vbarray->safearray, dim, &dim);
if(hres == DISP_E_BADINDEX) if(hres == DISP_E_BADINDEX)
return throw_range_error(ctx, ei, JS_E_SUBSCRIPT_OUT_OF_RANGE, NULL); return throw_range_error(ctx, JS_E_SUBSCRIPT_OUT_OF_RANGE, NULL);
else if(FAILED(hres)) else if(FAILED(hres))
return hres; return hres;
@ -135,7 +135,7 @@ static HRESULT VBArray_lbound(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, uns
} }
static HRESULT VBArray_toArray(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT VBArray_toArray(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
VBArrayInstance *vbarray; VBArrayInstance *vbarray;
jsdisp_t *array; jsdisp_t *array;
@ -148,7 +148,7 @@ static HRESULT VBArray_toArray(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, un
vbarray = vbarray_this(vthis); vbarray = vbarray_this(vthis);
if(!vbarray) if(!vbarray)
return throw_type_error(ctx, ei, JS_E_VBARRAY_EXPECTED, NULL); return throw_type_error(ctx, JS_E_VBARRAY_EXPECTED, NULL);
for(i=1; i<=SafeArrayGetDim(vbarray->safearray); i++) { for(i=1; i<=SafeArrayGetDim(vbarray->safearray); i++) {
SafeArrayGetLBound(vbarray->safearray, i, &lbound); SafeArrayGetLBound(vbarray->safearray, i, &lbound);
@ -169,7 +169,7 @@ static HRESULT VBArray_toArray(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, un
for(i=0; i<size; i++) { for(i=0; i<size; i++) {
hres = variant_to_jsval(v, &val); hres = variant_to_jsval(v, &val);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
hres = jsdisp_propput_idx(array, i, val, ei); hres = jsdisp_propput_idx(array, i, val);
jsval_release(val); jsval_release(val);
} }
if(FAILED(hres)) { if(FAILED(hres)) {
@ -188,7 +188,7 @@ static HRESULT VBArray_toArray(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, un
} }
static HRESULT VBArray_ubound(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT VBArray_ubound(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
VBArrayInstance *vbarray; VBArrayInstance *vbarray;
int dim; int dim;
@ -198,10 +198,10 @@ static HRESULT VBArray_ubound(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, uns
vbarray = vbarray_this(vthis); vbarray = vbarray_this(vthis);
if(!vbarray) if(!vbarray)
return throw_type_error(ctx, ei, JS_E_VBARRAY_EXPECTED, NULL); return throw_type_error(ctx, JS_E_VBARRAY_EXPECTED, NULL);
if(argc) { if(argc) {
hres = to_int32(ctx, argv[0], ei, &dim); hres = to_int32(ctx, argv[0], &dim);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
} else } else
@ -209,7 +209,7 @@ static HRESULT VBArray_ubound(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, uns
hres = SafeArrayGetUBound(vbarray->safearray, dim, &dim); hres = SafeArrayGetUBound(vbarray->safearray, dim, &dim);
if(hres == DISP_E_BADINDEX) if(hres == DISP_E_BADINDEX)
return throw_range_error(ctx, ei, JS_E_SUBSCRIPT_OUT_OF_RANGE, NULL); return throw_range_error(ctx, JS_E_SUBSCRIPT_OUT_OF_RANGE, NULL);
else if(FAILED(hres)) else if(FAILED(hres))
return hres; return hres;
@ -219,7 +219,7 @@ static HRESULT VBArray_ubound(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, uns
} }
static HRESULT VBArray_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT VBArray_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
FIXME("\n"); FIXME("\n");
@ -281,7 +281,7 @@ static HRESULT alloc_vbarray(script_ctx_t *ctx, jsdisp_t *object_prototype, VBAr
} }
static HRESULT VBArrayConstr_value(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT VBArrayConstr_value(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r, jsexcept_t *ei) jsval_t *r)
{ {
VBArrayInstance *vbarray; VBArrayInstance *vbarray;
HRESULT hres; HRESULT hres;
@ -291,13 +291,13 @@ static HRESULT VBArrayConstr_value(script_ctx_t *ctx, vdisp_t *vthis, WORD flags
switch(flags) { switch(flags) {
case DISPATCH_METHOD: case DISPATCH_METHOD:
if(argc<1 || !is_variant(argv[0]) || V_VT(get_variant(argv[0])) != (VT_ARRAY|VT_VARIANT)) if(argc<1 || !is_variant(argv[0]) || V_VT(get_variant(argv[0])) != (VT_ARRAY|VT_VARIANT))
return throw_type_error(ctx, ei, JS_E_VBARRAY_EXPECTED, NULL); return throw_type_error(ctx, JS_E_VBARRAY_EXPECTED, NULL);
return jsval_copy(argv[0], r); return jsval_copy(argv[0], r);
case DISPATCH_CONSTRUCT: case DISPATCH_CONSTRUCT:
if(argc<1 || !is_variant(argv[0]) || V_VT(get_variant(argv[0])) != (VT_ARRAY|VT_VARIANT)) if(argc<1 || !is_variant(argv[0]) || V_VT(get_variant(argv[0])) != (VT_ARRAY|VT_VARIANT))
return throw_type_error(ctx, ei, JS_E_VBARRAY_EXPECTED, NULL); return throw_type_error(ctx, JS_E_VBARRAY_EXPECTED, NULL);
hres = alloc_vbarray(ctx, NULL, &vbarray); hres = alloc_vbarray(ctx, NULL, &vbarray);
if(FAILED(hres)) if(FAILED(hres))