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 inJSPropertyEnum::is_enumerable.- GPN_
STRING_ MASK JS_GPN_STRING_MASK.- GPN_
SYMBOL_ MASK JS_GPN_SYMBOL_MASK.
Functions§
- JS_
Atom ⚠ToCString Len JS_AtomToCStringLen: the atom’s text as ajs_mallocblock.- JS_
Atom ⚠ToString JS_AtomToString:JS_AtomToValueunder its other name.- JS_
Atom ⚠ToValue JS_AtomToValue: the atom’s text as a string value, orundefinedforATOM_NULL.- JS_
Define ⚠Property JS_DefineProperty: define an accessor and/or a value in one call.- JS_
Define ⚠Property GetSet JS_DefinePropertyGetSet: the accessor-only spelling.- JS_
Define ⚠Property Value JS_DefinePropertyValue: define a data property, consumingval.- JS_
Define ⚠Property Value Int64 JS_DefinePropertyValueInt64: the same, keyed by a 64-bit index.- JS_
Define ⚠Property Value Str JS_DefinePropertyValueStr: the same, keyed by a string.- JS_
Define ⚠Property Value Uint32 JS_DefinePropertyValueUint32: the same, keyed by an index.- JS_
Define ⚠Property Value Value JS_DefinePropertyValueValue: the same, keyed by a value (ToPropertyKeyon it).- JS_
Delete ⚠Property JS_DeleteProperty: deleteobj[prop].- JS_
Delete ⚠Property Int64 JS_DeletePropertyInt64: the same, keyed by an index.- JS_
DupAtom JS_DupAtom: keep an atom alive.- JS_
Free Atom JS_FreeAtom: release an atom.- JS_
Free AtomRT JS_FreeAtomRT:JS_FreeAtom’s runtime-level spelling.- JS_
Free ⚠Property Enum JS_FreePropertyEnum: release whatJS_GetOwnPropertyNamesallocated.- JS_
GetOwn ⚠Property JS_GetOwnProperty: a complete descriptor forobj[prop].- JS_
GetOwn ⚠Property Names JS_GetOwnPropertyNames:ptab/plenfilled with the object’s own keys.- JS_
GetProperty ⚠Internal JS_GetPropertyInternal: the general read, with an explicit receiver.- JS_
GetProperty ⚠Uint32 JS_GetPropertyStr: readthis_obj[name].- JS_
GetPrototype ⚠ JS_GetPrototype:[[GetPrototypeOf]], ornullfor an object with none.- JS_
HasProperty ⚠ JS_HasProperty: whetherthis_objhasprop(own or inherited).- JS_
IsExtensible ⚠ JS_IsExtensible: whether new properties may be added.- JS_
NewAtom ⚠ JS_NewAtom: intern a NUL-terminated string.- JS_
NewAtom ⚠Len JS_NewAtomLen: internlenbytes as an atom.- JS_
NewAtomU ⚠Int32 JS_NewAtomUInt32: intern an unsigned 32-bit index.- JS_
Prevent ⚠Extensions JS_PreventExtensions: make the object non-extensible.- JS_
SetConstructor ⚠Bit JS_SetConstructorBit: whethernewis allowed on a function object.- JS_
SetIsHTMLDDA ⚠ JS_SetIsHTMLDDA: mark the object asdocument.all-like.- JS_
SetProperty ⚠Int64 JS_SetPropertyInt64: the same for a 64-bit index.- JS_
SetProperty ⚠Internal JS_SetPropertyInternal: the general store.- JS_
SetProperty ⚠Uint32 JS_SetPropertyStrlives incrate::objects. The numbered spellings are here.- JS_
SetPrototype ⚠ JS_SetPrototype:[[SetPrototypeOf]], answering-1for a refused cycle.- JS_
SetUncatchable ⚠Exception JS_SetUncatchableException: preventtry/catchfrom seeing the pending exception.- JS_
Value ⚠ToAtom JS_ValueToAtom: the atom for a value’s property key.