mirror of
https://github.com/bellard/quickjs.git
synced 2025-09-27 05:38:45 +03:00
Merge 752a3cac22e29416faa496a6e8320188d75b8c00 into f10ef299a6ab4c36c4162cc5840f128f74ec197c
This commit is contained in:
commit
359adf0ba4
44
quickjs.c
44
quickjs.c
@ -37874,6 +37874,7 @@ static JSValue JS_InstantiateFunctionListItem2(JSContext *ctx, JSObject *p,
|
|||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* return -1 if exception, 0 if OK */
|
||||||
static int JS_InstantiateFunctionListItem(JSContext *ctx, JSValueConst obj,
|
static int JS_InstantiateFunctionListItem(JSContext *ctx, JSValueConst obj,
|
||||||
JSAtom atom,
|
JSAtom atom,
|
||||||
const JSCFunctionListEntry *e)
|
const JSCFunctionListEntry *e)
|
||||||
@ -37916,8 +37917,9 @@ static int JS_InstantiateFunctionListItem(JSContext *ctx, JSValueConst obj,
|
|||||||
/* Function.prototype[Symbol.hasInstance] is not writable nor configurable */
|
/* Function.prototype[Symbol.hasInstance] is not writable nor configurable */
|
||||||
prop_flags = 0;
|
prop_flags = 0;
|
||||||
}
|
}
|
||||||
JS_DefineAutoInitProperty(ctx, obj, atom, JS_AUTOINIT_ID_PROP,
|
if (JS_DefineAutoInitProperty(ctx, obj, atom, JS_AUTOINIT_ID_PROP,
|
||||||
(void *)e, prop_flags);
|
(void *)e, prop_flags) < 0)
|
||||||
|
return -1;
|
||||||
return 0;
|
return 0;
|
||||||
case JS_DEF_CGETSET: /* XXX: use autoinit again ? */
|
case JS_DEF_CGETSET: /* XXX: use autoinit again ? */
|
||||||
case JS_DEF_CGETSET_MAGIC:
|
case JS_DEF_CGETSET_MAGIC:
|
||||||
@ -37931,6 +37933,8 @@ static int JS_InstantiateFunctionListItem(JSContext *ctx, JSValueConst obj,
|
|||||||
getter = JS_NewCFunction2(ctx, e->u.getset.get.generic,
|
getter = JS_NewCFunction2(ctx, e->u.getset.get.generic,
|
||||||
buf, 0, e->def_type == JS_DEF_CGETSET_MAGIC ? JS_CFUNC_getter_magic : JS_CFUNC_getter,
|
buf, 0, e->def_type == JS_DEF_CGETSET_MAGIC ? JS_CFUNC_getter_magic : JS_CFUNC_getter,
|
||||||
e->magic);
|
e->magic);
|
||||||
|
if (JS_IsException(getter))
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
setter = JS_UNDEFINED;
|
setter = JS_UNDEFINED;
|
||||||
if (e->u.getset.set.generic) {
|
if (e->u.getset.set.generic) {
|
||||||
@ -37938,8 +37942,13 @@ static int JS_InstantiateFunctionListItem(JSContext *ctx, JSValueConst obj,
|
|||||||
setter = JS_NewCFunction2(ctx, e->u.getset.set.generic,
|
setter = JS_NewCFunction2(ctx, e->u.getset.set.generic,
|
||||||
buf, 1, e->def_type == JS_DEF_CGETSET_MAGIC ? JS_CFUNC_setter_magic : JS_CFUNC_setter,
|
buf, 1, e->def_type == JS_DEF_CGETSET_MAGIC ? JS_CFUNC_setter_magic : JS_CFUNC_setter,
|
||||||
e->magic);
|
e->magic);
|
||||||
|
if (JS_IsException(setter)) {
|
||||||
|
JS_FreeValue(ctx, getter);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
JS_DefinePropertyGetSet(ctx, obj, atom, getter, setter, prop_flags);
|
}
|
||||||
|
if (JS_DefinePropertyGetSet(ctx, obj, atom, getter, setter, prop_flags) < 0)
|
||||||
|
return -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -37957,13 +37966,17 @@ static int JS_InstantiateFunctionListItem(JSContext *ctx, JSValueConst obj,
|
|||||||
break;
|
break;
|
||||||
case JS_DEF_PROP_STRING:
|
case JS_DEF_PROP_STRING:
|
||||||
case JS_DEF_OBJECT:
|
case JS_DEF_OBJECT:
|
||||||
JS_DefineAutoInitProperty(ctx, obj, atom, JS_AUTOINIT_ID_PROP,
|
if (JS_DefineAutoInitProperty(ctx, obj, atom, JS_AUTOINIT_ID_PROP,
|
||||||
(void *)e, prop_flags);
|
(void *)e, prop_flags) < 0)
|
||||||
|
return -1;
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
JS_DefinePropertyValue(ctx, obj, atom, val, prop_flags);
|
if (JS_DefinePropertyValue(ctx, obj, atom, val, prop_flags) < 0) {
|
||||||
|
JS_FreeValue(ctx, val);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37980,6 +37993,25 @@ void JS_SetPropertyFunctionList(JSContext *ctx, JSValueConst obj,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int JS_SetPropertyFunctionList2(JSContext *ctx, JSValueConst obj,
|
||||||
|
const JSCFunctionListEntry *tab, int len)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < len; i++) {
|
||||||
|
const JSCFunctionListEntry *e = &tab[i];
|
||||||
|
JSAtom atom = find_atom(ctx, e->name);
|
||||||
|
if (atom == JS_ATOM_NULL)
|
||||||
|
return -1;
|
||||||
|
if (JS_InstantiateFunctionListItem(ctx, obj, atom, e) < 0) {
|
||||||
|
JS_FreeAtom(ctx, atom);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
JS_FreeAtom(ctx, atom);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int JS_AddModuleExportList(JSContext *ctx, JSModuleDef *m,
|
int JS_AddModuleExportList(JSContext *ctx, JSModuleDef *m,
|
||||||
const JSCFunctionListEntry *tab, int len)
|
const JSCFunctionListEntry *tab, int len)
|
||||||
{
|
{
|
||||||
|
@ -1116,6 +1116,10 @@ typedef struct JSCFunctionListEntry {
|
|||||||
void JS_SetPropertyFunctionList(JSContext *ctx, JSValueConst obj,
|
void JS_SetPropertyFunctionList(JSContext *ctx, JSValueConst obj,
|
||||||
const JSCFunctionListEntry *tab,
|
const JSCFunctionListEntry *tab,
|
||||||
int len);
|
int len);
|
||||||
|
/* same as JS_SetPropertyFunctionList() returns -1 if exception, 0 if OK */
|
||||||
|
int JS_SetPropertyFunctionList2(JSContext *ctx, JSValueConst obj,
|
||||||
|
const JSCFunctionListEntry *tab,
|
||||||
|
int len);
|
||||||
|
|
||||||
/* C module definition */
|
/* C module definition */
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user