Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: adapt to V8 7.0 #808

Merged
merged 2 commits into from
Sep 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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