-
Couldn't load subscription status.
- Fork 205
Open
Labels
enhancementNew feature or requestNew feature or request
Description
We should consider introducing a JS_DefineProperties or something like it that sets properties in bulk, to make it easier to handle errors, and port code in quickjs.c over to it.
Case in point: js_regexp_exec dedicates 100 lines to setting properties on the result object. Here's an excerpt:
t = groups, groups = JS_UNDEFINED;
if (JS_DefinePropertyValue(ctx, obj, JS_ATOM_groups,
t, prop_flags) < 0) {
goto fail;
}
t = js_int32((capture[0] - str_buf) >> shift);
if (JS_DefinePropertyValue(ctx, obj, JS_ATOM_index, t, prop_flags) < 0)
goto fail;
t = str_val, str_val = JS_UNDEFINED;
if (JS_DefinePropertyValue(ctx, obj, JS_ATOM_input, t, prop_flags) < 0)
goto fail;
if (!JS_IsUndefined(indices)) {
t = indices_groups, indices_groups = JS_UNDEFINED;
if (JS_DefinePropertyValue(ctx, indices, JS_ATOM_groups,
t, prop_flags) < 0) {
goto fail;
}
t = indices, indices = JS_UNDEFINED;
if (JS_DefinePropertyValue(ctx, obj, JS_ATOM_indices,
t, prop_flags) < 0) {
goto fail;
}
}For the record: JS_SetPropertyFunctionList and JS_NewObjectFrom exist and sort of cover this use case, although not exactly.
saghul
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request