JS_EvaluateScriptForPrincipals

  • Revision slug: SpiderMonkey/JSAPI_Reference/JS_EvaluateScriptForPrincipals
  • Revision title: JS_EvaluateScriptForPrincipals
  • Revision id: 147076
  • Created:
  • Creator: Jorend
  • Is current revision? No
  • Comment typo

Revision Content

{{template.Jsapi_ref_header("JS_EvaluateScriptForPrincipals")}}

Compiles and executes a security-enabled script.

Syntax

JSBool JS_EvaluateScriptForPrincipals(JSContext *cx,
    JSObject *obj, JSPrincipals *principals, const char *bytes,
    uintN length, const char *filename, uintN lineno,
    jsval *rval);
Name Type Description
cx JSContext * The context in which to run the script. {{wiki.template('Jsapi-requires-request')}}
obj JSObject * Object with which the script is associated.
principals JSPrincipals * Pointer to the structure holding the security information for this script.
bytes const char * String containing the script to compile and execute.
length size_t Size, in bytes, of the script to compile and execute.
filename const char * Name of file or URL containing the script. Used to report filename or URL in error messages.
lineno uintN Line number. Used to report the offending line in the file or URL if an error occurs.
rval jsval * Pointer to the value from the last executed expression statement processed in the script.

Description

JS_EvaluateScriptForPrincipals compiles and executes a script associated with a JS object, obj. On successful completion, rval is a pointer to a variable that holds the value from the last executed expression statement processed in the script.

principals is a pointer to the JSPrincipals structure that contains the security information to associate with this script.

bytes is the string containing the text of the script. length indicates the size of the text version of the script in bytes.

filename is the name of the file (or URL) containing the script. This information is used in messages if an error occurs during compilation. Similarly, lineno is used to report the line number of the script or file where an error occurred during compilation.

If a secure script compiles and executes successfully, JS_EvaluateScriptForPrincipals returns JS_TRUE. Otherwise it returns JS_FALSE. On failure, your application should assume that rval is undefined.

See Also

{{template.LXRSearch("ident", "i", "JS_EvaluateScriptForPrincipals")}}

JSPrincipals, JS_CompileFile, JS_CompileScriptForPrincipals, JS_EvaluateScript, JS_EvaluateUCScriptForPrincipals

Revision Source

<p>{{template.Jsapi_ref_header("JS_EvaluateScriptForPrincipals")}}
</p><p>Compiles and executes a security-enabled script.
</p>
<h2 name="Syntax"> Syntax </h2>
<pre class="eval"><a href="en/JSBool">JSBool</a> <b>JS_EvaluateScriptForPrincipals</b>(<a href="en/JSContext">JSContext</a> *cx,
    <a href="en/JSObject">JSObject</a> *obj, <a href="en/JSPrincipals">JSPrincipals</a> *principals, const char *bytes,
    <a href="en/UintN">uintN</a> length, const char *filename, <a href="en/UintN">uintN</a> lineno,
    <a href="en/Jsval">jsval</a> *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><a href="en/JSContext">JSContext</a> *</code></td>
<td>The context in which to run the script.
{{wiki.template('Jsapi-requires-request')}}</td>
</tr>
<tr>
<td><code>obj</code></td>
<td><code><a href="en/JSObject">JSObject</a> *</code></td>
<td>Object with which the script is associated.</td>
</tr>
<tr>
<td><code>principals</code></td>
<td><code><a href="en/JSPrincipals">JSPrincipals</a> *</code></td>
<td>Pointer to the structure holding the security information for this script.</td>
</tr>
<tr>
<td><code>bytes</code></td>
<td><code>const char *</code></td>
<td>String containing the script to compile and execute.</td>
</tr>
<tr>
<td><code>length</code></td>
<td><code>size_t</code></td>
<td>Size, in bytes, of the script to compile and execute.</td>
</tr>
<tr>
<td><code>filename</code></td>
<td><code>const char *</code></td>
<td>Name of file or URL containing the script. Used to report filename or URL in error messages.</td>
</tr>
<tr>
<td><code>lineno</code></td>
<td><code><a href="en/UintN">uintN</a></code></td>
<td>Line number. Used to report the offending line in the file or URL if an error occurs.</td>
</tr>
<tr>
<td><code>rval</code></td>
<td><code><a href="en/Jsval">jsval</a> *</code></td>
<td>Pointer to the value from the last executed expression statement processed in the script.</td>
</tr>
</tbody></table>
<h2 name="Description"> Description </h2>
<p><code>JS_EvaluateScriptForPrincipals</code> compiles and executes a script associated with a JS object, <code>obj</code>. On successful completion, <code>rval</code> is a pointer to a variable that holds the value from the last executed expression statement processed in the script.
</p><p><code>principals</code> is a pointer to the <code><a href="en/JSPrincipals">JSPrincipals</a></code> structure that contains the security information to associate with this script.
</p><p><code>bytes</code> is the string containing the text of the script. <code>length</code> indicates the size of the text version of the script in bytes.
</p><p><code>filename</code> is the name of the file (or URL) containing the script. This information is used in messages if an error occurs during compilation. Similarly, <code>lineno</code> is used to report the line number of the script or file where an error occurred during compilation.
</p><p>If a secure script compiles and executes successfully, <code>JS_EvaluateScriptForPrincipals</code> returns <code>JS_TRUE</code>. Otherwise it returns <code>JS_FALSE</code>. On failure, your application should assume that <code>rval</code> is undefined.
</p>
<h2 name="See_Also"> See Also </h2>
<p>{{template.LXRSearch("ident", "i", "JS_EvaluateScriptForPrincipals")}}
</p><p><a href="en/JSPrincipals">JSPrincipals</a>,
<a href="en/JS_CompileFile">JS_CompileFile</a>,
<a href="en/JS_CompileScriptForPrincipals">JS_CompileScriptForPrincipals</a>,
<a href="en/JS_EvaluateScript">JS_EvaluateScript</a>,
<a href="en/JS_EvaluateUCScriptForPrincipals">JS_EvaluateUCScriptForPrincipals</a>
</p>
Revert to this revision