Skip to main content

Module properties

Module properties 

Source
Expand description

Properties and atoms: the JS_GetPropertyInternal family, JS_DefineProperty*, JS_DeleteProperty*, and the atom table’s C surface.

§The flags are a bitfield, and getting one bit wrong is silent

JS_PROP_* is sixteen bits with three meanings layered on one integer: the low three are the attributes, bits 4–5 say whether the property is a plain value or an accessor pair, and bits 8–13 say which descriptor fields the caller supplied — the same “present or absent” distinction Object.defineProperty’s descriptor object carries. A definition that ignores the “present” bits turns {value: 1} into {value: undefined, get: undefined, set: undefined} and so destroys an accessor the caller meant to keep. crate::cdefs::prop names them all, and every function below translates them once.

§Owners, once

The rule is the reference’s, and it is not uniform: JS_GetProperty* answers a new reference, JS_SetProperty* consumes the value it is given, and JS_DefinePropertyValue* consumes it too. JS_DefineProperty (the one taking both a value and a getter/setter) consumes only what the flags say it uses. This module says which is which at every function rather than leaving it to be inferred.

Constants§

GPN_ENUM_ONLY
JS_GPN_ENUM_ONLY: only the enumerable properties.
GPN_PRIVATE_MASK
JS_GPN_PRIVATE_MASK.
GPN_SET_ENUM
JS_GPN_SET_ENUM: fill in JSPropertyEnum::is_enumerable.
GPN_STRING_MASK
JS_GPN_STRING_MASK.
GPN_SYMBOL_MASK
JS_GPN_SYMBOL_MASK.

Functions§

JS_AtomToCStringLen⚠
JS_AtomToCStringLen: the atom’s text as a js_malloc block.
JS_AtomToString⚠
JS_AtomToString: JS_AtomToValue under its other name.
JS_AtomToValue⚠
JS_AtomToValue: the atom’s text as a string value, or undefined for ATOM_NULL.
JS_DefineProperty⚠
JS_DefineProperty: define an accessor and/or a value in one call.
JS_DefinePropertyGetSet⚠
JS_DefinePropertyGetSet: the accessor-only spelling.
JS_DefinePropertyValue⚠
JS_DefinePropertyValue: define a data property, consuming val.
JS_DefinePropertyValueInt64⚠
JS_DefinePropertyValueInt64: the same, keyed by a 64-bit index.
JS_DefinePropertyValueStr⚠
JS_DefinePropertyValueStr: the same, keyed by a string.
JS_DefinePropertyValueUint32⚠
JS_DefinePropertyValueUint32: the same, keyed by an index.
JS_DefinePropertyValueValue⚠
JS_DefinePropertyValueValue: the same, keyed by a value (ToPropertyKey on it).
JS_DeleteProperty⚠
JS_DeleteProperty: delete obj[prop].
JS_DeletePropertyInt64⚠
JS_DeletePropertyInt64: the same, keyed by an index.
JS_DupAtom
JS_DupAtom: keep an atom alive.
JS_FreeAtom
JS_FreeAtom: release an atom.
JS_FreeAtomRT
JS_FreeAtomRT: JS_FreeAtom’s runtime-level spelling.
JS_FreePropertyEnum⚠
JS_FreePropertyEnum: release what JS_GetOwnPropertyNames allocated.
JS_GetOwnProperty⚠
JS_GetOwnProperty: a complete descriptor for obj[prop].
JS_GetOwnPropertyNames⚠
JS_GetOwnPropertyNames: ptab/plen filled with the object’s own keys.
JS_GetPropertyInternal⚠
JS_GetPropertyInternal: the general read, with an explicit receiver.
JS_GetPropertyUint32⚠
JS_GetPropertyStr: read this_obj[name].
JS_GetPrototype⚠
JS_GetPrototype: [[GetPrototypeOf]], or null for an object with none.
JS_HasProperty⚠
JS_HasProperty: whether this_obj has prop (own or inherited).
JS_IsExtensible⚠
JS_IsExtensible: whether new properties may be added.
JS_NewAtom⚠
JS_NewAtom: intern a NUL-terminated string.
JS_NewAtomLen⚠
JS_NewAtomLen: intern len bytes as an atom.
JS_NewAtomUInt32⚠
JS_NewAtomUInt32: intern an unsigned 32-bit index.
JS_PreventExtensions⚠
JS_PreventExtensions: make the object non-extensible.
JS_SetConstructorBit⚠
JS_SetConstructorBit: whether new is allowed on a function object.
JS_SetIsHTMLDDA⚠
JS_SetIsHTMLDDA: mark the object as document.all-like.
JS_SetPropertyInt64⚠
JS_SetPropertyInt64: the same for a 64-bit index.
JS_SetPropertyInternal⚠
JS_SetPropertyInternal: the general store.
JS_SetPropertyUint32⚠
JS_SetPropertyStr lives in crate::objects. The numbered spellings are here.
JS_SetPrototype⚠
JS_SetPrototype: [[SetPrototypeOf]], answering -1 for a refused cycle.
JS_SetUncatchableException⚠
JS_SetUncatchableException: prevent try/catch from seeing the pending exception.
JS_ValueToAtom⚠
JS_ValueToAtom: the atom for a value’s property key.