Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kkoopa committed Aug 26, 2024
1 parent 7d3007b commit 22dd1e0
Showing 1 changed file with 37 additions and 9 deletions.
46 changes: 37 additions & 9 deletions nan_callbacks_12_inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<typename T>
class ReturnValue;

namespace imp {
template<typename T>
v8::Local<T> imp::GetReturnValue(const ReturnValue<T> &);
}
#endif

template<typename T>
class ReturnValue {
v8::ReturnValue<T> 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<typename S>
friend v8::Local<S> imp::GetReturnValue(const ReturnValue<S> &rv);
#endif

public:
template <class S>
Expand Down Expand Up @@ -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<typename T>
inline v8::Local<T> GetReturnValue(const ReturnValue<T> &rv) {
return rv.value_.Get();
}

static
v8::Intercepted PropertyGetterCallbackWrapper(
v8::Local<v8::Name> property
Expand All @@ -274,7 +302,7 @@ v8::Intercepted PropertyGetterCallbackWrapper(
obj->GetInternalField(kPropertyGetterIndex)
.As<v8::Value>().As<v8::External>()->Value()));
callback(property.As<v8::String>(), cbinfo);
return cbinfo.GetReturnValue().Get() ==
return imp::GetReturnValue(cbinfo.GetReturnValue()) ==
v8::Undefined(v8::Isolate::GetCurrent())
? v8::Intercepted::kNo
: v8::Intercepted::kYes;
Expand Down Expand Up @@ -319,7 +347,7 @@ v8::Intercepted PropertySetterCallbackWrapper(
obj->GetInternalField(kPropertySetterIndex)
.As<v8::Value>().As<v8::External>()->Value()));
callback(property.As<v8::String>(), value, cbinfo);
return cbinfo.GetReturnValue().Get() ==
return imp::GetReturnValue(cbinfo.GetReturnValue()) ==
v8::Undefined(v8::Isolate::GetCurrent())
? v8::Intercepted::kNo
: v8::Intercepted::kYes;
Expand Down Expand Up @@ -384,13 +412,13 @@ v8::Intercepted PropertyDeleterCallbackWrapper(
obj->GetInternalField(kPropertyDeleterIndex)
.As<v8::Value>().As<v8::External>()->Value()));
callback(property.As<v8::String>(), 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<v8::Name>, const v8::PropertyCallbackInfo<v8::Boolean> &);
#else
static
Expand Down Expand Up @@ -428,7 +456,7 @@ v8::Intercepted PropertyQueryCallbackWrapper(
obj->GetInternalField(kPropertyQueryIndex)
.As<v8::Value>().As<v8::External>()->Value()));
callback(property.As<v8::String>(), cbinfo);
return cbinfo.GetReturnValue().Get() ==
return imp::GetReturnValue(cbinfo.GetReturnValue()) ==
v8::Undefined(v8::Isolate::GetCurrent())
? v8::Intercepted::kNo
: v8::Intercepted::kYes;
Expand Down Expand Up @@ -559,7 +587,7 @@ v8::Intercepted IndexGetterCallbackWrapper(
obj->GetInternalField(kIndexPropertyGetterIndex)
.As<v8::Value>().As<v8::External>()->Value()));
callback(index, cbinfo);
return cbinfo.GetReturnValue().Get() ==
return imp::GetReturnValue(cbinfo.GetReturnValue()) ==
v8::Undefined(v8::Isolate::GetCurrent())
? v8::Intercepted::kNo
: v8::Intercepted::kYes;
Expand Down Expand Up @@ -603,7 +631,7 @@ v8::Intercepted IndexSetterCallbackWrapper(
obj->GetInternalField(kIndexPropertySetterIndex)
.As<v8::Value>().As<v8::External>()->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;
Expand Down Expand Up @@ -668,7 +696,7 @@ v8::Intercepted IndexDeleterCallbackWrapper(
obj->GetInternalField(kIndexPropertyDeleterIndex)
.As<v8::Value>().As<v8::External>()->Value()));
callback(index, cbinfo);
return cbinfo.GetReturnValue().Get() ==
return imp::GetReturnValue(cbinfo.GetReturnValue()) ==
v8::Undefined(v8::Isolate::GetCurrent())
? v8::Intercepted::kNo
: v8::Intercepted::kYes;
Expand Down Expand Up @@ -710,7 +738,7 @@ v8::Intercepted IndexQueryCallbackWrapper(
obj->GetInternalField(kIndexPropertyQueryIndex)
.As<v8::Value>().As<v8::External>()->Value()));
callback(index, cbinfo);
return cbinfo.GetReturnValue().Get() ==
return imp::GetReturnValue(cbinfo.GetReturnValue()) ==
v8::Undefined(v8::Isolate::GetCurrent())
? v8::Intercepted::kNo
: v8::Intercepted::kYes;
Expand Down

0 comments on commit 22dd1e0

Please sign in to comment.