@@ -537,6 +537,7 @@ to invoke such callbacks:
537537
538538namespace demo {
539539
540+ using v8::Context;
540541using v8::Function;
541542using v8::FunctionCallbackInfo;
542543using v8::Isolate;
@@ -549,13 +550,14 @@ using v8::Value;
549550
550551void RunCallback(const FunctionCallbackInfo<Value >& args) {
551552 Isolate* isolate = args.GetIsolate();
553+ Local<Context > context = isolate->GetCurrentContext();
552554 Local<Function > cb = Local<Function >::Cast(args[ 0] );
553555 const unsigned argc = 1;
554556 Local<Value > argv[ argc] = {
555557 String::NewFromUtf8(isolate,
556558 "hello world",
557559 NewStringType::kNormal).ToLocalChecked() };
558- cb->Call(Null(isolate), argc, argv);
560+ cb->Call(context, Null(isolate), argc, argv).ToLocalChecked( );
559561}
560562
561563void Init(Local<Object > exports, Local<Object > module) {
@@ -612,10 +614,12 @@ void CreateObject(const FunctionCallbackInfo<Value>& args) {
612614 Local<Context > context = isolate->GetCurrentContext();
613615
614616 Local<Object > obj = Object::New(isolate);
615- obj->Set(String::NewFromUtf8(isolate,
617+ obj->Set(context,
618+ String::NewFromUtf8(isolate,
616619 "msg",
617620 NewStringType::kNormal).ToLocalChecked(),
618- args[ 0] ->ToString(context).ToLocalChecked());
621+ args[ 0] ->ToString(context).ToLocalChecked())
622+ .FromJust();
619623
620624 args.GetReturnValue().Set(obj);
621625}
@@ -803,9 +807,9 @@ void MyObject::Init(Local<Object> exports) {
803807
804808 Local<Context > context = isolate->GetCurrentContext();
805809 constructor.Reset(isolate, tpl->GetFunction(context).ToLocalChecked());
806- exports->Set(String::NewFromUtf8(
810+ exports->Set(context, String::NewFromUtf8(
807811 isolate, "MyObject", NewStringType::kNormal).ToLocalChecked(),
808- tpl->GetFunction(context).ToLocalChecked());
812+ tpl->GetFunction(context).ToLocalChecked()).FromJust() ;
809813}
810814
811815void MyObject::New(const FunctionCallbackInfo<Value >& args) {
0 commit comments