5#ifndef INCLUDE_V8_PERSISTENT_HANDLE_H_
6#define INCLUDE_V8_PERSISTENT_HANDLE_H_
16template <
class K,
class V,
class T>
17class PersistentValueMapBase;
18template <
class V,
class T>
19class PersistentValueVector;
24template <
class K,
class V,
class T>
25class PersistentValueMap;
28namespace api_internal {
65 static_assert(std::is_base_of<T, S>::value,
"type check");
71namespace api_internal {
149 template <
typename P>
161 template <
typename P>
197 template <
class F1,
class F2>
205 template <
class F1,
class F2,
class F3>
207 template <
class F1,
class F2>
231 template <
class S,
class M>
234 static_assert(
sizeof(S) < 0,
235 "NonCopyablePersistentTraits::Copy is not instantiable");
249template <
class T,
class M>
266 static_assert(std::is_base_of<T, S>::value,
"type check");
274 template <
class S,
class M2>
278 static_assert(std::is_base_of<T, S>::value,
"type check");
290 template <
class S,
class M2>
298 template <
class S,
class M2>
310 if (M::kResetInDestructor) this->
Reset();
314 template <
class S,
class M2>
316#ifdef V8_ENABLE_CHECKS
319 if (!that.
IsEmpty()) T::Cast(that.template value<S>());
326 template <
class S,
class M2>
336 template <
class F1,
class F2>
341 template <
class S,
class M2>
367 static_assert(std::is_base_of<T, S>::value,
"type check");
379 static_assert(std::is_base_of<T, S>::value,
"type check");
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<T, S>::value,
"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<T, S>::value,
"type check");
469 this->slot() = New(isolate, *other);
480 static_assert(std::is_base_of<T, S>::value,
"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<T, S>::value,
"type check");
549 if (!rhs.IsEmpty()) {
550 this->slot() = rhs.slot();
Definition: v8-persistent-handle.h:47
Local< T > Get(Isolate *isolate) const
Definition: v8-persistent-handle.h:57
void Set(Isolate *isolate, Local< S > handle)
Definition: v8-persistent-handle.h:64
Eternal(Isolate *isolate, Local< S > handle)
Definition: v8-persistent-handle.h:52
Definition: v8-persistent-handle.h:351
void MoveOnlyTypeForCPP03
Definition: v8-persistent-handle.h:403
Global(Isolate *isolate, const PersistentBase< S > &that)
Definition: v8-persistent-handle.h:376
Global & operator=(Global< S > &&rhs)
void operator=(const Global &)=delete
~Global()
Definition: v8-persistent-handle.h:387
Global Pass()
Definition: v8-persistent-handle.h:398
Global(Isolate *isolate, Local< S > that)
Definition: v8-persistent-handle.h:364
Global(Global &&other)
Definition: v8-persistent-handle.h:536
Global(const Global &)=delete
Definition: v8-isolate.h:210
Definition: v8-local-handle.h:258
static Local< T > New(Isolate *isolate, Local< T > that)
Definition: v8-local-handle.h:338
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:238
Definition: v8-persistent-handle.h:91
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
void ClearWeak()
Definition: v8-persistent-handle.h:165
Local< T > Get(Isolate *isolate) const
Definition: v8-persistent-handle.h:113
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:123
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:128
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:118
friend class PersistentBase
Definition: v8-persistent-handle.h:202
friend class Utils
Definition: v8-persistent-handle.h:194
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:133
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-util.h:582
Definition: v8-persistent-handle.h:250
Persistent(Isolate *isolate, Local< S > that)
Definition: v8-persistent-handle.h:263
~Persistent()
Definition: v8-persistent-handle.h:309
Persistent(const Persistent< S, M2 > &that)
Definition: v8-persistent-handle.h:291
Persistent< S, M2 > & As() const
Definition: v8-persistent-handle.h:327
Persistent & operator=(const Persistent< S, M2 > &that)
Definition: v8-persistent-handle.h:299
Persistent & operator=(const Persistent &that)
Definition: v8-persistent-handle.h:294
friend class Utils
Definition: v8-persistent-handle.h:333
static Persistent< T, M > & Cast(const Persistent< S, M2 > &that)
Definition: v8-persistent-handle.h:315
Persistent(Isolate *isolate, const Persistent< S, M2 > &that)
Definition: v8-persistent-handle.h:275
Persistent(const Persistent &that)
Definition: v8-persistent-handle.h:287
Definition: v8-function-callback.h:35
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:1485
Definition: v8-internal.h:729
Definition: v8-internal.h:1416
static Address ValueAsAddress(const T *value)
Definition: v8-internal.h:1457
static bool IsEmpty(T *value)
Definition: v8-internal.h:1426
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:31
Definition: libplatform.h:15
WeakCallbackType
Definition: v8-weak-callback-info.h:57
#define V8_EXPORT
Definition: v8config.h:762
#define V8_INLINE
Definition: v8config.h:477