5#ifndef INCLUDE_V8_PERSISTENT_HANDLE_H_
6#define INCLUDE_V8_PERSISTENT_HANDLE_H_
16template <
class K,
class V,
class T>
17class PersistentValueMapBase;
22template <
class K,
class V,
class T>
23class PersistentValueMap;
26namespace api_internal {
63 static_assert(std::is_base_of<T, S>::value,
"type check");
69namespace api_internal {
147 template <
typename P>
159 template <
typename P>
195 template <
class F1,
class F2>
203 template <
class F1,
class F2,
class F3>
227 template <
class S,
class M>
230 static_assert(
sizeof(S) < 0,
231 "NonCopyablePersistentTraits::Copy is not instantiable");
245template <
class T,
class M>
262 static_assert(std::is_base_of<T, S>::value,
"type check");
270 template <
class S,
class M2>
274 static_assert(std::is_base_of<T, S>::value,
"type check");
286 template <
class S,
class M2>
294 template <
class S,
class M2>
306 if (M::kResetInDestructor) this->
Reset();
310 template <
class S,
class M2>
312#ifdef V8_ENABLE_CHECKS
315 if (!that.
IsEmpty()) T::Cast(that.template value<S>());
322 template <
class S,
class M2>
332 template <
class F1,
class F2>
337 template <
class S,
class M2>
363 static_assert(std::is_base_of<T, S>::value,
"type check");
375 static_assert(std::is_base_of<T, S>::value,
"type check");
420 uint16_t class_id) {}
427 reinterpret_cast<internal::Isolate*
>(isolate),
431template <
class T,
class M>
432template <
class S,
class M2>
433void Persistent<T, M>::Copy(
const Persistent<S, M2>& that) {
434 static_assert(std::is_base_of<T, S>::value,
"type check");
436 if (that.IsEmpty())
return;
444 if (this->IsEmpty())
return false;
445 return I::GetNodeState(this->slot()) == I::kNodeStateIsWeakValue;
450 if (this->IsEmpty())
return;
462 static_assert(std::is_base_of<T, S>::value,
"type check");
465 this->slot() = New(isolate, *other);
476 static_assert(std::is_base_of<T, S>::value,
"type check");
479 this->slot() = New(isolate, other.template value<S>());
488#if (__GNUC__ >= 8) && !defined(__clang__)
489#pragma GCC diagnostic push
490#pragma GCC diagnostic ignored "-Wcast-function-type"
493 reinterpret_cast<Callback
>(callback), type);
494#if (__GNUC__ >= 8) && !defined(__clang__)
495#pragma GCC diagnostic pop
518 if (this->IsEmpty())
return;
519 uint8_t* addr =
reinterpret_cast<uint8_t*
>(slot()) + I::kNodeClassIdOffset;
520 *
reinterpret_cast<uint16_t*
>(addr) = class_id;
526 if (this->IsEmpty())
return 0;
527 uint8_t* addr =
reinterpret_cast<uint8_t*
>(slot()) + I::kNodeClassIdOffset;
528 return *
reinterpret_cast<uint16_t*
>(addr);
533 if (!other.IsEmpty()) {
542 static_assert(std::is_base_of<T, S>::value,
"type check");
545 if (!rhs.IsEmpty()) {
546 this->slot() = rhs.slot();
Definition: v8-persistent-handle.h:45
Local< T > Get(Isolate *isolate) const
Definition: v8-persistent-handle.h:55
void Set(Isolate *isolate, Local< S > handle)
Definition: v8-persistent-handle.h:62
Eternal(Isolate *isolate, Local< S > handle)
Definition: v8-persistent-handle.h:50
Definition: v8-persistent-handle.h:347
void MoveOnlyTypeForCPP03
Definition: v8-persistent-handle.h:399
Global(Isolate *isolate, const PersistentBase< S > &that)
Definition: v8-persistent-handle.h:372
Global & operator=(Global< S > &&rhs)
void operator=(const Global &)=delete
~Global()
Definition: v8-persistent-handle.h:383
Global Pass()
Definition: v8-persistent-handle.h:394
Global(Isolate *isolate, Local< S > that)
Definition: v8-persistent-handle.h:360
Global(Global &&other)
Definition: v8-persistent-handle.h:532
Global(const Global &)=delete
Definition: v8-isolate.h:212
Definition: v8-local-handle.h:266
static Local< T > New(Isolate *isolate, Local< T > that)
Definition: v8-local-handle.h:346
Definition: v8-persistent-handle.h:223
static const bool kResetInDestructor
Definition: v8-persistent-handle.h:226
static void Copy(const Persistent< S, M > &source, NonCopyablePersistent *dest)
Definition: v8-persistent-handle.h:228
Definition: v8-object.h:233
Definition: v8-persistent-handle.h:89
void SetWeak(P *parameter, typename WeakCallbackInfo< P >::Callback callback, WeakCallbackType type)
Definition: v8-persistent-handle.h:484
void SetWeak()
Definition: v8-persistent-handle.h:500
void Reset()
Definition: v8-persistent-handle.h:449
void AnnotateStrongRetainer(const char *label)
Definition: v8-persistent-handle.h:511
void ClearWeak()
Definition: v8-persistent-handle.h:163
Local< T > Get(Isolate *isolate) const
Definition: v8-persistent-handle.h:111
bool IsWeak() const
Definition: v8-persistent-handle.h:442
void Reset(Isolate *isolate, const PersistentBase< S > &other)
Definition: v8-persistent-handle.h:474
bool operator==(const Local< S > &that) const
Definition: v8-persistent-handle.h:121
P * ClearWeak()
Definition: v8-persistent-handle.h:506
PersistentBase(const PersistentBase &other)=delete
bool operator!=(const PersistentBase< S > &that) const
Definition: v8-persistent-handle.h:126
void Reset(Isolate *isolate, const Local< S > &other)
Definition: v8-persistent-handle.h:461
bool operator==(const PersistentBase< S > &that) const
Definition: v8-persistent-handle.h:116
friend class PersistentBase
Definition: v8-persistent-handle.h:200
friend class Utils
Definition: v8-persistent-handle.h:192
void SetWrapperClassId(uint16_t class_id)
Definition: v8-persistent-handle.h:516
uint16_t WrapperClassId() const
Definition: v8-persistent-handle.h:524
bool operator!=(const Local< S > &that) const
Definition: v8-persistent-handle.h:131
void operator=(const PersistentBase &)=delete
Definition: v8-persistent-handle.h:416
virtual void VisitPersistentHandle(Persistent< Value > *value, uint16_t class_id)
Definition: v8-persistent-handle.h:419
virtual ~PersistentHandleVisitor()=default
Definition: v8-util.h:166
Definition: v8-persistent-handle.h:246
Persistent(Isolate *isolate, Local< S > that)
Definition: v8-persistent-handle.h:259
~Persistent()
Definition: v8-persistent-handle.h:305
Persistent(const Persistent< S, M2 > &that)
Definition: v8-persistent-handle.h:287
Persistent< S, M2 > & As() const
Definition: v8-persistent-handle.h:323
Persistent & operator=(const Persistent< S, M2 > &that)
Definition: v8-persistent-handle.h:295
Persistent & operator=(const Persistent &that)
Definition: v8-persistent-handle.h:290
friend class Utils
Definition: v8-persistent-handle.h:329
static Persistent< T, M > & Cast(const Persistent< S, M2 > &that)
Definition: v8-persistent-handle.h:311
Persistent(Isolate *isolate, const Persistent< S, M2 > &that)
Definition: v8-persistent-handle.h:271
Persistent(const Persistent &that)
Definition: v8-persistent-handle.h:283
Definition: v8-function-callback.h:41
Definition: v8-container.h:148
Definition: v8-value.h:32
void(*)(const WeakCallbackInfo< T > &data) Callback
Definition: v8-weak-callback-info.h:24
Definition: v8-handle-base.h:53
T * value() const
Definition: v8-handle-base.h:85
IndirectHandleBase()=default
internal::Address *const & slot() const
Definition: v8-handle-base.h:79
bool IsEmpty() const
Definition: v8-handle-base.h:56
static bool EqualHandles(const T1 &lhs, const T2 &rhs)
Definition: v8-internal.h:1726
Definition: v8-internal.h:855
Definition: v8-internal.h:1627
static Address ValueAsAddress(const T *value)
Definition: v8-internal.h:1687
static bool IsEmpty(T *value)
Definition: v8-internal.h:1646
void DisposeGlobal(internal::Address *global_handle)
void AnnotateStrongRetainer(internal::Address *location, const char *label)
void MoveGlobalReference(internal::Address **from, internal::Address **to)
internal::Address * GlobalizeReference(internal::Isolate *isolate, internal::Address value)
void * ClearWeak(internal::Address *location)
internal::Address * Eternalize(v8::Isolate *isolate, Value *handle)
void MakeWeak(internal::Address **location_addr)
internal::Address * CopyGlobalReference(internal::Address *from)
uintptr_t Address
Definition: v8-internal.h:51
Definition: libplatform.h:15
WeakCallbackType
Definition: v8-weak-callback-info.h:57
#define V8_EXPORT
Definition: v8config.h:793
#define V8_INLINE
Definition: v8config.h:499