diff --git a/nan_callbacks.h b/nan_callbacks.h index 2c54857f..2eb76fc0 100644 --- a/nan_callbacks.h +++ b/nan_callbacks.h @@ -13,6 +13,19 @@ template class FunctionCallbackInfo; template class PropertyCallbackInfo; template class Global; +#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 12 || \ + (V8_MAJOR_VERSION == 12 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION > 4)) +namespace Intercepted { + constexpr v8::Intercepted No() { return v8::Intercepted::kNo; } + constexpr v8::Intercepted Yes() { return v8::Intercepted::kYes; } +}; +#else +namespace Intercepted { + inline void No() {} + inline void Yes() {} +}; +#endif + typedef void(*FunctionCallback)(const FunctionCallbackInfo&); typedef void(*GetterCallback) (v8::Local, const PropertyCallbackInfo&); diff --git a/test/cpp/indexedinterceptors.cpp b/test/cpp/indexedinterceptors.cpp index f2cd97ac..700523f4 100644 --- a/test/cpp/indexedinterceptors.cpp +++ b/test/cpp/indexedinterceptors.cpp @@ -80,6 +80,7 @@ NAN_INDEX_GETTER(IndexedInterceptor::PropertyGetter) { } else { info.GetReturnValue().Set(Nan::New("bar").ToLocalChecked()); } + return Intercepted::Yes(); } NAN_INDEX_SETTER(IndexedInterceptor::PropertySetter) { @@ -94,12 +95,14 @@ NAN_INDEX_SETTER(IndexedInterceptor::PropertySetter) { } else { info.GetReturnValue().Set(info.This()); } + return Intercepted::Yes(); } NAN_INDEX_ENUMERATOR(IndexedInterceptor::PropertyEnumerator) { v8::Local arr = Nan::New(); Set(arr, 0, Nan::New(42)); info.GetReturnValue().Set(arr); + return Intercepted::Yes(); } NAN_INDEX_DELETER(IndexedInterceptor::PropertyDeleter) { @@ -107,15 +110,19 @@ NAN_INDEX_DELETER(IndexedInterceptor::PropertyDeleter) { ObjectWrap::Unwrap(info.Holder()); std::strncpy(interceptor->buf, "goober", sizeof (interceptor->buf)); info.GetReturnValue().Set(True()); + return Intercepted::Yes(); } NAN_INDEX_QUERY(IndexedInterceptor::PropertyQuery) { if (index == 1) { info.GetReturnValue().Set(Nan::New(v8::DontEnum)); + return Intercepted::Yes(); } if (index == 42) { info.GetReturnValue().Set(Nan::New(0)); + return Intercepted::Yes(); } + return Intercepted::No(); } NODE_MODULE(indexedinterceptors, IndexedInterceptor::Init) diff --git a/test/cpp/namedinterceptors.cpp b/test/cpp/namedinterceptors.cpp index 8ab5f47d..a846de7e 100644 --- a/test/cpp/namedinterceptors.cpp +++ b/test/cpp/namedinterceptors.cpp @@ -80,6 +80,7 @@ NAN_PROPERTY_GETTER(NamedInterceptor::PropertyGetter) { } else { info.GetReturnValue().Set(Nan::New("bar").ToLocalChecked()); } + return Intercepted::Yes(); } NAN_PROPERTY_SETTER(NamedInterceptor::PropertySetter) { @@ -94,6 +95,7 @@ NAN_PROPERTY_SETTER(NamedInterceptor::PropertySetter) { } else { info.GetReturnValue().Set(info.This()); } + return Intercepted::Yes(); } NAN_PROPERTY_ENUMERATOR(NamedInterceptor::PropertyEnumerator) { @@ -107,16 +109,20 @@ NAN_PROPERTY_DELETER(NamedInterceptor::PropertyDeleter) { ObjectWrap::Unwrap(info.Holder()); std::strncpy(interceptor->buf, "goober", sizeof (interceptor->buf)); info.GetReturnValue().Set(True()); + return Intercepted::Yes(); } NAN_PROPERTY_QUERY(NamedInterceptor::PropertyQuery) { Nan::Utf8String s(property); if (!std::strcmp(*s, "thing")) { - return info.GetReturnValue().Set(Nan::New(v8::DontEnum)); + info.GetReturnValue().Set(Nan::New(v8::DontEnum)); + return Intercepted::Yes(); } if (!std::strcmp(*s, "value")) { - return info.GetReturnValue().Set(Nan::New(0)); + info.GetReturnValue().Set(Nan::New(0)); + return Intercepted::Yes(); } + return Intercepted::No(); } NODE_MODULE(namedinterceptors, NamedInterceptor::Init)