JSClassDefinition class

struct JSStaticFunction This structure contains properties and callbacks that define a type of object. All fields other than the version field are optional. Any pointer may be NULL. The staticValues and staticFunctions arrays are the simplest and most efficient means for vending custom properties. Statically declared properties autmatically service requests like getProperty, setProperty, and getPropertyNames. Property access callbacks are required only to implement unusual properties, like array indexes, whose names are not known at compile-time.

If you named your getter function "GetX" and your setter function "SetX", you would declare a JSStaticValue array containing "X" like this:

JSStaticValue StaticValueArray[] = { Standard JavaScript practice calls for storing function objects in prototypes, so they can be shared. The default JSClass created by JSClassCreate follows this idiom, instantiating objects with a shared, automatically generating prototype containing the class's function objects. The kJSClassAttributeNoAutomaticPrototype attribute specifies that a JSClass should not automatically generate such a prototype. The resulting JSClass instantiates objects with the default object prototype, and gives each instance object its own copy of the class's function objects.

Available Extensions


JSClassDefinition.allocate({@required int version, @required int attributes, @required Pointer<Utf8> className, @required Pointer<NativeType> parentClass, @required Pointer<JSStaticValue> staticValues, @required Pointer<JSStaticFunction> staticFunctions, @required Pointer<NativeFunction<JSObjectInitializeCallback>> initialize, @required Pointer<NativeFunction<JSObjectFinalizeCallback>> finalize, @required Pointer<NativeFunction<JSObjectHasPropertyCallback>> hasProperty, @required Pointer<NativeFunction<JSObjectGetPropertyCallback>> getProperty, @required Pointer<NativeFunction<JSObjectSetPropertyCallback>> setProperty, @required Pointer<NativeFunction<JSObjectDeletePropertyCallback>> deleteProperty, @required Pointer<NativeFunction<JSObjectGetPropertyNamesCallback>> getPropertyNames, @required Pointer<NativeFunction<JSObjectCallAsFunctionCallback>> callAsFunction, @required Pointer<NativeFunction<JSObjectCallAsConstructorCallback>> callAsConstructor, @required Pointer<NativeFunction<JSObjectHasInstanceCallback>> hasInstance, @required Pointer<NativeFunction<JSObjectConvertToTypeCallback>> convertToType})


attributes int
(JSClassAttributes) A logically ORed set of JSClassAttributes to give to the class.
@Int16(), read / write
callAsConstructor Pointer<NativeFunction<JSObjectCallAsConstructorCallback>>
(JSObjectCallAsConstructorCallback) The callback invoked when an object is used as the target of an 'instanceof' expression.
read / write
callAsFunction Pointer<NativeFunction<JSObjectCallAsFunctionCallback>>
(JSObjectCallAsFunctionCallback) The callback invoked when an object is called as a function.
read / write
className Pointer<Utf8>
(const char* ) A null-terminated UTF8 string containing the class's name.
read / write
convertToType Pointer<NativeFunction<JSObjectConvertToTypeCallback>>
(JSObjectConvertToTypeCallback) The callback invoked when converting an object to a particular JavaScript type.
read / write
deleteProperty Pointer<NativeFunction<JSObjectDeletePropertyCallback>>
(JSObjectDeletePropertyCallback) The callback invoked when deleting a property.
read / write
finalize Pointer<NativeFunction<JSObjectFinalizeCallback>>
(JSObjectFinalizeCallback) The callback invoked when an object is finalized (prepared for garbage collection). Use this callback to release resources allocated for the object, and perform other cleanup.
read / write
getProperty Pointer<NativeFunction<JSObjectGetPropertyCallback>>
(JSObjectGetPropertyCallback) The callback invoked when getting a property's value.
read / write
getPropertyNames Pointer<NativeFunction<JSObjectGetPropertyNamesCallback>>
(JSObjectGetPropertyNamesCallback) The callback invoked when collecting the names of an object's properties.
read / write
hashCode int
The hash code for this object. [...]
read-only, inherited
hasInstance Pointer<NativeFunction<JSObjectHasInstanceCallback>>
(JSObjectHasInstanceCallback) The callback invoked when an object is used as a constructor in a 'new' expression.
read / write
hasProperty Pointer<NativeFunction<JSObjectHasPropertyCallback>>
(JSObjectHasPropertyCallback) The callback invoked when determining whether an object has a property. If this field is NULL, getProperty is called instead. The hasProperty callback enables optimization in cases where only a property's existence needs to be known, not its value, and computing its value is expensive.
read / write
initialize Pointer<NativeFunction<JSObjectInitializeCallback>>
(JSObjectInitializeCallback) The callback invoked when an object is first created. Use this callback to initialize the object.
read / write
parentClass Pointer<NativeType>
(JSClassRef) A JSClass to set as the class's parent class. Pass NULL use the default object class.
read / write
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
setProperty Pointer<NativeFunction<JSObjectSetPropertyCallback>>
(JSObjectSetPropertyCallback) The callback invoked when setting a property's value.
read / write
staticFunctions Pointer<JSStaticFunction>
(const JSStaticFunction*) A JSStaticFunction array containing the class's statically declared function properties. Pass NULL to specify no statically declared function properties. The array must be terminated by a JSStaticFunction whose name field is NULL.
read / write
staticValues Pointer<JSStaticValue>
(const JSStaticValue*) A JSStaticValue array containing the class's statically declared value properties. Pass NULL to specify no statically declared value properties. The array must be terminated by a JSStaticValue whose name field is NULL.
read / write
version int
(int) The version number of this structure. The current version is 0.
@Int32(), read / write


noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
toString() String
A string representation of this object. [...]


operator ==(Object other) bool
The equality operator. [...]