Entry: JS_DefineObject (Function)
Summary: Instantiates an object that is a property of another object.
Syntax:
JSObject * JS_DefineObject(JSContext *cx, JSObject *obj,
const char *name, JSClass *clasp, JSObject *proto,
uintN flags);
Argument Type Description
cx JSContext * Pointer to a JS context from which to derive runtime information for error reporting.
obj JSObject * Object to which this new object belongs as a property.
name const char * Name of the property that encapsulates the new object in obj.
clasp JSClass * Class to use for the new object.
proto JSObject * Prototype object to use for the new object.
flags uintN Property flags for the new object.
Description:
JS_DefineObject instantiates and names a new object for an existing object, obj. name is the property name to assign to obj to hold the new object, and 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: 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 Property is visible to Bfor/B and Bin/B loops./P /TD/TRTR TD VALIGN='baseline' ALIGN='left'P CODEJSPROP_READONLY/CODE/TDTD VALIGN='baseline' ALIGN='left'P Property is read only./P /TD/TRTR TD VALIGN='baseline' ALIGN='left'P CODEJSPROP_PERMANENT/CODE/TDTD VALIGN='baseline' ALIGN='left'P Property cannot be deleted./P /TD/TRTR TD VALIGN='baseline' ALIGN='left'P CODEJSPROP_EXPORTED/CODE/TDTD VALIGN='baseline' ALIGN='left'P Property 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
clasp is a pointer to the base class to use when creating the new object, and proto is an pointer to the prototype upon which to base the new object. If you set proto to NULL, JS sets the prototype object for you. The parent object for the new object is set to obj.
JS_DefineObject returns a pointer to the newly created property object if successful. If the property already exists, or cannot be created, JS_DefineObject returns NULL.
See also:
|
|
|