From: Fabrice Bellard Date: Sat, 10 Oct 2026 14:42:02 +0000 (+0200) Subject: added JS_CFUNC_constructor_or_func_flags X-Git-Url: https://git.kaiwu.me/?a=commitdiff_plain;h=c2a11b82f710c5abd74fcea41b838fb549a98779;p=quickjs.git added JS_CFUNC_constructor_or_func_flags --- diff --git a/quickjs.c b/quickjs.c index 9708737..8fec2f2 100644 --- a/quickjs.c +++ b/quickjs.c @@ -5997,7 +5997,8 @@ static JSValue JS_NewCFunction3(JSContext *ctx, JSCFunction *func, p->is_constructor = (cproto == JS_CFUNC_constructor || cproto == JS_CFUNC_constructor_magic || cproto == JS_CFUNC_constructor_or_func || - cproto == JS_CFUNC_constructor_or_func_magic); + cproto == JS_CFUNC_constructor_or_func_magic || + cproto == JS_CFUNC_constructor_or_func_flags); if (!name) name = ""; name_atom = JS_NewAtom(ctx, name); @@ -17785,6 +17786,9 @@ static JSValue js_call_c_function(JSContext *ctx, JSValueConst func_obj, case JS_CFUNC_generic: ret_val = func.generic(ctx, this_obj, argc, arg_buf); break; + case JS_CFUNC_constructor_or_func_flags: + ret_val = func.constructor_or_func_flags(ctx, func_obj, this_obj, argc, arg_buf, flags); + break; case JS_CFUNC_constructor_magic: case JS_CFUNC_constructor_or_func_magic: if (!(flags & JS_CALL_FLAG_CONSTRUCTOR)) { diff --git a/quickjs.h b/quickjs.h index e0ce63a..069097a 100644 --- a/quickjs.h +++ b/quickjs.h @@ -1033,6 +1033,7 @@ typedef enum JSCFunctionEnum { /* XXX: should rename for namespace isolation */ JS_CFUNC_constructor_magic, JS_CFUNC_constructor_or_func, JS_CFUNC_constructor_or_func_magic, + JS_CFUNC_constructor_or_func_flags, JS_CFUNC_f_f, JS_CFUNC_f_f_f, JS_CFUNC_getter, @@ -1048,6 +1049,7 @@ typedef union JSCFunctionType { JSCFunction *constructor; JSValue (*constructor_magic)(JSContext *ctx, JSValueConst new_target, int argc, JSValueConst *argv, int magic); JSCFunction *constructor_or_func; + JSValue (*constructor_or_func_flags)(JSContext *ctx, JSValueConst func_obj, JSValueConst this_val, int argc, JSValueConst *argv, int flags); double (*f_f)(double); double (*f_f_f)(double, double); JSValue (*getter)(JSContext *ctx, JSValueConst this_val);