JavaScript-1.5 Reference

JS_DefineUCPropertyWithTinyID Function

Summary

Creates a single, Unicode-encoded property for a specified object and assigns it an ID number.

Syntax

JSBool JS_DefinePropertyWithTinyId( JSContext *cx,
    JSObject *obj, const jschar *name, size_t namelen,
    int8 tinyid, jsval value, JSPropertyOp getter,
    JSPropertyOp setter, uintN attrs);
NameTypeDescription
cxJSContext *Pointer to a JS context from which to derive runtime information.
objJSObject *Object for which to create the new property.
nameconst jschar *Name for the property to create.
namelensize_tLength, in bytes, of name.
tinyidint88-bit ID to aid in sharing getProperty/setProperty methods among properties.
valuejsvalInitial value to assign to the property.
getterJSPropertyOpgetProperty method for retrieving the current property value.
setterJSPropertyOpsetProperty method for specifying a new property value.
attrsuintNProperty flags.

Description

JS_DefineUCPropertyWithTinyId defines a single, Unicode-encoded property for a specified object, obj.

name is the Unicode-encoded name to assign to the property in the object. namelen is the length, in bytes, of name. 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_DefineUCPropertyWithTinyId assigns the default getProperty and setProperty methods to this property. attrs contains the property flags to set for the newly created property. The following table lists possible values you can pass in sttrs, 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_DefineUCPropertyWithTinyId returns JS_TRUE. If the property already exists, or cannot be created, it returns JS_FALSE.

Notes

While you can assign a setProperty method to a property and set attrs to JSPROP_READONLY, the setter method will not be called on this property.

See Also

Groups [ Function ]
Documents [ LXR ID Search ]
Entries [ JSPROP_READONLY | JS_DefineConstDoubles | JS_DefineElement | JS_DefineFunction | JS_DefineFunctions | JS_DefineObject | JS_DefineProperties | JS_DefineProperty | JS_DefinePropertyWithTinyId | JS_DefineUCProperty ]

This page was generated by APIDOC