Skip to content

Commit

Permalink
squash: fix compiler warning 07_passing_wrapped_ob
Browse files Browse the repository at this point in the history
Currently the following compiler warning is emitted:
1 warning generated.
../addon.cc:24:16:
warning: 'ToObject' is deprecated:
Use maybe version [-Wdeprecated-declarations]
      args[0]->ToObject(isolate));
               ^
./deps/v8/include/v8.h:2539:3:
note: 'ToObject' has been explicitly marked deprecated here
  V8_DEPRECATED("Use maybe version",
  ^

This commit updates example to use the non-deprecated version.
  • Loading branch information
danbev committed Oct 9, 2018
1 parent 6e1fdb8 commit 0a0dc00
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions doc/api/addons.md
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,7 @@ that can take two `MyObject` objects as input arguments:

namespace demo {

using v8::Context;
using v8::FunctionCallbackInfo;
using v8::Isolate;
using v8::Local;
Expand All @@ -1095,11 +1096,12 @@ void CreateObject(const FunctionCallbackInfo<Value>& args) {

void Add(const FunctionCallbackInfo<Value>& args) {
Isolate* isolate = args.GetIsolate();
Local<Context> context = isolate->GetCurrentContext();

MyObject* obj1 = node::ObjectWrap::Unwrap<MyObject>(
args[0]->ToObject(isolate));
args[0]->ToObject(context).ToLocalChecked());
MyObject* obj2 = node::ObjectWrap::Unwrap<MyObject>(
args[1]->ToObject(isolate));
args[1]->ToObject(context).ToLocalChecked());

double sum = obj1->value() + obj2->value();
args.GetReturnValue().Set(Number::New(isolate, sum));
Expand Down

0 comments on commit 0a0dc00

Please sign in to comment.