Skip to content
Closed
Changes from 1 commit
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
Next Next commit
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.
  • Loading branch information
danbev committed Oct 9, 2018
commit 6e1fdb818751005df80ab0c88b659bc393673436
5 changes: 4 additions & 1 deletion doc/api/addons.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -596,9 +597,11 @@ using v8::Value;

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

Local<Object> 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);
}
Expand Down