Entry: JS_DefineElement (Function)
Summary: Creates a single element or numeric property for a specified object.
Syntax:
JSBool JS_DefineElement(JSContext *cx, JSObject *obj,
jsint index, jsval value, JSPropertyOp getter,
JSPropertyOp setter, uintN flags);
Argument Type Description
cx JSContext * Pointer to a JS context from which to derive runtime information.
obj JSObject * Object for which to create the new element.
index jsint Array index number for the element to define.
value jsval Initial value to assign to the element.
getter JSPropertyOp getProperty method for retrieving the current element value.
setter JSPropertyOp setProperty method for specifying a new element value.
flags uintN Property flags.
Description:
JS_DefineElement defines a single element or numeric property for a specified object, obj.
index is the slot number in the array for which to define an element. It may be an valid jsval integer. value is a jsval that defines the element's data type and initial value. getter and setter identify the getProperty and setProperty methods for the element, respectively. If you pass null values for these entries, JS_DefineElement assigns the default getProperty and setProperty methods to this element. flags contains the property flags to set for the newly created element. The following table lists possible values you can pass in flags, either singly, or OR'd together: TABLE BORDER="0" TRTD VALIGN='baseline' ALIGN='left' BFlag /B/TDTD VALIGN='baseline' ALIGN='left' BPurpose /B /TD/TRTR TD VALIGN='baseline' ALIGN='left'P CODEJSPROP_ENUMERATE/CODE/TDTD VALIGN='baseline' ALIGN='left'P Element is visible in Bfor/B and Bin/B loops./P /TD/TRTR TD VALIGN='baseline' ALIGN='left'P CODEJSPROP_READONLY/CODE/TDTD VALIGN='baseline' ALIGN='left'P Element is read only./P /TD/TRTR TD VALIGN='baseline' ALIGN='left'P CODEJSPROP_PERMANENT/CODE/TDTD VALIGN='baseline' ALIGN='left'P Element cannot be deleted./P /TD/TRTR TD VALIGN='baseline' ALIGN='left'P CODEJSPROP_EXPORTED/CODE/TDTD VALIGN='baseline' ALIGN='left'P Element can be imported by other objects./P /TD/TRTR TD VALIGN='baseline' ALIGN='left'P CODEJSPROP_INDEX/CODE/TDTD VALIGN='baseline' ALIGN='left'P Property is actually an index into an array of properties, and is cast to a CODEconst char */CODE./P /TD/TR/TABLE
If it successfully creates the element, JS_DefineElement returns JS_TRUE. Otherwise it returns JS_FALSE.
See also:
|
|
|