JS ConstructObject
From MDC
Create a new JavaScript object and invoke its constructor.
[edit] Syntax
JSObject * JS_ConstructObject(JSContext *cx, JSClass *clasp, JSObject *proto, JSObject *parent);
| Name | Type | Description |
|---|---|---|
cx |
JSContext * |
The context in which to create the new object.
Requires request. (In a |
clasp |
JSClass * |
Pointer to the class to use for the new object. If this is NULL, an ordinary JavaScript Object is created.
|
proto |
JSObject * |
Pointer to the prototype object to use for the new class. |
parent |
JSObject * |
Pointer to which to set the new object's __parent__ property. |
[edit] Description
JS_ConstructObject instantiates a new object based on a specified class, prototype, and parent object, and then invokes its constructor function. cx is a pointer to a context associated with the runtime in which to establish the new object. clasp is a pointer to an existing class to use for internal methods, such as finalize. proto is an optional pointer to the prototype object with which to associate the new object.
Set proto to NULL to force JS to assign a prototype object for you. In this case, JS_ConstructObject attempts to assign the new object the prototype object belonging to clasp, if one is defined there. Otherwise, it creates an empty object stub for the prototype.
parent is an optional pointer to an existing object to which to set the new object's parent object property. You can set parent to NULL if you do not want to set the parent property.
On success, JS_ConstructObject returns a pointer to the newly instantiated object. Otherwise it returns NULL.
[edit] See Also
LXR ID Search for JS_ConstructObject
JS_DefineObject, JS_GetFunctionObject, JS_NewArrayObject, JS_NewObject, JS_ValueToObject