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 {
53 requires(std::is_base_of_v<T, S>)
66 requires(std::is_base_of_v<T, S>)
73namespace api_internal {
151 template <
typename P>
163 template <
typename P>
199 template <
class F1,
class F2>
207 template <
class F1,
class F2,
class F3>
231 template <
class S,
class M>
234 static_assert(
sizeof(S) < 0,
235 "NonCopyablePersistentTraits::Copy is not instantiable");
249template <
class T,
class M>
263 requires(std::is_base_of_v<T, S>)
273 template <
class S,
class M2>
274 requires(std::is_base_of_v<T, S>)
288 template <
class S,
class M2>
296 template <
class S,
class M2>
308 if (M::kResetInDestructor) this->
Reset();
311 template <
class S,
class M2>
314#ifdef V8_ENABLE_CHECKS
317 if (!that.IsEmpty()) T::Cast(that.template value<S>());
323 template <
class S,
class M2>
326#ifdef V8_ENABLE_CHECKS
327 if (!this->
IsEmpty()) S::Cast(this->
template value<T>());
338 template <
class F1,
class F2>
343 template <
class S,
class M2>
366 requires(std::is_base_of_v<T, S>)
377 requires(std::is_base_of_v<T, S>)
424 uint16_t class_id) {}
431 reinterpret_cast<internal::Isolate*
>(isolate),
435template <
class T,
class M>
436template <
class S,
class M2>
437void Persistent<T, M>::Copy(
const Persistent<S, M2>& that) {
438 static_assert(std::is_base_of_v<T, S>,
"type check");
440 if (that.IsEmpty())
return;
448 if (this->IsEmpty())
return false;
449 return I::GetNodeState(this->slot()) == I::kNodeStateIsWeakValue;
454 if (this->IsEmpty())
return;
466 static_assert(std::is_base_of_v<T, S>,
"type check");
469 this->slot() = New(isolate, *other);
480 static_assert(std::is_base_of_v<T, S>,
"type check");
483 this->slot() = New(isolate, other.template value<S>());
492#if (__GNUC__ >= 8) || defined(__clang__)
493#pragma GCC diagnostic push
494#pragma GCC diagnostic ignored "-Wcast-function-type"
497 reinterpret_cast<Callback
>(callback), type);
498#if (__GNUC__ >= 8) || defined(__clang__)
499#pragma GCC diagnostic pop
522 if (this->IsEmpty())
return;
523 uint8_t* addr =
reinterpret_cast<uint8_t*
>(slot()) + I::kNodeClassIdOffset;
524 *
reinterpret_cast<uint16_t*
>(addr) = class_id;
530 if (this->IsEmpty())
return 0;
531 uint8_t* addr =
reinterpret_cast<uint8_t*
>(slot()) + I::kNodeClassIdOffset;
532 return *
reinterpret_cast<uint16_t*
>(addr);
537 if (!other.IsEmpty()) {
546 static_assert(std::is_base_of_v<T, S>,
"type check");
549 if (!rhs.IsEmpty()) {
550 this->slot() = rhs.slot();
Definition: v8-persistent-handle.h:45
Local< T > Get(Isolate *isolate) const
Definition: v8-persistent-handle.h:59
Eternal(Isolate *isolate, Local< S > handle)
Definition: v8-persistent-handle.h:54
void Set(Isolate *isolate, Local< S > handle)
Definition: v8-persistent-handle.h:67
Definition: v8-persistent-handle.h:353
void MoveOnlyTypeForCPP03
Definition: v8-persistent-handle.h:403
Global & operator=(Global< S > &&rhs)
void operator=(const Global &)=delete
~Global()
Definition: v8-persistent-handle.h:387
Global(Isolate *isolate, Local< S > that)
Definition: v8-persistent-handle.h:367
Global Pass()
Definition: v8-persistent-handle.h:398
Global(Global &&other)
Definition: v8-persistent-handle.h:536
Global(Isolate *isolate, const PersistentBase< S > &that)
Definition: v8-persistent-handle.h:378
Global(const Global &)=delete
Definition: v8-isolate.h:291
Definition: v8-local-handle.h:366
static Local< T > New(Isolate *isolate, Local< T > that)
Definition: v8-local-handle.h:448
Definition: v8-persistent-handle.h:227
static const bool kResetInDestructor
Definition: v8-persistent-handle.h:230
static void Copy(const Persistent< S, M > &source, NonCopyablePersistent *dest)
Definition: v8-persistent-handle.h:232
Definition: v8-object.h:266
Definition: v8-persistent-handle.h:93
void SetWeak(P *parameter, typename WeakCallbackInfo< P >::Callback callback, WeakCallbackType type)
Definition: v8-persistent-handle.h:488
void SetWeak()
Definition: v8-persistent-handle.h:504
void Reset()
Definition: v8-persistent-handle.h:453
void AnnotateStrongRetainer(const char *label)
Definition: v8-persistent-handle.h:515
Local< T > Get(Isolate *isolate) const
Definition: v8-persistent-handle.h:115
bool IsWeak() const
Definition: v8-persistent-handle.h:446
void Reset(Isolate *isolate, const PersistentBase< S > &other)
Definition: v8-persistent-handle.h:478
bool operator==(const Local< S > &that) const
Definition: v8-persistent-handle.h:125
P * ClearWeak()
Definition: v8-persistent-handle.h:510
PersistentBase(const PersistentBase &other)=delete
bool operator!=(const PersistentBase< S > &that) const
Definition: v8-persistent-handle.h:130
void Reset(Isolate *isolate, const Local< S > &other)
Definition: v8-persistent-handle.h:465
bool operator==(const PersistentBase< S > &that) const
Definition: v8-persistent-handle.h:120
friend class PersistentBase
Definition: v8-persistent-handle.h:204
friend class Utils
Definition: v8-persistent-handle.h:196
void SetWrapperClassId(uint16_t class_id)
Definition: v8-persistent-handle.h:520
uint16_t WrapperClassId() const
Definition: v8-persistent-handle.h:528
bool operator!=(const Local< S > &that) const
Definition: v8-persistent-handle.h:135
void operator=(const PersistentBase &)=delete
Definition: v8-persistent-handle.h:420
virtual void VisitPersistentHandle(Persistent< Value > *value, uint16_t class_id)
Definition: v8-persistent-handle.h:423
virtual ~PersistentHandleVisitor()=default
Definition: v8-util.h:166
Definition: v8-persistent-handle.h:250
~Persistent()
Definition: v8-persistent-handle.h:307
Persistent(const Persistent< S, M2 > &that)
Definition: v8-persistent-handle.h:289
Persistent< S, M2 > & As() const
Definition: v8-persistent-handle.h:325
Persistent & operator=(const Persistent< S, M2 > &that)
Definition: v8-persistent-handle.h:297
Persistent & operator=(const Persistent &that)
Definition: v8-persistent-handle.h:292
friend class Utils
Definition: v8-persistent-handle.h:335
Persistent(Isolate *isolate, const Persistent< S, M2 > &that)
Definition: v8-persistent-handle.h:275
static Persistent< T, M > & Cast(const Persistent< S, M2 > &that)
Definition: v8-persistent-handle.h:313
Persistent(Isolate *isolate, Local< S > that)
Definition: v8-persistent-handle.h:264
Persistent(const Persistent &that)
Definition: v8-persistent-handle.h:285
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:28
Definition: v8-handle-base.h:57
IndirectHandleBase()=default
internal::Address *const & slot() const
Definition: v8-handle-base.h:83
bool IsEmpty() const
Definition: v8-handle-base.h:60
static bool EqualHandles(const T1 &lhs, const T2 &rhs)
Definition: v8-internal.h:1892
Definition: v8-internal.h:986
Definition: v8-internal.h:1793
static Address ValueAsAddress(const T *value)
Definition: v8-internal.h:1853
static bool IsEmpty(T *value)
Definition: v8-internal.h:1812
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:38
Definition: libplatform.h:15
WeakCallbackType
Definition: v8-weak-callback-info.h:65
#define V8_EXPORT
Definition: v8config.h:854
#define V8_INLINE
Definition: v8config.h:508
#define V8_DEPRECATE_SOON(message)
Definition: v8config.h:621