@@ -65,15 +65,14 @@ namespace demo {
65
65
using v8::FunctionCallbackInfo;
66
66
using v8::Isolate;
67
67
using v8::Local;
68
- using v8::NewStringType;
69
68
using v8::Object;
70
69
using v8::String;
71
70
using v8::Value;
72
71
73
72
void Method(const FunctionCallbackInfo<Value >& args) {
74
73
Isolate* isolate = args.GetIsolate();
75
74
args.GetReturnValue().Set(String::NewFromUtf8(
76
- isolate, "world", NewStringType::kNormal ).ToLocalChecked());
75
+ isolate, "world").ToLocalChecked());
77
76
}
78
77
79
78
void Initialize(Local<Object > exports) {
@@ -226,8 +225,7 @@ NODE_MODULE_INIT(/* exports, module, context */) {
226
225
// per-addon-instance data we created above by passing ` external ` as the
227
226
// third parameter to the ` FunctionTemplate ` constructor.
228
227
exports->Set(context,
229
- String::NewFromUtf8(isolate, "method", NewStringType::kNormal)
230
- .ToLocalChecked(),
228
+ String::NewFromUtf8(isolate, "method").ToLocalChecked(),
231
229
FunctionTemplate::New(isolate, Method, external)
232
230
->GetFunction(context).ToLocalChecked()).FromJust();
233
231
}
@@ -538,7 +536,6 @@ using v8::Exception;
538
536
using v8::FunctionCallbackInfo;
539
537
using v8::Isolate;
540
538
using v8::Local;
541
- using v8::NewStringType;
542
539
using v8::Number;
543
540
using v8::Object;
544
541
using v8::String;
@@ -555,17 +552,15 @@ void Add(const FunctionCallbackInfo<Value>& args) {
555
552
// Throw an Error that is passed back to JavaScript
556
553
isolate->ThrowException(Exception::TypeError(
557
554
String::NewFromUtf8(isolate,
558
- "Wrong number of arguments",
559
- NewStringType::kNormal).ToLocalChecked()));
555
+ "Wrong number of arguments").ToLocalChecked()));
560
556
return;
561
557
}
562
558
563
559
// Check the argument types
564
560
if (!args[ 0] ->IsNumber() || !args[ 1] ->IsNumber()) {
565
561
isolate->ThrowException(Exception::TypeError(
566
562
String::NewFromUtf8(isolate,
567
- "Wrong arguments",
568
- NewStringType::kNormal).ToLocalChecked()));
563
+ "Wrong arguments").ToLocalChecked()));
569
564
return;
570
565
}
571
566
@@ -614,7 +609,6 @@ using v8::Function;
614
609
using v8::FunctionCallbackInfo;
615
610
using v8::Isolate;
616
611
using v8::Local;
617
- using v8::NewStringType;
618
612
using v8::Null;
619
613
using v8::Object;
620
614
using v8::String;
@@ -627,8 +621,7 @@ void RunCallback(const FunctionCallbackInfo<Value>& args) {
627
621
const unsigned argc = 1;
628
622
Local<Value > argv[ argc] = {
629
623
String::NewFromUtf8(isolate,
630
- "hello world",
631
- NewStringType::kNormal).ToLocalChecked() };
624
+ "hello world").ToLocalChecked() };
632
625
cb->Call(context, Null(isolate), argc, argv).ToLocalChecked();
633
626
}
634
627
@@ -676,7 +669,6 @@ using v8::Context;
676
669
using v8::FunctionCallbackInfo;
677
670
using v8::Isolate;
678
671
using v8::Local;
679
- using v8::NewStringType;
680
672
using v8::Object;
681
673
using v8::String;
682
674
using v8::Value;
@@ -688,8 +680,7 @@ void CreateObject(const FunctionCallbackInfo<Value>& args) {
688
680
Local<Object > obj = Object::New(isolate);
689
681
obj->Set(context,
690
682
String::NewFromUtf8(isolate,
691
- "msg",
692
- NewStringType::kNormal).ToLocalChecked(),
683
+ "msg").ToLocalChecked(),
693
684
args[ 0] ->ToString(context).ToLocalChecked())
694
685
.FromJust();
695
686
@@ -734,15 +725,14 @@ using v8::FunctionCallbackInfo;
734
725
using v8::FunctionTemplate;
735
726
using v8::Isolate;
736
727
using v8::Local;
737
- using v8::NewStringType;
738
728
using v8::Object;
739
729
using v8::String;
740
730
using v8::Value;
741
731
742
732
void MyFunction(const FunctionCallbackInfo<Value >& args) {
743
733
Isolate* isolate = args.GetIsolate();
744
734
args.GetReturnValue().Set(String::NewFromUtf8(
745
- isolate, "hello world", NewStringType::kNormal ).ToLocalChecked());
735
+ isolate, "hello world").ToLocalChecked());
746
736
}
747
737
748
738
void CreateFunction(const FunctionCallbackInfo<Value >& args) {
@@ -754,7 +744,7 @@ void CreateFunction(const FunctionCallbackInfo<Value>& args) {
754
744
755
745
// omit this to make it anonymous
756
746
fn->SetName(String::NewFromUtf8(
757
- isolate, "theFunction", NewStringType::kNormal ).ToLocalChecked());
747
+ isolate, "theFunction").ToLocalChecked());
758
748
759
749
args.GetReturnValue().Set(fn);
760
750
}
@@ -850,7 +840,6 @@ using v8::FunctionCallbackInfo;
850
840
using v8::FunctionTemplate;
851
841
using v8::Isolate;
852
842
using v8::Local;
853
- using v8::NewStringType;
854
843
using v8::Number;
855
844
using v8::Object;
856
845
using v8::ObjectTemplate;
@@ -874,8 +863,7 @@ void MyObject::Init(Local<Object> exports) {
874
863
875
864
// Prepare constructor template
876
865
Local<FunctionTemplate > tpl = FunctionTemplate::New(isolate, New, addon_data);
877
- tpl->SetClassName(String::NewFromUtf8(
878
- isolate, "MyObject", NewStringType::kNormal).ToLocalChecked());
866
+ tpl->SetClassName(String::NewFromUtf8(isolate, "MyObject").ToLocalChecked());
879
867
tpl->InstanceTemplate()->SetInternalFieldCount(1);
880
868
881
869
// Prototype
@@ -884,8 +872,8 @@ void MyObject::Init(Local<Object> exports) {
884
872
Local<Function > constructor = tpl->GetFunction(context).ToLocalChecked();
885
873
addon_data->SetInternalField(0, constructor);
886
874
exports->Set(context, String::NewFromUtf8(
887
- isolate, "MyObject", NewStringType::kNormal ).ToLocalChecked(),
888
- constructor).FromJust();
875
+ isolate, "MyObject").ToLocalChecked(),
876
+ constructor).FromJust();
889
877
}
890
878
891
879
void MyObject::New(const FunctionCallbackInfo<Value >& args) {
@@ -1055,7 +1043,6 @@ using v8::FunctionTemplate;
1055
1043
using v8::Global;
1056
1044
using v8::Isolate;
1057
1045
using v8::Local;
1058
- using v8::NewStringType;
1059
1046
using v8::Number;
1060
1047
using v8::Object;
1061
1048
using v8::String;
@@ -1074,8 +1061,7 @@ MyObject::~MyObject() {
1074
1061
void MyObject::Init(Isolate* isolate) {
1075
1062
// Prepare constructor template
1076
1063
Local<FunctionTemplate > tpl = FunctionTemplate::New(isolate, New);
1077
- tpl->SetClassName(String::NewFromUtf8(
1078
- isolate, "MyObject", NewStringType::kNormal).ToLocalChecked());
1064
+ tpl->SetClassName(String::NewFromUtf8(isolate, "MyObject").ToLocalChecked());
1079
1065
tpl->InstanceTemplate()->SetInternalFieldCount(1);
1080
1066
1081
1067
// Prototype
@@ -1279,7 +1265,6 @@ using v8::FunctionTemplate;
1279
1265
using v8::Global;
1280
1266
using v8::Isolate;
1281
1267
using v8::Local;
1282
- using v8::NewStringType;
1283
1268
using v8::Object;
1284
1269
using v8::String;
1285
1270
using v8::Value;
@@ -1297,8 +1282,7 @@ MyObject::~MyObject() {
1297
1282
void MyObject::Init(Isolate* isolate) {
1298
1283
// Prepare constructor template
1299
1284
Local<FunctionTemplate > tpl = FunctionTemplate::New(isolate, New);
1300
- tpl->SetClassName(String::NewFromUtf8(
1301
- isolate, "MyObject", NewStringType::kNormal).ToLocalChecked());
1285
+ tpl->SetClassName(String::NewFromUtf8(isolate, "MyObject").ToLocalChecked());
1302
1286
tpl->InstanceTemplate()->SetInternalFieldCount(1);
1303
1287
1304
1288
Local<Context > context = isolate->GetCurrentContext();
0 commit comments