V8 Project
|
An object reference managed by the v8 garbage collector. More...
#include <v8.h>
Public Member Functions | |
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... | |
T * | operator-> () const |
T * | operator* () 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< S > | As () |
Static Public Member Functions | |
template<class S > | |
static Handle< T > | Cast (Handle< S > that) |
static Handle< T > | New (Isolate *isolate, Handle< T > that) |
static Handle< T > | New (Isolate *isolate, const PersistentBase< T > &that) |
Private Member Functions | |
Handle (T *val) | |
Creates a new handle for the specified value. More... | |
Static Private Member Functions | |
static Handle< T > | New (Isolate *isolate, T *that) |
Private Attributes | |
T * | val_ |
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< Primitive > | Undefined (Isolate *isolate) |
Handle< Primitive > | Null (Isolate *isolate) |
Handle< Boolean > | True (Isolate *isolate) |
Handle< Boolean > | False (Isolate *isolate) |
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.
|
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 215 of file v8.h.
References S, T, and TYPE_CHECK.
|
inlineexplicitprivate |
Definition at line 286 of file v8.h.
References v8::Handle< T >::Cast().
|
inlinestatic |
Definition at line 277 of file v8.h.
References v8::Handle< T >::IsEmpty().
Referenced by v8::Handle< T >::As(), v8::Shell::DebugCommandToJSONRequest(), v8::Shell::DebugMessageDetails(), v8::internal::DeleteNativeObjectAt(), v8::Shell::ExecuteString(), v8::HandleDebugEvent(), and v8::Shell::System().
|
inline |
Sets the handle to be empty.
IsEmpty() will then return true.
Definition at line 233 of file v8.h.
References v8::Handle< T >::val_.
|
inline |
Returns true if the handle is empty.
Definition at line 228 of file v8.h.
References v8::Handle< T >::val_.
Referenced by v8::V8::AddMessageListener(), v8::Debug::Call(), v8::Handle< T >::Cast(), v8::Local< T >::Cast(), v8::CreateEnvironment(), v8::Shell::CreateEvaluationContext(), v8::internal::JSObject::DeleteElementWithInterceptor(), v8::internal::JSObject::DeletePropertyWithInterceptor(), v8::Value::Equals(), v8::SourceGroup::Execute(), v8::Shell::ExecuteString(), v8::FunctionTemplateNew(), v8::internal::JSObject::GetElementAttributeWithInterceptor(), v8::internal::JSObject::GetElementWithCallback(), v8::internal::JSObject::GetElementWithInterceptor(), v8::internal::MessageImpl::GetEventContext(), v8::internal::JSObject::GetKeysForIndexedInterceptor(), v8::internal::JSObject::GetKeysForNamedInterceptor(), v8::Debug::GetMirror(), v8::internal::JSObject::GetPropertyAttributesWithInterceptor(), v8::internal::Object::GetPropertyWithAccessor(), v8::internal::JSObject::GetPropertyWithInterceptor(), v8::internal::HandleApiCallAsFunctionOrConstructor(), v8::internal::HandleApiCallHelper(), v8::Shell::Load(), v8::MakeAccessorInfo(), v8::ObjectTemplate::New(), v8::Signature::New(), v8::Shell::Read(), v8::Shell::RealmEval(), v8::Shell::ReportException(), v8::PersistentBase< T >::Reset(), v8::Shell::RunShell(), v8::internal::RUNTIME_FUNCTION(), v8::Value::SameValue(), v8::ObjectTemplate::SetAccessCheckCallbacks(), v8::SetAccessorInfoProperties(), v8::Template::SetAccessorProperty(), v8::ObjectTemplate::SetCallAsFunctionHandler(), v8::FunctionTemplate::SetCallHandler(), v8::internal::JSObject::SetElementWithInterceptor(), v8::Object::SetHiddenValue(), v8::ObjectTemplate::SetIndexedPropertyHandler(), v8::ObjectTemplate::SetNamedPropertyHandler(), v8::internal::JSObject::SetPropertyWithInterceptor(), v8::Value::StrictEquals(), v8::TemplateSet(), v8::Isolate::ThrowException(), v8::String::Utf8Value::Utf8Value(), and v8::String::Value::Value().
|
inlinestatic |
Definition at line 293 of file v8.h.
References v8::Handle< T >::New(), and v8::PersistentBase< T >::val_.
|
inlinestatic |
Definition at line 290 of file v8.h.
References v8::Handle< T >::val_.
Referenced by v8::Handle< T >::New().
|
inlinestaticprivate |
Definition at line 5997 of file v8.h.
References v8::HandleScope::CreateHandle(), NULL, and T.
|
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 268 of file v8.h.
References v8::Handle< T >::operator==().
|
inline |
Definition at line 272 of file v8.h.
References v8::Handle< T >::operator==().
|
inline |
|
inline |
|
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 245 of file v8.h.
References v8::Handle< T >::val_.
Referenced by v8::Handle< T >::operator!=().
|
inline |
Definition at line 253 of file v8.h.
References v8::Handle< T >::val_, and v8::PersistentBase< T >::val_.
|
friend |
|
private |
Definition at line 323 of file v8.h.
Referenced by v8::Handle< T >::Clear(), v8::Handle< T >::IsEmpty(), v8::Handle< T >::New(), v8::Local< T >::New(), v8::Handle< T >::operator*(), v8::Handle< T >::operator->(), v8::Handle< T >::operator==(), v8::PersistentBase< T >::operator==(), and v8::PersistentBase< T >::Reset().