Function JSObjectMakeConstructor

Source
pub unsafe extern "C-unwind" fn JSObjectMakeConstructor(
    ctx: JSContextRef,
    js_class: JSClassRef,
    call_as_constructor: JSObjectCallAsConstructorCallback,
) -> JSObjectRef
Available on crate features JSObjectRef and JSBase only.
Expand description

Convenience method for creating a JavaScript constructor.

Parameter ctx: The execution context to use.

Parameter jsClass: A JSClass that is the class your constructor will assign to the objects its constructs. jsClass will be used to set the constructor’s .prototype property, and to evaluate ‘instanceof’ expressions. Pass NULL to use the default object class.

Parameter callAsConstructor: A JSObjectCallAsConstructorCallback to invoke when your constructor is used in a ‘new’ expression. Pass NULL to use the default object constructor.

Returns: A JSObject that is a constructor. The object’s prototype will be the default object prototype.

The default object constructor takes no arguments and constructs an object of class jsClass with no private data. If the constructor is inherited via JS subclassing and the value returned from callAsConstructor was created with jsClass, then the returned object will have it’s prototype overridden to the derived class’s prototype.