JavaScript-1.5 Reference

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);
NameTypeDescription
cxJSContext *Pointer to a JS context from which to derive runtime information for error reporting.
objJSObject *Object to which this new object belongs as a property.
nameconst char *Name of the property that encapsulates the new object in obj.
claspJSClass *Class to use for the new object.
protoJSObject *Prototype object to use for the new object.
flagsuintNProperty 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:
Flag Purpose

JSPROP_ENUMERATE

Property is visible to 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 *.

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

Groups [ Function ]
Documents [ LXR ID Search ]
Entries [ JSClass | JS_DefineConstDoubles | JS_DefineElement | JS_DefineFunction | JS_DefineFunctions | JS_DefineProperties | JS_DefineProperty | JS_DefinePropertyWithTinyId | JS_NewObject | JS_ValueToObject ]

This page was generated by APIDOC