Your Search Results

    JS_GetReservedSlot

    Access an object's reserved slots.

    Syntax

    JS::Value JS_GetReservedSlot(JSObject *obj, uint32 index);
    
    void JS_SetReservedSlot(JSObject *obj, uint32 index, JS::Value v);
    
    Name Type Description
    obj JSObject * An object that has reserved slots.
    index uint32 Index of the reserved slot to access.
    v JS::Value (in JS_SetReservedSlot) The value to store.

    Description

    If a JSClass has JSCLASS_HAS_RESERVED_SLOTS(n) in its flags, with n > 0, or has a non-null JSClass.reserveSlots callback, then objects of that class have n reserved slots in which the application may store data.  These fields are not directly exposed to scripts.

    Reserved slots may contain any JS::Value, and the garbage collector will hold the value alive as long as the object itself is alive.

    Reserved slots may also contain private values to store pointer values (whose lowest bit is 0) or uint32_t, when non-JavaScript values must be stored; the garbage collector ignores such values when it sees them.  (Note that private values must not be exposed directly to JavaScript.  It's only legal to store and retrieve data from private values.  They cannot be returned from functions, set as properties on objects, embedded in JavaScript arrays, and so on.)

    New objects' reserved slots are initialized to undefined.

    MXR ID Search for JS_GetReservedSlot
    MXR ID Search for JS_SetReservedSlot

    Document Tags and Contributors

    Contributors to this page: Sheppy, Dmandelin, Waldo, Jorend, nikhilm
    Last updated by: Sheppy,