From 8135021f49150e27faba6eee23171b38f94afd3c Mon Sep 17 00:00:00 2001 From: Gerhard Stoebich <18708370+Flarna@users.noreply.github.com> Date: Sun, 16 Dec 2018 17:30:29 +0100 Subject: [PATCH] add support for node master --- nan_converters_43_inl.h | 22 ++++++++++++++++++++-- nan_implementation_12_inl.h | 4 ++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/nan_converters_43_inl.h b/nan_converters_43_inl.h index 742f5432..ef483e50 100644 --- a/nan_converters_43_inl.h +++ b/nan_converters_43_inl.h @@ -19,13 +19,22 @@ imp::ToFactory::convert(v8::Local val) { \ .FromMaybe(v8::Local())); \ } -X(Boolean) X(Number) X(String) X(Object) X(Integer) X(Uint32) X(Int32) +#if NODE_MODULE_VERSION <= NODE_11_0_MODULE_VERSION +X(Boolean) +#else +imp::ToFactory::return_t \ +imp::ToFactory::convert(v8::Local val) { \ + v8::Isolate *isolate = v8::Isolate::GetCurrent(); \ + v8::EscapableHandleScope scope(isolate); \ + return scope.Escape(val->ToBoolean(isolate)); \ +} +#endif #undef X @@ -37,11 +46,20 @@ imp::ToFactory::convert(v8::Local val) { \ return val->NAME ## Value(isolate->GetCurrentContext()); \ } -X(bool, Boolean) X(double, Number) X(int64_t, Integer) X(uint32_t, Uint32) X(int32_t, Int32) +#if NODE_MODULE_VERSION <= NODE_11_0_MODULE_VERSION +X(bool, Boolean) +#else +imp::ToFactory::return_t \ +imp::ToFactory::convert(v8::Local val) { \ + v8::Isolate *isolate = v8::Isolate::GetCurrent(); \ + v8::HandleScope scope(isolate); \ + return Just(val->BooleanValue(isolate)); \ +} +#endif #undef X diff --git a/nan_implementation_12_inl.h b/nan_implementation_12_inl.h index 6d68ed50..9af2629e 100644 --- a/nan_implementation_12_inl.h +++ b/nan_implementation_12_inl.h @@ -345,6 +345,9 @@ Factory::New(ExternalOneByteStringResource * value) { // TODO(bnoordhuis) Use isolate-based version in Node.js v12. Factory::return_t Factory::New(v8::Local value) { +#if NODE_MODULE_VERSION > NODE_11_0_MODULE_VERSION + return v8::StringObject::New(v8::Isolate::GetCurrent(), value).As(); +#else #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable : 4996) @@ -360,6 +363,7 @@ Factory::New(v8::Local value) { #ifdef _MSC_VER #pragma warning(pop) #endif +#endif } //=== Unbound Script ===========================================================