diff options
author | Andreas Haas <ahaas@google.com> | 2018-09-21 14:13:35 +0300 |
---|---|---|
committer | Daniel Bevenius <daniel.bevenius@gmail.com> | 2018-09-24 06:44:28 +0300 |
commit | 7dde560beb736e82b7867130a2d5824544122a60 (patch) | |
tree | c34d8cdc7be51ceee11ed3160e49acd1270319de /doc/api/addons.md | |
parent | a0c1326257b9679b056d8611ccdee2d6757b0bf0 (diff) |
src: replace deprecated uses of FunctionTemplate::GetFunction
PR-URL: https://github.com/nodejs/node/pull/22993
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'doc/api/addons.md')
-rw-r--r-- | doc/api/addons.md | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/doc/api/addons.md b/doc/api/addons.md index 5e06336a85a..b2c52d5128b 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<Value>& args) { void CreateFunction(const FunctionCallbackInfo<Value>& args) { Isolate* isolate = args.GetIsolate(); + Local<Context> context = isolate->GetCurrentContext(); Local<FunctionTemplate> tpl = FunctionTemplate::New(isolate, MyFunction); - Local<Function> fn = tpl->GetFunction(); + Local<Function> 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<Object> exports) { // Prototype NODE_SET_PROTOTYPE_METHOD(tpl, "plusOne", PlusOne); - constructor.Reset(isolate, tpl->GetFunction()); + Local<Context> 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<Value>& 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> context = isolate->GetCurrentContext(); + constructor.Reset(isolate, tpl->GetFunction(context).ToLocalChecked()); } void MyObject::New(const FunctionCallbackInfo<Value>& 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> context = isolate->GetCurrentContext(); + constructor.Reset(isolate, tpl->GetFunction(context).ToLocalChecked()); } void MyObject::New(const FunctionCallbackInfo<Value>& args) { |