From 7dde560beb736e82b7867130a2d5824544122a60 Mon Sep 17 00:00:00 2001 From: Andreas Haas Date: Fri, 21 Sep 2018 13:13:35 +0200 Subject: src: replace deprecated uses of FunctionTemplate::GetFunction MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/22993 Reviewed-By: Michaƫl Zasso Reviewed-By: Colin Ihrig Reviewed-By: Ujjwal Sharma Reviewed-By: Joyee Cheung Reviewed-By: Eugene Ostroukhov Reviewed-By: Anna Henningsen Reviewed-By: James M Snell --- doc/api/addons.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'doc/api/addons.md') diff --git a/doc/api/addons.md b/doc/api/addons.md index 5e06336a85..b2c52d5128 100644 --- a/doc/api/addons.md +++ b/doc/api/addons.md @@ -635,6 +635,7 @@ functions and returning those back to JavaScript: namespace demo { +using v8::Context; using v8::Function; using v8::FunctionCallbackInfo; using v8::FunctionTemplate; @@ -652,8 +653,9 @@ void MyFunction(const FunctionCallbackInfo& args) { void CreateFunction(const FunctionCallbackInfo& args) { Isolate* isolate = args.GetIsolate(); + Local context = isolate->GetCurrentContext(); Local tpl = FunctionTemplate::New(isolate, MyFunction); - Local fn = tpl->GetFunction(); + Local fn = tpl->GetFunction(context).ToLocalChecked(); // omit this to make it anonymous fn->SetName(String::NewFromUtf8(isolate, "theFunction")); @@ -777,9 +779,10 @@ void MyObject::Init(Local exports) { // Prototype NODE_SET_PROTOTYPE_METHOD(tpl, "plusOne", PlusOne); - constructor.Reset(isolate, tpl->GetFunction()); + Local context = isolate->GetCurrentContext(); + constructor.Reset(isolate, tpl->GetFunction(context).ToLocalChecked()); exports->Set(String::NewFromUtf8(isolate, "MyObject"), - tpl->GetFunction()); + tpl->GetFunction(context).ToLocalChecked()); } void MyObject::New(const FunctionCallbackInfo& args) { @@ -969,7 +972,8 @@ void MyObject::Init(Isolate* isolate) { // Prototype NODE_SET_PROTOTYPE_METHOD(tpl, "plusOne", PlusOne); - constructor.Reset(isolate, tpl->GetFunction()); + Local context = isolate->GetCurrentContext(); + constructor.Reset(isolate, tpl->GetFunction(context).ToLocalChecked()); } void MyObject::New(const FunctionCallbackInfo& args) { @@ -1177,7 +1181,8 @@ void MyObject::Init(Isolate* isolate) { tpl->SetClassName(String::NewFromUtf8(isolate, "MyObject")); tpl->InstanceTemplate()->SetInternalFieldCount(1); - constructor.Reset(isolate, tpl->GetFunction()); + Local context = isolate->GetCurrentContext(); + constructor.Reset(isolate, tpl->GetFunction(context).ToLocalChecked()); } void MyObject::New(const FunctionCallbackInfo& args) { -- cgit v1.2.1