@@ -63,13 +63,15 @@ namespace demo {
6363using v8::FunctionCallbackInfo;
6464using v8::Isolate;
6565using v8::Local;
66+ using v8::NewStringType;
6667using v8::Object;
6768using v8::String;
6869using v8::Value;
6970
7071void Method(const FunctionCallbackInfo<Value >& args) {
7172 Isolate* isolate = args.GetIsolate();
72- args.GetReturnValue().Set(String::NewFromUtf8(isolate, "world"));
73+ args.GetReturnValue().Set(String::NewFromUtf8(
74+ isolate, "world", NewStringType::kNormal).ToLocalChecked());
7375}
7476
7577void Initialize(Local<Object > exports) {
@@ -464,6 +466,7 @@ using v8::Exception;
464466using v8::FunctionCallbackInfo;
465467using v8::Isolate;
466468using v8::Local;
469+ using v8::NewStringType;
467470using v8::Number;
468471using v8::Object;
469472using v8::String;
@@ -479,14 +482,18 @@ void Add(const FunctionCallbackInfo<Value>& args) {
479482 if (args.Length() < 2) {
480483 // Throw an Error that is passed back to JavaScript
481484 isolate->ThrowException(Exception::TypeError(
482- String::NewFromUtf8(isolate, "Wrong number of arguments")));
485+ String::NewFromUtf8(isolate,
486+ "Wrong number of arguments",
487+ NewStringType::kNormal).ToLocalChecked()));
483488 return;
484489 }
485490
486491 // Check the argument types
487492 if (!args[ 0] ->IsNumber() || !args[ 1] ->IsNumber()) {
488493 isolate->ThrowException(Exception::TypeError(
489- String::NewFromUtf8(isolate, "Wrong arguments")));
494+ String::NewFromUtf8(isolate,
495+ "Wrong arguments",
496+ NewStringType::kNormal).ToLocalChecked()));
490497 return;
491498 }
492499
@@ -534,6 +541,7 @@ using v8::Function;
534541using v8::FunctionCallbackInfo;
535542using v8::Isolate;
536543using v8::Local;
544+ using v8::NewStringType;
537545using v8::Null;
538546using v8::Object;
539547using v8::String;
@@ -543,7 +551,10 @@ void RunCallback(const FunctionCallbackInfo<Value>& args) {
543551 Isolate* isolate = args.GetIsolate();
544552 Local<Function > cb = Local<Function >::Cast(args[ 0] );
545553 const unsigned argc = 1;
546- Local<Value > argv[ argc] = { String::NewFromUtf8(isolate, "hello world") };
554+ Local<Value > argv[ argc] = {
555+ String::NewFromUtf8(isolate,
556+ "hello world",
557+ NewStringType::kNormal).ToLocalChecked() };
547558 cb->Call(Null(isolate), argc, argv);
548559}
549560
@@ -591,6 +602,7 @@ using v8::Context;
591602using v8::FunctionCallbackInfo;
592603using v8::Isolate;
593604using v8::Local;
605+ using v8::NewStringType;
594606using v8::Object;
595607using v8::String;
596608using v8::Value;
@@ -600,7 +612,9 @@ void CreateObject(const FunctionCallbackInfo<Value>& args) {
600612 Local<Context > context = isolate->GetCurrentContext();
601613
602614 Local<Object > obj = Object::New(isolate);
603- obj->Set(String::NewFromUtf8(isolate, "msg"),
615+ obj->Set(String::NewFromUtf8(isolate,
616+ "msg",
617+ NewStringType::kNormal).ToLocalChecked(),
604618 args[ 0] ->ToString(context).ToLocalChecked());
605619
606620 args.GetReturnValue().Set(obj);
@@ -644,13 +658,15 @@ using v8::FunctionCallbackInfo;
644658using v8::FunctionTemplate;
645659using v8::Isolate;
646660using v8::Local;
661+ using v8::NewStringType;
647662using v8::Object;
648663using v8::String;
649664using v8::Value;
650665
651666void MyFunction(const FunctionCallbackInfo<Value >& args) {
652667 Isolate* isolate = args.GetIsolate();
653- args.GetReturnValue().Set(String::NewFromUtf8(isolate, "hello world"));
668+ args.GetReturnValue().Set(String::NewFromUtf8(
669+ isolate, "hello world", NewStringType::kNormal).ToLocalChecked());
654670}
655671
656672void CreateFunction(const FunctionCallbackInfo<Value >& args) {
@@ -661,7 +677,8 @@ void CreateFunction(const FunctionCallbackInfo<Value>& args) {
661677 Local<Function > fn = tpl->GetFunction(context).ToLocalChecked();
662678
663679 // omit this to make it anonymous
664- fn->SetName(String::NewFromUtf8(isolate, "theFunction"));
680+ fn->SetName(String::NewFromUtf8(
681+ isolate, "theFunction", NewStringType::kNormal).ToLocalChecked());
665682
666683 args.GetReturnValue().Set(fn);
667684}
@@ -757,6 +774,7 @@ using v8::FunctionCallbackInfo;
757774using v8::FunctionTemplate;
758775using v8::Isolate;
759776using v8::Local;
777+ using v8::NewStringType;
760778using v8::Number;
761779using v8::Object;
762780using v8::Persistent;
@@ -776,15 +794,17 @@ void MyObject::Init(Local<Object> exports) {
776794
777795 // Prepare constructor template
778796 Local<FunctionTemplate > tpl = FunctionTemplate::New(isolate, New);
779- tpl->SetClassName(String::NewFromUtf8(isolate, "MyObject"));
797+ tpl->SetClassName(String::NewFromUtf8(
798+ isolate, "MyObject", NewStringType::kNormal).ToLocalChecked());
780799 tpl->InstanceTemplate()->SetInternalFieldCount(1);
781800
782801 // Prototype
783802 NODE_SET_PROTOTYPE_METHOD(tpl, "plusOne", PlusOne);
784803
785804 Local<Context > context = isolate->GetCurrentContext();
786805 constructor.Reset(isolate, tpl->GetFunction(context).ToLocalChecked());
787- exports->Set(String::NewFromUtf8(isolate, "MyObject"),
806+ exports->Set(String::NewFromUtf8(
807+ isolate, "MyObject", NewStringType::kNormal).ToLocalChecked(),
788808 tpl->GetFunction(context).ToLocalChecked());
789809}
790810
@@ -952,6 +972,7 @@ using v8::FunctionCallbackInfo;
952972using v8::FunctionTemplate;
953973using v8::Isolate;
954974using v8::Local;
975+ using v8::NewStringType;
955976using v8::Number;
956977using v8::Object;
957978using v8::Persistent;
@@ -969,7 +990,8 @@ MyObject::~MyObject() {
969990void MyObject::Init(Isolate* isolate) {
970991 // Prepare constructor template
971992 Local<FunctionTemplate > tpl = FunctionTemplate::New(isolate, New);
972- tpl->SetClassName(String::NewFromUtf8(isolate, "MyObject"));
993+ tpl->SetClassName(String::NewFromUtf8(
994+ isolate, "MyObject", NewStringType::kNormal).ToLocalChecked());
973995 tpl->InstanceTemplate()->SetInternalFieldCount(1);
974996
975997 // Prototype
@@ -1167,6 +1189,7 @@ using v8::FunctionCallbackInfo;
11671189using v8::FunctionTemplate;
11681190using v8::Isolate;
11691191using v8::Local;
1192+ using v8::NewStringType;
11701193using v8::Object;
11711194using v8::Persistent;
11721195using v8::String;
@@ -1183,7 +1206,8 @@ MyObject::~MyObject() {
11831206void MyObject::Init(Isolate* isolate) {
11841207 // Prepare constructor template
11851208 Local<FunctionTemplate > tpl = FunctionTemplate::New(isolate, New);
1186- tpl->SetClassName(String::NewFromUtf8(isolate, "MyObject"));
1209+ tpl->SetClassName(String::NewFromUtf8(
1210+ isolate, "MyObject", NewStringType::kNormal).ToLocalChecked());
11871211 tpl->InstanceTemplate()->SetInternalFieldCount(1);
11881212
11891213 Local<Context > context = isolate->GetCurrentContext();
0 commit comments