Public Member Functions | Friends

v8::Persistent< T > Class Template Reference

#include <v8.h>

List of all members.

Public Member Functions

 V8_INLINE (Persistent())
 V8_INLINE (bool IsEmpty() const)
 V8_INLINE (void Clear())
template<class S >
 V8_INLINE (Persistent(Isolate *isolate, Handle< S > that))
template<class S >
 V8_INLINE (Persistent(Isolate *isolate, const Persistent< S > &that))
template<class S >
 V8_INLINE (static Persistent< T > &Cast(Persistent< S > &that))
template<class S >
 V8_INLINE (Persistent< S > &As())
template<class S >
 V8_INLINE (bool operator==(const Persistent< S > &that) const)
template<class S >
 V8_INLINE (bool operator==(const Handle< S > that) const)
 V8_INLINE (void Dispose())
 V8_INLINE (void Dispose(Isolate *isolate))
template<typename S , typename P >
 V8_INLINE (void MakeWeak(P *parameters, typename WeakReferenceCallbacks< S, P >::Revivable callback))
template<typename P >
 V8_INLINE (void MakeWeak(P *parameters, typename WeakReferenceCallbacks< T, P >::Revivable callback))
template<typename S , typename P >
 V8_DEPRECATED (void MakeWeak(Isolate *isolate, P *parameters, typename WeakReferenceCallbacks< S, P >::Revivable callback))
template<typename P >
 V8_DEPRECATED (void MakeWeak(Isolate *isolate, P *parameters, typename WeakReferenceCallbacks< T, P >::Revivable callback))
 V8_INLINE (void ClearWeak())
 V8_INLINE (void ClearWeak(Isolate *isolate))
 V8_INLINE (void MarkIndependent())
 V8_INLINE (void MarkIndependent(Isolate *isolate))
 V8_INLINE (void MarkPartiallyDependent())
 V8_INLINE (void MarkPartiallyDependent(Isolate *isolate))
 V8_INLINE (bool IsIndependent() const)
 V8_INLINE (bool IsIndependent(Isolate *isolate) const)
 V8_INLINE (bool IsNearDeath() const)
 V8_INLINE (bool IsNearDeath(Isolate *isolate) const)
 V8_INLINE (bool IsWeak() const)
 V8_INLINE (bool IsWeak(Isolate *isolate) const)
 V8_INLINE (void SetWrapperClassId(uint16_t class_id))
 V8_INLINE (void SetWrapperClassId(Isolate *isolate, uint16_t class_id))
 V8_INLINE (uint16_t WrapperClassId() const)
 V8_INLINE (uint16_t WrapperClassId(Isolate *isolate) const)
 V8_INLINE (void Reset(Isolate *isolate, const Handle< T > &other))
 V8_INLINE (void Reset(Isolate *isolate, const Persistent< T > &other))
 V8_INLINE (T *ClearAndLeak())


class Utils
class Handle
class Local
class Persistent
class ReturnValue

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.

Member Function Documentation

template<class T>
v8::Persistent< T >::V8_INLINE ( void   ResetIsolate *isolate, const Handle< T > &other  ) 

Disposes the current contents of the handle and replaces it.

template<class T>
v8::Persistent< T >::V8_INLINE ( uint16_t WrapperClassId()  const  ) 

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

template<class T>
v8::Persistent< T >::V8_INLINE ( void   SetWrapperClassIduint16_t class_id  ) 

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

template<class T>
v8::Persistent< T >::V8_INLINE ( bool IsWeak()  const  ) 

Returns true if the handle's reference is weak.

template<class T>
v8::Persistent< T >::V8_INLINE ( bool IsNearDeath()  const  ) 

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

template<class T>
v8::Persistent< T >::V8_INLINE ( void   MarkPartiallyDependent()  ) 

Marks the reference to this object partially dependent. Partially dependent handles only depend on other partially dependent handles and these dependencies are provided through object groups. It provides a way to build smaller object groups for young objects that represent only a subset of all external dependencies. This mark is automatically cleared after each garbage collection.

template<class T>
v8::Persistent< T >::V8_INLINE ( void   MarkIndependent()  ) 

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.

template<class T>
template<typename S , typename P >
v8::Persistent< T >::V8_INLINE ( void   MakeWeakP *parameters, typename WeakReferenceCallbacks< S, P >::Revivable callback  ) 

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::NearDeathCallback function, passing it the object reference and the given parameters.

template<class T>
v8::Persistent< T >::V8_INLINE ( void   DisposeIsolate *isolate  )  [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.

template<class T>
template<class S >
v8::Persistent< T >::V8_INLINE ( Persistent< T >(Isolate *isolate, Handle< S > that)   )  [inline]

A constructor that creates a new global cell pointing to that. In contrast to the copy constructor, this creates a new persistent handle which needs to be separately disposed.

template<class T>
v8::Persistent< T >::V8_INLINE ( T *  ClearAndLeak()  ) 

Returns the underlying raw pointer and clears the handle. The caller is responsible of eventually destroying the underlying object (by creating a Persistent handle which points to it and Disposing it). In the future, destructing a Persistent will also Dispose it. With this function, the embedder can let the Persistent go out of scope without it getting disposed.

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