User Guide

The C-level API 385
JSBool JS_ExecuteScript()
Usage
JS_ExecuteScript (JSContext *cx, JSObject *obj, unsigned short *script,
unsigned int sz, jsval *rval)
Description
Method; compiles and executes a JavaScript string. If the script generates a return value, it returns
in
*rval.
Arguments
JSContext *cx
, JSObject *obj, unsigned short *script, unsigned int sz, jsval *rval
The cx argument is the opaque JSContext pointer that passes to the JavaScript function.
The obj argument is a pointer to the object in whose context the script executes. While the
script is running, the
this keyword is equal to this object. Usually this is the JSObject pointer
that passes to the JavaScript function.
The script argument is a string that contains JavaScript code. If the string size is not specified
(see the
sz argument), the string must be null-terminated.
The sz argument is the size of the string, in bytes. If sz is 0, the length of the null-terminated
string is computed automatically.
The rval argument is a pointer to a single jsval structure. The functions return value is
stored in
*rval.
Returns
A Boolean value: JS_TRUE indicates success; JS_FALSE indicates failure.