Type Alias

JSObjectCallAsFunctionCallback

The callback invoked when an object is called as a function.

Declaration

typealias JSObjectCallAsFunctionCallback = (JSContextRef?, JSObjectRef?, JSObjectRef?, Int, UnsafePointer<JSValueRef?>?, UnsafeMutablePointer<JSValueRef?>?) -> JSValueRef?

Parameters

ctx

The execution context to use.

function

A JSObject that is the function being called.

thisObject

A JSObject that is the 'this' variable in the function's scope.

argumentCount

An integer count of the number of arguments in arguments.

arguments

A JSValue array of the arguments passed to the function.

exception

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

Return Value

A JSValue that is the function's return value.

Discussion

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

JSValueRef CallAsFunction(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);

If your callback were invoked by the JavaScript expression 'myObject.myFunction()', function would be set to myFunction, and thisObject would be set to myObject.

If this callback is NULL, calling your object as a function will throw an exception.

See Also

Callbacks

typealias JSObjectCallAsConstructorCallback

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

typealias JSObjectConvertToTypeCallback

The callback invoked when converting an object to a particular JavaScript type.

typealias JSObjectDeletePropertyCallback

The callback invoked when deleting a property.

typealias JSObjectFinalizeCallback

The callback invoked when an object is finalized (prepared for garbage collection). An object may be finalized on any thread.

typealias JSObjectGetPropertyCallback

The callback invoked when getting a property’s value.

typealias JSObjectGetPropertyNamesCallback

The callback invoked when collecting the names of an object’s properties.

typealias JSObjectHasInstanceCallback

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

typealias JSObjectHasPropertyCallback

The callback invoked when determining whether an object has a property.

typealias JSObjectInitializeCallback

The callback invoked when an object is first created.

typealias JSObjectSetPropertyCallback

The callback invoked when setting a property’s value.