Type Alias

JSObjectConvertToTypeCallback

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

Declaration

typedef JSValueRef (*JSObjectConvertToTypeCallback)(JSContextRef ctx, JSObjectRef object, JSType type, JSValueRef *exception);

Parameters

ctx

The execution context to use.

object

The JSObject to convert.

type

A JSType specifying the JavaScript type to convert to.

exception

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

Return Value

The objects's converted value, or NULL if the object was not converted.

Discussion

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

JSValueRef ConvertToType(JSContextRef ctx, JSObjectRef object, JSType type, JSValueRef* exception);

If this function returns false, the conversion request forwards to object's parent class chain (which includes the default object class).

This function is only invoked when converting an object to number or string. An object converted to boolean is 'true.' An object converted to object is itself.

See Also

Callbacks

JSObjectCallAsConstructorCallback

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

JSObjectCallAsFunctionCallback

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

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.