@@ -635,6 +635,7 @@ functions and returning those back to JavaScript:
635635
636636namespace demo {
637637
638+ using v8::Context;
638639using v8::Function;
639640using v8::FunctionCallbackInfo;
640641using v8::FunctionTemplate;
@@ -652,8 +653,9 @@ void MyFunction(const FunctionCallbackInfo<Value>& args) {
652653void CreateFunction(const FunctionCallbackInfo<Value >& args) {
653654 Isolate* isolate = args.GetIsolate();
654655
656+ Local<Context > context = isolate->GetCurrentContext();
655657 Local<FunctionTemplate > tpl = FunctionTemplate::New(isolate, MyFunction);
656- Local<Function > fn = tpl->GetFunction();
658+ Local<Function > fn = tpl->GetFunction(context).ToLocalChecked( );
657659
658660 // omit this to make it anonymous
659661 fn->SetName(String::NewFromUtf8(isolate, "theFunction"));
@@ -777,9 +779,10 @@ void MyObject::Init(Local<Object> exports) {
777779 // Prototype
778780 NODE_SET_PROTOTYPE_METHOD(tpl, "plusOne", PlusOne);
779781
780- constructor.Reset(isolate, tpl->GetFunction());
782+ Local<Context > context = isolate->GetCurrentContext();
783+ constructor.Reset(isolate, tpl->GetFunction(context).ToLocalChecked());
781784 exports->Set(String::NewFromUtf8(isolate, "MyObject"),
782- tpl->GetFunction());
785+ tpl->GetFunction(context).ToLocalChecked( ));
783786}
784787
785788void MyObject::New(const FunctionCallbackInfo<Value >& args) {
@@ -969,7 +972,8 @@ void MyObject::Init(Isolate* isolate) {
969972 // Prototype
970973 NODE_SET_PROTOTYPE_METHOD(tpl, "plusOne", PlusOne);
971974
972- constructor.Reset(isolate, tpl->GetFunction());
975+ Local<Context > context = isolate->GetCurrentContext();
976+ constructor.Reset(isolate, tpl->GetFunction(context).ToLocalChecked());
973977}
974978
975979void MyObject::New(const FunctionCallbackInfo<Value >& args) {
@@ -1177,7 +1181,8 @@ void MyObject::Init(Isolate* isolate) {
11771181 tpl->SetClassName(String::NewFromUtf8(isolate, "MyObject"));
11781182 tpl->InstanceTemplate()->SetInternalFieldCount(1);
11791183
1180- constructor.Reset(isolate, tpl->GetFunction());
1184+ Local<Context > context = isolate->GetCurrentContext();
1185+ constructor.Reset(isolate, tpl->GetFunction(context).ToLocalChecked());
11811186}
11821187
11831188void MyObject::New(const FunctionCallbackInfo<Value >& args) {
0 commit comments