v8  3.25.30(node0.11.13)
V8 is Google's open source JavaScript engine
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Handle< T > Class Template Reference

#include <v8.h>

Inheritance diagram for Handle< T >:

Public Member Functions

V8_INLINE Handle ()
 
template<class S >
V8_INLINE Handle (Handle< S > that)
 
V8_INLINE bool IsEmpty () const
 
V8_INLINE void Clear ()
 
V8_INLINE Toperator-> () const
 
V8_INLINE Toperator* () const
 
template<class S >
V8_INLINE bool operator== (const Handle< S > &that) const
 
template<class S >
V8_INLINE bool operator== (const PersistentBase< S > &that) const
 
template<class S >
V8_INLINE bool operator!= (const Handle< S > &that) const
 
template<class S >
V8_INLINE bool operator!= (const Persistent< S > &that) const
 
template<class S >
V8_INLINE Handle< SAs ()
 
template<typename T >
 Handle (T *obj)
 
template<typename T >
 Handle (T *obj, Isolate *isolate)
 

Static Public Member Functions

template<class S >
static V8_INLINE Handle< TCast (Handle< S > that)
 
static V8_INLINE Handle< TNew (Isolate *isolate, Handle< T > that)
 
static V8_INLINE Handle< TNew (Isolate *isolate, const PersistentBase< T > &that)
 

Friends

class Utils
 
template<class F , class M >
class Persistent
 
template<class F >
class PersistentBase
 
template<class F >
class Handle
 
template<class F >
class Local
 
template<class F >
class FunctionCallbackInfo
 
template<class F >
class PropertyCallbackInfo
 
template<class F >
class internal::CustomArguments
 
class Context
 
class HandleScope
 
class Object
 
class Private
 
Handle< PrimitiveUndefined (Isolate *isolate)
 
Handle< PrimitiveNull (Isolate *isolate)
 
Handle< BooleanTrue (Isolate *isolate)
 
Handle< BooleanFalse (Isolate *isolate)
 

Detailed Description

template<class T>
class v8::Handle< 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. 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 Handle<Object>); the value will still be governed by a handle behind the scenes and the same rules apply to these values as to their handles.

Definition at line 123 of file v8.h.

Constructor & Destructor Documentation

V8_INLINE Handle ( )
inline

Creates an empty handle.

Definition at line 223 of file v8.h.

V8_INLINE Handle ( Handle< S that)
inline

Creates a handle for the contents of the specified handle. This constructor allows you to pass handles as arguments by value and to assign between handles. However, if you try to assign between incompatible handles, for instance from a Handle<String> to a Handle<Number> it will cause a compile-time error. Assigning between compatible handles, for instance assigning a Handle<String> to a variable declared as Handle<Value>, is legal because String is a subclass of Value.

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

Definition at line 235 of file v8.h.

Handle ( T obj)

Definition at line 41 of file handles-inl.h.

References ASSERT, HandleScope::CreateHandle(), and obj.

Handle ( T obj,
Isolate isolate 
)

Definition at line 48 of file handles-inl.h.

References ASSERT, and HandleScope::CreateHandle().

Member Function Documentation

V8_INLINE Handle<S> As ( )
inline

Definition at line 306 of file v8.h.

Referenced by CheckOwnProperties(), CheckProperties(), TEST(), and THREADED_TEST().

V8_INLINE void Clear ( )
inline

Sets the handle to be empty. IsEmpty() will then return true.

Definition at line 253 of file v8.h.

Referenced by TEST().

static V8_INLINE Handle<T> New ( Isolate isolate,
Handle< T that 
)
inlinestatic

Definition at line 310 of file v8.h.

Referenced by Handle< Value >::New().

static V8_INLINE Handle<T> New ( Isolate isolate,
const PersistentBase< T > &  that 
)
inlinestatic

Definition at line 313 of file v8.h.

V8_INLINE bool operator!= ( const Handle< S > &  that) const
inline

Checks whether two handles are different. Returns true if only one of the handles is empty, or if the objects to which they refer are different. The handles' references are not checked.

Definition at line 288 of file v8.h.

V8_INLINE bool operator!= ( const Persistent< S > &  that) const
inline

Definition at line 292 of file v8.h.

T * operator* ( ) const
inline

Definition at line 257 of file v8.h.

V8_INLINE T* operator-> ( ) const
inline

Definition at line 255 of file v8.h.

V8_INLINE bool operator== ( const Handle< S > &  that) const
inline

Checks whether two handles are the same. Returns true if both are empty, or if the objects to which they refer are identical. The handles' references are not checked.

Definition at line 265 of file v8.h.

Referenced by Handle< Value >::operator!=().

V8_INLINE bool operator== ( const PersistentBase< S > &  that) const
inline

Definition at line 273 of file v8.h.

Friends And Related Function Documentation

friend class Context
friend

Definition at line 340 of file v8.h.

Handle<Boolean> False ( Isolate isolate)
friend

Definition at line 6568 of file v8.h.

friend class FunctionCallbackInfo
friend

Definition at line 333 of file v8.h.

friend class Handle
friend

Definition at line 331 of file v8.h.

friend class HandleScope
friend

Definition at line 341 of file v8.h.

friend class internal::CustomArguments
friend

Definition at line 335 of file v8.h.

friend class Local
friend

Definition at line 332 of file v8.h.

Handle<Primitive> Null ( Isolate isolate)
friend

Definition at line 6550 of file v8.h.

friend class Object
friend

Definition at line 342 of file v8.h.

friend class Persistent
friend

Definition at line 329 of file v8.h.

friend class PersistentBase
friend

Definition at line 330 of file v8.h.

friend class Private
friend

Definition at line 343 of file v8.h.

friend class PropertyCallbackInfo
friend

Definition at line 334 of file v8.h.

Handle<Boolean> True ( Isolate isolate)
friend

Definition at line 6559 of file v8.h.

Handle<Primitive> Undefined ( Isolate isolate)
friend

Definition at line 6541 of file v8.h.

friend class Utils
friend

Definition at line 328 of file v8.h.


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