convert js Map to dart Map

This commit is contained in:
wgh19
2024-05-03 11:53:16 +08:00
parent 2c7d60cc1c
commit 022ab462c6
9 changed files with 71 additions and 8 deletions

View File

@@ -12148,6 +12148,21 @@ int JS_IsArray(JSContext *ctx, JSValueConst val)
}
}
/* return -1 if exception (proxy case) or TRUE/FALSE */
int JS_IsMap(JSContext *ctx, JSValueConst val)
{
JSObject *p;
if (JS_VALUE_GET_TAG(val) == JS_TAG_OBJECT) {
p = JS_VALUE_GET_OBJ(val);
if (unlikely(p->class_id == JS_CLASS_PROXY))
return js_proxy_isMap(ctx, val);
else
return p->class_id == JS_CLASS_MAP;
} else {
return FALSE;
}
}
static double js_pow(double a, double b)
{
if (unlikely(!isfinite(b)) && fabs(a) == 1) {
@@ -46709,6 +46724,22 @@ static int js_proxy_isArray(JSContext *ctx, JSValueConst obj)
return JS_IsArray(ctx, s->target);
}
static int js_proxy_isMap(JSContext *ctx, JSValueConst obj)
{
JSProxyData *s = JS_GetOpaque(obj, JS_CLASS_PROXY);
if (!s)
return FALSE;
if (js_check_stack_overflow(ctx->rt, 0)) {
JS_ThrowStackOverflow(ctx);
return -1;
}
if (s->is_revoked) {
JS_ThrowTypeErrorRevokedProxy(ctx);
return -1;
}
return JS_IsMap(ctx, s->target);
}
static const JSClassExoticMethods js_proxy_exotic_methods = {
.get_own_property = js_proxy_get_own_property,
.define_own_property = js_proxy_define_own_property,

View File

@@ -738,6 +738,7 @@ JS_BOOL JS_SetConstructorBit(JSContext *ctx, JSValueConst func_obj, JS_BOOL val)
JSValue JS_NewArray(JSContext *ctx);
int JS_IsArray(JSContext *ctx, JSValueConst val);
int JS_IsMap(JSContext *ctx, JSValueConst val);
JSValue JS_NewDate(JSContext *ctx, double epoch_ms);