Add JS_SetPropertyFunctionList2()

This commit is contained in:
Dmitry Volyntsev 2024-09-13 17:20:41 -07:00
parent 6e2e68fd08
commit 93d1ab715b
2 changed files with 23 additions and 0 deletions

View File

@ -36998,6 +36998,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)
{ {

View File

@ -1060,6 +1060,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 */