@@ -537,6 +537,7 @@ to invoke such callbacks:
537
537
538
538
namespace demo {
539
539
540
+ using v8::Context;
540
541
using v8::Function;
541
542
using v8::FunctionCallbackInfo;
542
543
using v8::Isolate;
@@ -549,13 +550,14 @@ using v8::Value;
549
550
550
551
void RunCallback(const FunctionCallbackInfo<Value >& args) {
551
552
Isolate* isolate = args.GetIsolate();
553
+ Local<Context > context = isolate->GetCurrentContext();
552
554
Local<Function > cb = Local<Function >::Cast(args[ 0] );
553
555
const unsigned argc = 1;
554
556
Local<Value > argv[ argc] = {
555
557
String::NewFromUtf8(isolate,
556
558
"hello world",
557
559
NewStringType::kNormal).ToLocalChecked() };
558
- cb->Call(Null(isolate), argc, argv);
560
+ cb->Call(context, Null(isolate), argc, argv).ToLocalChecked( );
559
561
}
560
562
561
563
void Init(Local<Object > exports, Local<Object > module) {
@@ -612,10 +614,12 @@ void CreateObject(const FunctionCallbackInfo<Value>& args) {
612
614
Local<Context > context = isolate->GetCurrentContext();
613
615
614
616
Local<Object > obj = Object::New(isolate);
615
- obj->Set(String::NewFromUtf8(isolate,
617
+ obj->Set(context,
618
+ String::NewFromUtf8(isolate,
616
619
"msg",
617
620
NewStringType::kNormal).ToLocalChecked(),
618
- args[ 0] ->ToString(context).ToLocalChecked());
621
+ args[ 0] ->ToString(context).ToLocalChecked())
622
+ .FromJust();
619
623
620
624
args.GetReturnValue().Set(obj);
621
625
}
@@ -803,9 +807,9 @@ void MyObject::Init(Local<Object> exports) {
803
807
804
808
Local<Context > context = isolate->GetCurrentContext();
805
809
constructor.Reset(isolate, tpl->GetFunction(context).ToLocalChecked());
806
- exports->Set(String::NewFromUtf8(
810
+ exports->Set(context, String::NewFromUtf8(
807
811
isolate, "MyObject", NewStringType::kNormal).ToLocalChecked(),
808
- tpl->GetFunction(context).ToLocalChecked());
812
+ tpl->GetFunction(context).ToLocalChecked()).FromJust() ;
809
813
}
810
814
811
815
void MyObject::New(const FunctionCallbackInfo<Value >& args) {
0 commit comments