JS CompileScriptForPrincipals
From MDC
Compile a security-enabled script for execution.
[edit] Syntax
JSScript * JS_CompileScriptForPrincipals(JSContext *cx, JSObject *obj, JSPrincipals *principals, const char *src, size_t length, const char *filename, uintN lineno); JSScript * JS_CompileUCScriptForPrincipals(JSContext *cx, JSObject *obj, JSPrincipals *principals, const jschar *src, size_t length, const char *filename, uintN lineno);
| Name | Type | Description |
|---|---|---|
cx |
JSContext * |
The context in which to compile the script.
Requires request. (In a |
obj |
JSObject * |
Object with which the script is associated. |
principals |
JSPrincipals * |
Pointer to the structure holding the security information for this script. |
src |
const char * or const jschar * |
String containing the script to compile. |
length |
size_t |
The length of src, in characters. |
filename |
const char * |
Name of file or URL containing the function. 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. |
[edit] Description
JS_CompileScriptForPrincipals compiles a security-enabled script, src, for execution. JS_CompileUCScriptForPrincipals is the Unicode version of the function. The script is associated with a JS object.
principals is a pointer to the JSPrincipals structure that contains the security information to associate with this script.
src is the string containing the text of the script. length indicates the length of the script, in characters.
filename is the name of the file (or URL) containing the script. This information is included in error 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.
On success, JS_CompileScriptForPrincipals and JS_CompileUCScriptForPrincipals return a pointer to the compiled script. On error or exception, they return NULL.
The application is responsible for ensuring that the new compiled script is cleaned up later—either by calling JS_DestroyScript directly or by calling JS_NewScriptObject, in which case the garbage collector cleans up the script.
[edit] See Also
LXR ID Search for JS_CompileScriptForPrincipals
LXR ID Search for JS_CompileUCScriptForPrincipals
JS_CompileFile, JS_CompileUCScript, JS_DecompileScript, JS_DestroyScript, JS_EvaluateScript, JS_EvaluateScriptForPrincipals, JS_ExecuteScript