diff --git a/benchmark/napi/function_args/binding.cc b/benchmark/napi/function_args/binding.cc index d0c1a079210532..9f250aaa83db50 100644 --- a/benchmark/napi/function_args/binding.cc +++ b/benchmark/napi/function_args/binding.cc @@ -33,7 +33,8 @@ void CallWithArray(const FunctionCallbackInfo& args) { uint32_t length = array->Length(); for (uint32_t i = 0; i < length; ++ i) { Local v; - v = array->Get(i); + v = array->Get(args.GetIsolate()->GetCurrentContext(), + i).ToLocalChecked(); } } } diff --git a/doc/api/addons.md b/doc/api/addons.md index e2530acb77d5e0..d993c72d346495 100644 --- a/doc/api/addons.md +++ b/doc/api/addons.md @@ -537,6 +537,7 @@ to invoke such callbacks: namespace demo { +using v8::Context; using v8::Function; using v8::FunctionCallbackInfo; using v8::Isolate; @@ -549,13 +550,14 @@ using v8::Value; void RunCallback(const FunctionCallbackInfo& args) { Isolate* isolate = args.GetIsolate(); + Local context = isolate->GetCurrentContext(); Local cb = Local::Cast(args[0]); const unsigned argc = 1; Local argv[argc] = { String::NewFromUtf8(isolate, "hello world", NewStringType::kNormal).ToLocalChecked() }; - cb->Call(Null(isolate), argc, argv); + cb->Call(context, Null(isolate), argc, argv).ToLocalChecked(); } void Init(Local exports, Local module) { @@ -612,10 +614,12 @@ void CreateObject(const FunctionCallbackInfo& args) { Local context = isolate->GetCurrentContext(); Local obj = Object::New(isolate); - obj->Set(String::NewFromUtf8(isolate, + obj->Set(context, + String::NewFromUtf8(isolate, "msg", NewStringType::kNormal).ToLocalChecked(), - args[0]->ToString(context).ToLocalChecked()); + args[0]->ToString(context).ToLocalChecked()) + .FromJust(); args.GetReturnValue().Set(obj); } @@ -803,9 +807,9 @@ void MyObject::Init(Local exports) { Local context = isolate->GetCurrentContext(); constructor.Reset(isolate, tpl->GetFunction(context).ToLocalChecked()); - exports->Set(String::NewFromUtf8( + exports->Set(context, String::NewFromUtf8( isolate, "MyObject", NewStringType::kNormal).ToLocalChecked(), - tpl->GetFunction(context).ToLocalChecked()); + tpl->GetFunction(context).ToLocalChecked()).FromJust(); } void MyObject::New(const FunctionCallbackInfo& args) { diff --git a/test/addons/async-hello-world/binding.cc b/test/addons/async-hello-world/binding.cc index 3a584a88a07bc9..1bf94ddd1d70bc 100644 --- a/test/addons/async-hello-world/binding.cc +++ b/test/addons/async-hello-world/binding.cc @@ -53,7 +53,8 @@ void AfterAsync(uv_work_t* r) { // This should be changed to an empty handle. assert(!ret.IsEmpty()); } else { - callback->Call(global, 2, argv); + callback->Call(isolate->GetCurrentContext(), + global, 2, argv).ToLocalChecked(); } // cleanup diff --git a/test/addons/heap-profiler/binding.cc b/test/addons/heap-profiler/binding.cc index 29f58a5920825a..9e1e97e9fc2afc 100644 --- a/test/addons/heap-profiler/binding.cc +++ b/test/addons/heap-profiler/binding.cc @@ -19,11 +19,11 @@ inline void Test(const v8::FunctionCallbackInfo& args) { inline void Initialize(v8::Local binding) { v8::Isolate* const isolate = binding->GetIsolate(); v8::Local context = isolate->GetCurrentContext(); - binding->Set(v8::String::NewFromUtf8( + binding->Set(context, v8::String::NewFromUtf8( isolate, "test", v8::NewStringType::kNormal).ToLocalChecked(), v8::FunctionTemplate::New(isolate, Test) ->GetFunction(context) - .ToLocalChecked()); + .ToLocalChecked()).FromJust(); } NODE_MODULE(NODE_GYP_MODULE_NAME, Initialize) diff --git a/test/addons/new-target/binding.cc b/test/addons/new-target/binding.cc index c2777c831e484a..48ceeb55ca1aae 100644 --- a/test/addons/new-target/binding.cc +++ b/test/addons/new-target/binding.cc @@ -12,11 +12,11 @@ inline void NewClass(const v8::FunctionCallbackInfo& args) { inline void Initialize(v8::Local binding) { auto isolate = binding->GetIsolate(); auto context = isolate->GetCurrentContext(); - binding->Set(v8::String::NewFromUtf8( + binding->Set(context, v8::String::NewFromUtf8( isolate, "Class", v8::NewStringType::kNormal).ToLocalChecked(), v8::FunctionTemplate::New(isolate, NewClass) ->GetFunction(context) - .ToLocalChecked()); + .ToLocalChecked()).FromJust(); } NODE_MODULE(NODE_GYP_MODULE_NAME, Initialize)