Skip to content

Commit 4ca6d9b

Browse files
authored
Don't share class functions across Set and Map
Map has groupBy and Set doesn't. Fixes: #714
1 parent 81e50f3 commit 4ca6d9b

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

quickjs.c

+14-8
Original file line numberDiff line numberDiff line change
@@ -40204,7 +40204,7 @@ typedef struct JSIteratorHelperData {
4020440204
JSValue func; // predicate (filter) or mapper (flatMap, map)
4020540205
JSValue inner; // innerValue (flatMap)
4020640206
int64_t count; // limit (drop, take) or counter (filter, map, flatMap)
40207-
JSIteratorHelperKindEnum kind : 8;
40207+
JSIteratorHelperKindEnum kind : 8;
4020840208
uint8_t executing : 1;
4020940209
uint8_t done : 1;
4021040210
} JSIteratorHelperData;
@@ -48318,6 +48318,10 @@ static const JSCFunctionListEntry js_map_funcs[] = {
4831848318
JS_CGETSET_DEF("[Symbol.species]", js_get_this, NULL ),
4831948319
};
4832048320

48321+
static const JSCFunctionListEntry js_set_funcs[] = {
48322+
JS_CGETSET_DEF("[Symbol.species]", js_get_this, NULL ),
48323+
};
48324+
4832148325
static const JSCFunctionListEntry js_map_proto_funcs[] = {
4832248326
JS_CFUNC_MAGIC_DEF("set", 2, js_map_set, 0 ),
4832348327
JS_CFUNC_MAGIC_DEF("get", 1, js_map_get, 0 ),
@@ -48406,17 +48410,19 @@ void JS_AddIntrinsicMapSet(JSContext *ctx)
4840648410
for(i = 0; i < 4; i++) {
4840748411
const char *name = JS_AtomGetStr(ctx, buf, sizeof(buf),
4840848412
JS_ATOM_Map + i);
48409-
ctx->class_proto[JS_CLASS_MAP + i] = JS_NewObject(ctx);
48410-
JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_MAP + i],
48413+
int class_id = JS_CLASS_MAP + i;
48414+
ctx->class_proto[class_id] = JS_NewObject(ctx);
48415+
JS_SetPropertyFunctionList(ctx, ctx->class_proto[class_id],
4841148416
js_map_proto_funcs_ptr[i],
4841248417
js_map_proto_funcs_count[i]);
4841348418
obj1 = JS_NewCFunctionMagic(ctx, js_map_constructor, name, 0,
4841448419
JS_CFUNC_constructor_magic, i);
48415-
if (i < 2) {
48416-
JS_SetPropertyFunctionList(ctx, obj1, js_map_funcs,
48417-
countof(js_map_funcs));
48418-
}
48419-
JS_NewGlobalCConstructor2(ctx, obj1, name, ctx->class_proto[JS_CLASS_MAP + i]);
48420+
if (class_id == JS_CLASS_MAP)
48421+
JS_SetPropertyFunctionList(ctx, obj1, js_map_funcs, countof(js_map_funcs));
48422+
else if (class_id == JS_CLASS_SET)
48423+
JS_SetPropertyFunctionList(ctx, obj1, js_set_funcs, countof(js_set_funcs));
48424+
48425+
JS_NewGlobalCConstructor2(ctx, obj1, name, ctx->class_proto[class_id]);
4842048426
}
4842148427

4842248428
for(i = 0; i < 2; i++) {

0 commit comments

Comments
 (0)