diff options
-rw-r--r-- | benchmark/napi/function_args/binding.cc | 3 | ||||
-rw-r--r-- | doc/api/addons.md | 14 | ||||
-rw-r--r-- | test/addons/async-hello-world/binding.cc | 3 | ||||
-rw-r--r-- | test/addons/heap-profiler/binding.cc | 4 | ||||
-rw-r--r-- | test/addons/new-target/binding.cc | 4 |
5 files changed, 17 insertions, 11 deletions
diff --git a/benchmark/napi/function_args/binding.cc b/benchmark/napi/function_args/binding.cc index d0c1a07921..9f250aaa83 100644 --- a/benchmark/napi/function_args/binding.cc +++ b/benchmark/napi/function_args/binding.cc @@ -33,7 +33,8 @@ void CallWithArray(const FunctionCallbackInfo<Value>& args) { uint32_t length = array->Length(); for (uint32_t i = 0; i < length; ++ i) { Local<Value> 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 e2530acb77..d993c72d34 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<Value>& args) { Isolate* isolate = args.GetIsolate(); + Local<Context> context = isolate->GetCurrentContext(); Local<Function> cb = Local<Function>::Cast(args[0]); const unsigned argc = 1; Local<Value> 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<Object> exports, Local<Object> module) { @@ -612,10 +614,12 @@ void CreateObject(const FunctionCallbackInfo<Value>& args) { Local<Context> context = isolate->GetCurrentContext(); Local<Object> 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<Object> exports) { Local<Context> 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<Value>& args) { diff --git a/test/addons/async-hello-world/binding.cc b/test/addons/async-hello-world/binding.cc index 3a584a88a0..1bf94ddd1d 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 29f58a5920..9e1e97e9fc 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<v8::Value>& args) { inline void Initialize(v8::Local<v8::Object> binding) { v8::Isolate* const isolate = binding->GetIsolate(); v8::Local<v8::Context> 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 c2777c831e..48ceeb55ca 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<v8::Value>& args) { inline void Initialize(v8::Local<v8::Object> 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) |