Function mozjs_sys::jsapi::JS_InitClass
source ยท pub unsafe extern "C" fn JS_InitClass(
cx: *mut JSContext,
obj: HandleObject,
protoClass: *const JSClass,
protoProto: HandleObject,
name: *const c_char,
constructor: JSNative,
nargs: c_uint,
ps: *const JSPropertySpec,
fs: *const JSFunctionSpec,
static_ps: *const JSPropertySpec,
static_fs: *const JSFunctionSpec,
) -> *mut JSObject
Expand description
Defines a builtin constructor and prototype. Returns the prototype object.
-
Defines a property named
name
onobj
, with its value set to a newly-created JS function that invokes theconstructor
JSNative. Thelength
of the function isnargs
. -
Creates a prototype object with proto
protoProto
and classprotoClass
. IfprotoProto
isnullptr
,Object.prototype
will be used instead. IfprotoClass
isnullptr
, the prototype object will be a plain JS object. -
The
ps
andfs
properties/functions will be defined on the prototype object. -
The
static_ps
andstatic_fs
properties/functions will be defined on the constructor.