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);
Name | Type | Description |
---|---|---|
cx | JSContext * | 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 . |
obj | JS::Handle<JSObject*> | 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
, andURIError
as well as a few SpiderMonkey-specific globals, depending on compile-time options:
escape
,unescape
,uneval
,InternalError
,Script
,XML
,Namespace
,QName
,File
,Generator
,Iterator
, andStopIteration
, 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论