@@ -635,6 +635,7 @@ functions and returning those back to JavaScript:
635
635
636
636
namespace demo {
637
637
638
+ using v8::Context;
638
639
using v8::Function;
639
640
using v8::FunctionCallbackInfo;
640
641
using v8::FunctionTemplate;
@@ -652,8 +653,9 @@ void MyFunction(const FunctionCallbackInfo<Value>& args) {
652
653
void CreateFunction(const FunctionCallbackInfo<Value >& args) {
653
654
Isolate* isolate = args.GetIsolate();
654
655
656
+ Local<Context > context = isolate->GetCurrentContext();
655
657
Local<FunctionTemplate > tpl = FunctionTemplate::New(isolate, MyFunction);
656
- Local<Function > fn = tpl->GetFunction();
658
+ Local<Function > fn = tpl->GetFunction(context).ToLocalChecked( );
657
659
658
660
// omit this to make it anonymous
659
661
fn->SetName(String::NewFromUtf8(isolate, "theFunction"));
@@ -777,9 +779,10 @@ void MyObject::Init(Local<Object> exports) {
777
779
// Prototype
778
780
NODE_SET_PROTOTYPE_METHOD(tpl, "plusOne", PlusOne);
779
781
780
- constructor.Reset(isolate, tpl->GetFunction());
782
+ Local<Context > context = isolate->GetCurrentContext();
783
+ constructor.Reset(isolate, tpl->GetFunction(context).ToLocalChecked());
781
784
exports->Set(String::NewFromUtf8(isolate, "MyObject"),
782
- tpl->GetFunction());
785
+ tpl->GetFunction(context).ToLocalChecked( ));
783
786
}
784
787
785
788
void MyObject::New(const FunctionCallbackInfo<Value >& args) {
@@ -969,7 +972,8 @@ void MyObject::Init(Isolate* isolate) {
969
972
// Prototype
970
973
NODE_SET_PROTOTYPE_METHOD(tpl, "plusOne", PlusOne);
971
974
972
- constructor.Reset(isolate, tpl->GetFunction());
975
+ Local<Context > context = isolate->GetCurrentContext();
976
+ constructor.Reset(isolate, tpl->GetFunction(context).ToLocalChecked());
973
977
}
974
978
975
979
void MyObject::New(const FunctionCallbackInfo<Value >& args) {
@@ -1177,7 +1181,8 @@ void MyObject::Init(Isolate* isolate) {
1177
1181
tpl->SetClassName(String::NewFromUtf8(isolate, "MyObject"));
1178
1182
tpl->InstanceTemplate()->SetInternalFieldCount(1);
1179
1183
1180
- constructor.Reset(isolate, tpl->GetFunction());
1184
+ Local<Context > context = isolate->GetCurrentContext();
1185
+ constructor.Reset(isolate, tpl->GetFunction(context).ToLocalChecked());
1181
1186
}
1182
1187
1183
1188
void MyObject::New(const FunctionCallbackInfo<Value >& args) {
0 commit comments