@@ -1060,8 +1060,10 @@ class Utf8String {
1060
1060
length_(0 ), str_(str_st_) {
1061
1061
HandleScope scope;
1062
1062
if (!from.IsEmpty ()) {
1063
- #if V8_MAJOR_VERSION >= 7
1064
- v8::Local<v8::String> string = from->ToString (v8::Isolate::GetCurrent ());
1063
+ #if NODE_MAJOR_VERSION >= 10
1064
+ v8::Local<v8::Context> context = GetCurrentContext ();
1065
+ v8::Local<v8::String> string =
1066
+ from->ToString (context).FromMaybe (v8::Local<v8::String>());
1065
1067
#else
1066
1068
v8::Local<v8::String> string = from->ToString ();
1067
1069
#endif
@@ -1074,7 +1076,7 @@ class Utf8String {
1074
1076
}
1075
1077
const int flags =
1076
1078
v8::String::NO_NULL_TERMINATION | imp::kReplaceInvalidUtf8 ;
1077
- #if V8_MAJOR_VERSION >= 7
1079
+ #if NODE_MAJOR_VERSION >= 10
1078
1080
length_ = string->WriteUtf8 (v8::Isolate::GetCurrent (), str_, static_cast <int >(len), 0 , flags);
1079
1081
#else
1080
1082
length_ = string->WriteUtf8 (str_, static_cast <int >(len), 0 , flags);
@@ -1852,36 +1854,41 @@ inline MaybeLocal<v8::Value> Call(
1852
1854
inline void SaveToPersistent (
1853
1855
const char *key, const v8::Local<v8::Value> &value) {
1854
1856
HandleScope scope;
1855
- New (persistentHandle)-> Set ( New (key).ToLocalChecked (), value);
1857
+ Set ( New (persistentHandle), New (key).ToLocalChecked (), value). FromJust ( );
1856
1858
}
1857
1859
1858
1860
inline void SaveToPersistent (
1859
1861
const v8::Local<v8::String> &key, const v8::Local<v8::Value> &value) {
1860
1862
HandleScope scope;
1861
- New (persistentHandle)-> Set ( key, value);
1863
+ Set ( New (persistentHandle), key, value). FromJust ( );
1862
1864
}
1863
1865
1864
1866
inline void SaveToPersistent (
1865
1867
uint32_t index, const v8::Local<v8::Value> &value) {
1866
1868
HandleScope scope;
1867
- New (persistentHandle)-> Set ( index , value);
1869
+ Set ( New (persistentHandle), index , value). FromJust ( );
1868
1870
}
1869
1871
1870
1872
inline v8::Local<v8::Value> GetFromPersistent (const char *key) const {
1871
1873
EscapableHandleScope scope;
1872
1874
return scope.Escape (
1873
- New (persistentHandle)->Get (New (key).ToLocalChecked ()));
1875
+ Get (New (persistentHandle), New (key).ToLocalChecked ())
1876
+ .FromMaybe (v8::Local<v8::Value>()));
1874
1877
}
1875
1878
1876
1879
inline v8::Local<v8::Value>
1877
1880
GetFromPersistent (const v8::Local<v8::String> &key) const {
1878
1881
EscapableHandleScope scope;
1879
- return scope.Escape (New (persistentHandle)->Get (key));
1882
+ return scope.Escape (
1883
+ Get (New (persistentHandle), key)
1884
+ .FromMaybe (v8::Local<v8::Value>()));
1880
1885
}
1881
1886
1882
1887
inline v8::Local<v8::Value> GetFromPersistent (uint32_t index) const {
1883
1888
EscapableHandleScope scope;
1884
- return scope.Escape (New (persistentHandle)->Get (index ));
1889
+ return scope.Escape (
1890
+ Get (New (persistentHandle), index )
1891
+ .FromMaybe (v8::Local<v8::Value>()));
1885
1892
}
1886
1893
1887
1894
virtual void Execute () = 0;
@@ -2375,7 +2382,7 @@ SetMethodAux(T recv,
2375
2382
v8::Local<v8::String> name,
2376
2383
v8::Local<v8::FunctionTemplate> tpl,
2377
2384
...) {
2378
- recv-> Set (name, GetFunction (tpl).ToLocalChecked ());
2385
+ Set (recv, name, GetFunction (tpl).ToLocalChecked ());
2379
2386
}
2380
2387
2381
2388
} // end of namespace imp
0 commit comments