Skip to content

Commit

Permalink
Remove V8 deprecation warnings (#568)
Browse files Browse the repository at this point in the history
* Remove V8 deprecation warnings

Current deprecation warnings on Node v6 are SetAccessor, CloneElementAt,
and BooleanObject::New.
  • Loading branch information
matthewloring authored and kkoopa committed May 28, 2016
1 parent 5cd24f7 commit 0592fb0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
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

0 comments on commit 0592fb0

Please sign in to comment.