JSObjectCallAsConstructorCallback
The callback type for using an object as a constructor.
Declaration
typealias JSObjectCallAsConstructorCallback = (JSContextRef?, JSObjectRef?, Int, UnsafePointer<JSValueRef?>?, UnsafeMutablePointer<JSValueRef?>?) -> JSObjectRef?Parameters
- ctx:
The execution context to use.
- constructor:
A Jsobjectref that is the constructor to call.
- argumentCount:
An integer count of the number of arguments in
arguments. - arguments:
A Jsvalueref array of the arguments to pass to the function.
- exception:
A pointer to a Jsvalueref to return an exception in, if any.
Return Value
A JSObjectRef that is the constructor’s return value.
Discussion
If you name your function CallAsConstructor, you declare it like this:
JSObjectRef CallAsConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);If the JavaScript expression new myConstructor() invokes your callback, it sets constructor to myConstructor.
If this callback is NULL, using your object as a constructor in a new expression throws an exception.