5#ifndef INCLUDE_V8_PERSISTENT_HANDLE_H_
6#define INCLUDE_V8_PERSISTENT_HANDLE_H_
16template <
class K,
class V,
class T>
22template <
class K,
class V,
class T>
23class PersistentValueMap;
41
42
43
50
51
53 requires(std::is_base_of_v<T, S>)
75 WeakCallbackInfo<
void>::Callback weak_callback,
80
81
82
83
84
85
86
87
88
89
90
91
96
97
98
102
103
104
109
110
111
116 return Local<T>::New(isolate, *
this);
121 return internal::HandleHelper::EqualHandles(*
this, that);
126 return internal::HandleHelper::EqualHandles(*
this, that);
131 return !operator==(that);
136 return !operator==(that);
140
141
142
143
144
145
146
147
148
149
150
151 template <
typename P>
157
158
159
160
163 template <
typename P>
170
171
172
173
174
181
182
186
187
188
199 template <
class F1,
class F2>
207 template <
class F1,
class F2,
class F3>
221
222
223
224
225
227class NonCopyablePersistentTraits {
229 using NonCopyablePersistent =
Persistent<T, NonCopyablePersistentTraits<T>>;
231 template <
class S,
class M>
233 NonCopyablePersistent* dest) {
234 static_assert(
sizeof(S) < 0,
235 "NonCopyablePersistentTraits::Copy is not instantiable");
240
241
242
243
244
245
246
247
248
249template <
class T,
class M>
253
254
258
259
260
261
263 requires(std::is_base_of_v<T, S>)
269
270
271
272
273 template <
class S,
class M2>
280
281
282
283
284
288 template <
class S,
class M2>
296 template <
class S,
class M2>
303
304
305
306
312 template <
class S,
class M2>
314#ifdef V8_ENABLE_CHECKS
324 template <
class S,
class M2>
334 template <
class F1,
class F2>
339 template <
class S,
class M2>
344
345
346
347
352
353
357
358
359
360
362 requires(std::is_base_of_v<T, S>)
368
369
370
371
379
380
386
387
392
393
397
398
399 using MoveOnlyTypeForCPP03 =
void;
414
415
420 uint16_t class_id) {}
425 if (
internal::ValueHelper::IsEmpty(that))
return nullptr;
427 reinterpret_cast<
internal::Isolate*>(isolate)
,
428 internal::ValueHelper::ValueAsAddress(that)
);
431template <
class T,
class M>
432template <
class S,
class M2>
434 static_assert(std::is_base_of_v<T, S>,
"type check");
436 if (that.IsEmpty())
return;
444 if (
this->IsEmpty())
return false;
450 if (
this->IsEmpty())
return;
456
457
458
462 static_assert(std::is_base_of_v<T, S>,
"type check");
464 if (other.IsEmpty())
return;
465 this->slot() = New(isolate, *other);
469
470
471
476 static_assert(std::is_base_of_v<T, S>,
"type check");
478 if (other.IsEmpty())
return;
479 this->slot() = New(isolate, other.
template value<S>());
487 using Callback = WeakCallbackInfo<
void>::Callback;
488#if (__GNUC__
>= 8
) && !defined(__clang__
)
489#pragma GCC diagnostic push
490#pragma GCC diagnostic ignored "-Wcast-function-type"
493#pragma clang diagnostic push
494#pragma clang diagnostic ignored "-Wcast-function-type"
499#pragma clang diagnostic pop
501#if (__GNUC__
>= 8
) && !defined(__clang__
)
502#pragma GCC diagnostic pop
525 if (
this->IsEmpty())
return;
527 *
reinterpret_cast<uint16_t*>(addr) = class_id;
533 if (
this->IsEmpty())
return 0;
535 return *
reinterpret_cast<uint16_t*>(addr);
540 if (!other.IsEmpty()) {
549 static_assert(std::is_base_of_v<T, S>,
"type check");
552 if (!rhs.IsEmpty()) {
553 this->slot() = rhs.slot();
V8_INLINE Eternal()=default
V8_INLINE Global()=default
V8_INLINE Global & operator=(Global< S > &&rhs)
Global(const Global &)=delete
void operator=(const Global &)=delete
static V8_INLINE void Copy(const Persistent< S, M > &source, NonCopyablePersistent *dest)
static const bool kResetInDestructor
V8_INLINE void Reset(Isolate *isolate, const Local< S > &other)
void operator=(const PersistentBase &)=delete
V8_INLINE uint16_t WrapperClassId() const
V8_INLINE bool IsWeak() const
V8_INLINE void ClearWeak()
V8_INLINE bool operator!=(const Local< S > &that) const
V8_INLINE bool operator==(const Local< S > &that) const
V8_INLINE P * ClearWeak()
V8_INLINE bool operator!=(const PersistentBase< S > &that) const
PersistentBase(const PersistentBase &other)=delete
V8_INLINE void AnnotateStrongRetainer(const char *label)
V8_INLINE bool operator==(const PersistentBase< S > &that) const
V8_INLINE void Reset(Isolate *isolate, const PersistentBase< S > &other)
V8_INLINE void SetWeak(P *parameter, typename WeakCallbackInfo< P >::Callback callback, WeakCallbackType type)
V8_INLINE Local< T > Get(Isolate *isolate) const
friend class PersistentBase
V8_INLINE void SetWrapperClassId(uint16_t class_id)
virtual void VisitPersistentHandle(Persistent< Value > *value, uint16_t class_id)
virtual ~PersistentHandleVisitor()=default
V8_INLINE Persistent()=default
friend class PersistentValueMapBase
static V8_INLINE uint8_t GetNodeState(Address *obj)
static const int kNodeStateIsWeakValue
static const int kNodeClassIdOffset
V8_EXPORT void MakeWeak(internal::Address **location_addr)
V8_EXPORT void DisposeGlobal(internal::Address *global_handle)
V8_EXPORT void MakeWeak(internal::Address *location, void *data, WeakCallbackInfo< void >::Callback weak_callback, WeakCallbackType type)
V8_EXPORT void * ClearWeak(internal::Address *location)
V8_EXPORT internal::Address * CopyGlobalReference(internal::Address *from)
V8_EXPORT void MoveGlobalReference(internal::Address **from, internal::Address **to)
V8_EXPORT internal::Address * Eternalize(v8::Isolate *isolate, Value *handle)
V8_EXPORT internal::Address * GlobalizeReference(internal::Isolate *isolate, internal::Address value)
V8_EXPORT void AnnotateStrongRetainer(internal::Address *location, const char *label)