Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix deprecation warnings on node 10.12
Browse files Browse the repository at this point in the history
node commit: nodejs/node@46c7d0d

Fixes nodejs#810
Jan Krems committed Oct 11, 2018
1 parent 85a74a1 commit 44eaa1c
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions nan.h
Original file line number Diff line number Diff line change
@@ -48,6 +48,10 @@
# error This version of node/NAN/v8 requires a C++11 compiler
#endif

#if NODE_MAJOR_VERSION == 10 && NODE_MINOR_VERSION >= 12
# define NAN_HAS_V8_7_DEPRECATIONS
#endif

#include <uv.h>
#include <node.h>
#include <node_buffer.h>
@@ -1060,8 +1064,9 @@ class Utf8String {
length_(0), str_(str_st_) {
HandleScope scope;
if (!from.IsEmpty()) {
#if V8_MAJOR_VERSION >= 7
v8::Local<v8::String> string = from->ToString(v8::Isolate::GetCurrent());
#if V8_MAJOR_VERSION >= 7 || defined(NAN_HAS_V8_7_DEPRECATIONS)
v8::Local<v8::String> string = from->ToString(
v8::Isolate::GetCurrent()->GetCurrentContext()).FromMaybe(v8::Local<v8::String>());
#else
v8::Local<v8::String> string = from->ToString();
#endif
@@ -1074,7 +1079,7 @@ class Utf8String {
}
const int flags =
v8::String::NO_NULL_TERMINATION | imp::kReplaceInvalidUtf8;
#if V8_MAJOR_VERSION >= 7
#if V8_MAJOR_VERSION >= 7 || (V8_MAJOR_VERSION == 6 && V8_MINOR_VERSION >= 8)
length_ = string->WriteUtf8(v8::Isolate::GetCurrent(), str_, static_cast<int>(len), 0, flags);
#else
length_ = string->WriteUtf8(str_, static_cast<int>(len), 0, flags);
2 changes: 1 addition & 1 deletion nan_implementation_12_inl.h
Original file line number Diff line number Diff line change
@@ -334,7 +334,7 @@ Factory<v8::String>::New(ExternalOneByteStringResource * value) {

Factory<v8::StringObject>::return_t
Factory<v8::StringObject>::New(v8::Local<v8::String> value) {
#if V8_MAJOR_VERSION >= 7
#if V8_MAJOR_VERSION >= 7 || defined(NAN_HAS_V8_7_DEPRECATIONS)
return v8::StringObject::New(v8::Isolate::GetCurrent(), value).As<v8::StringObject>();
#else
return v8::StringObject::New(value).As<v8::StringObject>();

0 comments on commit 44eaa1c

Please sign in to comment.