V8 Project
v8::Local< T > Class Template Reference

A light-weight stack-allocated object handle. More...

#include <v8.h>

+ Inheritance diagram for v8::Local< T >:
+ Collaboration diagram for v8::Local< T >:

Public Member Functions

 Local ()
 
template<class S >
 Local (Local< S > that)
 
template<class S >
 Local (Handle< S > that)
 
template<class S >
Local< SAs ()
 
- Public Member Functions inherited from v8::Handle< T >
 Handle ()
 Creates an empty handle. More...
 
template<class S >
 Handle (Handle< S > that)
 Creates a handle for the contents of the specified handle. More...
 
bool IsEmpty () const
 Returns true if the handle is empty. More...
 
void Clear ()
 Sets the handle to be empty. More...
 
Toperator-> () const
 
Toperator* () const
 
template<class S >
bool operator== (const Handle< S > &that) const
 Checks whether two handles are the same. More...
 
template<class S >
bool operator== (const PersistentBase< S > &that) const
 
template<class S >
bool operator!= (const Handle< S > &that) const
 Checks whether two handles are different. More...
 
template<class S >
bool operator!= (const Persistent< S > &that) const
 
template<class S >
Handle< SAs ()
 

Static Public Member Functions

template<class S >
static Local< TCast (Local< S > that)
 
static Local< TNew (Isolate *isolate, Handle< T > that)
 Create a local handle for the content of another handle. More...
 
static Local< TNew (Isolate *isolate, const PersistentBase< T > &that)
 
- Static Public Member Functions inherited from v8::Handle< T >
template<class S >
static Handle< TCast (Handle< S > that)
 
static Handle< TNew (Isolate *isolate, Handle< T > that)
 
static Handle< TNew (Isolate *isolate, const PersistentBase< T > &that)
 

Private Member Functions

template<class S >
 Local (S *that)
 

Static Private Member Functions

static Local< TNew (Isolate *isolate, T *that)
 

Friends

class Utils
 
template<class F >
class Eternal
 
template<class F >
class PersistentBase
 
template<class F , class M >
class Persistent
 
template<class F >
class Handle
 
template<class F >
class Local
 
template<class F >
class FunctionCallbackInfo
 
template<class F >
class PropertyCallbackInfo
 
class String
 
class Object
 
class Context
 
template<class F >
class internal::CustomArguments
 
class HandleScope
 
class EscapableHandleScope
 
template<class F1 , class F2 , class F3 >
class PersistentValueMap
 
template<class F1 , class F2 >
class PersistentValueVector
 

Detailed Description

template<class T>
class v8::Local< T >

A light-weight stack-allocated object handle.

All operations that return objects from within v8 return them in local handles. They are created within HandleScopes, and all local handles allocated within a handle scope are destroyed when the handle scope is destroyed. Hence it is not necessary to explicitly deallocate local handles.

Definition at line 334 of file v8.h.

Constructor & Destructor Documentation

◆ Local() [1/4]

template<class T >
v8::Local< T >::Local
inline

Definition at line 5983 of file v8.h.

5983 : Handle<T>() { }

◆ Local() [2/4]

template<class T >
template<class S >
v8::Local< T >::Local ( Local< S that)
inline

This check fails when trying to convert between incompatible handles. For example, converting from a Handle<String> to a Handle<Number>.

Definition at line 337 of file v8.h.

338  : Handle<T>(reinterpret_cast<T*>(*that)) {
339  /**
340  * This check fails when trying to convert between incompatible
341  * handles. For example, converting from a Handle<String> to a
342  * Handle<Number>.
343  */
344  TYPE_CHECK(T, S);
345  }
#define TYPE_CHECK(T, S)
Definition: v8.h:167
#define T(name, string, precedence)
Definition: token.cc:25
#define S(x)
Definition: version.cc:55

References S, T, and TYPE_CHECK.

◆ Local() [3/4]

template<class T >
template<class S >
v8::Local< T >::Local ( Handle< S that)
inline

Definition at line 356 of file v8.h.

357  : Handle<T>(reinterpret_cast<T*>(*that)) {
358  TYPE_CHECK(T, S);
359  }

References S, T, and TYPE_CHECK.

◆ Local() [4/4]

template<class T >
template<class S >
v8::Local< T >::Local ( S that)
inlineprivate

Definition at line 392 of file v8.h.

392 : Handle<T>(that) { }

Member Function Documentation

◆ As()

template<class T >
template<class S >
Local<S> v8::Local< T >::As ( )
inline

Definition at line 361 of file v8.h.

361  {
362  return Local<S>::Cast(*this);
363  }
static Local< T > Cast(Local< S > that)
Definition: v8.h:348

References v8::Local< T >::Cast().

+ Here is the call graph for this function:

◆ Cast()

template<class T >
template<class S >
static Local<T> v8::Local< T >::Cast ( Local< S that)
inlinestatic

