JS SetParent
From MDC
Sets the parent for an object.
[edit] Syntax
JSBool JS_SetParent(JSContext *cx, JSObject *obj, JSObject *parent);
| Name | Type | Description |
|---|---|---|
cx |
JSContext * |
Pointer to a JS context from which to derive runtime information.
Requires request. (In a |
obj |
JSObject * |
Pointer to the object for which to set the parent. |
parent |
JSObject * |
Pointer to the parent object to use. |
[edit] Description
JS_SetParent sets the parent object for a specified object. A parent object is part of the enclosing scope chain for an object. Ordinarily you set a parent for an object when you create the object with JS_NewObject, but if you do not set a parent at that time, you can later call JS_SetParent to do so.
obj is a pointer to an existing JS object, and parent is a pointer to a second existing object of which the first object is a child. If JS_SetParent is successful, it returns JS_TRUE. Otherwise, if it cannot create and fill a parent slot for the object, it returns JS_FALSE.
To get an object's parent object, use JS_GetParent.