Skip to content

Commit 6e1fdb8

Browse files
committed
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.
1 parent 2ec57a7 commit 6e1fdb8

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

doc/api/addons.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,7 @@ property `msg` that echoes the string passed to `createObject()`:
587587

588588
namespace demo {
589589

590+
using v8::Context;
590591
using v8::FunctionCallbackInfo;
591592
using v8::Isolate;
592593
using v8::Local;
@@ -596,9 +597,11 @@ using v8::Value;
596597

597598
void CreateObject(const FunctionCallbackInfo<Value>& args) {
598599
Isolate* isolate = args.GetIsolate();
600+
Local<Context> context = isolate->GetCurrentContext();
599601

600602
Local<Object> obj = Object::New(isolate);
601-
obj->Set(String::NewFromUtf8(isolate, "msg"), args[0]->ToString(isolate));
603+
obj->Set(String::NewFromUtf8(isolate, "msg"),
604+
args[0]->ToString(context).ToLocalChecked());
602605

603606
args.GetReturnValue().Set(obj);
604607
}

0 commit comments

Comments
 (0)