@@ -589,16 +589,19 @@ namespace demo {
589589
590590using v8::FunctionCallbackInfo;
591591using v8::Isolate;
592+ using v8::Context;
592593using v8::Local;
593594using v8::Object;
594595using v8::String;
595596using v8::Value;
596597
597598void 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}
@@ -1080,6 +1083,7 @@ namespace demo {
10801083
10811084using v8::FunctionCallbackInfo;
10821085using v8::Isolate;
1086+ using v8::Context;
10831087using v8::Local;
10841088using v8::Number;
10851089using v8::Object;
@@ -1092,11 +1096,12 @@ void CreateObject(const FunctionCallbackInfo<Value>& args) {
10921096
10931097void 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