JSObjectOps.setProto

  • Revision slug: SpiderMonkey/JSAPI_Reference/JSObjectOps.setProto
  • Revision title: JSObjectOps.setProto
  • Revision id: 170236
  • Created:
  • Creator: Jorend
  • Is current revision? No
  • Comment fmt, minor correction

Revision Content

{{template.Jsapi_ref_header("JSObjectOps.setProto")}} {{template.JSObjectOps_warning()}}

The JSObjectOps.setProto and setParent callbacks implement the JS_SetPrototype and JS_SetParent functions. These callbacks share the same type, JSSetObjectSlotOp.

Syntax

typedef JSBool (*JSSetObjectSlotOp)(JSContext *cx, JSObject *obj,
    uint32 slot, JSObject *pobj);
Name Type Description
cx JSContext * Pointer to the JS context in which the object's prototype or parent is being modified.
obj JSObject * The object whose prototype or parent is being modified.
slot uint32 The index of the slot being modified: JSSLOT_PROTO

for the setProto callback, and JSSLOT_PARENT

for the setParent callback.
pobj JSObject * The new prototype or parent object.

Description

These hooks must check for cycles without deadlocking, and otherwise take special steps. See js_SetPrototype or js_SetParent in {{template.Source("js/src/jsobj.c")}} for an example.

Revision Source

<p>{{template.Jsapi_ref_header("JSObjectOps.setProto")}}
{{template.JSObjectOps_warning()}}
</p><p>The <b><code><a href="en/JSObjectOps">JSObjectOps</a>.setProto</code></b> and <b><code>setParent</code></b> callbacks implement the <code><a href="en/JS_SetPrototype">JS_SetPrototype</a></code> and <code><a href="en/JS_SetParent">JS_SetParent</a></code> functions.  These callbacks share the same type, <code>JSSetObjectSlotOp</code>.
</p>
<h2 name="Syntax"> Syntax </h2>
<pre class="eval">typedef <a href="en/JSBool">JSBool</a> (*<b>JSSetObjectSlotOp</b>)(<a href="en/JSContext">JSContext</a> *cx, <a href="en/JSObject">JSObject</a> *obj,
    <a href="en/Uint32">uint32</a> slot, <a href="en/JSObject">JSObject</a> *pobj);
</pre>
<table class="fullwidth-table">
<tbody><tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td><code>cx</code></td>
<td><code><a href="en/JSContext">JSContext</a> *</code></td>
<td>Pointer to the JS context in which the object's prototype or parent is being modified.</td>
</tr>
<tr>
<td><code>obj</code></td>
<td><code><a href="en/JSObject">JSObject</a> *</code></td>
<td>The object whose prototype or parent is being modified.</td>
</tr>
<tr>
<td><code>slot</code></td>
<td><code>uint32</code></td>
<td>The index of the slot being modified: <code>JSSLOT_PROTO</code>
<p>for the <code>setProto</code> callback, and <code>JSSLOT_PARENT</code>
</p>
for the <code>setParent</code> callback.</td>
</tr>
<tr>
<td><code>pobj</code></td>
<td><code><a href="en/JSObject">JSObject</a> *</code></td>
<td>The new prototype or parent object.</td>
</tr>
</tbody></table>
<h2 name="Description"> Description </h2>
<p>These hooks must check for cycles without deadlocking, and otherwise take special steps.  See <code>js_SetPrototype</code> or <code>js_SetParent</code> in {{template.Source("js/src/jsobj.c")}} for an example.
</p>
Revert to this revision