From 22dd1e0444fcca71bb0d37531a782d5aa8b63bb9 Mon Sep 17 00:00:00 2001 From: Benjamin Byholm Date: Mon, 26 Aug 2024 18:50:21 +0300 Subject: [PATCH] fix --- nan_callbacks_12_inl.h | 46 +++++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/nan_callbacks_12_inl.h b/nan_callbacks_12_inl.h index 79f1d030..eea99d90 100644 --- a/nan_callbacks_12_inl.h +++ b/nan_callbacks_12_inl.h @@ -9,9 +9,31 @@ #ifndef NAN_CALLBACKS_12_INL_H_ #define NAN_CALLBACKS_12_INL_H_ +#if defined(V8_MAJOR_VERSION) && \ + (V8_MAJOR_VERSION > 12 || \ + (V8_MAJOR_VERSION == 12 && defined(V8_MINOR_VERSION) && \ + (V8_MINOR_VERSION > 6 || \ + V8_MINOR_VERSION == 6 && V8_BUILD_NUMBER >= 74))) +template +class ReturnValue; + +namespace imp { +template +v8::Local imp::GetReturnValue(const ReturnValue &); +} +#endif + template class ReturnValue { v8::ReturnValue value_; +#if defined(V8_MAJOR_VERSION) && \ + (V8_MAJOR_VERSION > 12 || \ + (V8_MAJOR_VERSION == 12 && defined(V8_MINOR_VERSION) && \ + (V8_MINOR_VERSION > 6 || \ + V8_MINOR_VERSION == 6 && V8_BUILD_NUMBER >= 74))) + template + friend v8::Local imp::GetReturnValue(const ReturnValue &rv); +#endif public: template @@ -262,6 +284,12 @@ typedef void (*NativeSetter)( (V8_MAJOR_VERSION == 12 && defined(V8_MINOR_VERSION) && \ (V8_MINOR_VERSION > 6 || \ V8_MINOR_VERSION == 6 && V8_BUILD_NUMBER >= 74))) + +template +inline v8::Local GetReturnValue(const ReturnValue &rv) { + return rv.value_.Get(); +} + static v8::Intercepted PropertyGetterCallbackWrapper( v8::Local property @@ -274,7 +302,7 @@ v8::Intercepted PropertyGetterCallbackWrapper( obj->GetInternalField(kPropertyGetterIndex) .As().As()->Value())); callback(property.As(), cbinfo); - return cbinfo.GetReturnValue().Get() == + return imp::GetReturnValue(cbinfo.GetReturnValue()) == v8::Undefined(v8::Isolate::GetCurrent()) ? v8::Intercepted::kNo : v8::Intercepted::kYes; @@ -319,7 +347,7 @@ v8::Intercepted PropertySetterCallbackWrapper( obj->GetInternalField(kPropertySetterIndex) .As().As()->Value())); callback(property.As(), value, cbinfo); - return cbinfo.GetReturnValue().Get() == + return imp::GetReturnValue(cbinfo.GetReturnValue()) == v8::Undefined(v8::Isolate::GetCurrent()) ? v8::Intercepted::kNo : v8::Intercepted::kYes; @@ -384,13 +412,13 @@ v8::Intercepted PropertyDeleterCallbackWrapper( obj->GetInternalField(kPropertyDeleterIndex) .As().As()->Value())); callback(property.As(), cbinfo); - return cbinfo.GetReturnValue().Get() == + return imp::GetReturnValue(cbinfo.GetReturnValue()) == v8::Undefined(v8::Isolate::GetCurrent()) ? v8::Intercepted::kNo : v8::Intercepted::kYes; } -typedef v8::Intercepted (NativePropertyDeleter) +typedef v8::Intercepted (*NativePropertyDeleter) (v8::Local, const v8::PropertyCallbackInfo &); #else static @@ -428,7 +456,7 @@ v8::Intercepted PropertyQueryCallbackWrapper( obj->GetInternalField(kPropertyQueryIndex) .As().As()->Value())); callback(property.As(), cbinfo); - return cbinfo.GetReturnValue().Get() == + return imp::GetReturnValue(cbinfo.GetReturnValue()) == v8::Undefined(v8::Isolate::GetCurrent()) ? v8::Intercepted::kNo : v8::Intercepted::kYes; @@ -559,7 +587,7 @@ v8::Intercepted IndexGetterCallbackWrapper( obj->GetInternalField(kIndexPropertyGetterIndex) .As().As()->Value())); callback(index, cbinfo); - return cbinfo.GetReturnValue().Get() == + return imp::GetReturnValue(cbinfo.GetReturnValue()) == v8::Undefined(v8::Isolate::GetCurrent()) ? v8::Intercepted::kNo : v8::Intercepted::kYes; @@ -603,7 +631,7 @@ v8::Intercepted IndexSetterCallbackWrapper( obj->GetInternalField(kIndexPropertySetterIndex) .As().As()->Value())); callback(index, value, cbinfo); - return cbinfo.GetReturnValue().Get() == + return imp::GetReturnValue(cbinfo.GetReturnValue()) == v8::Undefined(v8::Isolate::GetCurrent()) ? v8::Intercepted::kNo : v8::Intercepted::kYes; @@ -668,7 +696,7 @@ v8::Intercepted IndexDeleterCallbackWrapper( obj->GetInternalField(kIndexPropertyDeleterIndex) .As().As()->Value())); callback(index, cbinfo); - return cbinfo.GetReturnValue().Get() == + return imp::GetReturnValue(cbinfo.GetReturnValue()) == v8::Undefined(v8::Isolate::GetCurrent()) ? v8::Intercepted::kNo : v8::Intercepted::kYes; @@ -710,7 +738,7 @@ v8::Intercepted IndexQueryCallbackWrapper( obj->GetInternalField(kIndexPropertyQueryIndex) .As().As()->Value())); callback(index, cbinfo); - return cbinfo.GetReturnValue().Get() == + return imp::GetReturnValue(cbinfo.GetReturnValue()) == v8::Undefined(v8::Isolate::GetCurrent()) ? v8::Intercepted::kNo : v8::Intercepted::kYes;