constructors
This commit is contained in:
@@ -492,8 +492,5 @@ static JSValue js_simplex_constructor(JSContext *js, JSValueConst new_target, in
|
||||
CELL_USE_INIT(
|
||||
QJSCLASSPREP_FUNCS(simplex);
|
||||
JSValue ctor = JS_NewCFunction2(js, js_simplex_constructor, "simplex", 1, JS_CFUNC_generic, 0);
|
||||
JSValue proto = JS_GetClassProto(js, js_simplex_id);
|
||||
JS_SetConstructor(js, ctor, proto);
|
||||
JS_FreeValue(js, proto);
|
||||
return ctor;
|
||||
)
|
||||
|
||||
9
sprite.c
9
sprite.c
@@ -131,16 +131,7 @@ static JSValue js_sprite_constructor(JSContext *js, JSValueConst new_target, int
|
||||
}
|
||||
|
||||
CELL_USE_INIT(
|
||||
// Register the sprite class
|
||||
QJSCLASSPREP_FUNCS(sprite);
|
||||
|
||||
// Create the constructor function
|
||||
JSValue ctor = JS_NewCFunction2(js, js_sprite_constructor, "sprite", 1, JS_CFUNC_generic, 0);
|
||||
|
||||
// Set the prototype on the constructor
|
||||
JSValue proto = JS_GetClassProto(js, js_sprite_id);
|
||||
JS_SetConstructor(js, ctor, proto);
|
||||
JS_FreeValue(js, proto);
|
||||
|
||||
return ctor;
|
||||
)
|
||||
3
staef.c
3
staef.c
@@ -851,17 +851,14 @@ CELL_USE_INIT(
|
||||
|
||||
// Create font constructor (legacy)
|
||||
JSValue font_ctor = JS_NewCFunction2(js, js_font_constructor, "font", 2, JS_CFUNC_generic, 0);
|
||||
JS_SetConstructor(js, font_ctor, proto);
|
||||
JS_SetPropertyStr(js, mod, "font", font_ctor);
|
||||
|
||||
// Create SDF font constructor: sdf_font(data, em_px, range_px, padding_px, sharpness)
|
||||
JSValue sdf_font_ctor = JS_NewCFunction2(js, js_sdf_font_constructor, "sdf_font", 5, JS_CFUNC_generic, 0);
|
||||
JS_SetConstructor(js, sdf_font_ctor, proto);
|
||||
JS_SetPropertyStr(js, mod, "sdf_font", sdf_font_ctor);
|
||||
|
||||
// Create MSDF font constructor: msdf_font(data, em_px, range_px, padding_px, sharpness)
|
||||
JSValue msdf_font_ctor = JS_NewCFunction2(js, js_msdf_font_constructor, "msdf_font", 5, JS_CFUNC_generic, 0);
|
||||
JS_SetConstructor(js, msdf_font_ctor, proto);
|
||||
JS_SetPropertyStr(js, mod, "msdf_font", msdf_font_ctor);
|
||||
|
||||
return mod;
|
||||
|
||||
@@ -401,18 +401,10 @@ static const JSCFunctionListEntry js_transform_ctor_funcs[] = {
|
||||
};
|
||||
|
||||
CELL_USE_INIT(
|
||||
// Register the transform class
|
||||
QJSCLASSPREP_FUNCS(transform);
|
||||
|
||||
// Create the constructor function
|
||||
JSValue ctor = JS_NewCFunction2(js, js_transform_constructor, "transform", 0, JS_CFUNC_generic, 0);
|
||||
|
||||
// Set the prototype on the constructor
|
||||
JSValue proto = JS_GetClassProto(js, js_transform_id);
|
||||
JS_SetConstructor(js, ctor, proto);
|
||||
JS_FreeValue(js, proto);
|
||||
|
||||
// Add static methods to the constructor
|
||||
JS_SetPropertyFunctionList(js, ctor, js_transform_ctor_funcs, countof(js_transform_ctor_funcs));
|
||||
|
||||
return ctor;
|
||||
|
||||
Reference in New Issue
Block a user