Skip to content

Commit 24a22c3

Browse files
refackkkoopa
authored andcommitted
deps: adapt to V8 7.0 (#808)
adapt to V8 7.0
1 parent 2865d21 commit 24a22c3

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

nan.h

+8
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,11 @@ class Utf8String {
10601060
length_(0), str_(str_st_) {
10611061
HandleScope scope;
10621062
if (!from.IsEmpty()) {
1063+
#if V8_MAJOR_VERSION >= 7
1064+
v8::Local<v8::String> string = from->ToString(v8::Isolate::GetCurrent());
1065+
#else
10631066
v8::Local<v8::String> string = from->ToString();
1067+
#endif
10641068
if (!string.IsEmpty()) {
10651069
size_t len = 3 * string->Length() + 1;
10661070
assert(len <= INT_MAX);
@@ -1070,7 +1074,11 @@ class Utf8String {
10701074
}
10711075
const int flags =
10721076
v8::String::NO_NULL_TERMINATION | imp::kReplaceInvalidUtf8;
1077+
#if V8_MAJOR_VERSION >= 7
1078+
length_ = string->WriteUtf8(v8::Isolate::GetCurrent(), str_, static_cast<int>(len), 0, flags);
1079+
#else
10731080
length_ = string->WriteUtf8(str_, static_cast<int>(len), 0, flags);
1081+
#endif
10741082
str_[length_] = '\0';
10751083
}
10761084
}

nan_implementation_12_inl.h

+4
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,11 @@ 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
338+
return v8::StringObject::New(v8::Isolate::GetCurrent(), value).As<v8::StringObject>();
339+
#else
337340
return v8::StringObject::New(value).As<v8::StringObject>();
341+
#endif
338342
}
339343

340344
//=== Unbound Script ===========================================================

0 commit comments

Comments
 (0)