JSObject.make constructor

JSObject.make(
  1. JSContext context,
  2. JSClass jsClass, {
  3. Pointer<NativeType>? data,
})

Creates a JavaScript object. The default object class does not allocate storage for private data, so you must provide a non-NULL jsClass to JSObjectMake if you want your object to be able to store private data.

data is set on the created object before the intialize methods in its class chain are called. This enables the initialize methods to retrieve and manipulate data through JSObjectGetPrivate. jsClass (JSClassRef) The JSClass to assign to the object. Pass NULL to use the default object class. data (void*) A void* to set as the object's private data. Pass NULL to specify no private data.

Implementation

JSObject.make(
  this.context,
  JSClass jsClass, {
  Pointer? data,
}) : this.pointer = JSObjectRef.jSObjectMake(
          context.pointer, jsClass.pointer, data ?? nullptr);