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

#include <v8.h>

Inheritance diagram for Persistent< T >:
Collaboration diagram for Persistent< T >:

Public Member Functions

 Persistent ()
 
template<class S >
 Persistent (Persistent< S > that)
 
template<class S >
 Persistent (S *that)
 
template<class S >
 Persistent (Handle< S > that)
 
template<class S >
Persistent< SAs ()
 
void Dispose ()
 
void MakeWeak (void *parameters, WeakReferenceCallback callback)
 
void ClearWeak ()
 
void MarkIndependent ()
 
bool IsIndependent () const
 
bool IsNearDeath () const
 
bool IsWeak () const
 
void SetWrapperClassId (uint16_t class_id)
 
uint16_t WrapperClassId () const
 
- Public Member Functions inherited from Handle< T >
 Handle ()
 
 Handle (T *val)
 
template<class S >
 Handle (Handle< S > that)
 
bool IsEmpty () const
 
void Clear ()
 
Toperator-> () const
 
Toperator* () const
 
template<class S >
bool operator== (Handle< S > that) const
 
template<class S >
bool operator!= (Handle< S > that) const
 
template<class S >
Handle< SAs ()
 
template<typename T >
 Handle (T *obj)
 
template<typename T >
 Handle (T *obj, Isolate *isolate)
 

Static Public Member Functions

template<class S >
static Persistent< TCast (Persistent< S > that)
 
static Persistent< TNew (Handle< T > that)
 
- Static Public Member Functions inherited from Handle< T >
template<class S >
static Handle< TCast (Handle< S > that)
 

Friends

class ImplementationUtilities
 
class ObjectTemplate
 

Detailed Description

template<class T>
class v8::Persistent< T >

An object reference that is independent of any handle scope. Where a Local handle only lives as long as the HandleScope in which it was allocated, a Persistent handle remains valid until it is explicitly disposed.

A persistent handle contains a reference to a storage cell within the v8 engine which holds an object value and which is updated by the garbage collector whenever the object is moved. A new storage cell can be created using Persistent::New and existing handles can be disposed using Persistent::Dispose. Since persistent handles are passed by value you may have many persistent handle objects that point to the same storage cell. For instance, if you pass a persistent handle as an argument to a function you will not get two different storage cells but rather two references to the same storage cell.

Definition at line 107 of file v8.h.

Constructor & Destructor Documentation

Persistent ( )
inline

Creates an empty persistent handle that doesn't point to any storage cell.

Definition at line 4242 of file v8.h.

Persistent ( Persistent< S that)
inline

Creates a persistent handle for the same storage cell as the specified handle. This constructor allows you to pass persistent handles as arguments by value and to assign between persistent handles. However, attempting to assign between incompatible persistent handles, for instance from a Persistent<String> to a Persistent<Number> will cause a compile-time error. Assigning between compatible persistent handles, for instance assigning a Persistent<String> to a variable declared as Persistent<Value>, is allowed as 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 339 of file v8.h.

Persistent ( S that)
inline

Definition at line 349 of file v8.h.

Persistent ( Handle< S that)
inlineexplicit

"Casts" a plain handle which is known to be a persistent handle to a persistent handle.

Definition at line 355 of file v8.h.

Member Function Documentation

Persistent<S> As ( )
inline

Definition at line 367 of file v8.h.

static Persistent<T> Cast ( Persistent< S that)
inlinestatic

Definition at line 358 of file v8.h.

Referenced by Persistent< Value >::As(), and Visitor42::VisitPersistentHandle().

void ClearWeak ( )
inline

Clears the weak reference to this object.

Definition at line 4252 of file v8.h.

void Dispose ( )
inline

Releases the storage cell referenced by this persistent handle. Does not remove the reference to the cell from any handles. This handle's reference, and any other references to the storage cell remain and IsEmpty will still return false.

Definition at line 4235 of file v8.h.

Referenced by DisposeAndForceGcCallback(), DisposingCallback(), HandleCreatingCallback(), main(), NewPersistentHandleCallback(), LoopingThread::Run(), IsolateGenesisThread::Run(), ShellThread::Run(), Shell::RunMain(), TEST(), THREADED_TEST(), LocalContext::~LocalContext(), SimpleContext::~SimpleContext(), and Whammy::~Whammy().

bool IsIndependent ( ) const
inline

Returns true if this handle was previously marked as independent.

Definition at line 4214 of file v8.h.

Referenced by THREADED_TEST().

bool IsNearDeath ( ) const
inline

Checks if the handle holds the only reference to an object.

Definition at line 4221 of file v8.h.

bool IsWeak ( ) const
inline

Returns true if the handle's reference is weak.

Definition at line 4228 of file v8.h.

void MakeWeak ( void *  parameters,
WeakReferenceCallback  callback 
)
inline

Make the reference to this object weak. When only weak handles refer to the object, the garbage collector will perform a callback to the given V8::WeakReferenceCallback function, passing it the object reference and the given parameters.

Definition at line 4245 of file v8.h.

Referenced by Shell::ReadBuffer(), TEST(), THREADED_TEST(), and WhammyPropertyGetter().

void MarkIndependent ( )
inline

Marks the reference to this object independent. Garbage collector is free to ignore any object groups containing this object. Weak callback for an independent handle should not assume that it will be preceded by a global GC prologue callback or followed by a global GC epilogue callback.

Definition at line 4257 of file v8.h.

Referenced by Shell::ReadBuffer(), and THREADED_TEST().

Persistent< T > New ( Handle< T that)
inlinestatic

Creates a new persistent handle for an existing local or persistent handle.

Definition at line 4206 of file v8.h.

References T.

Referenced by GraphWithImplicitRefs::GraphWithImplicitRefs(), HandleCreatingCallback(), NewPersistentHandleCallback(), Shell::ReadBuffer(), RunMain(), TEST(), THREADED_TEST(), and WhammyPropertyGetter().

void SetWrapperClassId ( uint16_t  class_id)
inline

Assigns a wrapper class ID to the handle. See RetainedObjectInfo interface description in v8-profiler.h for details.

Definition at line 4262 of file v8.h.

Referenced by TEST().

uint16_t WrapperClassId ( ) const
inline

Returns the class ID previously assigned to this handle or 0 if no class ID was previously assigned.

Definition at line 4267 of file v8.h.

Friends And Related Function Documentation

friend class ImplementationUtilities
friend

Definition at line 427 of file v8.h.

friend class ObjectTemplate
friend

Definition at line 428 of file v8.h.


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