Type Alias

JSObjectCallAsConstructorCallback

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

Declaration

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

Parameters

ctx

The execution context to use.

constructor

A JSObject that is the constructor being called.

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 JSObject that is the constructor's return value.

Discussion

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

Callbacks

JSObjectCallAsFunctionCallback

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

JSObjectConvertToTypeCallback

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

JSObjectDeletePropertyCallback

The callback invoked when deleting a property.

JSObjectFinalizeCallback

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

JSObjectGetPropertyCallback

The callback invoked when getting a property’s value.

JSObjectGetPropertyNamesCallback

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

JSObjectHasInstanceCallback

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

JSObjectHasPropertyCallback

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

JSObjectInitializeCallback

The callback invoked when an object is first created.

JSObjectSetPropertyCallback

The callback invoked when setting a property’s value.