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

Remove V8 deprecation warnings #568

Merged
merged 3 commits into from
May 28, 2016
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
11 changes: 11 additions & 0 deletions nan.h
Original file line number Diff line number Diff line change
Expand Up @@ -1986,13 +1986,24 @@ inline bool SetAccessor(
, New<v8::External>(reinterpret_cast<void *>(setter)));
}

#if (NODE_MODULE_VERSION >= NODE_6_0_MODULE_VERSION)
return obj->SetAccessor(
GetCurrentContext()
, name
, getter_
, setter_
, dataobj
, settings
, attribute).FromMaybe(false);
#else
return obj->SetAccessor(
name
, getter_
, setter_
, dataobj
, settings
, attribute);
#endif
}

inline void SetNamedPropertyHandler(
Expand Down
5 changes: 5 additions & 0 deletions nan_implementation_12_inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ Factory<v8::Boolean>::New(bool value) {

Factory<v8::BooleanObject>::return_t
Factory<v8::BooleanObject>::New(bool value) {
#if (NODE_MODULE_VERSION >= NODE_6_0_MODULE_VERSION)
return v8::BooleanObject::New(
v8::Isolate::GetCurrent(), value).As<v8::BooleanObject>();
#else
return v8::BooleanObject::New(value).As<v8::BooleanObject>();
#endif
}

//=== Context ==================================================================
Expand Down
16 changes: 15 additions & 1 deletion nan_maybe_43_inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,21 @@ NAN_INLINE Maybe<int> GetEndColumn(v8::Local<v8::Message> msg) {
NAN_INLINE MaybeLocal<v8::Object> CloneElementAt(
v8::Local<v8::Array> array
, uint32_t index) {
return array->CloneElementAt(GetCurrentContext(), index);
v8::EscapableHandleScope handle_scope(v8::Isolate::GetCurrent());
v8::Local<v8::Context> context = GetCurrentContext();
#if (NODE_MODULE_VERSION >= NODE_6_0_MODULE_VERSION)
v8::Local<v8::Value> elem;
if (!array->Get(context, index).ToLocal(&elem)) {
return MaybeLocal<v8::Object>();
}
v8::Local<v8::Object> obj;
if (!elem->ToObject(context).ToLocal(&obj)) {
return MaybeLocal<v8::Object>();
}
return handle_scope.Escape(obj->Clone());
#else
return handle_scope.Escape(array->CloneElementAt(context, index));
#endif
}

NAN_INLINE MaybeLocal<v8::Value> Call(
Expand Down