diff --git a/nan_persistent_12_inl.h b/nan_persistent_12_inl.h index 7779bdcc..1c26f85b 100644 --- a/nan_persistent_12_inl.h +++ b/nan_persistent_12_inl.h @@ -84,8 +84,9 @@ template class PersistentBase { private: NAN_INLINE PersistentBase() : persistent() {} - NAN_INLINE explicit PersistentBase(v8::Persistent that) : - persistent(v8::Isolate::GetCurrent(), that) { } + NAN_INLINE explicit PersistentBase(v8::Persistent that) { + std::memcpy(&that, &persistent, sizeof (v8::Persistent)); + } NAN_INLINE explicit PersistentBase(v8::Local that) : persistent(v8::Isolate::GetCurrent(), that) { } template friend class Persistent; @@ -181,12 +182,12 @@ class Global : public PersistentBase { template NAN_INLINE Global(const PersistentBase& that) - : PersistentBase(that) { + : PersistentBase(v8::Persistent(v8::Isolate::GetCurrent(), that.persistent)) { TYPE_CHECK(T, S); } NAN_INLINE Global(Global&& other) : PersistentBase(other.persistent) { - other.Reset(); + other.Empty(); } NAN_INLINE ~Global() { this->Reset(); } @@ -195,8 +196,8 @@ class Global : public PersistentBase { NAN_INLINE Global& operator=(Global&& rhs) { TYPE_CHECK(T, S); if (this != &rhs) { - this->Reset(rhs.persistent); - rhs.Reset(); + std::memcpy(&rhs.persistent, &this->persistent, sizeof (v8::PersistentBase)); + rhs.Empty(); } return *this; } @@ -226,7 +227,7 @@ class Global : public PersistentBase { template NAN_INLINE Global(const PersistentBase &that) - : PersistentBase(that) { + : PersistentBase(v8::Persistent(v8::Isolate::GetCurrent(), that.persistent)) { TYPE_CHECK(T, S); } @@ -234,8 +235,8 @@ class Global : public PersistentBase { * Move constructor. */ NAN_INLINE Global(RValue rvalue) - : PersistentBase(rvalue.object.persistent) { - rvalue.object->Reset(); + : PersistentBase(rvalue.object->persistent) { + rvalue.object->Empty(); } NAN_INLINE ~Global() { this->Reset(); } @@ -246,8 +247,8 @@ class Global : public PersistentBase { template NAN_INLINE Global &operator=(Global rhs) { TYPE_CHECK(T, S); - this->Reset(rhs.persistent); - rhs.Reset(); + std::memcpy(&rhs.persistent, &this->persistent, sizeof (v8::Persistent)); + rhs.Empty(); return *this; } diff --git a/nan_persistent_pre_12_inl.h b/nan_persistent_pre_12_inl.h index 2b212159..a5692809 100644 --- a/nan_persistent_pre_12_inl.h +++ b/nan_persistent_pre_12_inl.h @@ -207,7 +207,7 @@ class Global : public PersistentBase { template NAN_INLINE Global(const PersistentBase &that) - : PersistentBase(that) { + : PersistentBase(v8::Peristent::New(that.persistent)) { TYPE_CHECK(T, S); } /** @@ -215,7 +215,7 @@ class Global : public PersistentBase { */ NAN_INLINE Global(RValue rvalue) : PersistentBase(rvalue.object.persistent) { - rvalue.object->Reset(); + rvalue.object->Clear(); } NAN_INLINE ~Global() { this->Reset(); } /** @@ -224,8 +224,8 @@ class Global : public PersistentBase { template NAN_INLINE Global &operator=(Global rhs) { TYPE_CHECK(T, S); - this->Reset(rhs.persistent); - rhs.Reset(); + this->persistent = rhs.persistent; + rhs.Clear(); return *this; } /**