Skip to content

Commit 92961d7

Browse files
authored
Expose JS_NewCFunction3 (#877)
Useful if you want to set the prototype of a constructor to its parent constructor when creating a custom type hierarchy. (e.g. in browsers, `Text.__proto__` == `CharacterData`, and to implement this you can pass the `CharacterData` constructor as `proto_val`.)
1 parent 26581b9 commit 92961d7

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

quickjs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5242,10 +5242,10 @@ static int js_method_set_properties(JSContext *ctx, JSValue func_obj,
52425242

52435243
/* Note: at least 'length' arguments will be readable in 'argv' */
52445244
/* `name` may be NULL, pure ASCII or UTF-8 encoded */
5245-
static JSValue JS_NewCFunction3(JSContext *ctx, JSCFunction *func,
5246-
const char *name,
5247-
int length, JSCFunctionEnum cproto, int magic,
5248-
JSValue proto_val)
5245+
JSValue JS_NewCFunction3(JSContext *ctx, JSCFunction *func,
5246+
const char *name,
5247+
int length, JSCFunctionEnum cproto, int magic,
5248+
JSValue proto_val)
52495249
{
52505250
JSValue func_obj;
52515251
JSObject *p;

quickjs.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,6 +1006,10 @@ typedef union JSCFunctionType {
10061006
JS_EXTERN JSValue JS_NewCFunction2(JSContext *ctx, JSCFunction *func,
10071007
const char *name,
10081008
int length, JSCFunctionEnum cproto, int magic);
1009+
JS_EXTERN JSValue JS_NewCFunction3(JSContext *ctx, JSCFunction *func,
1010+
const char *name,
1011+
int length, JSCFunctionEnum cproto, int magic,
1012+
JSValue proto_val);
10091013
JS_EXTERN JSValue JS_NewCFunctionData(JSContext *ctx, JSCFunctionData *func,
10101014
int length, int magic, int data_len,
10111015
JSValue *data);

0 commit comments

Comments
 (0)