Contents

JSObjectGetPropertyCallback

The callback type for getting a property’s value.

Declaration

typealias JSObjectGetPropertyCallback = (JSContextRef?, JSObjectRef?, JSStringRef?, UnsafeMutablePointer<JSValueRef?>?) -> JSValueRef?

Parameters

  • ctx:

    The execution context to use.

  • object:

    The Jsobjectref to search for the property.

  • propertyName:

    A Jsstringref that contains the name of the property to get.

  • exception:

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

Return Value

The property’s value if the object has the property; otherwise, NULL.

Discussion

If you name your function GetProperty, you declare it like this:

JSValueRef GetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);

If this function returns NULL, the get request forwards to the object’s statically declared properties, then its parent class chain (which includes the default object class), and then its prototype chain.

See Also

Managing Callbacks