@@ -358,7 +358,7 @@ Local<v8::FunctionTemplate> NewFunctionTemplate(
358
358
359
359
void SetMethod (Local<v8::Context> context,
360
360
Local<v8::Object> that,
361
- const char * name,
361
+ const std::string_view name,
362
362
v8::FunctionCallback callback) {
363
363
Isolate* isolate = context->GetIsolate ();
364
364
Local<v8::Function> function =
@@ -372,14 +372,15 @@ void SetMethod(Local<v8::Context> context,
372
372
// kInternalized strings are created in the old space.
373
373
const v8::NewStringType type = v8::NewStringType::kInternalized ;
374
374
Local<v8::String> name_string =
375
- v8::String::NewFromUtf8 (isolate, name, type).ToLocalChecked ();
375
+ v8::String::NewFromUtf8 (isolate, name.data (), type, name.size ())
376
+ .ToLocalChecked ();
376
377
that->Set (context, name_string, function).Check ();
377
378
function->SetName (name_string); // NODE_SET_METHOD() compatibility.
378
379
}
379
380
380
381
void SetMethod (v8::Isolate* isolate,
381
382
v8::Local<v8::Template> that,
382
- const char * name,
383
+ const std::string_view name,
383
384
v8::FunctionCallback callback) {
384
385
Local<v8::FunctionTemplate> t =
385
386
NewFunctionTemplate (isolate,
@@ -390,13 +391,14 @@ void SetMethod(v8::Isolate* isolate,
390
391
// kInternalized strings are created in the old space.
391
392
const v8::NewStringType type = v8::NewStringType::kInternalized ;
392
393
Local<v8::String> name_string =
393
- v8::String::NewFromUtf8 (isolate, name, type).ToLocalChecked ();
394
+ v8::String::NewFromUtf8 (isolate, name.data (), type, name.size ())
395
+ .ToLocalChecked ();
394
396
that->Set (name_string, t);
395
397
}
396
398
397
399
void SetFastMethod (Isolate* isolate,
398
400
Local<Template> that,
399
- const char * name,
401
+ const std::string_view name,
400
402
v8::FunctionCallback slow_callback,
401
403
const v8::CFunction* c_function) {
402
404
Local<v8::FunctionTemplate> t =
@@ -409,13 +411,14 @@ void SetFastMethod(Isolate* isolate,
409
411
// kInternalized strings are created in the old space.
410
412
const v8::NewStringType type = v8::NewStringType::kInternalized ;
411
413
Local<v8::String> name_string =
412
- v8::String::NewFromUtf8 (isolate, name, type).ToLocalChecked ();
414
+ v8::String::NewFromUtf8 (isolate, name.data (), type, name.size ())
415
+ .ToLocalChecked ();
413
416
that->Set (name_string, t);
414
417
}
415
418
416
419
void SetFastMethod (Local<v8::Context> context,
417
420
Local<v8::Object> that,
418
- const char * name,
421
+ const std::string_view name,
419
422
v8::FunctionCallback slow_callback,
420
423
const v8::CFunction* c_function) {
421
424
Isolate* isolate = context->GetIsolate ();
@@ -430,13 +433,14 @@ void SetFastMethod(Local<v8::Context> context,
430
433
.ToLocalChecked ();
431
434
const v8::NewStringType type = v8::NewStringType::kInternalized ;
432
435
Local<v8::String> name_string =
433
- v8::String::NewFromUtf8 (isolate, name, type).ToLocalChecked ();
436
+ v8::String::NewFromUtf8 (isolate, name.data (), type, name.size ())
437
+ .ToLocalChecked ();
434
438
that->Set (context, name_string, function).Check ();
435
439
}
436
440
437
441
void SetFastMethodNoSideEffect (Local<v8::Context> context,
438
442
Local<v8::Object> that,
439
- const char * name,
443
+ const std::string_view name,
440
444
v8::FunctionCallback slow_callback,
441
445
const v8::CFunction* c_function) {
442
446
Isolate* isolate = context->GetIsolate ();
@@ -451,13 +455,14 @@ void SetFastMethodNoSideEffect(Local<v8::Context> context,
451
455
.ToLocalChecked ();
452
456
const v8::NewStringType type = v8::NewStringType::kInternalized ;
453
457
Local<v8::String> name_string =
454
- v8::String::NewFromUtf8 (isolate, name, type).ToLocalChecked ();
458
+ v8::String::NewFromUtf8 (isolate, name.data (), type, name.size ())
459
+ .ToLocalChecked ();
455
460
that->Set (context, name_string, function).Check ();
456
461
}
457
462
458
463
void SetFastMethodNoSideEffect (Isolate* isolate,
459
464
Local<Template> that,
460
- const char * name,
465
+ const std::string_view name,
461
466
v8::FunctionCallback slow_callback,
462
467
const v8::CFunction* c_function) {
463
468
Local<v8::FunctionTemplate> t =
@@ -470,13 +475,14 @@ void SetFastMethodNoSideEffect(Isolate* isolate,
470
475
// kInternalized strings are created in the old space.
471
476
const v8::NewStringType type = v8::NewStringType::kInternalized ;
472
477
Local<v8::String> name_string =
473
- v8::String::NewFromUtf8 (isolate, name, type).ToLocalChecked ();
478
+ v8::String::NewFromUtf8 (isolate, name.data (), type, name.size ())
479
+ .ToLocalChecked ();
474
480
that->Set (name_string, t);
475
481
}
476
482
477
483
void SetMethodNoSideEffect (Local<v8::Context> context,
478
484
Local<v8::Object> that,
479
- const char * name,
485
+ const std::string_view name,
480
486
v8::FunctionCallback callback) {
481
487
Isolate* isolate = context->GetIsolate ();
482
488
Local<v8::Function> function =
@@ -490,14 +496,15 @@ void SetMethodNoSideEffect(Local<v8::Context> context,
490
496
// kInternalized strings are created in the old space.
491
497
const v8::NewStringType type = v8::NewStringType::kInternalized ;
492
498
Local<v8::String> name_string =
493
- v8::String::NewFromUtf8 (isolate, name, type).ToLocalChecked ();
499
+ v8::String::NewFromUtf8 (isolate, name.data (), type, name.size ())
500
+ .ToLocalChecked ();
494
501
that->Set (context, name_string, function).Check ();
495
502
function->SetName (name_string); // NODE_SET_METHOD() compatibility.
496
503
}
497
504
498
505
void SetMethodNoSideEffect (Isolate* isolate,
499
506
Local<v8::Template> that,
500
- const char * name,
507
+ const std::string_view name,
501
508
v8::FunctionCallback callback) {
502
509
Local<v8::FunctionTemplate> t =
503
510
NewFunctionTemplate (isolate,
@@ -508,13 +515,14 @@ void SetMethodNoSideEffect(Isolate* isolate,
508
515
// kInternalized strings are created in the old space.
509
516
const v8::NewStringType type = v8::NewStringType::kInternalized ;
510
517
Local<v8::String> name_string =
511
- v8::String::NewFromUtf8 (isolate, name, type).ToLocalChecked ();
518
+ v8::String::NewFromUtf8 (isolate, name.data (), type, name.size ())
519
+ .ToLocalChecked ();
512
520
that->Set (name_string, t);
513
521
}
514
522
515
523
void SetProtoMethod (v8::Isolate* isolate,
516
524
Local<v8::FunctionTemplate> that,
517
- const char * name,
525
+ const std::string_view name,
518
526
v8::FunctionCallback callback) {
519
527
Local<v8::Signature> signature = v8::Signature::New (isolate, that);
520
528
Local<v8::FunctionTemplate> t =
@@ -526,14 +534,15 @@ void SetProtoMethod(v8::Isolate* isolate,
526
534
// kInternalized strings are created in the old space.
527
535
const v8::NewStringType type = v8::NewStringType::kInternalized ;
528
536
Local<v8::String> name_string =
529
- v8::String::NewFromUtf8 (isolate, name, type).ToLocalChecked ();
537
+ v8::String::NewFromUtf8 (isolate, name.data (), type, name.size ())
538
+ .ToLocalChecked ();
530
539
that->PrototypeTemplate ()->Set (name_string, t);
531
540
t->SetClassName (name_string); // NODE_SET_PROTOTYPE_METHOD() compatibility.
532
541
}
533
542
534
543
void SetProtoMethodNoSideEffect (v8::Isolate* isolate,
535
544
Local<v8::FunctionTemplate> that,
536
- const char * name,
545
+ const std::string_view name,
537
546
v8::FunctionCallback callback) {
538
547
Local<v8::Signature> signature = v8::Signature::New (isolate, that);
539
548
Local<v8::FunctionTemplate> t =
@@ -545,14 +554,15 @@ void SetProtoMethodNoSideEffect(v8::Isolate* isolate,
545
554
// kInternalized strings are created in the old space.
546
555
const v8::NewStringType type = v8::NewStringType::kInternalized ;
547
556
Local<v8::String> name_string =
548
- v8::String::NewFromUtf8 (isolate, name, type).ToLocalChecked ();
557
+ v8::String::NewFromUtf8 (isolate, name.data (), type, name.size ())
558
+ .ToLocalChecked ();
549
559
that->PrototypeTemplate ()->Set (name_string, t);
550
560
t->SetClassName (name_string); // NODE_SET_PROTOTYPE_METHOD() compatibility.
551
561
}
552
562
553
563
void SetInstanceMethod (v8::Isolate* isolate,
554
564
Local<v8::FunctionTemplate> that,
555
- const char * name,
565
+ const std::string_view name,
556
566
v8::FunctionCallback callback) {
557
567
Local<v8::Signature> signature = v8::Signature::New (isolate, that);
558
568
Local<v8::FunctionTemplate> t =
@@ -564,7 +574,8 @@ void SetInstanceMethod(v8::Isolate* isolate,
564
574
// kInternalized strings are created in the old space.
565
575
const v8::NewStringType type = v8::NewStringType::kInternalized ;
566
576
Local<v8::String> name_string =
567
- v8::String::NewFromUtf8 (isolate, name, type).ToLocalChecked ();
577
+ v8::String::NewFromUtf8 (isolate, name.data (), type, name.size ())
578
+ .ToLocalChecked ();
568
579
that->InstanceTemplate ()->Set (name_string, t);
569
580
t->SetClassName (name_string);
570
581
}
0 commit comments