Skip to content

Commit e774d1b

Browse files
danbevjasnell
authored andcommitted
test: fix compiler warning in doc/api/addons.md
Currently there are compiler warnings 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 examples to use the non-deprecated versions. PR-URL: #23323 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
1 parent db8b524 commit e774d1b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

doc/api/addons.md

+8-3
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
}
@@ -1078,6 +1081,7 @@ that can take two `MyObject` objects as input arguments:
10781081

10791082
namespace demo {
10801083

1084+
using v8::Context;
10811085
using v8::FunctionCallbackInfo;
10821086
using v8::Isolate;
10831087
using v8::Local;
@@ -1092,11 +1096,12 @@ void CreateObject(const FunctionCallbackInfo<Value>& args) {
10921096

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

10961101
MyObject* obj1 = node::ObjectWrap::Unwrap<MyObject>(
1097-
args[0]->ToObject(isolate));
1102+
args[0]->ToObject(context).ToLocalChecked());
10981103
MyObject* obj2 = node::ObjectWrap::Unwrap<MyObject>(
1099-
args[1]->ToObject(isolate));
1104+
args[1]->ToObject(context).ToLocalChecked());
11001105

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

0 commit comments

Comments
 (0)