Obsolete since JSAPI 30
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.
Create a new object property with a tiny id.
JSBool JS_DefinePropertyWithTinyId( JSContext *cx, JSObject *obj, const char *name, int8 tinyid, jsval value, JSPropertyOp getter, JSPropertyOp setter, uintN attrs); JSBool JS_DefineUCPropertyWithTinyId( JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, int8 tinyid, jsval value, JSPropertyOp getter, JSPropertyOp setter, uintN attrs);
||The context in which to define the property. Requires request. In a
||Object for which to create the new property.|
||Name for the property to create.|
||8-bit ID to aid in sharing getter and setter callbacks among properties.|
||Initial stored value for the new property.|
JS_DefinePropertyWithTinyId defines an object property with a tiny id.
JS_DefineUCPropertyWithTinyId is the Unicode version of the function. Except for the
tinyid parameter, these functions behave exactly as
JS_DefineUCProperty. See those functions for more details.
tinyid is a signed 8-bit integer that affects the
id parameter of a tiny-id-aware callback, it passes
INT_TO_JSVAL(tinyid) instead. The tiny-id-aware callbacks are: property getters and setters; and
.setProperty. Tiny ids only affect the
Tiny ids are helpful for getters and setters that are shared by several different properties. Those getters and setters can use
switch (JSVAL_TO_INT(id)), instead of checking the value of
id as a string, to determine which property is being accessed.
However, tiny ids can cause confusion when used with
JSClass callbacks. For example, if a property named
"color" is defined with tiny id
obj.color will both result in
INT_TO_JSVAL(10) being passed to
JSClass.getProperty as the
id parameter. Per-property getters and setters do not suffer from this confusion: in the above example,
color property, but
obj wouldn't. Traditionally, negative tiny ids are used to minimize the potential confusion, but it is best to specify a non-null
setter when defining a property with a tiny id.
JS_TRUE. If the property already exists or cannot be created, they return