Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef NAN_PERSISTENT_12_INL_H_
00010 #define NAN_PERSISTENT_12_INL_H_
00011
00012 template<typename T, typename M> class Persistent :
00013 public v8::Persistent<T, M> {
00014 public:
00015 inline Persistent() : v8::Persistent<T, M>() {}
00016
00017 template<typename S> inline Persistent(v8::Local<S> that) :
00018 v8::Persistent<T, M>(v8::Isolate::GetCurrent(), that) {}
00019
00020 template<typename S, typename M2>
00021 inline Persistent(const v8::Persistent<S, M2> &that) :
00022 v8::Persistent<T, M2>(v8::Isolate::GetCurrent(), that) {}
00023
00024 inline void Reset() { v8::PersistentBase<T>::Reset(); }
00025
00026 template <typename S>
00027 inline void Reset(const v8::Local<S> &other) {
00028 v8::PersistentBase<T>::Reset(v8::Isolate::GetCurrent(), other);
00029 }
00030
00031 template <typename S>
00032 inline void Reset(const v8::PersistentBase<S> &other) {
00033 v8::PersistentBase<T>::Reset(v8::Isolate::GetCurrent(), other);
00034 }
00035
00036 template<typename P>
00037 inline void SetWeak(
00038 P *parameter
00039 , typename WeakCallbackInfo<P>::Callback callback
00040 , WeakCallbackType type);
00041
00042 private:
00043 inline T *operator*() const { return *PersistentBase<T>::persistent; }
00044
00045 template<typename S, typename M2>
00046 inline void Copy(const Persistent<S, M2> &that) {
00047 TYPE_CHECK(T, S);
00048
00049 this->Reset();
00050
00051 if (!that.IsEmpty()) {
00052 this->Reset(that);
00053 M::Copy(that, this);
00054 }
00055 }
00056 };
00057
00058 #if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
00059 (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
00060 template<typename T>
00061 class Global : public v8::Global<T> {
00062 public:
00063 inline Global() : v8::Global<T>() {}
00064
00065 template<typename S> inline Global(v8::Local<S> that) :
00066 v8::Global<T>(v8::Isolate::GetCurrent(), that) {}
00067
00068 template<typename S>
00069 inline Global(const v8::PersistentBase<S> &that) :
00070 v8::Global<S>(v8::Isolate::GetCurrent(), that) {}
00071
00072 inline void Reset() { v8::PersistentBase<T>::Reset(); }
00073
00074 template <typename S>
00075 inline void Reset(const v8::Local<S> &other) {
00076 v8::PersistentBase<T>::Reset(v8::Isolate::GetCurrent(), other);
00077 }
00078
00079 template <typename S>
00080 inline void Reset(const v8::PersistentBase<S> &other) {
00081 v8::PersistentBase<T>::Reset(v8::Isolate::GetCurrent(), other);
00082 }
00083
00084 template<typename P>
00085 inline void SetWeak(
00086 P *parameter
00087 , typename WeakCallbackInfo<P>::Callback callback
00088 , WeakCallbackType type) {
00089 reinterpret_cast<Persistent<T>*>(this)->SetWeak(
00090 parameter, callback, type);
00091 }
00092 };
00093 #else
00094 template<typename T>
00095 class Global : public v8::UniquePersistent<T> {
00096 public:
00097 inline Global() : v8::UniquePersistent<T>() {}
00098
00099 template<typename S> inline Global(v8::Local<S> that) :
00100 v8::UniquePersistent<T>(v8::Isolate::GetCurrent(), that) {}
00101
00102 template<typename S>
00103 inline Global(const v8::PersistentBase<S> &that) :
00104 v8::UniquePersistent<S>(v8::Isolate::GetCurrent(), that) {}
00105
00106 inline void Reset() { v8::PersistentBase<T>::Reset(); }
00107
00108 template <typename S>
00109 inline void Reset(const v8::Local<S> &other) {
00110 v8::PersistentBase<T>::Reset(v8::Isolate::GetCurrent(), other);
00111 }
00112
00113 template <typename S>
00114 inline void Reset(const v8::PersistentBase<S> &other) {
00115 v8::PersistentBase<T>::Reset(v8::Isolate::GetCurrent(), other);
00116 }
00117
00118 template<typename P>
00119 inline void SetWeak(
00120 P *parameter
00121 , typename WeakCallbackInfo<P>::Callback callback
00122 , WeakCallbackType type) {
00123 reinterpret_cast<Persistent<T>*>(this)->SetWeak(
00124 parameter, callback, type);
00125 }
00126 };
00127 #endif
00128
00129 #endif // NAN_PERSISTENT_12_INL_H_