JSObjectCallAsConstructorCallback

Type Alias JSObjectCallAsConstructorCallback 

Source
pub type JSObjectCallAsConstructorCallback = Option<unsafe extern "C-unwind" fn(JSContextRef, JSObjectRef, usize, *mut JSValueRef, *mut JSValueRef) -> JSObjectRef>;
Available on crate features JSBase and JSObjectRef only.
Expand description

The callback invoked when an object is used as a constructor in a ‘new’ expression.

Parameter ctx: The execution context to use.

Parameter constructor: A JSObject that is the constructor being called.

Parameter argumentCount: An integer count of the number of arguments in arguments.

Parameter arguments: A JSValue array of the arguments passed to the function.

Parameter exception: A pointer to a JSValueRef in which to return an exception, if any.

Returns: A JSObject that is the constructor’s return value.

If you named your function CallAsConstructor, you would declare it like this:

JSObjectRef CallAsConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);

If your callback were invoked by the JavaScript expression ‘new myConstructor()’, constructor would be set to myConstructor.

If this callback is NULL, using your object as a constructor in a ‘new’ expression will throw an exception.

See also Apple’s documentation

Aliased Type§

pub enum JSObjectCallAsConstructorCallback {
    None,
    Some(unsafe extern "C-unwind" fn(*const OpaqueJSContext, *mut OpaqueJSValue, usize, *mut *const OpaqueJSValue, *mut *const OpaqueJSValue) -> *mut OpaqueJSValue),
}

Variants§

§1.0.0

None

No value.

§1.0.0

Some(unsafe extern "C-unwind" fn(*const OpaqueJSContext, *mut OpaqueJSValue, usize, *mut *const OpaqueJSValue, *mut *const OpaqueJSValue) -> *mut OpaqueJSValue)

Some value of type T.