Skip to content

Commit d63a550

Browse files
author
Jan Krems
committed
Fix deprecation warnings on node 10.12
node commit: nodejs/node@46c7d0d Fixes #810
1 parent 85a74a1 commit d63a550

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

nan.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@
4848
# error This version of node/NAN/v8 requires a C++11 compiler
4949
#endif
5050

51+
#if NODE_MAJOR_VERSION == 10 && NODE_MINOR_VERSION >= 12
52+
# define NAN_HAS_V8_7_DEPRECATIONS
53+
#endif
54+
5155
#include <uv.h>
5256
#include <node.h>
5357
#include <node_buffer.h>
@@ -1060,8 +1064,9 @@ class Utf8String {
10601064
length_(0), str_(str_st_) {
10611065
HandleScope scope;
10621066
if (!from.IsEmpty()) {
1063-
#if V8_MAJOR_VERSION >= 7
1064-
v8::Local<v8::String> string = from->ToString(v8::Isolate::GetCurrent());
1067+
#if V8_MAJOR_VERSION >= 7 || defined(NAN_HAS_V8_7_DEPRECATIONS)
1068+
v8::Local<v8::String> string = from->ToString(
1069+
v8::Isolate::GetCurrent()->GetCurrentContext()).FromMaybe(v8::Local<v8::String>());
10651070
#else
10661071
v8::Local<v8::String> string = from->ToString();
10671072
#endif
@@ -1074,7 +1079,7 @@ class Utf8String {
10741079
}
10751080
const int flags =
10761081
v8::String::NO_NULL_TERMINATION | imp::kReplaceInvalidUtf8;
1077-
#if V8_MAJOR_VERSION >= 7
1082+
#if V8_MAJOR_VERSION >= 7 || defined(NAN_HAS_V8_7_DEPRECATIONS)
10781083
length_ = string->WriteUtf8(v8::Isolate::GetCurrent(), str_, static_cast<int>(len), 0, flags);
10791084
#else
10801085
length_ = string->WriteUtf8(str_, static_cast<int>(len), 0, flags);

nan_implementation_12_inl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ Factory<v8::String>::New(ExternalOneByteStringResource * value) {
334334

335335
Factory<v8::StringObject>::return_t
336336
Factory<v8::StringObject>::New(v8::Local<v8::String> value) {
337-
#if V8_MAJOR_VERSION >= 7
337+
#if V8_MAJOR_VERSION >= 7 || defined(NAN_HAS_V8_7_DEPRECATIONS)
338338
return v8::StringObject::New(v8::Isolate::GetCurrent(), value).As<v8::StringObject>();
339339
#else
340340
return v8::StringObject::New(value).As<v8::StringObject>();

0 commit comments

Comments
 (0)