Instead of crashing.
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/jscript/activex.c | 3 ++- dlls/jscript/array.c | 4 ++++ dlls/jscript/bool.c | 3 +++ dlls/jscript/date.c | 6 ++++-- dlls/jscript/enumerator.c | 3 ++- dlls/jscript/function.c | 3 ++- dlls/jscript/number.c | 11 ++++++----- dlls/jscript/set.c | 4 ++++ dlls/jscript/string.c | 9 ++++++--- dlls/jscript/tests/api.js | 15 +++++++++++++++ dlls/jscript/vbarray.c | 4 +++- 11 files changed, 51 insertions(+), 14 deletions(-)
diff --git a/dlls/jscript/activex.c b/dlls/jscript/activex.c index 5d79d2b..a74f6ac 100644 --- a/dlls/jscript/activex.c +++ b/dlls/jscript/activex.c @@ -181,7 +181,8 @@ static HRESULT ActiveXObject_value(script_ctx_t *ctx, jsval_t vthis, WORD flags, return E_NOTIMPL; }
- *r = jsval_disp(disp); + if(r) *r = jsval_disp(disp); + else IDispatch_Release(disp); return S_OK; }
diff --git a/dlls/jscript/array.c b/dlls/jscript/array.c index dcabc0d..ee72579 100644 --- a/dlls/jscript/array.c +++ b/dlls/jscript/array.c @@ -1374,6 +1374,8 @@ static HRESULT ArrayConstr_value(script_ctx_t *ctx, jsval_t vthis, WORD flags, u
if(n < 0 || !is_int32(n)) return JS_E_INVALID_LENGTH; + if(!r) + return S_OK;
hres = create_array(ctx, n, &obj); if(FAILED(hres)) @@ -1383,6 +1385,8 @@ static HRESULT ArrayConstr_value(script_ctx_t *ctx, jsval_t vthis, WORD flags, u return S_OK; }
+ if(!r) + return S_OK; hres = create_array(ctx, argc, &obj); if(FAILED(hres)) return hres; diff --git a/dlls/jscript/bool.c b/dlls/jscript/bool.c index a230855..3a4aa9c 100644 --- a/dlls/jscript/bool.c +++ b/dlls/jscript/bool.c @@ -151,6 +151,9 @@ static HRESULT BoolConstr_value(script_ctx_t *ctx, jsval_t vthis, WORD flags, un case DISPATCH_CONSTRUCT: { jsdisp_t *bool;
+ if(!r) + return S_OK; + hres = create_bool(ctx, value, &bool); if(FAILED(hres)) return hres; diff --git a/dlls/jscript/date.c b/dlls/jscript/date.c index e482c4a..bc09f05 100644 --- a/dlls/jscript/date.c +++ b/dlls/jscript/date.c @@ -2248,7 +2248,8 @@ static HRESULT DateConstr_parse(script_ctx_t *ctx, jsval_t vthis, WORD flags, un if(FAILED(hres)) return hres;
- *r = jsval_number(n); + if(r) + *r = jsval_number(n); return S_OK; }
@@ -2403,7 +2404,8 @@ static HRESULT DateConstr_value(script_ctx_t *ctx, jsval_t vthis, WORD flags, un } }
- *r = jsval_obj(&date->dispex); + if(r) *r = jsval_obj(&date->dispex); + else jsdisp_release(&date->dispex); return S_OK;
case INVOKE_FUNC: { diff --git a/dlls/jscript/enumerator.c b/dlls/jscript/enumerator.c index 94eb9f2..f82263e 100644 --- a/dlls/jscript/enumerator.c +++ b/dlls/jscript/enumerator.c @@ -300,7 +300,8 @@ static HRESULT EnumeratorConstr_value(script_ctx_t *ctx, jsval_t vthis, WORD fla if(FAILED(hres)) return hres;
- *r = jsval_obj(obj); + if(r) *r = jsval_obj(obj); + else jsdisp_release(obj); break; } default: diff --git a/dlls/jscript/function.c b/dlls/jscript/function.c index 03c541c..12511bb 100644 --- a/dlls/jscript/function.c +++ b/dlls/jscript/function.c @@ -1008,7 +1008,8 @@ static HRESULT FunctionConstr_value(script_ctx_t *ctx, jsval_t vthis, WORD flags if(FAILED(hres)) return hres;
- *r = jsval_disp(ret); + if(r) *r = jsval_disp(ret); + else IDispatch_Release(ret); break; } default: diff --git a/dlls/jscript/number.c b/dlls/jscript/number.c index 472acd0..be733fb 100644 --- a/dlls/jscript/number.c +++ b/dlls/jscript/number.c @@ -554,11 +554,12 @@ static HRESULT NumberConstr_value(script_ctx_t *ctx, jsval_t vthis, WORD flags, n = 0; }
- hres = create_number(ctx, n, &obj); - if(FAILED(hres)) - return hres; - - *r = jsval_obj(obj); + if(r) { + hres = create_number(ctx, n, &obj); + if(FAILED(hres)) + return hres; + *r = jsval_obj(obj); + } break; } default: diff --git a/dlls/jscript/set.c b/dlls/jscript/set.c index 7973d42..8098d76 100644 --- a/dlls/jscript/set.c +++ b/dlls/jscript/set.c @@ -114,6 +114,8 @@ static HRESULT Set_constructor(script_ctx_t *ctx, jsval_t vthis, WORD flags, uns case DISPATCH_CONSTRUCT: TRACE("\n");
+ if(!r) + return S_OK; if(!(set = heap_alloc_zero(sizeof(*set)))) return E_OUTOFMEMORY;
@@ -461,6 +463,8 @@ static HRESULT Map_constructor(script_ctx_t *ctx, jsval_t vthis, WORD flags, uns case DISPATCH_CONSTRUCT: TRACE("\n");
+ if(!r) + return S_OK; if(!(map = heap_alloc_zero(sizeof(*map)))) return E_OUTOFMEMORY;
diff --git a/dlls/jscript/string.c b/dlls/jscript/string.c index 0b2e695..e73b9e8 100644 --- a/dlls/jscript/string.c +++ b/dlls/jscript/string.c @@ -1644,7 +1644,8 @@ static HRESULT StringConstr_value(script_ctx_t *ctx, jsval_t vthis, WORD flags, str = jsstr_empty(); }
- *r = jsval_string(str); + if(r) *r = jsval_string(str); + else jsstr_release(str); break; } case DISPATCH_CONSTRUCT: { @@ -1659,8 +1660,10 @@ static HRESULT StringConstr_value(script_ctx_t *ctx, jsval_t vthis, WORD flags, str = jsstr_empty(); }
- hres = create_string(ctx, str, &ret); - if (SUCCEEDED(hres)) *r = jsval_obj(ret); + if(r) { + hres = create_string(ctx, str, &ret); + if(SUCCEEDED(hres)) *r = jsval_obj(ret); + } jsstr_release(str); return hres; } diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js index fe336d4..1efc023 100644 --- a/dlls/jscript/tests/api.js +++ b/dlls/jscript/tests/api.js @@ -287,6 +287,8 @@ ok(Object.prototype.hasOwnProperty('toString'), "Object.prototype.hasOwnProperty ok(Object.prototype.hasOwnProperty('isPrototypeOf'), "Object.prototype.hasOwnProperty('isPrototypeOf') is false"); ok(Function.prototype.hasOwnProperty('call'), "Function.prototype.hasOwnProperty('call') is false");
+Object(); +new Object(); obj = new Object();
ok(!obj.hasOwnProperty('toString'), "obj.hasOwnProperty('toString') is true"); @@ -296,28 +298,37 @@ ok(!Object.hasOwnProperty('isPrototypeOf'), "Object.hasOwnProperty('isPrototypeO ok(!parseFloat.hasOwnProperty('call'), "parseFloat.hasOwnProperty('call') is true"); ok(!Function.hasOwnProperty('call'), "Function.hasOwnProperty('call') is true");
+Array(); +new Array(); obj = new Array(); ok(Array.prototype.hasOwnProperty('sort'), "Array.prototype.hasOwnProperty('sort') is false"); ok(Array.prototype.hasOwnProperty('length'), "Array.prototype.hasOwnProperty('length') is false"); ok(!obj.hasOwnProperty('sort'), "obj.hasOwnProperty('sort') is true"); ok(obj.hasOwnProperty('length'), "obj.hasOwnProperty('length') is true");
+Boolean(); +new Boolean(); obj = new Boolean(false); ok(!obj.hasOwnProperty('toString'), "obj.hasOwnProperty('toString') is true"); ok(!Boolean.hasOwnProperty('toString'), "Boolean.hasOwnProperty('toString') is true"); ok(Boolean.prototype.hasOwnProperty('toString'), "Boolean.prototype.hasOwnProperty('toString') is false");
+Date(); +new Date(); obj = new Date(); ok(!obj.hasOwnProperty('getTime'), "obj.hasOwnProperty('getTime') is true"); ok(!Date.hasOwnProperty('getTime'), "Date.hasOwnProperty('getTime') is true"); ok(Date.prototype.hasOwnProperty('getTime'), "Date.prototype.hasOwnProperty('getTime') is false"); ok(!("now" in Date), "now found in Date");
+Number(); +new Number(); obj = new Number(); ok(!obj.hasOwnProperty('toFixed'), "obj.hasOwnProperty('toFixed') is true"); ok(!Number.hasOwnProperty('toFixed'), "Number.hasOwnProperty('toFixed') is true"); ok(Number.prototype.hasOwnProperty('toFixed'), "Number.prototype.hasOwnProperty('toFixed') is false");
+/x/; obj = /x/; ok(!obj.hasOwnProperty('exec'), "obj.hasOwnProperty('exec') is true"); ok(obj.hasOwnProperty('source'), "obj.hasOwnProperty('source') is false"); @@ -325,6 +336,8 @@ ok(!RegExp.hasOwnProperty('exec'), "RegExp.hasOwnProperty('exec') is true"); ok(!RegExp.hasOwnProperty('source'), "RegExp.hasOwnProperty('source') is true"); ok(RegExp.prototype.hasOwnProperty('source'), "RegExp.prototype.hasOwnProperty('source') is false");
+String(); +new String(); obj = new String(); ok(!obj.hasOwnProperty('charAt'), "obj.hasOwnProperty('charAt') is true"); ok(obj.hasOwnProperty('length'), "obj.hasOwnProperty('length') is false"); @@ -3127,6 +3140,8 @@ ok(String.length == 1, "String.length = " + String.length); var tmp = createArray(); ok(getVT(tmp) == "VT_ARRAY|VT_VARIANT", "getVT(createArray()) = " + getVT(tmp)); ok(getVT(VBArray(tmp)) == "VT_ARRAY|VT_VARIANT", "getVT(VBArray(tmp)) = " + getVT(VBArray(tmp))); +VBArray(tmp); +new VBArray(tmp); tmp = new VBArray(tmp); tmp = new VBArray(VBArray(createArray())); ok(tmp.dimensions() == 2, "tmp.dimensions() = " + tmp.dimensions()); diff --git a/dlls/jscript/vbarray.c b/dlls/jscript/vbarray.c index 987d714..d55e90d 100644 --- a/dlls/jscript/vbarray.c +++ b/dlls/jscript/vbarray.c @@ -291,11 +291,13 @@ static HRESULT VBArrayConstr_value(script_ctx_t *ctx, jsval_t vthis, WORD flags, if(argc<1 || !is_variant(argv[0]) || V_VT(get_variant(argv[0])) != (VT_ARRAY|VT_VARIANT)) return JS_E_VBARRAY_EXPECTED;
- return jsval_copy(argv[0], r); + return r ? jsval_copy(argv[0], r) : S_OK;
case DISPATCH_CONSTRUCT: if(argc<1 || !is_variant(argv[0]) || V_VT(get_variant(argv[0])) != (VT_ARRAY|VT_VARIANT)) return JS_E_VBARRAY_EXPECTED; + if(!r) + return S_OK;
hres = alloc_vbarray(ctx, NULL, &vbarray); if(FAILED(hres))
So it can be implemented on top of Map.
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/jscript/set.c | 190 ++++++++++++++++++++++----------------------- 1 file changed, 95 insertions(+), 95 deletions(-)
diff --git a/dlls/jscript/set.c b/dlls/jscript/set.c index 8098d76..d87ce97 100644 --- a/dlls/jscript/set.c +++ b/dlls/jscript/set.c @@ -37,101 +37,6 @@ typedef struct { size_t size; } MapInstance;
-static HRESULT Set_add(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, - jsval_t *r) -{ - FIXME("%p\n", debugstr_jsval(vthis)); - return E_NOTIMPL; -} - -static HRESULT Set_clear(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, - jsval_t *r) -{ - FIXME("%p\n", debugstr_jsval(vthis)); - return E_NOTIMPL; -} - -static HRESULT Set_delete(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, - jsval_t *r) -{ - FIXME("%p\n", debugstr_jsval(vthis)); - return E_NOTIMPL; -} - -static HRESULT Set_forEach(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, - jsval_t *r) -{ - FIXME("%p\n", debugstr_jsval(vthis)); - return E_NOTIMPL; -} - -static HRESULT Set_has(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, - jsval_t *r) -{ - FIXME("%p\n", debugstr_jsval(vthis)); - return E_NOTIMPL; -} - -static HRESULT Set_value(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, - jsval_t *r) -{ - FIXME("\n"); - return E_NOTIMPL; -} - -static const builtin_prop_t Set_props[] = { - {L"add", Set_add, PROPF_METHOD|1}, - {L"clear", Set_clear, PROPF_METHOD}, - {L"delete" , Set_delete, PROPF_METHOD|1}, - {L"forEach", Set_forEach, PROPF_METHOD|1}, - {L"has", Set_has, PROPF_METHOD|1}, -}; - -static const builtin_info_t Set_prototype_info = { - JSCLASS_SET, - Set_value, - ARRAY_SIZE(Set_props), - Set_props, - NULL, - NULL -}; - -static const builtin_info_t Set_info = { - JSCLASS_SET, - Set_value, - 0, NULL, - NULL, - NULL -}; - -static HRESULT Set_constructor(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, - jsval_t *r) -{ - SetInstance *set; - HRESULT hres; - - switch(flags) { - case DISPATCH_CONSTRUCT: - TRACE("\n"); - - if(!r) - return S_OK; - if(!(set = heap_alloc_zero(sizeof(*set)))) - return E_OUTOFMEMORY; - - hres = init_dispex(&set->dispex, ctx, &Set_info, ctx->set_prototype); - if(FAILED(hres)) - return hres; - - *r = jsval_obj(&set->dispex); - return S_OK; - - default: - FIXME("unimplemented flags %x\n", flags); - return E_NOTIMPL; - } -} - struct jsval_map_entry { struct wine_rb_entry entry; jsval_t key; @@ -483,6 +388,101 @@ static HRESULT Map_constructor(script_ctx_t *ctx, jsval_t vthis, WORD flags, uns } }
+static HRESULT Set_add(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, + jsval_t *r) +{ + FIXME("%p\n", debugstr_jsval(vthis)); + return E_NOTIMPL; +} + +static HRESULT Set_clear(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, + jsval_t *r) +{ + FIXME("%p\n", debugstr_jsval(vthis)); + return E_NOTIMPL; +} + +static HRESULT Set_delete(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, + jsval_t *r) +{ + FIXME("%p\n", debugstr_jsval(vthis)); + return E_NOTIMPL; +} + +static HRESULT Set_forEach(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, + jsval_t *r) +{ + FIXME("%p\n", debugstr_jsval(vthis)); + return E_NOTIMPL; +} + +static HRESULT Set_has(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, + jsval_t *r) +{ + FIXME("%p\n", debugstr_jsval(vthis)); + return E_NOTIMPL; +} + +static HRESULT Set_value(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, + jsval_t *r) +{ + FIXME("\n"); + return E_NOTIMPL; +} + +static const builtin_prop_t Set_props[] = { + {L"add", Set_add, PROPF_METHOD|1}, + {L"clear", Set_clear, PROPF_METHOD}, + {L"delete" , Set_delete, PROPF_METHOD|1}, + {L"forEach", Set_forEach, PROPF_METHOD|1}, + {L"has", Set_has, PROPF_METHOD|1}, +}; + +static const builtin_info_t Set_prototype_info = { + JSCLASS_SET, + Set_value, + ARRAY_SIZE(Set_props), + Set_props, + NULL, + NULL +}; + +static const builtin_info_t Set_info = { + JSCLASS_SET, + Set_value, + 0, NULL, + NULL, + NULL +}; + +static HRESULT Set_constructor(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, + jsval_t *r) +{ + SetInstance *set; + HRESULT hres; + + switch(flags) { + case DISPATCH_CONSTRUCT: + TRACE("\n"); + + if(!r) + return S_OK; + if(!(set = heap_alloc_zero(sizeof(*set)))) + return E_OUTOFMEMORY; + + hres = init_dispex(&set->dispex, ctx, &Set_info, ctx->set_prototype); + if(FAILED(hres)) + return hres; + + *r = jsval_obj(&set->dispex); + return S_OK; + + default: + FIXME("unimplemented flags %x\n", flags); + return E_NOTIMPL; + } +} + HRESULT init_set_constructor(script_ctx_t *ctx) { jsdisp_t *constructor;
Signed-off-by: Jacek Caban jacek@codeweavers.com
So it can be re-used by Set objects.
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/jscript/set.c | 64 +++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 29 deletions(-)
diff --git a/dlls/jscript/set.c b/dlls/jscript/set.c index d87ce97..8946dbb 100644 --- a/dlls/jscript/set.c +++ b/dlls/jscript/set.c @@ -127,6 +127,40 @@ static void delete_map_entry(MapInstance *map, struct jsval_map_entry *entry) release_map_entry(entry); }
+static HRESULT iterate_map(MapInstance *map, script_ctx_t *ctx, unsigned argc, jsval_t *argv, jsval_t *r) +{ + struct jsval_map_entry *entry; + HRESULT hres; + + if(!argc || !is_object_instance(argv[0])) { + FIXME("invalid callback %s\n", debugstr_jsval(argc ? argv[0] : jsval_undefined())); + return E_FAIL; + } + + if(argc > 1) { + FIXME("Unsupported argument\n"); + return E_NOTIMPL; + } + + LIST_FOR_EACH_ENTRY(entry, &map->entries, struct jsval_map_entry, list_entry) { + jsval_t args[2], v; + if(entry->deleted) + continue; + args[0] = entry->value; + args[1] = entry->key; + grab_map_entry(entry); + hres = disp_call_value(ctx, get_object(argv[0]), NULL, DISPATCH_METHOD, + ARRAY_SIZE(args), args, &v); + release_map_entry(entry); + if(FAILED(hres)) + return hres; + jsval_release(v); + } + + if(r) *r = jsval_undefined(); + return S_OK; +} + static HRESULT Map_clear(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r) { @@ -170,8 +204,6 @@ static HRESULT Map_delete(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned static HRESULT Map_forEach(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r) { - jsval_t callback = argc ? argv[0] : jsval_undefined(); - struct jsval_map_entry *entry; MapInstance *map; HRESULT hres;
@@ -181,33 +213,7 @@ static HRESULT Map_forEach(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigne
TRACE("%p (%s)\n", map, debugstr_jsval(argc >= 1 ? argv[0] : jsval_undefined()));
- if(!is_object_instance(callback)) { - FIXME("invalid callback %s\n", debugstr_jsval(callback)); - return E_FAIL; - } - - if(argc > 1) { - FIXME("Unsupported argument\n"); - return E_NOTIMPL; - } - - LIST_FOR_EACH_ENTRY(entry, &map->entries, struct jsval_map_entry, list_entry) { - jsval_t args[2], v; - if(entry->deleted) - continue; - args[0] = entry->value; - args[1] = entry->key; - grab_map_entry(entry); - hres = disp_call_value(ctx, get_object(argv[0]), NULL, DISPATCH_METHOD, - ARRAY_SIZE(args), args, &v); - release_map_entry(entry); - if(FAILED(hres)) - return hres; - jsval_release(v); - } - - if(r) *r = jsval_undefined(); - return S_OK; + return iterate_map(map, ctx, argc, argv, r); }
static HRESULT Map_get(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
Signed-off-by: Jacek Caban jacek@codeweavers.com
So it can be re-used by Set objects.
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/jscript/set.c | 67 +++++++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 30 deletions(-)
diff --git a/dlls/jscript/set.c b/dlls/jscript/set.c index 8946dbb..640bf44 100644 --- a/dlls/jscript/set.c +++ b/dlls/jscript/set.c @@ -127,6 +127,42 @@ static void delete_map_entry(MapInstance *map, struct jsval_map_entry *entry) release_map_entry(entry); }
+static HRESULT set_map_entry(MapInstance *map, jsval_t key, jsval_t value, jsval_t *r) +{ + struct jsval_map_entry *entry; + HRESULT hres; + + if((entry = get_map_entry(map, key))) { + jsval_t val; + hres = jsval_copy(value, &val); + if(FAILED(hres)) + return hres; + + jsval_release(entry->value); + entry->value = val; + }else { + if(!(entry = heap_alloc_zero(sizeof(*entry)))) return E_OUTOFMEMORY; + + hres = jsval_copy(key, &entry->key); + if(SUCCEEDED(hres)) { + hres = jsval_copy(value, &entry->value); + if(FAILED(hres)) + jsval_release(entry->key); + } + if(FAILED(hres)) { + heap_free(entry); + return hres; + } + grab_map_entry(entry); + wine_rb_put(&map->map, &entry->key, &entry->entry); + list_add_tail(&map->entries, &entry->list_entry); + map->size++; + } + + if(r) *r = jsval_undefined(); + return S_OK; +} + static HRESULT iterate_map(MapInstance *map, script_ctx_t *ctx, unsigned argc, jsval_t *argv, jsval_t *r) { struct jsval_map_entry *entry; @@ -243,7 +279,6 @@ static HRESULT Map_set(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned ar { jsval_t key = argc >= 1 ? argv[0] : jsval_undefined(); jsval_t value = argc >= 2 ? argv[1] : jsval_undefined(); - struct jsval_map_entry *entry; MapInstance *map; HRESULT hres;
@@ -253,35 +288,7 @@ static HRESULT Map_set(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned ar
TRACE("%p (%s %s)\n", map, debugstr_jsval(key), debugstr_jsval(value));
- if((entry = get_map_entry(map, key))) { - jsval_t val; - hres = jsval_copy(value, &val); - if(FAILED(hres)) - return hres; - - jsval_release(entry->value); - entry->value = val; - }else { - if(!(entry = heap_alloc_zero(sizeof(*entry)))) return E_OUTOFMEMORY; - - hres = jsval_copy(key, &entry->key); - if(SUCCEEDED(hres)) { - hres = jsval_copy(value, &entry->value); - if(FAILED(hres)) - jsval_release(entry->key); - } - if(FAILED(hres)) { - heap_free(entry); - return hres; - } - grab_map_entry(entry); - wine_rb_put(&map->map, &entry->key, &entry->entry); - list_add_tail(&map->entries, &entry->list_entry); - map->size++; - } - - if(r) *r = jsval_undefined(); - return S_OK; + return set_map_entry(map, key, value, r); }
static HRESULT Map_has(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
Signed-off-by: Jacek Caban jacek@codeweavers.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/jscript/set.c | 3 ++- dlls/mshtml/tests/documentmode.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/dlls/jscript/set.c b/dlls/jscript/set.c index 640bf44..dd6829d 100644 --- a/dlls/jscript/set.c +++ b/dlls/jscript/set.c @@ -179,11 +179,12 @@ static HRESULT iterate_map(MapInstance *map, script_ctx_t *ctx, unsigned argc, j }
LIST_FOR_EACH_ENTRY(entry, &map->entries, struct jsval_map_entry, list_entry) { - jsval_t args[2], v; + jsval_t args[3], v; if(entry->deleted) continue; args[0] = entry->value; args[1] = entry->key; + args[2] = jsval_obj(&map->dispex); grab_map_entry(entry); hres = disp_call_value(ctx, get_object(argv[0]), NULL, DISPATCH_METHOD, ARRAY_SIZE(args), args, &v); diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index 28450f7..ed41ac1 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -995,7 +995,7 @@ sync_test("map_obj", function() {
var calls = []; i = 0; - r = s.forEach(function(value, key) { + r = s.forEach(function(value, key, map) { if(isNaN(test_keys[i])) { ok(isNaN(key), "key = " + key + " expected NaN"); ok(isNaN(value), "value = " + value + " expected NaN"); @@ -1003,6 +1003,7 @@ sync_test("map_obj", function() { ok(key === test_keys[i], "key = " + key + " expected " + test_keys[i]); ok(value === key + 1, "value = " + value); } + ok(map === s, "map = " + map); i++; }); ok(i === test_keys.length, "i = " + i);
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=112579
Your paranoid android.
=== w7u_adm (32 bit report) ===
mshtml: script.c:634: Test failed: L"/index.html?es5.js:date_now: unexpected Date.now() result 1649954397831 expected 1649954397884"
Signed-off-by: Jacek Caban jacek@codeweavers.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/jscript/set.c | 14 +++++++++----- dlls/mshtml/tests/documentmode.js | 3 ++- 2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/dlls/jscript/set.c b/dlls/jscript/set.c index dd6829d..281049a 100644 --- a/dlls/jscript/set.c +++ b/dlls/jscript/set.c @@ -166,6 +166,7 @@ static HRESULT set_map_entry(MapInstance *map, jsval_t key, jsval_t value, jsval static HRESULT iterate_map(MapInstance *map, script_ctx_t *ctx, unsigned argc, jsval_t *argv, jsval_t *r) { struct jsval_map_entry *entry; + IDispatch *context_obj = NULL; HRESULT hres;
if(!argc || !is_object_instance(argv[0])) { @@ -173,9 +174,12 @@ static HRESULT iterate_map(MapInstance *map, script_ctx_t *ctx, unsigned argc, j return E_FAIL; }
- if(argc > 1) { - FIXME("Unsupported argument\n"); - return E_NOTIMPL; + if(argc > 1 && !is_undefined(argv[1])) { + if(!is_object_instance(argv[1])) { + FIXME("Unsupported context this %s\n", debugstr_jsval(argv[1])); + return E_NOTIMPL; + } + context_obj = get_object(argv[1]); }
LIST_FOR_EACH_ENTRY(entry, &map->entries, struct jsval_map_entry, list_entry) { @@ -186,8 +190,8 @@ static HRESULT iterate_map(MapInstance *map, script_ctx_t *ctx, unsigned argc, j args[1] = entry->key; args[2] = jsval_obj(&map->dispex); grab_map_entry(entry); - hres = disp_call_value(ctx, get_object(argv[0]), NULL, DISPATCH_METHOD, - ARRAY_SIZE(args), args, &v); + hres = disp_call_value(ctx, get_object(argv[0]), context_obj, + DISPATCH_METHOD, ARRAY_SIZE(args), args, &v); release_map_entry(entry); if(FAILED(hres)) return hres; diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index ed41ac1..0da8d12 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -1004,8 +1004,9 @@ sync_test("map_obj", function() { ok(value === key + 1, "value = " + value); } ok(map === s, "map = " + map); + ok(this === test_keys, "this = " + this); i++; - }); + }, test_keys); ok(i === test_keys.length, "i = " + i); ok(r === undefined, "forEach returned " + r);
Signed-off-by: Jacek Caban jacek@codeweavers.com
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=112580
Your paranoid android.
=== w1064_2qxl (64 bit report) ===
mshtml: htmldoc.c:2541: Test failed: unexpected call UpdateUI htmldoc.c:2853: Test failed: unexpected call Exec_UPDATECOMMANDS htmldoc.c:350: Test failed: expected Exec_SETTITLE htmldoc.c:2859: Test failed: unexpected call Exec_SETTITLE
=== w7u_2qxl (32 bit report) ===
mshtml: script.c:634: Test failed: L"/index.html?es5.js:date_now: unexpected Date.now() result 1649961368460 expected 1649961368518"
Native treats -0 and 0 differently, so it must be doing a bitwise comparison. This might not order the numbers correctly, but that's not important, since we don't need them sorted other than for quick lookup (and any arbitrary sorting is fine, as long as it's consistent).
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/jscript/set.c | 11 +++++++++-- dlls/mshtml/tests/documentmode.js | 9 +++++++++ 2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/dlls/jscript/set.c b/dlls/jscript/set.c index 281049a..bdfe7b7 100644 --- a/dlls/jscript/set.c +++ b/dlls/jscript/set.c @@ -56,6 +56,10 @@ static int jsval_map_compare(const void *k, const struct wine_rb_entry *e) { const struct jsval_map_entry *entry = WINE_RB_ENTRY_VALUE(e, const struct jsval_map_entry, entry); const jsval_t *key = k; + union { + double d; + INT64 n; + } bits1, bits2;
if(jsval_type(entry->key) != jsval_type(*key)) return (int)jsval_type(entry->key) - (int)jsval_type(*key); @@ -70,10 +74,13 @@ static int jsval_map_compare(const void *k, const struct wine_rb_entry *e) case JSV_STRING: return jsstr_cmp(get_string(*key), get_string(entry->key)); case JSV_NUMBER: - if(get_number(*key) == get_number(entry->key)) return 0; if(isnan(get_number(*key))) return isnan(get_number(entry->key)) ? 0 : -1; if(isnan(get_number(entry->key))) return 1; - return get_number(*key) < get_number(entry->key) ? -1 : 1; + + /* native treats -0 differently than 0, so need to compare bitwise */ + bits1.d = get_number(*key); + bits2.d = get_number(entry->key); + return (bits1.n == bits2.n) ? 0 : (bits1.n < bits2.n ? -1 : 1); case JSV_BOOL: if(get_bool(*key) == get_bool(entry->key)) return 0; return get_bool(*key) ? 1 : -1; diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index 0da8d12..6d06dad 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -1051,6 +1051,15 @@ sync_test("map_obj", function() { }); ok(i === 66, "i = " + i);
+ s = new Map(); + s.set(0, 10); + s.set(-0, 20); + ok(s.size === 2, "size = " + s.size + " expected 2"); + r = s.get(-0); + ok(r === 20, "get(-0) returned " + r); + r = s.get(0); + ok(r === 10, "get(0) returned " + r); + try { Map.prototype.set.call({}, 1, 2); ok(false, "expected exception");
Signed-off-by: Jacek Caban jacek@codeweavers.com
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=112581
Your paranoid android.
=== w10pro64_he (64 bit report) ===
mshtml: htmldoc.c:2541: Test failed: unexpected call UpdateUI htmldoc.c:2853: Test failed: unexpected call Exec_UPDATECOMMANDS htmldoc.c:350: Test failed: expected Exec_SETTITLE htmldoc.c:2859: Test failed: unexpected call Exec_SETTITLE
Because a Set is just a Map where key == value.
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/jscript/set.c | 111 ++++++++++++++++++++++++------ dlls/mshtml/tests/documentmode.js | 65 +++++++++++++++++ dlls/mshtml/tests/es5.js | 1 + 3 files changed, 156 insertions(+), 21 deletions(-)
diff --git a/dlls/jscript/set.c b/dlls/jscript/set.c index bdfe7b7..f3e8fe6 100644 --- a/dlls/jscript/set.c +++ b/dlls/jscript/set.c @@ -26,10 +26,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(jscript);
-typedef struct { - jsdisp_t dispex; -} SetInstance; - typedef struct { jsdisp_t dispex; struct wine_rb_tree map; @@ -105,6 +101,21 @@ static HRESULT get_map_this(jsval_t vthis, MapInstance **ret) return S_OK; }
+static HRESULT get_set_this(jsval_t vthis, MapInstance **ret) +{ + jsdisp_t *jsdisp; + + if(!is_object_instance(vthis)) + return JS_E_OBJECT_EXPECTED; + if(!(jsdisp = to_jsdisp(get_object(vthis))) || !is_class(jsdisp, JSCLASS_SET)) { + WARN("not a Set object passed as 'this'\n"); + return JS_E_MAP_EXPECTED; + } + + *ret = CONTAINING_RECORD(jsdisp, MapInstance, dispex); + return S_OK; +} + static struct jsval_map_entry *get_map_entry(MapInstance *map, jsval_t key) { struct wine_rb_entry *entry; @@ -416,36 +427,91 @@ static HRESULT Map_constructor(script_ctx_t *ctx, jsval_t vthis, WORD flags, uns static HRESULT Set_add(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r) { - FIXME("%p\n", debugstr_jsval(vthis)); - return E_NOTIMPL; + jsval_t key = argc ? argv[0] : jsval_undefined(); + MapInstance *set; + HRESULT hres; + + hres = get_set_this(vthis, &set); + if(FAILED(hres)) + return hres; + + TRACE("%p (%s)\n", set, debugstr_jsval(key)); + + return set_map_entry(set, key, key, r); }
static HRESULT Set_clear(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r) { - FIXME("%p\n", debugstr_jsval(vthis)); - return E_NOTIMPL; + MapInstance *set; + HRESULT hres; + + hres = get_set_this(vthis, &set); + if(FAILED(hres)) + return hres; + + TRACE("%p\n", set); + + while(!list_empty(&set->entries)) { + struct jsval_map_entry *entry = LIST_ENTRY(list_head(&set->entries), struct jsval_map_entry, list_entry); + delete_map_entry(set, entry); + } + + if(r) *r = jsval_undefined(); + return S_OK; }
static HRESULT Set_delete(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r) { - FIXME("%p\n", debugstr_jsval(vthis)); - return E_NOTIMPL; + jsval_t key = argc ? argv[0] : jsval_undefined(); + struct jsval_map_entry *entry; + MapInstance *set; + HRESULT hres; + + hres = get_set_this(vthis, &set); + if(FAILED(hres)) + return hres; + + TRACE("%p (%s)\n", set, debugstr_jsval(key)); + + if((entry = get_map_entry(set, key))) delete_map_entry(set, entry); + if(r) *r = jsval_bool(!!entry); + return S_OK; }
static HRESULT Set_forEach(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r) { - FIXME("%p\n", debugstr_jsval(vthis)); - return E_NOTIMPL; + MapInstance *set; + HRESULT hres; + + hres = get_set_this(vthis, &set); + if(FAILED(hres)) + return hres; + + TRACE("%p (%s)\n", set, debugstr_jsval(argc ? argv[0] : jsval_undefined())); + + return iterate_map(set, ctx, argc, argv, r); }
static HRESULT Set_has(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r) { - FIXME("%p\n", debugstr_jsval(vthis)); - return E_NOTIMPL; + jsval_t key = argc ? argv[0] : jsval_undefined(); + struct jsval_map_entry *entry; + MapInstance *set; + HRESULT hres; + + hres = get_set_this(vthis, &set); + if(FAILED(hres)) + return hres; + + TRACE("%p (%s)\n", set, debugstr_jsval(key)); + + entry = get_map_entry(set, key); + if(r) *r = jsval_bool(!!entry); + return S_OK; }
static HRESULT Set_value(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, @@ -455,7 +521,7 @@ static HRESULT Set_value(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned return E_NOTIMPL; }
-static const builtin_prop_t Set_props[] = { +static const builtin_prop_t Set_prototype_props[] = { {L"add", Set_add, PROPF_METHOD|1}, {L"clear", Set_clear, PROPF_METHOD}, {L"delete" , Set_delete, PROPF_METHOD|1}, @@ -464,10 +530,10 @@ static const builtin_prop_t Set_props[] = { };
static const builtin_info_t Set_prototype_info = { - JSCLASS_SET, + JSCLASS_OBJECT, Set_value, - ARRAY_SIZE(Set_props), - Set_props, + ARRAY_SIZE(Set_prototype_props), + Set_prototype_props, NULL, NULL }; @@ -475,15 +541,16 @@ static const builtin_info_t Set_prototype_info = { static const builtin_info_t Set_info = { JSCLASS_SET, Set_value, - 0, NULL, - NULL, + ARRAY_SIZE(Map_props), + Map_props, + Map_destructor, NULL };
static HRESULT Set_constructor(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r) { - SetInstance *set; + MapInstance *set; HRESULT hres;
switch(flags) { @@ -499,6 +566,8 @@ static HRESULT Set_constructor(script_ctx_t *ctx, jsval_t vthis, WORD flags, uns if(FAILED(hres)) return hres;
+ wine_rb_init(&set->map, jsval_map_compare); + list_init(&set->entries); *r = jsval_obj(&set->dispex); return S_OK;
diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index 6d06dad..74e871e 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -912,6 +912,12 @@ sync_test("set_obj", function() {
function test_length(name, len) { ok(Set.prototype[name].length === len, "Set.prototype." + name + " = " + Set.prototype[name].length); + try { + Set.prototype[name].call({}, 0); + ok(false, "expected exception calling Set.prototype." + name + "(object)"); + }catch(e) { + ok(e.number === 0xa13fc - 0x80000000, "Set.prototype." + name + "(object) threw " + e.number); + } } test_length("add", 1); test_length("clear", 0); @@ -924,6 +930,65 @@ sync_test("set_obj", function() {
r = Object.prototype.toString.call(s); ok(r === "[object Object]", "toString returned " + r); + + r = s.has(-0); + ok(r === false, "has(-0) returned " + r); + ok(s.size === 0, "size = " + s.size); + + r = s.add(42); + ok(r === undefined, "add(42) returned " + r); + r = s.add(42); + ok(r === undefined, "add(42) returned " + r); + r = s.add(0); + ok(r === undefined, "add(0) returned " + r); + r = s.has(-0); + ok(r === false, "has(-0) returned " + r); + r = s.add(-0); + ok(r === undefined, "add(-0) returned " + r); + r = s.has(-0); + ok(r === true, "has(-0) after add returned " + r); + r = s.add("test"); + ok(r === undefined, "add(test) returned " + r); + r = s.add(13); + ok(r === undefined, "add(13) returned " + r); + r = s.add(s); + ok(r === undefined, "add(s) returned " + r); + + r = s["delete"]("test"); /* using s.delete() would break parsing in quirks mode */ + ok(r === true, "delete(test) returned " + r); + r = s["delete"]("test"); + ok(r === false, "delete(test) returned " + r); + + ok(s.size === 5, "size = " + s.size); + s.size = 100; + ok(s.size === 5, "size (after set) = " + s.size); + + var a = []; + r = s.forEach(function(value, key, obj) { + var t = s["delete"](key); + ok(t === true, "delete(" + key + ") returned " + r); + ok(value === key, "value = " + value + ", key = " + key); + ok(obj === s, "set = " + obj); + ok(this === a, "this = " + this); + a.push(value); + }, a); + ok(r === undefined, "forEach returned " + r); + ok(a.length === 5, "a.length = " + a.length); + for(var i = 0; i < a.length; i++) + ok(a[i] === [42, 0, -0, 13, s][i], "a[" + i + "] = " + a[i]); + ok(s.size === 0, "size = " + s.size); + + s = new Set(); + ok(s.size === 0, "size = " + s.size); + s.add(1); + s.add(2); + ok(s.size === 2, "size = " + s.size); + r = s.clear(); + ok(r === undefined, "clear returned " + r); + ok(s.size === 0, "size = " + s.size); + + s = new Set([1, 2, 3]); + ok(s.size === 0, "size = " + s.size); });
sync_test("map_obj", function() { diff --git a/dlls/mshtml/tests/es5.js b/dlls/mshtml/tests/es5.js index 43a6ce7..4892207 100644 --- a/dlls/mshtml/tests/es5.js +++ b/dlls/mshtml/tests/es5.js @@ -1376,6 +1376,7 @@ sync_test("builtin_context", function() { [ "Number.toFixed", JS_E_NUMBER_EXPECTED, function(ctx) { Number.prototype.toFixed.call(ctx); } ], [ "Object.isPrototypeOf", JS_E_OBJECT_EXPECTED, function(ctx) { Object.prototype.isPrototypeOf.call(ctx, Object); } ], [ "RegExp.exec", JS_E_REGEXP_EXPECTED, function(ctx) { RegExp.prototype.exec.call(ctx, "foobar"); } ], + [ "Set.add", JS_E_OBJECT_EXPECTED, function(ctx) { Set.prototype.add.call(ctx, 5); } ], [ "String.search", JS_E_OBJECT_EXPECTED, function(ctx) { String.prototype.search.call(ctx, /foobar/g); } ], [ "String.trim", JS_E_OBJECT_EXPECTED, function(ctx) { String.prototype.trim.call(ctx); } ], [ "VBArray.dimensions", JS_E_VBARRAY_EXPECTED, function(ctx) { VBArray.prototype.dimensions.call(ctx); } ]
Signed-off-by: Jacek Caban jacek@codeweavers.com
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=112582
Your paranoid android.
=== w8adm (32 bit report) ===
mshtml: htmldoc.c:3084: Test failed: Incorrect error code: -2146697211 htmldoc.c:3089: Test failed: Page address: L"http://test.winehq.org/tests/winehq_snapshot/" htmldoc.c:5861: Test failed: expected OnChanged_1012 htmldoc.c:5862: Test failed: expected Exec_HTTPEQUIV htmldoc.c:5864: Test failed: expected Exec_SETTITLE htmldoc.c:5905: Test failed: expected FireNavigateComplete2
=== w10pro64_he (64 bit report) ===
mshtml: htmldoc.c:2541: Test failed: unexpected call UpdateUI htmldoc.c:2853: Test failed: unexpected call Exec_UPDATECOMMANDS
=== w7u_adm (32 bit report) ===
mshtml: script.c:634: Test failed: L"/index.html?es5.js:date_now: unexpected Date.now() result 1649965885991 expected 1649965886124"
Map and Set share the same error code, but the description given is different, so we need to throw it manually.
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/jscript/jscript.rc | 2 +- dlls/jscript/set.c | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/dlls/jscript/jscript.rc b/dlls/jscript/jscript.rc index c931eef..2fd0b33 100644 --- a/dlls/jscript/jscript.rc +++ b/dlls/jscript/jscript.rc @@ -75,7 +75,7 @@ STRINGTABLE IDS_OBJECT_NONEXTENSIBLE "Cannot define property '|': object is not extensible" IDS_NONCONFIGURABLE_REDEFINED "Cannot redefine non-configurable property '|'" IDS_NONWRITABLE_MODIFIED "Cannot modify non-writable property '|'" - IDS_MAP_EXPECTED "'this' is not a Map object" + IDS_MAP_EXPECTED "'this' is not a | object" IDS_PROP_DESC_MISMATCH "Property cannot have both accessors and a value"
IDS_COMPILATION_ERROR "Microsoft JScript compilation error" diff --git a/dlls/jscript/set.c b/dlls/jscript/set.c index f3e8fe6..dbb4a5d 100644 --- a/dlls/jscript/set.c +++ b/dlls/jscript/set.c @@ -86,7 +86,7 @@ static int jsval_map_compare(const void *k, const struct wine_rb_entry *e) } }
-static HRESULT get_map_this(jsval_t vthis, MapInstance **ret) +static HRESULT get_map_this(script_ctx_t *ctx, jsval_t vthis, MapInstance **ret) { jsdisp_t *jsdisp;
@@ -94,14 +94,14 @@ static HRESULT get_map_this(jsval_t vthis, MapInstance **ret) return JS_E_OBJECT_EXPECTED; if(!(jsdisp = to_jsdisp(get_object(vthis))) || !is_class(jsdisp, JSCLASS_MAP)) { WARN("not a Map object passed as 'this'\n"); - return JS_E_MAP_EXPECTED; + return throw_error(ctx, JS_E_MAP_EXPECTED, L"Map"); }
*ret = CONTAINING_RECORD(jsdisp, MapInstance, dispex); return S_OK; }
-static HRESULT get_set_this(jsval_t vthis, MapInstance **ret) +static HRESULT get_set_this(script_ctx_t *ctx, jsval_t vthis, MapInstance **ret) { jsdisp_t *jsdisp;
@@ -109,7 +109,7 @@ static HRESULT get_set_this(jsval_t vthis, MapInstance **ret) return JS_E_OBJECT_EXPECTED; if(!(jsdisp = to_jsdisp(get_object(vthis))) || !is_class(jsdisp, JSCLASS_SET)) { WARN("not a Set object passed as 'this'\n"); - return JS_E_MAP_EXPECTED; + return throw_error(ctx, JS_E_MAP_EXPECTED, L"Set"); }
*ret = CONTAINING_RECORD(jsdisp, MapInstance, dispex); @@ -226,7 +226,7 @@ static HRESULT Map_clear(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned MapInstance *map; HRESULT hres;
- hres = get_map_this(vthis, &map); + hres = get_map_this(ctx, vthis, &map); if(FAILED(hres)) return hres;
@@ -249,7 +249,7 @@ static HRESULT Map_delete(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned MapInstance *map; HRESULT hres;
- hres = get_map_this(vthis, &map); + hres = get_map_this(ctx, vthis, &map); if(FAILED(hres)) return hres;
@@ -266,7 +266,7 @@ static HRESULT Map_forEach(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigne MapInstance *map; HRESULT hres;
- hres = get_map_this(vthis, &map); + hres = get_map_this(ctx, vthis, &map); if(FAILED(hres)) return hres;
@@ -283,7 +283,7 @@ static HRESULT Map_get(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned ar MapInstance *map; HRESULT hres;
- hres = get_map_this(vthis, &map); + hres = get_map_this(ctx, vthis, &map); if(FAILED(hres)) return hres;
@@ -305,7 +305,7 @@ static HRESULT Map_set(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned ar MapInstance *map; HRESULT hres;
- hres = get_map_this(vthis, &map); + hres = get_map_this(ctx, vthis, &map); if(FAILED(hres)) return hres;
@@ -322,7 +322,7 @@ static HRESULT Map_has(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned ar MapInstance *map; HRESULT hres;
- hres = get_map_this(vthis, &map); + hres = get_map_this(ctx, vthis, &map); if(FAILED(hres)) return hres;
@@ -431,7 +431,7 @@ static HRESULT Set_add(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned ar MapInstance *set; HRESULT hres;
- hres = get_set_this(vthis, &set); + hres = get_set_this(ctx, vthis, &set); if(FAILED(hres)) return hres;
@@ -446,7 +446,7 @@ static HRESULT Set_clear(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned MapInstance *set; HRESULT hres;
- hres = get_set_this(vthis, &set); + hres = get_set_this(ctx, vthis, &set); if(FAILED(hres)) return hres;
@@ -469,7 +469,7 @@ static HRESULT Set_delete(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned MapInstance *set; HRESULT hres;
- hres = get_set_this(vthis, &set); + hres = get_set_this(ctx, vthis, &set); if(FAILED(hres)) return hres;
@@ -486,7 +486,7 @@ static HRESULT Set_forEach(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigne MapInstance *set; HRESULT hres;
- hres = get_set_this(vthis, &set); + hres = get_set_this(ctx, vthis, &set); if(FAILED(hres)) return hres;
@@ -503,7 +503,7 @@ static HRESULT Set_has(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned ar MapInstance *set; HRESULT hres;
- hres = get_set_this(vthis, &set); + hres = get_set_this(ctx, vthis, &set); if(FAILED(hres)) return hres;
Signed-off-by: Jacek Caban jacek@codeweavers.com