From 615c19d9e03d4be2049c10db0151edbc3b229246 Mon Sep 17 00:00:00 2001 From: Benjamin Byholm Date: Sat, 28 May 2016 18:28:23 +0300 Subject: [PATCH] Fix new versions not to use WeakCallbackInfo::IsFirstPass (#569) --- nan_weak.h | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/nan_weak.h b/nan_weak.h index ed3f92e2..25dde955 100644 --- a/nan_weak.h +++ b/nan_weak.h @@ -90,8 +90,16 @@ class WeakCallbackInfo { static WeakCallbackInfo *unwrap(NAN_WEAK_CALLBACK_DATA_TYPE_ data); # endif #else +# if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \ + (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3)) + template + static void invokeparameter(NAN_WEAK_PARAMETER_CALLBACK_SIG_ data); + template + static void invoketwofield(NAN_WEAK_TWOFIELD_CALLBACK_SIG_ data); +# else static void invokeparameter(NAN_WEAK_PARAMETER_CALLBACK_SIG_ data); static void invoketwofield(NAN_WEAK_TWOFIELD_CALLBACK_SIG_ data); +# endif static WeakCallbackInfo *unwrapparameter( NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_ data); static WeakCallbackInfo *unwraptwofield( @@ -104,12 +112,13 @@ class WeakCallbackInfo { (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3)) template +template void WeakCallbackInfo::invokeparameter(NAN_WEAK_PARAMETER_CALLBACK_SIG_ data) { WeakCallbackInfo *cbinfo = unwrapparameter(data); - if (data.IsFirstPass()) { + if (isFirstPass) { cbinfo->persistent_.Reset(); - data.SetSecondPassCallback(invokeparameter); + data.SetSecondPassCallback(invokeparameter); } else { cbinfo->callback_(*cbinfo); delete cbinfo; @@ -117,12 +126,13 @@ WeakCallbackInfo::invokeparameter(NAN_WEAK_PARAMETER_CALLBACK_SIG_ data) { } template +template void WeakCallbackInfo::invoketwofield(NAN_WEAK_TWOFIELD_CALLBACK_SIG_ data) { WeakCallbackInfo *cbinfo = unwraptwofield(data); - if (data.IsFirstPass()) { + if (isFirstPass) { cbinfo->persistent_.Reset(); - data.SetSecondPassCallback(invoketwofield); + data.SetSecondPassCallback(invoketwofield); } else { cbinfo->callback_(*cbinfo); delete cbinfo; @@ -257,7 +267,7 @@ NAN_INLINE void Persistent::SetWeak( , parameter); v8::PersistentBase::SetWeak( wcbd - , WeakCallbackInfo

::invokeparameter + , WeakCallbackInfo

::template invokeparameter , type); } else { v8::Local* self = reinterpret_cast*>(this); @@ -276,7 +286,7 @@ NAN_INLINE void Persistent::SetWeak( (*self)->SetAlignedPointerInInternalField(0, wcbd); v8::PersistentBase::SetWeak( static_cast*>(0) - , WeakCallbackInfo

::invoketwofield + , WeakCallbackInfo

::template invoketwofield , type); } }