Methods

Here, ptr represents the private member of JS::Rooted<T>, typed with T.

Method

Description

T &get()

Returns ptr.

const T &get() const

operator const T&() const

T operator->() const

T *address()

Returns a pointer to ptr.

const T *address() const

T &operator=(T value)

Sets the value of ptr to value.

T &operator=(const Rooted &value)

void set(T value)

bool operator!=(const T &other) const

Compares ptr and other.

bool operator==(const T &other) const

Description

JS::Rooted<T> declares a local variable of type T whose value is always rooted. This is typically used for local variables, or for non-rooted values being passed to a function that requires a handle, e.g. Foo(JS::Rooted<T>(cx, x)).

JS::Rooted<T> may be automatically coerced to a JS::Handle&lt;T&gt;. JS::Rooted<T> should be used whenever a local variable's value may be held live across a call which can trigger a GC.

If you want to add additional methods to Rooted for a specific specialization, define a js::RootedBase<T> specialization containing them.