v8  7.9.317(node13.2.0)
V8 is Google's open source JavaScript engine
v8-util.h
Go to the documentation of this file.
1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef V8_UTIL_H_
6 #define V8_UTIL_H_
7 
8 #include "v8.h" // NOLINT(build/include)
9 #include <assert.h>
10 #include <map>
11 #include <vector>
12 
20 namespace v8 {
21 
22 typedef uintptr_t PersistentContainerValue;
23 static const uintptr_t kPersistentContainerNotFound = 0;
26  // These correspond to v8::WeakCallbackType
29 };
30 
37 template<typename K, typename V>
38 class StdMapTraits {
39  public:
40  // STL map & related:
41  typedef std::map<K, PersistentContainerValue> Impl;
42  typedef typename Impl::iterator Iterator;
43 
44  static bool Empty(Impl* impl) { return impl->empty(); }
45  static size_t Size(Impl* impl) { return impl->size(); }
46  static void Swap(Impl& a, Impl& b) { std::swap(a, b); } // NOLINT
47  static Iterator Begin(Impl* impl) { return impl->begin(); }
48  static Iterator End(Impl* impl) { return impl->end(); }
49  static K Key(Iterator it) { return it->first; }
50  static PersistentContainerValue Value(Iterator it) { return it->second; }
51  static PersistentContainerValue Set(Impl* impl, K key,
53  std::pair<Iterator, bool> res = impl->insert(std::make_pair(key, value));
54  PersistentContainerValue old_value = kPersistentContainerNotFound;
55  if (!res.second) {
56  old_value = res.first->second;
57  res.first->second = value;
58  }
59  return old_value;
60  }
61  static PersistentContainerValue Get(Impl* impl, K key) {
62  Iterator it = impl->find(key);
63  if (it == impl->end()) return kPersistentContainerNotFound;
64  return it->second;
65  }
66  static PersistentContainerValue Remove(Impl* impl, K key) {
67  Iterator it = impl->find(key);
68  if (it == impl->end()) return kPersistentContainerNotFound;
69  PersistentContainerValue value = it->second;
70  impl->erase(it);
71  return value;
72  }
73 };
74 
75 
84 template<typename K, typename V>
86  public:
87  // Weak callback & friends:
91  typedef void WeakCallbackDataType;
92 
94  MapType* map, const K& key, Local<V> value) {
95  return nullptr;
96  }
99  return nullptr;
100  }
103  return K();
104  }
106  static void Dispose(Isolate* isolate, Global<V> value, K key) {}
107 };
108 
109 
110 template <typename K, typename V>
111 class DefaultGlobalMapTraits : public StdMapTraits<K, V> {
112  private:
113  template <typename T>
114  struct RemovePointer;
115 
116  public:
117  // Weak callback & friends:
120  typedef void WeakCallbackDataType;
121 
123  Local<V> value) {
124  return nullptr;
125  }
128  return nullptr;
129  }
132  return K();
133  }
135  static void OnWeakCallback(
137  static void Dispose(Isolate* isolate, Global<V> value, K key) {}
138  // This is a second pass callback, so SetSecondPassCallback cannot be called.
140 
141  private:
142  template <typename T>
143  struct RemovePointer<T*> {
144  typedef T Type;
145  };
146 };
147 
148 
159 template <typename K, typename V, typename Traits>
161  public:
162  Isolate* GetIsolate() { return isolate_; }
163 
167  size_t Size() { return Traits::Size(&impl_); }
168 
172  bool IsWeak() { return Traits::kCallbackType != kNotWeak; }
173 
177  Local<V> Get(const K& key) {
178  return Local<V>::New(isolate_, FromVal(Traits::Get(&impl_, key)));
179  }
180 
184  bool Contains(const K& key) {
185  return Traits::Get(&impl_, key) != kPersistentContainerNotFound;
186  }
187 
192  bool SetReturnValue(const K& key,
193  ReturnValue<Value> returnValue) {
194  return SetReturnValueFromVal(&returnValue, Traits::Get(&impl_, key));
195  }
196 
200  Global<V> Remove(const K& key) {
201  return Release(Traits::Remove(&impl_, key)).Pass();
202  }
203 
208  void Clear() {
209  typedef typename Traits::Iterator It;
210  HandleScope handle_scope(isolate_);
211  // TODO(dcarney): figure out if this swap and loop is necessary.
212  while (!Traits::Empty(&impl_)) {
213  typename Traits::Impl impl;
214  Traits::Swap(impl_, impl);
215  for (It i = Traits::Begin(&impl); i != Traits::End(&impl); ++i) {
216  Traits::Dispose(isolate_, Release(Traits::Value(i)).Pass(),
217  Traits::Key(i));
218  }
219  }
220  }
221 
227  public:
228  PersistentValueReference() : value_(kPersistentContainerNotFound) { }
230  : value_(other.value_) { }
231 
233  return Local<V>::New(isolate, FromVal(value_));
234  }
235  bool IsEmpty() const {
236  return value_ == kPersistentContainerNotFound;
237  }
238  template<typename T>
239  bool SetReturnValue(ReturnValue<T> returnValue) {
240  return SetReturnValueFromVal(&returnValue, value_);
241  }
242  void Reset() {
243  value_ = kPersistentContainerNotFound;
244  }
245  void operator=(const PersistentValueReference& other) {
246  value_ = other.value_;
247  }
248 
249  private:
251  friend class PersistentValueMap<K, V, Traits>;
252  friend class GlobalValueMap<K, V, Traits>;
253 
255  : value_(value) { }
256 
257  void operator=(PersistentContainerValue value) {
258  value_ = value;
259  }
260 
262  };
263 
275  return PersistentValueReference(Traits::Get(&impl_, key));
276  }
277 
278  protected:
280  : isolate_(isolate), label_(nullptr) {}
282  : isolate_(isolate), label_(label) {}
283 
285 
286  Isolate* isolate() { return isolate_; }
287  typename Traits::Impl* impl() { return &impl_; }
288 
290  return reinterpret_cast<V*>(v);
291  }
292 
294  V* v = persistent->val_;
295  persistent->val_ = nullptr;
296  return reinterpret_cast<PersistentContainerValue>(v);
297  }
298 
300  return reinterpret_cast<PersistentContainerValue>(persistent->val_);
301  }
302 
309  Global<V> p;
310  p.val_ = FromVal(v);
311  if (Traits::kCallbackType != kNotWeak && p.IsWeak()) {
312  Traits::DisposeCallbackData(
313  p.template ClearWeak<typename Traits::WeakCallbackDataType>());
314  }
315  return p.Pass();
316  }
317 
318  void RemoveWeak(const K& key) {
319  Global<V> p;
320  p.val_ = FromVal(Traits::Remove(&impl_, key));
321  p.Reset();
322  }
323 
324  void AnnotateStrongRetainer(Global<V>* persistent) {
325  persistent->AnnotateStrongRetainer(label_);
326  }
327 
328  private:
330  void operator=(PersistentValueMapBase&);
331 
332  static bool SetReturnValueFromVal(ReturnValue<Value>* returnValue,
333  PersistentContainerValue value) {
334  bool hasValue = value != kPersistentContainerNotFound;
335  if (hasValue) {
336  returnValue->SetInternal(
337  *reinterpret_cast<internal::Address*>(FromVal(value)));
338  }
339  return hasValue;
340  }
341 
342  Isolate* isolate_;
343  typename Traits::Impl impl_;
344  const char* label_;
345 };
346 
347 template <typename K, typename V, typename Traits>
348 class PersistentValueMap : public PersistentValueMapBase<K, V, Traits> {
349  public:
351  : PersistentValueMapBase<K, V, Traits>(isolate) {}
352  PersistentValueMap(Isolate* isolate, const char* label)
353  : PersistentValueMapBase<K, V, Traits>(isolate, label) {}
354 
355  typedef
358 
364  Global<V> Set(const K& key, Local<V> value) {
365  Global<V> persistent(this->isolate(), value);
366  return SetUnique(key, &persistent);
367  }
368 
372  Global<V> Set(const K& key, Global<V> value) {
373  return SetUnique(key, &value);
374  }
375 
380  Global<V> SetUnique(const K& key, Global<V>* persistent) {
381  if (Traits::kCallbackType == kNotWeak) {
382  this->AnnotateStrongRetainer(persistent);
383  } else {
384  WeakCallbackType callback_type =
385  Traits::kCallbackType == kWeakWithInternalFields
388  Local<V> value(Local<V>::New(this->isolate(), *persistent));
389  persistent->template SetWeak<typename Traits::WeakCallbackDataType>(
390  Traits::WeakCallbackParameter(this, key, value), WeakCallback,
391  callback_type);
392  }
393  PersistentContainerValue old_value =
394  Traits::Set(this->impl(), key, this->ClearAndLeak(persistent));
395  return this->Release(old_value).Pass();
396  }
397 
402  Global<V> Set(const K& key, Global<V> value,
403  PersistentValueReference* reference) {
404  *reference = this->Leak(&value);
405  return SetUnique(key, &value);
406  }
407 
408  private:
409  static void WeakCallback(
411  if (Traits::kCallbackType != kNotWeak) {
412  PersistentValueMap<K, V, Traits>* persistentValueMap =
413  Traits::MapFromWeakCallbackInfo(data);
414  K key = Traits::KeyFromWeakCallbackInfo(data);
415  Traits::Dispose(data.GetIsolate(),
416  persistentValueMap->Remove(key).Pass(), key);
417  Traits::DisposeCallbackData(data.GetParameter());
418  }
419  }
420 };
421 
422 
423 template <typename K, typename V, typename Traits>
424 class GlobalValueMap : public PersistentValueMapBase<K, V, Traits> {
425  public:
427  : PersistentValueMapBase<K, V, Traits>(isolate) {}
428  GlobalValueMap(Isolate* isolate, const char* label)
429  : PersistentValueMapBase<K, V, Traits>(isolate, label) {}
430 
431  typedef
434 
440  Global<V> Set(const K& key, Local<V> value) {
441  Global<V> persistent(this->isolate(), value);
442  return SetUnique(key, &persistent);
443  }
444 
448  Global<V> Set(const K& key, Global<V> value) {
449  return SetUnique(key, &value);
450  }
451 
456  Global<V> SetUnique(const K& key, Global<V>* persistent) {
457  if (Traits::kCallbackType == kNotWeak) {
458  this->AnnotateStrongRetainer(persistent);
459  } else {
460  WeakCallbackType callback_type =
461  Traits::kCallbackType == kWeakWithInternalFields
464  Local<V> value(Local<V>::New(this->isolate(), *persistent));
465  persistent->template SetWeak<typename Traits::WeakCallbackDataType>(
466  Traits::WeakCallbackParameter(this, key, value), OnWeakCallback,
467  callback_type);
468  }
469  PersistentContainerValue old_value =
470  Traits::Set(this->impl(), key, this->ClearAndLeak(persistent));
471  return this->Release(old_value).Pass();
472  }
473 
478  Global<V> Set(const K& key, Global<V> value,
479  PersistentValueReference* reference) {
480  *reference = this->Leak(&value);
481  return SetUnique(key, &value);
482  }
483 
484  private:
485  static void OnWeakCallback(
487  if (Traits::kCallbackType != kNotWeak) {
488  auto map = Traits::MapFromWeakCallbackInfo(data);
489  K key = Traits::KeyFromWeakCallbackInfo(data);
490  map->RemoveWeak(key);
491  Traits::OnWeakCallback(data);
492  data.SetSecondPassCallback(SecondWeakCallback);
493  }
494  }
495 
496  static void SecondWeakCallback(
497  const WeakCallbackInfo<typename Traits::WeakCallbackDataType>& data) {
498  Traits::DisposeWeak(data);
499  }
500 };
501 
502 
510 template<typename K, typename V,
511  typename Traits = DefaultPersistentValueMapTraits<K, V> >
512 class StdPersistentValueMap : public PersistentValueMap<K, V, Traits> {
513  public:
515  : PersistentValueMap<K, V, Traits>(isolate) {}
516 };
517 
518 
526 template <typename K, typename V,
527  typename Traits = DefaultGlobalMapTraits<K, V> >
528 class StdGlobalValueMap : public GlobalValueMap<K, V, Traits> {
529  public:
531  : GlobalValueMap<K, V, Traits>(isolate) {}
532 };
533 
534 
536  public:
537  typedef std::vector<PersistentContainerValue> Impl;
538 
539  static void Append(Impl* impl, PersistentContainerValue value) {
540  impl->push_back(value);
541  }
542  static bool IsEmpty(const Impl* impl) {
543  return impl->empty();
544  }
545  static size_t Size(const Impl* impl) {
546  return impl->size();
547  }
548  static PersistentContainerValue Get(const Impl* impl, size_t i) {
549  return (i < impl->size()) ? impl->at(i) : kPersistentContainerNotFound;
550  }
551  static void ReserveCapacity(Impl* impl, size_t capacity) {
552  impl->reserve(capacity);
553  }
554  static void Clear(Impl* impl) {
555  impl->clear();
556  }
557 };
558 
559 
570 template<typename V, typename Traits = DefaultPersistentValueVectorTraits>
572  public:
573  explicit PersistentValueVector(Isolate* isolate) : isolate_(isolate) { }
574 
576  Clear();
577  }
578 
582  void Append(Local<V> value) {
583  Global<V> persistent(isolate_, value);
584  Traits::Append(&impl_, ClearAndLeak(&persistent));
585  }
586 
590  void Append(Global<V> persistent) {
591  Traits::Append(&impl_, ClearAndLeak(&persistent));
592  }
593 
597  bool IsEmpty() const {
598  return Traits::IsEmpty(&impl_);
599  }
600 
604  size_t Size() const {
605  return Traits::Size(&impl_);
606  }
607 
611  Local<V> Get(size_t index) const {
612  return Local<V>::New(isolate_, FromVal(Traits::Get(&impl_, index)));
613  }
614 
618  void Clear() {
619  size_t length = Traits::Size(&impl_);
620  for (size_t i = 0; i < length; i++) {
621  Global<V> p;
622  p.val_ = FromVal(Traits::Get(&impl_, i));
623  }
624  Traits::Clear(&impl_);
625  }
626 
631  void ReserveCapacity(size_t capacity) {
632  Traits::ReserveCapacity(&impl_, capacity);
633  }
634 
635  private:
636  static PersistentContainerValue ClearAndLeak(Global<V>* persistent) {
637  V* v = persistent->val_;
638  persistent->val_ = nullptr;
639  return reinterpret_cast<PersistentContainerValue>(v);
640  }
641 
642  static V* FromVal(PersistentContainerValue v) {
643  return reinterpret_cast<V*>(v);
644  }
645 
646  Isolate* isolate_;
647  typename Traits::Impl impl_;
648 };
649 
650 } // namespace v8
651 
652 #endif // V8_UTIL_H
v8::GlobalValueMap::SetUnique
Global< V > SetUnique(const K &key, Global< V > *persistent)
Definition: v8-util.h:456
v8::HandleScope
Definition: v8.h:1161
v8::DefaultPersistentValueVectorTraits::Size
static size_t Size(const Impl *impl)
Definition: v8-util.h:545
v8::GlobalValueMap::GlobalValueMap
GlobalValueMap(Isolate *isolate)
Definition: v8-util.h:426
v8::PersistentValueMapBase::IsWeak
bool IsWeak()
Definition: v8-util.h:172
v8::StdMapTraits
Definition: v8-util.h:38
v8::PersistentValueMapBase::RemoveWeak
void RemoveWeak(const K &key)
Definition: v8-util.h:318
v8::PersistentValueVector::Get
Local< V > Get(size_t index) const
Definition: v8-util.h:611
v8::GlobalValueMap
Definition: v8-util.h:424
v8::StdPersistentValueMap::StdPersistentValueMap
StdPersistentValueMap(Isolate *isolate)
Definition: v8-util.h:514
v8::PersistentValueMapBase::FromVal
static V * FromVal(PersistentContainerValue v)
Definition: v8-util.h:289
v8::StdMapTraits::Value
static PersistentContainerValue Value(Iterator it)
Definition: v8-util.h:50
v8::PersistentBase::IsWeak
V8_INLINE bool IsWeak() const
Definition: v8.h:10257
v8::DefaultGlobalMapTraits::Dispose
static void Dispose(Isolate *isolate, Global< V > value, K key)
Definition: v8-util.h:137
v8::PersistentValueMapBase::Leak
static PersistentContainerValue Leak(Global< V > *persistent)
Definition: v8-util.h:299
v8::PersistentValueMapBase::Release
static Global< V > Release(PersistentContainerValue v)
Definition: v8-util.h:308
v8::PersistentValueMapBase::Clear
void Clear()
Definition: v8-util.h:208
v8::DefaultGlobalMapTraits::DisposeWeak
static void DisposeWeak(const WeakCallbackInfo< WeakCallbackDataType > &data)
Definition: v8-util.h:139
v8::PersistentValueMapBase
Definition: v8-util.h:160
v8::PersistentValueVector::IsEmpty
bool IsEmpty() const
Definition: v8-util.h:597
v8::DefaultPersistentValueVectorTraits::Get
static PersistentContainerValue Get(const Impl *impl, size_t i)
Definition: v8-util.h:548
v8::PersistentBase::Reset
V8_INLINE void Reset()
Definition: v8.h:10266
v8::GlobalValueMap::Set
Global< V > Set(const K &key, Global< V > value, PersistentValueReference *reference)
Definition: v8-util.h:478
v8::DefaultGlobalMapTraits::MapType
GlobalValueMap< K, V, DefaultGlobalMapTraits< K, V > > MapType
Definition: v8-util.h:119
v8::StdMapTraits::Begin
static Iterator Begin(Impl *impl)
Definition: v8-util.h:47
v8::WeakCallbackInfo::GetParameter
V8_INLINE T * GetParameter() const
Definition: v8.h:431
v8::WeakCallbackInfo
Definition: v8.h:417
v8::DefaultGlobalMapTraits::KeyFromWeakCallbackInfo
static K KeyFromWeakCallbackInfo(const WeakCallbackInfo< WeakCallbackDataType > &data)
Definition: v8-util.h:130
v8::StdMapTraits::Key
static K Key(Iterator it)
Definition: v8-util.h:49
v8::PersistentValueMapBase::GetReference
PersistentValueReference GetReference(const K &key)
Definition: v8-util.h:274
v8::PersistentValueMapBase::PersistentValueReference::Reset
void Reset()
Definition: v8-util.h:242
v8::DefaultPersistentValueMapTraits::MapType
PersistentValueMap< K, V, DefaultPersistentValueMapTraits< K, V > > MapType
Definition: v8-util.h:90
v8::GlobalValueMap::PersistentValueReference
PersistentValueMapBase< K, V, Traits >::PersistentValueReference PersistentValueReference
Definition: v8-util.h:433
v8::DefaultPersistentValueMapTraits
Definition: v8-util.h:85
v8::PersistentValueMapBase::PersistentValueReference::PersistentValueReference
PersistentValueReference(const PersistentValueReference &other)
Definition: v8-util.h:229
v8::DefaultGlobalMapTraits::WeakCallbackDataType
void WeakCallbackDataType
Definition: v8-util.h:120
v8::PersistentValueMapBase::SetReturnValue
bool SetReturnValue(const K &key, ReturnValue< Value > returnValue)
Definition: v8-util.h:192
v8::Global
Definition: v8.h:97
v8::kWeakWithParameter
Definition: v8-util.h:27
v8::StdMapTraits::End
static Iterator End(Impl *impl)
Definition: v8-util.h:48
v8::StdGlobalValueMap
Definition: v8-util.h:528
v8::StdPersistentValueMap
Definition: v8-util.h:512
v8::WeakCallbackInfo::GetIsolate
V8_INLINE Isolate * GetIsolate() const
Definition: v8.h:430
v8::DefaultPersistentValueMapTraits::MapFromWeakCallbackInfo
static MapType * MapFromWeakCallbackInfo(const WeakCallbackInfo< WeakCallbackDataType > &data)
Definition: v8-util.h:97
v8::StdMapTraits::Get
static PersistentContainerValue Get(Impl *impl, K key)
Definition: v8-util.h:61
v8::StdMapTraits::Set
static PersistentContainerValue Set(Impl *impl, K key, PersistentContainerValue value)
Definition: v8-util.h:51
v8::PersistentValueVector::ReserveCapacity
void ReserveCapacity(size_t capacity)
Definition: v8-util.h:631
v8::PersistentValueMapBase::PersistentValueReference::operator=
void operator=(const PersistentValueReference &other)
Definition: v8-util.h:245
v8::Local::New
static V8_INLINE Local< T > New(Isolate *isolate, Local< T > that)
Definition: v8.h:10177
v8::PersistentValueMapBase::~PersistentValueMapBase
~PersistentValueMapBase()
Definition: v8-util.h:284
v8::DefaultPersistentValueMapTraits::WeakCallbackParameter
static WeakCallbackDataType * WeakCallbackParameter(MapType *map, const K &key, Local< V > value)
Definition: v8-util.h:93
v8::DefaultGlobalMapTraits::DisposeCallbackData
static void DisposeCallbackData(WeakCallbackDataType *data)
Definition: v8-util.h:134
v8::StdMapTraits::Empty
static bool Empty(Impl *impl)
Definition: v8-util.h:44
v8::PersistentValueVector::Append
void Append(Global< V > persistent)
Definition: v8-util.h:590
v8::PersistentValueVector::Clear
void Clear()
Definition: v8-util.h:618
v8::PersistentValueMapBase::PersistentValueMapBase
PersistentValueMapBase(Isolate *isolate, const char *label)
Definition: v8-util.h:281
v8::PersistentValueVector::~PersistentValueVector
~PersistentValueVector()
Definition: v8-util.h:575
v8::GlobalValueMap::GlobalValueMap
GlobalValueMap(Isolate *isolate, const char *label)
Definition: v8-util.h:428
v8::StdMapTraits::Impl
std::map< K, PersistentContainerValue > Impl
Definition: v8-util.h:41
v8::DefaultGlobalMapTraits::kCallbackType
static const PersistentContainerCallbackType kCallbackType
Definition: v8-util.h:118
v8::PersistentValueMap::Set
Global< V > Set(const K &key, Local< V > value)
Definition: v8-util.h:364
v8::DefaultPersistentValueVectorTraits::Clear
static void Clear(Impl *impl)
Definition: v8-util.h:554
v8::Isolate
Definition: v8.h:7773
V
#define V(Name)
v8::DefaultPersistentValueVectorTraits::Impl
std::vector< PersistentContainerValue > Impl
Definition: v8-util.h:537
v8::DefaultPersistentValueMapTraits::kCallbackType
static const PersistentContainerCallbackType kCallbackType
Definition: v8-util.h:88
v8
Definition: libplatform.h:15
v8::PersistentValueMapBase::AnnotateStrongRetainer
void AnnotateStrongRetainer(Global< V > *persistent)
Definition: v8-util.h:324
v8::Local
Definition: v8.h:88
v8::PersistentValueMapBase::PersistentValueReference
Definition: v8-util.h:226
v8::DefaultGlobalMapTraits::OnWeakCallback
static void OnWeakCallback(const WeakCallbackInfo< WeakCallbackDataType > &data)
Definition: v8-util.h:135
v8::PersistentValueVector::PersistentValueVector
PersistentValueVector(Isolate *isolate)
Definition: v8-util.h:573
v8::WeakCallbackInfo::SetSecondPassCallback
void SetSecondPassCallback(Callback callback) const
Definition: v8.h:440
v8::WeakCallbackType::kInternalFields
v8::PersistentValueMapBase::GetIsolate
Isolate * GetIsolate()
Definition: v8-util.h:162
v8::GlobalValueMap::Set
Global< V > Set(const K &key, Local< V > value)
Definition: v8-util.h:440
v8::PersistentValueMapBase::PersistentValueReference::NewLocal
Local< V > NewLocal(Isolate *isolate) const
Definition: v8-util.h:232
v8::PersistentValueMapBase::Size
size_t Size()
Definition: v8-util.h:167
v8::StdMapTraits::Size
static size_t Size(Impl *impl)
Definition: v8-util.h:45
v8::PersistentValueMapBase::Contains
bool Contains(const K &key)
Definition: v8-util.h:184
v8::PersistentValueVector::Append
void Append(Local< V > value)
Definition: v8-util.h:582
v8::DefaultGlobalMapTraits::WeakCallbackParameter
static WeakCallbackDataType * WeakCallbackParameter(MapType *map, const K &key, Local< V > value)
Definition: v8-util.h:122
v8::PersistentValueMapBase::PersistentValueReference::IsEmpty
bool IsEmpty() const
Definition: v8-util.h:235
v8::PersistentValueMapBase::isolate
Isolate * isolate()
Definition: v8-util.h:286
v8::PersistentValueMapBase::PersistentValueReference::SetReturnValue
bool SetReturnValue(ReturnValue< T > returnValue)
Definition: v8-util.h:239
v8::DefaultPersistentValueVectorTraits
Definition: v8-util.h:535
v8::DefaultPersistentValueVectorTraits::ReserveCapacity
static void ReserveCapacity(Impl *impl, size_t capacity)
Definition: v8-util.h:551
v8::Global::Pass
Global Pass()
Definition: v8.h:785
v8.h
v8::StdMapTraits::Iterator
Impl::iterator Iterator
Definition: v8-util.h:42
v8::PersistentValueMap::PersistentValueReference
PersistentValueMapBase< K, V, Traits >::PersistentValueReference PersistentValueReference
Definition: v8-util.h:357
v8::WeakCallbackType::kParameter
v8::PersistentContainerCallbackType
PersistentContainerCallbackType
Definition: v8-util.h:24
v8::StdMapTraits::Swap
static void Swap(Impl &a, Impl &b)
Definition: v8-util.h:46
v8::PersistentValueMapBase::Get
Local< V > Get(const K &key)
Definition: v8-util.h:177
v8::PersistentValueMapBase::PersistentValueMapBase
PersistentValueMapBase(Isolate *isolate)
Definition: v8-util.h:279
v8::PersistentValueMap
Definition: v8-util.h:348
v8::DefaultPersistentValueMapTraits::DisposeCallbackData
static void DisposeCallbackData(WeakCallbackDataType *data)
Definition: v8-util.h:105
v8::PersistentValueMap::SetUnique
Global< V > SetUnique(const K &key, Global< V > *persistent)
Definition: v8-util.h:380
v8::ReturnValue
Definition: v8.h:120
v8::PersistentValueVector
Definition: v8-util.h:571
v8::PersistentValueMapBase::impl
Traits::Impl * impl()
Definition: v8-util.h:287
v8::kNotWeak
Definition: v8-util.h:25
v8::WeakCallbackType
WeakCallbackType
Definition: v8.h:455
v8::GlobalValueMap::Set
Global< V > Set(const K &key, Global< V > value)
Definition: v8-util.h:448
v8::DefaultPersistentValueMapTraits::WeakCallbackDataType
void WeakCallbackDataType
Definition: v8-util.h:91
v8::PersistentValueMap::PersistentValueMap
PersistentValueMap(Isolate *isolate, const char *label)
Definition: v8-util.h:352
v8::PersistentBase::AnnotateStrongRetainer
V8_INLINE void AnnotateStrongRetainer(const char *label)
Definition: v8.h:10317
v8::DefaultGlobalMapTraits::MapFromWeakCallbackInfo
static MapType * MapFromWeakCallbackInfo(const WeakCallbackInfo< WeakCallbackDataType > &data)
Definition: v8-util.h:126
v8::PersistentValueMap::Set
Global< V > Set(const K &key, Global< V > value, PersistentValueReference *reference)
Definition: v8-util.h:402
v8::StdMapTraits::Remove
static PersistentContainerValue Remove(Impl *impl, K key)
Definition: v8-util.h:66
v8::StdGlobalValueMap::StdGlobalValueMap
StdGlobalValueMap(Isolate *isolate)
Definition: v8-util.h:530
v8::DefaultPersistentValueMapTraits::KeyFromWeakCallbackInfo
static K KeyFromWeakCallbackInfo(const WeakCallbackInfo< WeakCallbackDataType > &data)
Definition: v8-util.h:101
v8::PersistentValueVector::Size
size_t Size() const
Definition: v8-util.h:604
v8::DefaultGlobalMapTraits
Definition: v8-util.h:111
v8::DefaultPersistentValueVectorTraits::IsEmpty
static bool IsEmpty(const Impl *impl)
Definition: v8-util.h:542
v8::DefaultPersistentValueMapTraits::Dispose
static void Dispose(Isolate *isolate, Global< V > value, K key)
Definition: v8-util.h:106
v8::PersistentContainerValue
uintptr_t PersistentContainerValue
Definition: v8-util.h:22
v8::PersistentValueMapBase::PersistentValueReference::PersistentValueReference
PersistentValueReference()
Definition: v8-util.h:228
v8::PersistentValueMap::PersistentValueMap
PersistentValueMap(Isolate *isolate)
Definition: v8-util.h:350
v8::PersistentValueMap::Set
Global< V > Set(const K &key, Global< V > value)
Definition: v8-util.h:372
v8::kWeakWithInternalFields
Definition: v8-util.h:28
v8::DefaultPersistentValueVectorTraits::Append
static void Append(Impl *impl, PersistentContainerValue value)
Definition: v8-util.h:539
v8::PersistentValueMapBase::Remove
Global< V > Remove(const K &key)
Definition: v8-util.h:200
v8::PersistentValueMapBase::ClearAndLeak
static PersistentContainerValue ClearAndLeak(Global< V > *persistent)
Definition: v8-util.h:293