JS_LeaveLocalRootScopeWithResult

  • Revision slug: SpiderMonkey/JSAPI_Reference/JS_LeaveLocalRootScopeWithResult
  • Revision title: JS_LeaveLocalRootScopeWithResult
  • Revision id: 75371
  • Created:
  • Creator: Waldo
  • Is current revision? No
  • Comment formatting

Revision Content

{{template.Jsapiref()}}

Summary

Leave a local root scope, transferring the result value to the next

Syntax

void JS_LeaveLocalRootScopeWithResult(JSContext *cx, jsval rval);
Name Type Description
cx JSContext * Pointer to the context.
rval jsval The result value that should remain protected from garbage collection.

Description

See JS_EnterLocalRootScope for an explanation of local root scopes.

The protection this function affords to rval is tenuous. If there is an enclosing local root scope, then rval is transferred to it. Otherwise, the value is stored in an internal per-JSContext slot. This slot is rooted, but the value will eventually be overwritten by some other operation, and it is very difficult to figure out exactly when this will happen--or more to the point, guarantee that it won't happen in the time it takes some specific chunk of code to run.

In any case, all other newborn values protected by the local root scope, aside from rval, become subject to garbage collection.

See Also

Groups Functions
Documents {{template.LXRSearch("ident", "i", "JS_EnterLocalRootScope", "LXR ID Search")}}
Entries

{{template.Jsapixref("JS_AddRoot")}}, {{template.Jsapixref("JS_EnterLocalRootScope")}}, {{template.Jsapixref("JS_LeaveLocalRootScope")}}, {{template.Jsapixref("JS_ForgetLocalRoot")}}

Revision Source

<p>
{{template.Jsapiref()}}
</p>
<h3 name="Summary"> Summary </h3>
<p>Leave a local root scope, transferring the result value to the next 
</p>
<h3 name="Syntax"> Syntax </h3>
<pre class="eval">void JS_LeaveLocalRootScopeWithResult(JSContext *cx, jsval rval);
</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>JSContext *</code></td>
<td>Pointer to the context.</td>
</tr>
<tr>
<td><code>rval</code></td>
<td><code>jsval</code></td>
<td>The result value that should remain protected from garbage collection.</td>
</tr>
</tbody></table>
<h3 name="Description"> Description </h3>
<p>See <a href="en/JS_EnterLocalRootScope">JS_EnterLocalRootScope</a> for an explanation of local root scopes.
</p><p>The protection this function affords to <code>rval</code> is tenuous.  If there is an enclosing local root scope, then <code>rval</code> is transferred to it.  Otherwise, the value is stored in an internal per-JSContext slot.  This slot is rooted, but the value will eventually be overwritten by some other operation, and it is very difficult to figure out exactly when this will happen--or more to the point, guarantee that it won't happen in the time it takes some specific chunk of code to run.
</p><p>In any case, all <i>other</i> newborn values protected by the local root scope, aside from <code>rval</code>, become subject to garbage collection.
</p>
<h3 name="See_Also"> See Also </h3>
<table class="fullwidth-table">
<tbody><tr>
<td>Groups</td>
<td><a href="en/JSAPI_Reference#Functions">Functions</a></td>
</tr>
<tr>
<td>Documents</td>
<td>{{template.LXRSearch("ident", "i", "JS_EnterLocalRootScope", "LXR ID Search")}}</td>
</tr>
<tr>
<td>Entries</td>
<td>
<p>{{template.Jsapixref("JS_AddRoot")}},
{{template.Jsapixref("JS_EnterLocalRootScope")}},
{{template.Jsapixref("JS_LeaveLocalRootScope")}},
{{template.Jsapixref("JS_ForgetLocalRoot")}}
</p>
</td>
</tr>
</tbody></table>
Revert to this revision