JS_EvaluateScriptForPrincipals 编辑
Obsolete since JSAPI 30
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.
Compile and execute a security-enabled script.
Syntax
JSBool
JS_EvaluateScriptForPrincipals(JSContext *cx, JSObject *obj,
JSPrincipals *principals, const char *src, unsigned int length,
const char *filename, unsigned int lineno, jsval *rval);
JSBool
JS_EvaluateScriptUCForPrincipals(JSContext *cx, JSObject *obj,
JSPrincipals *principals, const jschar *src, unsigned int length,
const char *filename, unsigned int lineno, jsval *rval);
JSBool
JS_EvaluateScriptForPrincipalsVersion(JSContext *cx, JSObject *obj,
JSPrincipals *principals, const char *bytes, unsigned int length,
const char *filename, unsigned int lineno, jsval *rval, JSVersion version);
JSBool
JS_EvaluateUCScriptForPrincipalsVersion(JSContext *cx, JSObject *obj,
JSPrincipals *principals, const jschar *chars, unsigned int length,
const char *filename, unsigned int lineno, jsval *rval, JSVersion version);
Name | Type | Description |
---|---|---|
cx | JSContext * | The context in which to run the script. Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext . |
obj | JSObject * | The scope in which to execute the script. This parameter is documented in detail at JS_ExecuteScript . |
principals | JSPrincipals * | Pointer to the structure holding the security information for this script. |
src / bytes / chars | const char * or const | String containing the script to compile and execute. |
length | unsigned int | The length of src , in characters. |
filename | const char * | Name of file or URL containing the script. Used to report filename or URL in error messages. |
lineno | unsigned int | Line number. Used to report the offending line in the file or URL if an error occurs. |
rval | jsval * | Out parameter. On success, *rval receives the value from the last-executed expression statement in the script. |
version | JSVersion | JavaScript Version for the script. |
Description
JS_EvaluateScriptForPrincipals
compiles and executes a script in the specified scope, obj
. JS_EvaluateUCScriptForPrincipals
is the Unicode version of the function.
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
is the length of the script, in characters.
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 the script compiles and executes successfully, *rval
receives the value from the last-executed expression statement processed in the script, and JS_EvaluateScriptForPrincipals
or JS_EvaluateUCScriptForPrincipals
returns JS_TRUE
. Otherwise it returns JS_FALSE
, and the value left in *rval
is undefined.
See Also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论