Visit Mozilla.org

JS InitStandardClasses

From MDC

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

[edit] Syntax

JSBool JS_InitStandardClasses(JSContext *cx, 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 JSObject * The object to set as the global object.

[edit] 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.

For full ECMAScript standard compliance, obj should 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.

LXR ID Search for JS_InitStandardClasses