1 /*********************************************************************
2 * NAN - Native Abstractions for Node.js
4 * Copyright (c) 2017 NAN contributors
6 * MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
7 ********************************************************************/
9 #ifndef NAN_PERSISTENT_12_INL_H_
10 #define NAN_PERSISTENT_12_INL_H_
12 template<typename T, typename M> class Persistent :
13 public v8::Persistent<T, M> {
15 inline Persistent() : v8::Persistent<T, M>() {}
17 template<typename S> inline Persistent(v8::Local<S> that) :
18 v8::Persistent<T, M>(v8::Isolate::GetCurrent(), that) {}
20 template<typename S, typename M2>
22 Persistent(const v8::Persistent<S, M2> &that) : // NOLINT(runtime/explicit)
23 v8::Persistent<T, M2>(v8::Isolate::GetCurrent(), that) {}
25 inline void Reset() { v8::PersistentBase<T>::Reset(); }
28 inline void Reset(const v8::Local<S> &other) {
29 v8::PersistentBase<T>::Reset(v8::Isolate::GetCurrent(), other);
33 inline void Reset(const v8::PersistentBase<S> &other) {
34 v8::PersistentBase<T>::Reset(v8::Isolate::GetCurrent(), other);
40 , typename WeakCallbackInfo<P>::Callback callback
41 , WeakCallbackType type);
44 inline T *operator*() const { return *PersistentBase<T>::persistent; }
46 template<typename S, typename M2>
47 inline void Copy(const Persistent<S, M2> &that) {
52 if (!that.IsEmpty()) {
59 #if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
60 (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
62 class Global : public v8::Global<T> {
64 inline Global() : v8::Global<T>() {}
66 template<typename S> inline Global(v8::Local<S> that) :
67 v8::Global<T>(v8::Isolate::GetCurrent(), that) {}
71 Global(const v8::PersistentBase<S> &that) : // NOLINT(runtime/explicit)
72 v8::Global<S>(v8::Isolate::GetCurrent(), that) {}
74 inline void Reset() { v8::PersistentBase<T>::Reset(); }
77 inline void Reset(const v8::Local<S> &other) {
78 v8::PersistentBase<T>::Reset(v8::Isolate::GetCurrent(), other);
82 inline void Reset(const v8::PersistentBase<S> &other) {
83 v8::PersistentBase<T>::Reset(v8::Isolate::GetCurrent(), other);
89 , typename WeakCallbackInfo<P>::Callback callback
90 , WeakCallbackType type) {
91 reinterpret_cast<Persistent<T>*>(this)->SetWeak(
92 parameter, callback, type);
97 class Global : public v8::UniquePersistent<T> {
99 inline Global() : v8::UniquePersistent<T>() {}
101 template<typename S> inline Global(v8::Local<S> that) :
102 v8::UniquePersistent<T>(v8::Isolate::GetCurrent(), that) {}
106 Global(const v8::PersistentBase<S> &that) : // NOLINT(runtime/explicit)
107 v8::UniquePersistent<S>(v8::Isolate::GetCurrent(), that) {}
109 inline void Reset() { v8::PersistentBase<T>::Reset(); }
111 template <typename S>
112 inline void Reset(const v8::Local<S> &other) {
113 v8::PersistentBase<T>::Reset(v8::Isolate::GetCurrent(), other);
116 template <typename S>
117 inline void Reset(const v8::PersistentBase<S> &other) {
118 v8::PersistentBase<T>::Reset(v8::Isolate::GetCurrent(), other);
124 , typename WeakCallbackInfo<P>::Callback callback
125 , WeakCallbackType type) {
126 reinterpret_cast<Persistent<T>*>(this)->SetWeak(
127 parameter, callback, type);
132 #endif // NAN_PERSISTENT_12_INL_H_