From: Fabrice Bellard Date: Sat, 10 Oct 2026 14:49:45 +0000 (+0200) Subject: exported JS_NewCConstructor() X-Git-Url: https://git.kaiwu.me/$%7BGITURL%7D$%7Bcid%7D?a=commitdiff_plain;h=7b1b755d207f932953eb623db105488fdace69c8;p=quickjs.git exported JS_NewCConstructor() --- diff --git a/quickjs.c b/quickjs.c index a1787b2..2d4c848 100644 --- a/quickjs.c +++ b/quickjs.c @@ -40054,21 +40054,16 @@ int JS_SetConstructor(JSContext *ctx, JSValueConst func_obj, 0, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE); } -#define JS_NEW_CTOR_NO_GLOBAL (1 << 0) /* don't create a global binding */ -#define JS_NEW_CTOR_PROTO_CLASS (1 << 1) /* the prototype class is 'class_id' instead of JS_CLASS_OBJECT */ -#define JS_NEW_CTOR_PROTO_EXIST (1 << 2) /* the prototype is already defined */ -#define JS_NEW_CTOR_READONLY (1 << 3) /* read-only constructor field */ - /* Return the constructor and. Define it as a global variable unless JS_NEW_CTOR_NO_GLOBAL is set. The new class inherit from parent_ctor if it is not JS_UNDEFINED. if class_id is != -1, class_proto[class_id] is set. */ -static JSValue JS_NewCConstructor(JSContext *ctx, int class_id, const char *name, - JSCFunction *func, int length, JSCFunctionEnum cproto, int magic, - JSValueConst parent_ctor, - const JSCFunctionListEntry *ctor_fields, int n_ctor_fields, - const JSCFunctionListEntry *proto_fields, int n_proto_fields, - int flags) +JSValue JS_NewCConstructor(JSContext *ctx, int class_id, const char *name, + JSCFunction *func, int length, JSCFunctionEnum cproto, int magic, + JSValueConst parent_ctor, + const JSCFunctionListEntry *ctor_fields, int n_ctor_fields, + const JSCFunctionListEntry *proto_fields, int n_proto_fields, + int flags) { JSValue ctor = JS_UNDEFINED, proto, parent_proto; int proto_class_id, proto_flags, ctor_flags; diff --git a/quickjs.h b/quickjs.h index e3c366a..1d4c29e 100644 --- a/quickjs.h +++ b/quickjs.h @@ -1151,6 +1151,18 @@ int JS_SetPropertyFunctionList(JSContext *ctx, JSValueConst obj, const JSCFunctionListEntry *tab, int len); +#define JS_NEW_CTOR_NO_GLOBAL (1 << 0) /* don't create a global binding */ +#define JS_NEW_CTOR_PROTO_CLASS (1 << 1) /* the prototype class is 'class_id' instead of JS_CLASS_OBJECT */ +#define JS_NEW_CTOR_PROTO_EXIST (1 << 2) /* the prototype is already defined */ +#define JS_NEW_CTOR_READONLY (1 << 3) /* read-only constructor field */ + +JSValue JS_NewCConstructor(JSContext *ctx, int class_id, const char *name, + JSCFunction *func, int length, JSCFunctionEnum cproto, int magic, + JSValueConst parent_ctor, + const JSCFunctionListEntry *ctor_fields, int n_ctor_fields, + const JSCFunctionListEntry *proto_fields, int n_proto_fields, + int flags); + /* iterator helpers */ JSValue JS_GetIterator(JSContext *ctx, JSValueConst obj, JS_BOOL is_async);