5 #ifndef INCLUDE_V8_PERSISTENT_HANDLE_H_
6 #define INCLUDE_V8_PERSISTENT_HANDLE_H_
16 template <
class K,
class V,
class T>
18 template <
class V,
class T>
24 template <
class K,
class V,
class T>
25 class PersistentValueMap;
58 return Local<T>(val_);
65 static_assert(std::is_base_of<T, S>::value,
"type check");
66 val_ =
reinterpret_cast<T*>(
120 return Local<T>::New(isolate, *
this);
127 if (a ==
nullptr)
return b ==
nullptr;
128 if (b ==
nullptr)
return false;
136 if (a ==
nullptr)
return b ==
nullptr;
137 if (b ==
nullptr)
return false;
143 return !operator==(that);
148 return !operator==(that);
163 template <
typename P>
177 template <
typename P>
213 template <
class F1,
class F2>
221 template <
class F1,
class F2,
class F3>
223 template <
class F1,
class F2>
227 explicit V8_INLINE PersistentBase(T* val) : val_(val) {}
240 class NonCopyablePersistentTraits {
242 using NonCopyablePersistent =
Persistent<T, NonCopyablePersistentTraits<T>>;
244 template <
class S,
class M>
246 NonCopyablePersistent* dest) {
247 static_assert(
sizeof(S) < 0,
248 "NonCopyablePersistentTraits::Copy is not instantiable");
260 template <
class S,
class M>
262 CopyablePersistent* dest) {
275 template <
class T,
class M>
290 static_assert(std::is_base_of<T, S>::value,
"type check");
297 template <
class S,
class M2>
300 static_assert(std::is_base_of<T, S>::value,
"type check");
311 template <
class S,
class M2>
319 template <
class S,
class M2>
330 if (M::kResetInDestructor)
this->Reset();
336 #ifdef V8_ENABLE_CHECKS
339 if (!that.IsEmpty()) T::Cast(*that);
355 template <
class F1,
class F2>
361 V8_INLINE T* operator*()
const {
return this->val_; }
362 template <
class S,
class M2>
387 static_assert(std::is_base_of<T, S>::value,
"type check");
398 static_assert(std::is_base_of<T, S>::value,
"type check");
422 using MoveOnlyTypeForCPP03 =
void;
430 V8_INLINE T* operator*()
const {
return this->val_; }
444 uint16_t class_id) {}
449 if (that ==
nullptr)
return nullptr;
452 reinterpret_cast<
internal::Isolate*>(isolate)
, p
));
455 template <
class T,
class M>
456 template <
class S,
class M2>
458 static_assert(std::is_base_of<T, S>::value,
"type check");
460 if (that.IsEmpty())
return;
469 if (
this->IsEmpty())
return false;
476 if (
this->IsEmpty())
return;
488 static_assert(std::is_base_of<T, S>::value,
"type check");
490 if (other.IsEmpty())
return;
491 this->val_ = New(isolate, other.val_);
502 static_assert(std::is_base_of<T, S>::value,
"type check");
504 if (other.IsEmpty())
return;
505 this->val_ = New(isolate, other.val_);
509 template <
typename P>
514 #if (__GNUC__
>= 8
) && !defined(__clang__
)
515 #pragma GCC diagnostic push
516 #pragma GCC diagnostic ignored "-Wcast-function-type"
519 parameter,
reinterpret_cast<Callback>(callback), type);
520 #if (__GNUC__
>= 8
) && !defined(__clang__
)
521 #pragma GCC diagnostic pop
531 template <
typename P>
546 if (
this->IsEmpty())
return;
549 *
reinterpret_cast<uint16_t*>(addr) = class_id;
555 if (
this->IsEmpty())
return 0;
558 return *
reinterpret_cast<uint16_t*>(addr);
563 if (other.val_ !=
nullptr) {
567 other.val_ =
nullptr;
574 static_assert(std::is_base_of<T, S>::value,
"type check");
577 if (rhs.val_ !=
nullptr) {
578 this->val_ = rhs.val_;