V8: v8::Local< T > Class Template Reference (original) (raw)

#include <[v8-local-handle.h](v8-local-handle%5F8h%5Fsource.html)>

Public Member Functions
Local ()=default
template requires std::is_base_of_v<T, S>
Local (Local< S > that)
T * operator-> () const
T * operator* () const
template
bool operator== (const Local< S > &that) const
template
bool operator== (const PersistentBase< S > &that) const
template
bool operator!= (const Local< S > &that) const
template
bool operator!= (const Persistent< S > &that) const
template
Local< S > As () const
- Public Member Functions inherited from v8::api_internal::IndirectHandleBase
bool IsEmpty () const
void Clear ()
- Public Member Functions inherited from v8::api_internal::StackAllocated< false >
StackAllocated ()=default
Static Public Member Functions
template
static Local< T > Cast (Local< S > that)
static Local< T > New (Isolate *isolate, Local< T > that)
static Local< T > New (Isolate *isolate, const PersistentBase< T > &that)
static Local< T > New (Isolate *isolate, const BasicTracedReference< T > &that)
Friends
class TracedReferenceBase
class Utils
template
class Eternal
template
class Global
template
class Local
template
class MaybeLocal
template<class F , class M >
class Persistent
template
class FunctionCallbackInfo
template
class PropertyCallbackInfo
class String
class Object
class Context
class Isolate
class Private
template
class internal::CustomArguments
class HandleScope
class EscapableHandleScope
class InternalEscapableScope
template<class F1 , class F2 , class F3 >
class PersistentValueMapBase
template
class ReturnValue
template
class Traced
class internal::SamplingHeapProfiler
class internal::HandleHelper
class debug::ConsoleCallArguments
class internal::LocalUnchecked< T >
Local< Primitive > Undefined (Isolate *isolate)
Local< Primitive > Null (Isolate *isolate)
Local< Boolean > True (Isolate *isolate)
Local< Boolean > False (Isolate *isolate)
Additional Inherited Members
- Protected Member Functions inherited from v8::LocalBase< T >
LocalBase ()=default
LocalBase (internal::Address *location)
template
LocalBase (const LocalBase< S > &other)
- Protected Member Functions inherited from v8::api_internal::IndirectHandleBase
IndirectHandleBase ()=default
IndirectHandleBase (const IndirectHandleBase &other)=default
IndirectHandleBase & operator= (const IndirectHandleBase &that)=default
IndirectHandleBase (internal::Address *location)
internal::Address ptr () const
internal::Address *const & slot () const
internal::Address *& slot ()
template<typename T , bool check_null = false>
T * value () const
internal::ValueHelper::InternalRepresentationType repr () const
- Protected Member Functions inherited from v8::api_internal::StackAllocated< false >
StackAllocated (no_checking_tag)
StackAllocated (const StackAllocated &other, no_checking_tag)
void VerifyOnStack () const
- Static Protected Member Functions inherited from v8::LocalBase< T >
static LocalBase< T > New (Isolate *isolate, internal::Address value)
static LocalBase< T > New (Isolate *isolate, T *that)
static LocalBase< T > FromSlot (internal::Address *slot)
static LocalBase< T > FromRepr (internal::ValueHelper::InternalRepresentationType repr)
- Static Protected Attributes inherited from v8::api_internal::StackAllocated< false >
static constexpr no_checking_tag do_not_check

template
class v8::Local< T >

An object reference managed by the v8 garbage collector.

All objects returned from v8 have to be tracked by the garbage collector so that it knows that the objects are still alive. Also, because the garbage collector may move objects, it is unsafe to point directly to an object. Instead, all objects are stored in handles which are known by the garbage collector and updated whenever an object moves. Handles should always be passed by value (except in cases like out-parameters) and they should never be allocated on the heap.

There are two types of handles: local and persistent handles.

Local handles are light-weight and transient and typically used in local operations. They are managed by HandleScopes. That means that a HandleScope must exist on the stack when they are created and that they are only valid inside of the HandleScope active during their creation. For passing a local handle to an outer HandleScope, an EscapableHandleScope and its Escape() method must be used.

Persistent handles can be used when storing objects across several independent operations and have to be explicitly deallocated when they're no longer used.

It is safe to extract the object stored in the handle by dereferencing the handle (for instance, to extract the Object* from a Local); the value will still be governed by a handle behind the scenes and the same rules apply to these values as to their handles.

Examples

process.cc, and shell.cc.

Local() [1/2]

Default constructor: Returns an empty handle.

Local() [2/2]

template

template
requires std::is_base_of_v<T, S>

Constructor for handling automatic up casting. Ex. Local can be passed when Local is expected but not the other way round.

As()

template

template

Calling this is equivalent to Local::Cast(). In particular, this is only valid if the handle actually refers to a value of the target type or if the handle is empty.

Examples

shell.cc.

Cast()

template

template

Cast a handle to a subclass, e.g. Local to Local. This is only valid if the handle actually refers to a value of the target type or if the handle is empty.

New() [1/3]

New() [2/3]

New() [3/3]

Create a local handle for the content of another handle. The referee is kept alive by the local handle even when the original handle is destroyed/disposed.

Examples

process.cc.

operator!=() [1/2]

template

template

bool v8::Local< T >::operator!= ( const Local< S > & that) const inline

operator!=() [2/2]

template

template

operator*()

template

T * v8::Local< T >::operator* ( ) const inline

operator->()

template

T * v8::Local< T >::operator-> ( ) const inline

operator==() [1/2]

template

template

bool v8::Local< T >::operator== ( const Local< S > & that) const inline

Checks whether two handles are equal or different. They are equal iff they are both empty or they are both non-empty and the objects to which they refer are physically equal.

If both handles refer to JS objects, this is the same as strict non-equality. For primitives, such as numbers or strings, a false return value does not indicate that the values aren't equal in the JavaScript sense. Use [Value::StrictEquals()](classv8%5F1%5F1Value.html#aca359114a4beedaf2858254013d0279e) to check primitives for equality.

operator==() [2/2]

template

template

Context

debug::ConsoleCallArguments

template

friend class debug::ConsoleCallArguments friend

EscapableHandleScope

Eternal

template

template

False

FunctionCallbackInfo

template

template

Global

template

template

HandleScope

internal::CustomArguments

template

template

internal::HandleHelper

internal::LocalUnchecked< T >

internal::SamplingHeapProfiler

template

friend class internal::SamplingHeapProfiler friend

InternalEscapableScope

template

friend class InternalEscapableScope friend

Isolate

template

template

MaybeLocal

template

template

Null

Object

Persistent

template

template<class F , class M >

Persistent is a way to create a strong pointer from an off-heap object to another on-heap object. As long as the Persistent handle is alive the GC will keep the object pointed to alive. The Persistent handle is always a GC root from the point of view of the GC. Persistent must be constructed and destructed in the same thread.

PersistentValueMapBase

template

template<class F1 , class F2 , class F3 >

Private

PropertyCallbackInfo

template

template

ReturnValue

template

template

String

Traced

template

template

TracedReferenceBase

True

Undefined

Utils


The documentation for this class was generated from the following file: