| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d34343f commit 8f52649
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -549,6 +549,7 @@ prototype: | |||
| 549 | 549 | ||
| 550 | 550 | namespace demo { | |
| 551 | 551 | ||
| 552 | + using v8::Context; | ||
| 552 | 553 | using v8::Function; | |
| 553 | 554 | using v8::FunctionCallbackInfo; | |
| 554 | 555 | using v8::FunctionTemplate; | |
@@ -597,8 +598,11 @@ void MyObject::New(const FunctionCallbackInfo<Value>& args) { | |||
| 597 | 598 | // Invoked as plain function `MyObject(...)`, turn into construct call. | |
| 598 | 599 | const int argc = 1; | |
| 599 | 600 | Local<Value> argv[argc] = { args[0] }; | |
| 601 | + Local<Context> context = isolate->GetCurrentContext(); | ||
| 600 | 602 | Local<Function> cons = Local<Function>::New(isolate, constructor); | |
| 601 | - args.GetReturnValue().Set(cons->NewInstance(argc, argv)); | ||
| 603 | + Local<Object> result = | ||
| 604 | + cons->NewInstance(context, argc, argv).ToLocalChecked(); | ||
| 605 | + args.GetReturnValue().Set(result); | ||
| 602 | 606 | } | |
| 603 | 607 | } | |
| 604 | 608 | ||
@@ -728,6 +732,7 @@ The implementation in `myobject.cc` is similar to the previous example: | |||
| 728 | 732 | ||
| 729 | 733 | namespace demo { | |
| 730 | 734 | ||
| 735 | + using v8::Context; | ||
| 731 | 736 | using v8::Function; | |
| 732 | 737 | using v8::FunctionCallbackInfo; | |
| 733 | 738 | using v8::FunctionTemplate; | |
@@ -773,7 +778,10 @@ void MyObject::New(const FunctionCallbackInfo<Value>& args) { | |||
| 773 | 778 | const int argc = 1; | |
| 774 | 779 | Local<Value> argv[argc] = { args[0] }; | |
| 775 | 780 | Local<Function> cons = Local<Function>::New(isolate, constructor); | |
| 776 | - args.GetReturnValue().Set(cons->NewInstance(argc, argv)); | ||
| 781 | + Local<Context> context = isolate->GetCurrentContext(); | ||
| 782 | + Local<Object> instance = | ||
| 783 | + cons->NewInstance(context, argc, argv).ToLocalChecked(); | ||
| 784 | + args.GetReturnValue().Set(instance); | ||
| 777 | 785 | } | |
| 778 | 786 | } | |
| 779 | 787 | ||
@@ -783,7 +791,9 @@ void MyObject::NewInstance(const FunctionCallbackInfo<Value>& args) { | |||
| 783 | 791 | const unsigned argc = 1; | |
| 784 | 792 | Local<Value> argv[argc] = { args[0] }; | |
| 785 | 793 | Local<Function> cons = Local<Function>::New(isolate, constructor); | |
| 786 | - Local<Object> instance = cons->NewInstance(argc, argv); | ||
| 794 | + Local<Context> context = isolate->GetCurrentContext(); | ||
| 795 | + Local<Object> instance = | ||
| 796 | + cons->NewInstance(context, argc, argv).ToLocalChecked(); | ||
| 787 | 797 | ||
| 788 | 798 | args.GetReturnValue().Set(instance); | |
| 789 | 799 | } | |
@@ -928,6 +938,7 @@ The implementation of `myobject.cc` is similar to before: | |||
| 928 | 938 | ||
| 929 | 939 | namespace demo { | |
| 930 | 940 | ||
| 941 | + using v8::Context; | ||
| 931 | 942 | using v8::Function; | |
| 932 | 943 | using v8::FunctionCallbackInfo; | |
| 933 | 944 | using v8::FunctionTemplate; | |
@@ -968,8 +979,11 @@ void MyObject::New(const FunctionCallbackInfo<Value>& args) { | |||
| 968 | 979 | // Invoked as plain function `MyObject(...)`, turn into construct call. | |
| 969 | 980 | const int argc = 1; | |
| 970 | 981 | Local<Value> argv[argc] = { args[0] }; | |
| 982 | + Local<Context> context = isolate->GetCurrentContext(); | ||
| 971 | 983 | Local<Function> cons = Local<Function>::New(isolate, constructor); | |
| 972 | - args.GetReturnValue().Set(cons->NewInstance(argc, argv)); | ||
| 984 | + Local<Object> instance = | ||
| 985 | + cons->NewInstance(context, argc, argv).ToLocalChecked(); | ||
| 986 | + args.GetReturnValue().Set(instance); | ||
| 973 | 987 | } | |
| 974 | 988 | } | |
| 975 | 989 | ||
@@ -979,7 +993,9 @@ void MyObject::NewInstance(const FunctionCallbackInfo<Value>& args) { | |||
| 979 | 993 | const unsigned argc = 1; | |
| 980 | 994 | Local<Value> argv[argc] = { args[0] }; | |
| 981 | 995 | Local<Function> cons = Local<Function>::New(isolate, constructor); | |
| 982 | - Local<Object> instance = cons->NewInstance(argc, argv); | ||
| 996 | + Local<Context> context = isolate->GetCurrentContext(); | ||
| 997 | + Local<Object> instance = | ||
| 998 | + cons->NewInstance(context, argc, argv).ToLocalChecked(); | ||
| 983 | 999 | ||
| 984 | 1000 | args.GetReturnValue().Set(instance); | |
| 985 | 1001 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments