mozilla
Your Search Results

    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, 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

    Document Tags and Contributors

    Contributors to this page: fscholz, Wesgarland, Nickolay, arai, Kreist, Tservo, Dria, Jorend
    Last updated by: arai,
    Hide Sidebar