Definition at line 348 of file v8.h.

348  {
349 #ifdef V8_ENABLE_CHECKS
350  // If we're going to perform the type check then we have to check
351  // that the handle isn't empty before doing the checked cast.
352  if (that.IsEmpty()) return Local<T>();
353 #endif
354  return Local<T>(T::Cast(*that));
355  }

References v8::Handle< T >::IsEmpty().

Referenced by v8::Local< T >::As(), v8::Promise::Catch(), v8::Promise::Chain(), v8::Shell::GetCompletions(), v8::Promise::Resolver::GetPromise(), v8::HandleDebugEvent(), v8::Promise::Resolver::New(), and v8::Promise::Then().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ New() [1/3]

template<class T >
Local< T > v8::Local< T >::New ( Isolate isolate,
const PersistentBase< T > &  that 
)
inlinestatic

Definition at line 5992 of file v8.h.

5992  {
5993  return New(isolate, that.val_);
5994 }
static Local< T > New(Isolate *isolate, Handle< T > that)
Create a local handle for the content of another handle.
Definition: v8.h:5987

References v8::PersistentBase< T >::val_.

◆ New() [2/3]

template<class T >
Local< T > v8::Local< T >::New ( Isolate isolate,
Handle< T that 
)
inlinestatic

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.

Definition at line 5987 of file v8.h.

5987  {
5988  return New(isolate, that.val_);
5989 }

References v8::Handle< T >::val_.

Referenced by v8::ReadLineEditor::CompletionGenerator(), v8::Shell::DebugCommandToJSONRequest(), v8::Shell::DebugMessageDetails(), v8::Shell::ExecuteString(), v8::PersistentValueMap< K, V, Traits >::Get(), v8::PersistentValueVector< V, Traits >::Get(), v8::Shell::GetCompletions(), v8::Shell::InstallUtilityScript(), v8::PersistentValueMap< K, V, Traits >::PersistentValueReference::NewLocal(), v8::Shell::RealmEval(), v8::Shell::ReportException(), v8::Shell::RunShell(), and v8::TryCatch::~TryCatch().

+ Here is the caller graph for this function:

◆ New() [3/3]

template<class T >
Local< T > v8::Local< T >::New ( Isolate isolate,
T that 
)
inlinestaticprivate

Definition at line 6007 of file v8.h.

6007  {
6008  if (that == NULL) return Local<T>();
6009  T* that_ptr = that;
6010  internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr);
6011  return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(
6012  reinterpret_cast<internal::Isolate*>(isolate), *p)));
6013 }
static internal::Object ** CreateHandle(internal::Isolate *isolate, internal::Object *value)
Definition: api.cc:579
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL
kSerializedDataOffset Object
Definition: objects-inl.h:5322

References v8::HandleScope::CreateHandle(), NULL, and T.

+ Here is the call graph for this function:

Friends And Related Function Documentation

◆ Context

template<class T >
friend class Context
friend

Definition at line 385 of file v8.h.

◆ EscapableHandleScope

template<class T >
friend class EscapableHandleScope
friend

Definition at line 388 of file v8.h.

◆ Eternal

template<class T >
template<class F >
friend class Eternal
friend

Definition at line 376 of file v8.h.

◆ FunctionCallbackInfo

template<class T >
template<class F >
friend class FunctionCallbackInfo
friend

Definition at line 381 of file v8.h.

◆ Handle

template<class T >
template<class F >
friend class Handle
friend

Definition at line 379 of file v8.h.

◆ HandleScope

template<class T >
friend class HandleScope
friend

Definition at line 387 of file v8.h.

◆ internal::CustomArguments

template<class T >
template<class F >
friend class internal::CustomArguments
friend

Definition at line 386 of file v8.h.

◆ Local

template<class T >
template<class F >
friend class Local
friend

Definition at line 380 of file v8.h.

◆ Object

template<class T >
friend class Object
friend

Definition at line 384 of file v8.h.

◆ Persistent

template<class T >
template<class F , class M >
friend class Persistent
friend

Definition at line 378 of file v8.h.

◆ PersistentBase

template<class T >
template<class F >
friend class PersistentBase
friend

Definition at line 377 of file v8.h.

◆ PersistentValueMap

template<class T >
template<class F1 , class F2 , class F3 >
friend class PersistentValueMap
friend

Definition at line 389 of file v8.h.

◆ PersistentValueVector

template<class T >
template<class F1 , class F2 >
friend class PersistentValueVector
friend

Definition at line 390 of file v8.h.

◆ PropertyCallbackInfo

template<class T >
template<class F >
friend class PropertyCallbackInfo
friend

Definition at line 382 of file v8.h.

◆ String

template<class T >
friend class String
friend

Definition at line 383 of file v8.h.

◆ Utils

template<class T >
friend class Utils
friend

Definition at line 375 of file v8.h.


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