Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

JSClass.flags

The JSClass.flags field allows an application to enable optional JSClass features on a per-class basis.

The flags field is of type uint32_t. Its value is the logical OR of zero or more of the following constants:

Flag Meaning

JSCLASS_HAS_PRIVATE

This class uses private data. If this flag is set, each instance of the class has a field for private data. The field can be accessed using JS_GetPrivate and JS_SetPrivate.

MXR ID Search for JSCLASS_HAS_PRIVATE

JSCLASS_PRIVATE_IS_NSISUPPORTS

Mozilla extension. The private field of each object of this class points to an XPCOM object (see nsISupports). This is only meaningful if SpiderMonkey is built with XPConnect and the JSCLASS_HAS_PRIVATE flag is also set.

MXR ID Search for JSCLASS_PRIVATE_IS_NSISUPPORTS

JSCLASS_IS_DOMJSCLASS

Added in SpiderMonkey 17 Objects are DOM.

MXR ID Search for JSCLASS_IS_DOMJSCLASS

JSCLASS_IMPLEMENTS_BARRIERS

Added in SpiderMonkey 17 Correctly implements GC read and write barriers.

MXR ID Search for JSCLASS_IMPLEMENTS_BARRIERS

JSCLASS_EMULATES_UNDEFINED

Added in SpiderMonkey 24 Causes objects which have this class to emulate undefined in certain circumstances.  An object obj that emulates undefined behaves like any other object, except in the following ways:

  • typeof obj === "undefined"
  • obj converts to false when obj is converted to a boolean when used in boolean contexts (if conditions, loop continuation/termination conditions [for/while/do { } while], the condition in a ternary ?: expression, and so on)
  • (obj == undefined) is true, and (obj != undefined) is false
  • (obj == null) is true, and (obj != null) is false

== and != comparisons to values other than null or undefined (including to an object that emulates undefined) are unaffected by this flag.  Strict equality (=== and !==) comparisons are also unaffected by this flag.

MXR ID Search for JSCLASS_EMULATES_UNDEFINED

JSCLASS_HAS_RESERVED_SLOTS(n)

Indicates that instances of this class have n reserved slots. n is an integer in the range [0..255]. The slots initially contain unspecified valid jsval values. They can be accessed using JS_GetReservedSlot and JS_SetReservedSlot.

(The JSClass.reserveSlots hook also allocates reserved slots to objects.)

MXR ID Search for JSCLASS_HAS_RESERVED_SLOTS

JSCLASS_GLOBAL_FLAGS

This flag is only relevant for the class of an object that is used as a global object. (ECMAScript specifies a single global object, but in SpiderMonkey the global object is the last object in the scope chain, which can be different objects at different times. This is actually quite subtle. JS_ExecuteScript and similar APIs set the global object for the code they execute. JS_SetGlobalObject sets an object which is sometimes used as the global object, as a last resort.)

Enable standard ECMAScript behavior for setting the prototype of certain objects, such as Function objects. If the global object does not have this flag, then scripts may cause nonstandard behavior by replacing standard constructors or prototypes (such as Function.prototype.)

Objects that can end up with the wrong prototype object, if this flag is not present, include: arguments objects (§10.1.8 specifies "the original Object prototype"), Function objects (§13.2 specifies "the original Function prototype"), and objects created by many standard constructors (§15.4.2.1 and others).

MXR ID Search for JSCLASS_GLOBAL_FLAGS

JSCLASS_NEW_ENUMERATE

Obsolete since JSAPI 37 This class's enumerate hook is actually a JSNewEnumerateOp, not a JSEnumerateOp.

JSCLASS_NEW_RESOLVE

Obsolete since JSAPI 36 This class's resolve hook is actually a JSNewResolveOp, not a JSResolveOp.

JSCLASS_SHARE_ALL_PROPERTIES

Obsolete since JavaScript 1.8.5 Instructs SpiderMonkey to automatically give all properties of objects of this class the JSPROP_SHARED attribute.

JSCLASS_NEW_RESOLVE_GETS_START

Obsolete since JSAPI 16 The resolve hook expects to receive the starting object in the prototype chain passed in via the *objp in/out parameter. (This is meaningful only if the JSCLASS_NEW_RESOLVE flag is also set.)

JSCLASS_CONSTRUCT_PROTOTYPE

Obsolete since JSAPI 11 Instructs JS_InitClass to invoke the constructor when creating the class prototype.

JSCLASS_IS_EXTENDED

Obsolete since JSAPI 17Indicates that this JSClass is really a JSExtendedClass.

JSCLASS_MARK_IS_TRACE

Obsolete since JSAPI 5 Indicates that the mark hook implements the new JSTraceOp signature instead of the old JSMarkOp signature. This is recommended for all new code that needs custom marking.

SpiderMonkey reserves a few other flags for its internal use. They are JSCLASS_IS_ANONYMOUS, JSCLASS_IS_GLOBAL, JSCLASS_IS_PROXY, JSCLASS_BACKGROUND_FINALIZE, and JSCLASS_HAS_CACHED_PROTO. JSAPI applications should not use these flags.

See Also

Document Tags and Contributors

 Contributors to this page: arai, fscholz, Waldo, tschneidereit, markg, Jorend
 Last updated by: arai,