Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix new versions not to use WeakCallbackInfo::IsFirstPass #569

Merged
merged 1 commit into from
May 28, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions nan_weak.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool isFirstPass>
static void invokeparameter(NAN_WEAK_PARAMETER_CALLBACK_SIG_ data);
template<bool isFirstPass>
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(
Expand All @@ -104,25 +112,27 @@ class WeakCallbackInfo {
(V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))

template<typename T>
template<bool isFirstPass>
void
WeakCallbackInfo<T>::invokeparameter(NAN_WEAK_PARAMETER_CALLBACK_SIG_ data) {
WeakCallbackInfo<T> *cbinfo = unwrapparameter(data);
if (data.IsFirstPass()) {
if (isFirstPass) {
cbinfo->persistent_.Reset();
data.SetSecondPassCallback(invokeparameter);
data.SetSecondPassCallback(invokeparameter<false>);
} else {
cbinfo->callback_(*cbinfo);
delete cbinfo;
}
}

template<typename T>
template<bool isFirstPass>
void
WeakCallbackInfo<T>::invoketwofield(NAN_WEAK_TWOFIELD_CALLBACK_SIG_ data) {
WeakCallbackInfo<T> *cbinfo = unwraptwofield(data);
if (data.IsFirstPass()) {
if (isFirstPass) {
cbinfo->persistent_.Reset();
data.SetSecondPassCallback(invoketwofield);
data.SetSecondPassCallback(invoketwofield<false>);
} else {
cbinfo->callback_(*cbinfo);
delete cbinfo;
Expand Down Expand Up @@ -257,7 +267,7 @@ NAN_INLINE void Persistent<T, M>::SetWeak(
, parameter);
v8::PersistentBase<T>::SetWeak(
wcbd
, WeakCallbackInfo<P>::invokeparameter
, WeakCallbackInfo<P>::template invokeparameter<true>
, type);
} else {
v8::Local<T>* self = reinterpret_cast<v8::Local<T>*>(this);
Expand All @@ -276,7 +286,7 @@ NAN_INLINE void Persistent<T, M>::SetWeak(
(*self)->SetAlignedPointerInInternalField(0, wcbd);
v8::PersistentBase<T>::SetWeak(
static_cast<WeakCallbackInfo<P>*>(0)
, WeakCallbackInfo<P>::invoketwofield
, WeakCallbackInfo<P>::template invoketwofield<true>
, type);
}
}
Expand Down