From 6e1fdb818751005df80ab0c88b659bc393673436 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Mon, 8 Oct 2018 07:28:11 +0200 Subject: [PATCH 1/2] test: fix compiler warning in addons/02_callbacks Currently the following compiler warning is emitted: ../addon.cc:17:58: warning: 'ToString' is deprecated: Use maybe version [-Wdeprecated-declarations] obj->Set(String::NewFromUtf8(isolate, "msg"), args[0]->ToString(isolate)); ^ deps/v8/include/v8.h:2537:3: note: 'ToString' has been explicitly marked deprecated here V8_DEPRECATED("Use maybe version", ^ This commit updates example to use the non-deprecated version. --- doc/api/addons.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/api/addons.md b/doc/api/addons.md index b2c52d5128b5bc..6c448d690be686 100644 --- a/doc/api/addons.md +++ b/doc/api/addons.md @@ -587,6 +587,7 @@ property `msg` that echoes the string passed to `createObject()`: namespace demo { +using v8::Context; using v8::FunctionCallbackInfo; using v8::Isolate; using v8::Local; @@ -596,9 +597,11 @@ using v8::Value; void CreateObject(const FunctionCallbackInfo& args) { Isolate* isolate = args.GetIsolate(); + Local context = isolate->GetCurrentContext(); Local obj = Object::New(isolate); - obj->Set(String::NewFromUtf8(isolate, "msg"), args[0]->ToString(isolate)); + obj->Set(String::NewFromUtf8(isolate, "msg"), + args[0]->ToString(context).ToLocalChecked()); args.GetReturnValue().Set(obj); } From 0a0dc00bba8d8e10b74e3238a4fc87d45f72a606 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Mon, 8 Oct 2018 07:28:11 +0200 Subject: [PATCH 2/2] squash: fix compiler warning 07_passing_wrapped_ob 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. --- doc/api/addons.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/api/addons.md b/doc/api/addons.md index 6c448d690be686..757f24c5194271 100644 --- a/doc/api/addons.md +++ b/doc/api/addons.md @@ -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; @@ -1095,11 +1096,12 @@ void CreateObject(const FunctionCallbackInfo& args) { void Add(const FunctionCallbackInfo& args) { Isolate* isolate = args.GetIsolate(); + Local context = isolate->GetCurrentContext(); MyObject* obj1 = node::ObjectWrap::Unwrap( - args[0]->ToObject(isolate)); + args[0]->ToObject(context).ToLocalChecked()); MyObject* obj2 = node::ObjectWrap::Unwrap( - args[1]->ToObject(isolate)); + args[1]->ToObject(context).ToLocalChecked()); double sum = obj1->value() + obj2->value(); args.GetReturnValue().Set(Number::New(isolate, sum));