JSObjectConvertToTypeCallback
The callback type for converting an object to a particular JavaScript type.
Declaration
typealias JSObjectConvertToTypeCallback = (JSContextRef?, JSObjectRef?, JSType, UnsafeMutablePointer<JSValueRef?>?) -> JSValueRef?Parameters
- ctx:
The execution context to use.
- object:
The Jsobjectref to convert.
- type:
A Jstype that specifies the JavaScript type to convert to.
- exception:
A pointer to a Jsvalueref to return an exception in, if any.
Return Value
The object’s converted value, or NULL if the object doesn’t convert.
Discussion
If you name your function ConvertToType, you declare it like this:
JSValueRef ConvertToType(JSContextRef ctx, JSObjectRef object, JSType type, JSValueRef* exception);If this function returns false, the conversion request forwards to the object’s parent class chain (which includes the default object class).
The system only invokes this function when converting an object to kJSTypeNumber or kJSTypeString. An object that converts to kJSTypeBoolean is true. An object that converts to kJSTypeObject is itself.