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();
312 template <
class S,
class M2>
314#ifdef V8_ENABLE_CHECKS
317 if (!that.
IsEmpty()) T::Cast(that.template value<S>());
324 template <
class S,
class M2>
334 template <
class F1,
class F2>
339 template <
class S,
class M2>
362 requires(std::is_base_of_v<T, S>)
373 requires(std::is_base_of_v<T, S>)
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: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:349
void MoveOnlyTypeForCPP03
Definition: v8-persistent-handle.h:399
Global & operator=(Global< S > &&rhs)
void operator=(const Global &)=delete
~Global()
Definition: v8-persistent-handle.h:383
Global(Isolate *isolate, Local< S > that)
Definition: v8-persistent-handle.h:363
Global Pass()
Definition: v8-persistent-handle.h:394
Global(Global &&other)
Definition: v8-persistent-handle.h:532
Global(Isolate *isolate, const PersistentBase< S > &that)
Definition: v8-persistent-handle.h:374
Global(const Global &)=delete
Definition: v8-isolate.h:274
Definition: v8-local-handle.h:267
static Local< T > New(Isolate *isolate, Local< T > that)
Definition: v8-local-handle.h:349
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:233
Definition: v8-persistent-handle.h:93
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:167
Local< T > Get(Isolate *isolate) const
Definition: v8-persistent-handle.h:115
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:125
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:130
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: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:516
uint16_t WrapperClassId() const
Definition: v8-persistent-handle.h:524
bool operator!=(const Local< S > &that) const
Definition: v8-persistent-handle.h:135
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: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:331
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:1714
Definition: v8-internal.h:829
Definition: v8-internal.h:1615
static Address ValueAsAddress(const T *value)
Definition: v8-internal.h:1675
static bool IsEmpty(T *value)
Definition: v8-internal.h:1634
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:52
Definition: libplatform.h:15
WeakCallbackType
Definition: v8-weak-callback-info.h:65
#define V8_EXPORT
Definition: v8config.h:800
#define V8_INLINE
Definition: v8config.h:500