Skip to main content

Module atoms

Module atoms 

Source
Expand description

The atom table: JSAtom, the C API’s interned property keys.

§Why the identifiers are the reference’s

JS_ATOM_* values are part of the ABI. A C module writes JS_ATOM_length and we have to read the same number, so the table below is a transcription of oracle/quickjs-master/quickjs-atom.h in its own order — not a curated subset and not re-sorted. tests/atoms.rs re-parses that header and asserts index for index, which is what keeps a transcription from silently drifting.

§Why a table and not a hash of the pointer

The reference’s atoms are refcounted strings with the first few hundred pinned. Here an atom is an index into a per-runtime vector, with the pinned prefix pre-filled: index 0 is JS_ATOM_NULL, indices 1..=JS_ATOM_END - 1 are the constants below, and anything a program interns afterwards is appended. Duplicates hash to the index already there, so JS_NewAtom(ctx, "length") twice answers the same atom, which is the only property the C API actually promises.

Structs§

AtomTable
The atoms one runtime has interned.

Constants§

ATOM_END
JS_ATOM_END: one past the last pinned atom, which is also the first free index.
ATOM_NULL
JS_ATOM_NULL: the atom that addresses no property.
PINNED
The pinned atoms, in the reference’s order: JS_ATOM_null is 1.

Type Aliases§

Atom
JSAtom: a uint32_t. JS_ATOM_NULL (0) is the null atom.