Description
JS_DefinePropertyWithTinyId defines a single property for a specified object, obj .name is the name to assign to the property in the object. value is a jsval that defines the property's data type and initial value.
tinyid is an 8-bit value that simplifies determining which property to access, and is especially useful in getProperty and setProperty methods that are shared by a number of different properties.
getter and setter identify the getProperty and setProperty methods for the property, respectively. If you pass null values for these entries, JS_DefinePropertyWithTinyId assigns the default getProperty and setProperty methods to this property. flags contains the property flags to set for the newly created property. The following table lists possible values you can pass in flags , either singly, or OR 'd together:
Flag
|
Purpose
|
JSPROP_ENUMERATE |
Property is visible in for and in loops.
|
JSPROP_READONLY |
Property is read only.
|
JSPROP_PERMANENT |
Property cannot be deleted.
|
JSPROP_EXPORTED |
Property can be imported by other objects.
|
JSPROP_INDEX |
Property is actually an index into an array of properties, and is cast to a const char * .
|
If it successfully creates the property, JS_DefinePropertyWithTinyId returns JS_TRUE . If the property already exists, or cannot be created, it returns JS_FALSE .
|