@@ -214,20 +214,6 @@ inline v8::Local<v8::String> OneByteString(v8::Isolate* isolate,
214
214
.ToLocalChecked ();
215
215
}
216
216
217
- v8::MaybeLocal<v8::String> StringViewToV8String (
218
- v8::Isolate* isolate, v8_inspector::StringView string) {
219
- if (string.is8Bit ()) {
220
- return v8::String::NewFromOneByte (isolate,
221
- string.characters8 (),
222
- v8::NewStringType::kNormal ,
223
- string.length ());
224
- }
225
- return v8::String::NewFromTwoByte (isolate,
226
- string.characters16 (),
227
- v8::NewStringType::kNormal ,
228
- string.length ());
229
- }
230
-
231
217
void SwapBytes16 (char * data, size_t nbytes) {
232
218
CHECK_EQ (nbytes % 2 , 0 );
233
219
@@ -455,6 +441,31 @@ v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context,
455
441
.FromMaybe (v8::Local<v8::String>());
456
442
}
457
443
444
+ v8::MaybeLocal<v8::Value> ToV8Value (v8::Local<v8::Context> context,
445
+ v8_inspector::StringView str,
446
+ v8::Isolate* isolate) {
447
+ if (isolate == nullptr ) isolate = context->GetIsolate ();
448
+ if (UNLIKELY (str.length () >= static_cast <size_t >(v8::String::kMaxLength ))) {
449
+ // V8 only has a TODO comment about adding an exception when the maximum
450
+ // string size is exceeded.
451
+ ThrowErrStringTooLong (isolate);
452
+ return v8::MaybeLocal<v8::Value>();
453
+ }
454
+
455
+ if (str.is8Bit ()) {
456
+ return v8::String::NewFromOneByte (isolate,
457
+ str.characters8 (),
458
+ v8::NewStringType::kNormal ,
459
+ str.length ())
460
+ .FromMaybe (v8::Local<v8::String>());
461
+ }
462
+ return v8::String::NewFromTwoByte (isolate,
463
+ str.characters16 (),
464
+ v8::NewStringType::kNormal ,
465
+ str.length ())
466
+ .FromMaybe (v8::Local<v8::String>());
467
+ }
468
+
458
469
template <typename T>
459
470
v8::MaybeLocal<v8::Value> ToV8Value (v8::Local<v8::Context> context,
460
471
const std::vector<T>& vec,
0 commit comments