JS_InitStandardClasses 编辑

Initializes general JS function and object classes, and the built-in object classes used in most scripts.

Syntax

bool
JS_InitStandardClasses(JSContext *cx, JS::Handle<JSObject*> obj);
NameTypeDescription
cxJSContext *Pointer to the executable script context for which to initialize JS function and object classes. Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext.
objJS::Handle&lt;JSObject*&gt;The global object to initialize. This object must be of a JSClass that has the JSCLASS_GLOBAL_FLAGS bits set.

Description

JS_InitStandardClasses initializes the built-in JavaScript global properties. These include all the standard ECMAScript global properties defined in ECMA 262-3 §15.1:

Array, Boolean, Date, decodeURI, decodeURIComponent, encodeURI, encodeURIComponent, Error, eval, EvalError, Function, Infinity, isNaN, isFinite, Math, NaN, Number, Object, parseInt, parseFloat, RangeError, ReferenceError, RegExp, String, SyntaxError, TypeError, undefined, and URIError

as well as a few SpiderMonkey-specific globals, depending on compile-time options:

escape, unescape, uneval, InternalError, Script, XML, Namespace, QName, File, Generator, Iterator, and StopIteration, as of SpiderMonkey 1.7.

These global objects, functions, constructors, and constants are created as properties of obj. As a side effect, JS_InitStandardClasses establishes obj as the global object for cx, if one is not already established. This means that scripts executed in cx will see the properties of obj as global variables. See JS_SetGlobalObject for details.

obj must be of a JSClass that has the JSCLASS_GLOBAL_FLAGS flag.

JS_InitStandardClasses returns JS_TRUE on success, and JS_FALSE if an error occurs.

To initialize custom classes, use JS_InitClass.

See Also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:97 次

字数:4302

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文