JSObjectHasInstanceCallback

Type Alias JSObjectHasInstanceCallback 

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

hasInstance The callback invoked when an object is used as the target of an ‘instanceof’ expression.

Parameter ctx: The execution context to use.

Parameter constructor: The JSObject that is the target of the ‘instanceof’ expression.

Parameter possibleInstance: The JSValue being tested to determine if it is an instance of constructor.

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

Returns: true if possibleInstance is an instance of constructor, otherwise false.

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

bool HasInstance(JSContextRef ctx, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);

If your callback were invoked by the JavaScript expression ‘someValue instanceof myObject’, constructor would be set to myObject and possibleInstance would be set to someValue.

If this callback is NULL, ‘instanceof’ expressions that target your object will return false.

Standard JavaScript practice calls for objects that implement the callAsConstructor callback to implement the hasInstance callback as well.

See also Apple’s documentation

Aliased Type§

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

Variants§

§1.0.0

None

No value.

§1.0.0

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

Some value of type T.