Contents

JSObjectGetPropertyNamesCallback

The callback type for collecting the names of an object’s properties.

Declaration

typealias JSObjectGetPropertyNamesCallback = (JSContextRef?, JSObjectRef?, JSPropertyNameAccumulatorRef?) -> Void

Parameters

  • ctx:

    The execution context to use.

  • object:

    The Jsobjectref with the property names to collect.

  • accumulator:

    A JavaScript property name accumulator to accumulate the names of the object’s properties in.

Discussion

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

void GetPropertyNames(JSContextRef ctx, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames);

JSObjectCopyPropertyNames(_:_:) and JavaScript for-in loops use property name accumulators.

Use JSPropertyNameAccumulatorAddName(_:_:) to add property names to accumulator. A class’s getPropertyNames callback only needs to provide the names of properties that the class vends through a custom getProperty or setProperty callback. The system adds other properties independently, including statically declared properties, properties that other classes vend, and properties that belong to the object’s prototype.

See Also

Managing Callbacks