V8 Project
|
A map wrapper that allows using UniquePersistent as a mapped value. More...
#include <v8-util.h>
Classes | |
class | PersistentValueReference |
Helper class for GetReference/SetWithReference. More... | |
Public Member Functions | |
PersistentValueMap (Isolate *isolate) | |
~PersistentValueMap () | |
Isolate * | GetIsolate () |
size_t | Size () |
Return size of the map. More... | |
bool | IsWeak () |
Return whether the map holds weak persistents. More... | |
Local< V > | Get (const K &key) |
Get value stored in map. More... | |
bool | Contains (const K &key) |
Check whether a value is contained in the map. More... | |
bool | SetReturnValue (const K &key, ReturnValue< Value > returnValue) |
Get value stored in map and set it in returnValue. More... | |
void | SetReference (const K &key, const Persistent< Object > &parent) |
Call Isolate::SetReference with the given parent and the map value. More... | |
UniquePersistent< V > | Set (const K &key, Local< V > value) |
Put value into map. More... | |
UniquePersistent< V > | Set (const K &key, UniquePersistent< V > value) |
Put value into map, like Set(const K&, Local<V>). More... | |
UniquePersistent< V > | Remove (const K &key) |
Return value for key and remove it from the map. More... | |
void | Clear () |
Traverses the map repeatedly, in case side effects of disposal cause insertions. More... | |
PersistentValueReference | GetReference (const K &key) |
Get a reference to a map value. More... | |
UniquePersistent< V > | Set (const K &key, UniquePersistent< V > value, PersistentValueReference *reference) |
Put a value into the map and update the reference. More... | |
Private Member Functions | |
PersistentValueMap (PersistentValueMap &) | |
void | operator= (PersistentValueMap &) |
UniquePersistent< V > | SetUnique (const K &key, UniquePersistent< V > *persistent) |
Put the value into the map, and set the 'weak' callback when demanded by the Traits class. More... | |
Static Private Member Functions | |
static void | WeakCallback (const WeakCallbackData< V, typename Traits::WeakCallbackDataType > &data) |
static V * | FromVal (PersistentContainerValue v) |
static bool | SetReturnValueFromVal (ReturnValue< Value > *returnValue, PersistentContainerValue value) |
static PersistentContainerValue | ClearAndLeak (UniquePersistent< V > *persistent) |
static PersistentContainerValue | Leak (UniquePersistent< V > *persistent) |
static UniquePersistent< V > | Release (PersistentContainerValue v) |
Return a container value as UniquePersistent and make sure the weak callback is properly disposed of. More... | |
Private Attributes | |
Isolate * | isolate_ |
Traits::Impl | impl_ |
A map wrapper that allows using UniquePersistent as a mapped value.
C++11 embedders don't need this class, as they can use UniquePersistent directly in std containers.
The map relies on a backing map, whose type and accessors are described by the Traits class. The backing map will handle values of type PersistentContainerValue, with all conversion into and out of V8 handles being transparently handled by this class.
|
inlineexplicit |
|
inline |
Definition at line 123 of file v8-util.h.
References v8::PersistentValueMap< K, V, Traits >::Clear().
|
private |
|
inline |
Traverses the map repeatedly, in case side effects of disposal cause insertions.
Definition at line 198 of file v8-util.h.
References v8::PersistentValueMap< K, V, Traits >::impl_, v8::PersistentValueMap< K, V, Traits >::isolate_, and v8::PersistentValueMap< K, V, Traits >::Release().
Referenced by v8::PersistentValueMap< K, V, Traits >::~PersistentValueMap().
|
inlinestaticprivate |
Definition at line 321 of file v8-util.h.
References v8::PersistentBase< T >::val_.
Referenced by v8::PersistentValueMap< K, V, Traits >::SetUnique().
|
inline |
Check whether a value is contained in the map.
Definition at line 147 of file v8-util.h.
References v8::PersistentValueMap< K, V, Traits >::impl_, and v8::kPersistentContainerNotFound.
|
inlinestaticprivate |
Definition at line 307 of file v8-util.h.
Referenced by v8::PersistentValueMap< K, V, Traits >::Get(), v8::PersistentValueMap< K, V, Traits >::PersistentValueReference::NewLocal(), v8::PersistentValueMap< K, V, Traits >::Release(), v8::PersistentValueMap< K, V, Traits >::SetReference(), and v8::PersistentValueMap< K, V, Traits >::SetReturnValueFromVal().
|
inline |
Get value stored in map.
Definition at line 140 of file v8-util.h.
References v8::PersistentValueMap< K, V, Traits >::FromVal(), v8::PersistentValueMap< K, V, Traits >::impl_, v8::PersistentValueMap< K, V, Traits >::isolate_, and v8::Local< T >::New().
|
inline |
Definition at line 125 of file v8-util.h.
References v8::PersistentValueMap< K, V, Traits >::isolate_.
Referenced by v8::PersistentValueMap< K, V, Traits >::SetReference().
|
inline |
Get a reference to a map value.
This enables fast, repeated access to a value stored in the map while the map remains unchanged.
Careful: This is potentially unsafe, so please use with care. The value will become invalid if the value for this key changes in the underlying map, as a result of Set or Remove for the same key; as a result of the weak callback for the same key; or as a result of calling Clear() or destruction of the map.
Definition at line 262 of file v8-util.h.
References v8::PersistentValueMap< K, V, Traits >::impl_.
|
inline |
Return whether the map holds weak persistents.
Definition at line 135 of file v8-util.h.
References v8::kNotWeak.
|
inlinestaticprivate |
Definition at line 328 of file v8-util.h.
References v8::PersistentBase< T >::val_.
Referenced by v8::PersistentValueMap< K, V, Traits >::Set().
|
private |
|
inlinestaticprivate |
Return a container value as UniquePersistent and make sure the weak callback is properly disposed of.
All remove functionality should go through this.
Definition at line 338 of file v8-util.h.
References v8::PersistentValueMap< K, V, Traits >::FromVal(), v8::PersistentBase< T >::IsWeak(), v8::kNotWeak, v8::UniquePersistent< T >::Pass(), and v8::PersistentBase< T >::val_.
Referenced by v8::PersistentValueMap< K, V, Traits >::Clear(), v8::PersistentValueMap< K, V, Traits >::Remove(), and v8::PersistentValueMap< K, V, Traits >::SetUnique().
|
inline |
Return value for key and remove it from the map.
Definition at line 190 of file v8-util.h.
References v8::PersistentValueMap< K, V, Traits >::impl_, and v8::PersistentValueMap< K, V, Traits >::Release().
Referenced by v8::PersistentValueMap< K, V, Traits >::WeakCallback().
|
inline |
Put value into map.
Depending on Traits::kIsWeak, the value will be held by the map strongly or weakly. Returns old value as UniquePersistent.
Definition at line 175 of file v8-util.h.
References v8::PersistentValueMap< K, V, Traits >::isolate_, and v8::PersistentValueMap< K, V, Traits >::SetUnique().
|
inline |
Put value into map, like Set(const K&, Local<V>).
Definition at line 183 of file v8-util.h.
References v8::PersistentValueMap< K, V, Traits >::SetUnique().
|
inline |
Put a value into the map and update the reference.
Restrictions of GetReference apply here as well.
Definition at line 270 of file v8-util.h.
References v8::PersistentValueMap< K, V, Traits >::Leak(), and v8::PersistentValueMap< K, V, Traits >::SetUnique().
|
inline |
Call Isolate::SetReference with the given parent and the map value.
Definition at line 163 of file v8-util.h.
References v8::PersistentValueMap< K, V, Traits >::FromVal(), v8::PersistentValueMap< K, V, Traits >::GetIsolate(), v8::PersistentValueMap< K, V, Traits >::impl_, v8::Isolate::SetReference(), and v8::PersistentBase< T >::val_.
|
inline |
Get value stored in map and set it in returnValue.
Return true if a value was found.
Definition at line 155 of file v8-util.h.
References v8::PersistentValueMap< K, V, Traits >::impl_, and v8::PersistentValueMap< K, V, Traits >::SetReturnValueFromVal().
|
inlinestaticprivate |
Definition at line 311 of file v8-util.h.
References v8::PersistentValueMap< K, V, Traits >::FromVal(), v8::kPersistentContainerNotFound, and v8::ReturnValue< T >::SetInternal().
Referenced by v8::PersistentValueMap< K, V, Traits >::SetReturnValue(), and v8::PersistentValueMap< K, V, Traits >::PersistentValueReference::SetReturnValue().
|
inlineprivate |
Put the value into the map, and set the 'weak' callback when demanded by the Traits class.
Definition at line 284 of file v8-util.h.
References v8::PersistentValueMap< K, V, Traits >::ClearAndLeak(), v8::PersistentValueMap< K, V, Traits >::impl_, v8::PersistentValueMap< K, V, Traits >::isolate_, v8::kNotWeak, v8::PersistentValueMap< K, V, Traits >::Release(), and v8::PersistentValueMap< K, V, Traits >::WeakCallback().
Referenced by v8::PersistentValueMap< K, V, Traits >::Set().
|
inline |
Return size of the map.
Definition at line 130 of file v8-util.h.
References v8::PersistentValueMap< K, V, Traits >::impl_.
|
inlinestaticprivate |
Definition at line 295 of file v8-util.h.
References v8::WeakCallbackData< T, P >::GetIsolate(), v8::WeakCallbackData< T, P >::GetParameter(), v8::kNotWeak, and v8::PersistentValueMap< K, V, Traits >::Remove().
Referenced by v8::PersistentValueMap< K, V, Traits >::SetUnique().
|
private |
Definition at line 349 of file v8-util.h.
Referenced by v8::PersistentValueMap< K, V, Traits >::Clear(), v8::PersistentValueMap< K, V, Traits >::Contains(), v8::PersistentValueMap< K, V, Traits >::Get(), v8::PersistentValueMap< K, V, Traits >::GetReference(), v8::PersistentValueMap< K, V, Traits >::Remove(), v8::PersistentValueMap< K, V, Traits >::SetReference(), v8::PersistentValueMap< K, V, Traits >::SetReturnValue(), v8::PersistentValueMap< K, V, Traits >::SetUnique(), and v8::PersistentValueMap< K, V, Traits >::Size().
|
private |
Definition at line 348 of file v8-util.h.
Referenced by v8::PersistentValueMap< K, V, Traits >::Clear(), v8::PersistentValueMap< K, V, Traits >::Get(), v8::PersistentValueMap< K, V, Traits >::GetIsolate(), v8::PersistentValueMap< K, V, Traits >::Set(), and v8::PersistentValueMap< K, V, Traits >::SetUnique().