Skip to content

Class jac::Atom

ClassList > jac > Atom

A wrapper around JSAtom with RAII. In the context of QuickJS, Atom is used to represent identifiers of properties, variables, functions, etc.

  • #include <atom.h>

Public Functions

Type Name
Atom (ContextRef ctx, JSAtom atom)
Wrap an existing JSAtom. The JSAtom will be freed when the Atom is destroyed.
Atom (const Atom & other)
Atom (Atom && other)
JSAtom & get ()
Get reference to the underlying JSAtom.
std::pair< ContextRef, JSAtom > loot ()
Release ownership of the JSAtom. The JSAtom will have to be freed manually.
Atom & operator= (const Atom & other)
Atom & operator= (Atom && other)
StringView toString () const
Get string representation of the atom.
~Atom ()

Public Static Functions

Type Name
Atom create (ContextRef ctx, uint32_t value)
Create a new atom from an uint32_t value.
Atom create (ContextRef ctx, const char * value)
Create a new atom from a string.
Atom create (ContextRef ctx, std::string value)
Create a new atom from a string.

Protected Attributes

Type Name
JSAtom _atom
ContextRef _ctx

Public Functions Documentation

function Atom [1/3]

Wrap an existing JSAtom. The JSAtom will be freed when the Atom is destroyed.

inline jac::Atom::Atom (
    ContextRef ctx,
    JSAtom atom
) 

Note:

Used internally when directly working with QuickJS API. New Atom should be created using Atom::create().

Parameters:

  • ctx context to work in
  • atom JSAtom to wrap

function Atom [2/3]

inline jac::Atom::Atom (
    const Atom & other
) 

function Atom [3/3]

inline jac::Atom::Atom (
    Atom && other
) 

function get

Get reference to the underlying JSAtom.

inline JSAtom & jac::Atom::get () 

Returns:

JSAtom reference

function loot

Release ownership of the JSAtom. The JSAtom will have to be freed manually.

inline std::pair< ContextRef , JSAtom > jac::Atom::loot () 

Note:

After this call, the Atom will be in an invalid state.

Returns:

Pair of ContextRef and JSAtom

function operator=

inline Atom & jac::Atom::operator= (
    const Atom & other
) 

function operator=

inline Atom & jac::Atom::operator= (
    Atom && other
) 

function toString

Get string representation of the atom.

inline StringView jac::Atom::toString () const

Returns:

StringView

function ~Atom

inline jac::Atom::~Atom () 

Public Static Functions Documentation

function create [1/3]

Create a new atom from an uint32_t value.

static inline Atom jac::Atom::create (
    ContextRef ctx,
    uint32_t value
) 

Parameters:

  • ctx context to create the atom in
  • value the value

Returns:

The newly constructed atom

function create [2/3]

Create a new atom from a string.

static inline Atom jac::Atom::create (
    ContextRef ctx,
    const char * value
) 

Parameters:

  • ctx context to create the atom in
  • value the value

Returns:

The newly constructed atom

function create [3/3]

Create a new atom from a string.

static inline Atom jac::Atom::create (
    ContextRef ctx,
    std::string value
) 

Parameters:

  • ctx context to create the atom in
  • value the value

Returns:

The newly constructed atom

Protected Attributes Documentation

variable _atom

JSAtom jac::Atom::_atom;

variable _ctx

ContextRef jac::Atom::_ctx;

Friends Documentation

friend operator<<

inline std::ostream & jac::Atom::operator<< (
    std::ostream & os,
    Atom & val
) 

The documentation for this class was generated from the following file src/jac/machine/atom.h