Skip to content

Commit ccf01ae

Browse files
winesyncMishaProductions
authored andcommitted
[WINESYNC] jscript: Add Map.prototype.forEach implementation.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org> wine commit id edda9c1f28d5df8302cb9a7472f82de5f3f5004d by Jacek Caban <jacek@codeweavers.com>
1 parent 3a412e0 commit ccf01ae

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

dll/win32/jscript/set.c

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,42 @@ static HRESULT Map_delete(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsign
252252
static HRESULT Map_forEach(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
253253
jsval_t *r)
254254
{
255-
FIXME("%p\n", jsthis);
256-
return E_NOTIMPL;
255+
jsval_t callback = argc ? argv[0] : jsval_undefined();
256+
struct jsval_map_entry *entry;
257+
MapInstance *map;
258+
HRESULT hres;
259+
260+
if(!(map = get_map_this(jsthis))) return JS_E_MAP_EXPECTED;
261+
262+
TRACE("%p (%s)\n", map, debugstr_jsval(argc >= 1 ? argv[0] : jsval_undefined()));
263+
264+
if(!is_object_instance(callback) || !get_object(callback)) {
265+
FIXME("invalid callback %s\n", debugstr_jsval(callback));
266+
return E_FAIL;
267+
}
268+
269+
if(argc > 1) {
270+
FIXME("Unsupported argument\n");
271+
return E_NOTIMPL;
272+
}
273+
274+
LIST_FOR_EACH_ENTRY(entry, &map->entries, struct jsval_map_entry, list_entry) {
275+
jsval_t args[2], v;
276+
if(entry->deleted)
277+
continue;
278+
args[0] = entry->value;
279+
args[1] = entry->key;
280+
grab_map_entry(entry);
281+
hres = disp_call_value(ctx, get_object(argv[0]), NULL, DISPATCH_METHOD,
282+
ARRAY_SIZE(args), args, &v);
283+
release_map_entry(entry);
284+
if(FAILED(hres))
285+
return hres;
286+
jsval_release(v);
287+
}
288+
289+
if(r) *r = jsval_undefined();
290+
return S_OK;
257291
}
258292

259293
static HRESULT Map_get(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,

sdk/tools/winesync/jscript.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ directories:
33
dlls/jscript/tests: modules/rostests/winetests/jscript
44
files: null
55
tags:
6-
wine: b8f17fa48add830e4119f4cd738d2512cb82eec7
6+
wine: edda9c1f28d5df8302cb9a7472f82de5f3f5004d

0 commit comments

Comments
 (0)