Skip to content

Commit

Permalink
deps: adapt to V8 7.0 (#808)
Browse files Browse the repository at this point in the history
adapt to V8 7.0
  • Loading branch information
refack authored and kkoopa committed Sep 29, 2018
1 parent 2865d21 commit 24a22c3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions nan.h
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,11 @@ 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());
#else
v8::Local<v8::String> string = from->ToString();
#endif
if (!string.IsEmpty()) {
size_t len = 3 * string->Length() + 1;
assert(len <= INT_MAX);
Expand All @@ -1070,7 +1074,11 @@ class Utf8String {
}
const int flags =
v8::String::NO_NULL_TERMINATION | imp::kReplaceInvalidUtf8;
#if V8_MAJOR_VERSION >= 7
length_ = string->WriteUtf8(v8::Isolate::GetCurrent(), str_, static_cast<int>(len), 0, flags);
#else
length_ = string->WriteUtf8(str_, static_cast<int>(len), 0, flags);
#endif
str_[length_] = '\0';
}
}
Expand Down
4 changes: 4 additions & 0 deletions nan_implementation_12_inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,11 @@ 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
return v8::StringObject::New(v8::Isolate::GetCurrent(), value).As<v8::StringObject>();
#else
return v8::StringObject::New(value).As<v8::StringObject>();
#endif
}

//=== Unbound Script ===========================================================
Expand Down

0 comments on commit 24a22c3

Please sign in to comment.