GeezerVison is showing github.com — src: add ability to overload fast api functions · nodejs/node@497df82
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: src/util.cc +47Lines changed: 47 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -482,6 +482,53 @@ void SetFastMethodNoSideEffect(Isolate* isolate, | 482 | 482 | that->Set(name_string, t); | 483 | 483 | } | 484 | 484 |
| | 485 | +void SetFastMethod(Isolate* isolate, | | 486 | + Local<Template> that, | | 487 | + const std::string_view name, | | 488 | + v8::FunctionCallback slow_callback, | | 489 | + const v8::MemorySpan<const v8::CFunction>& methods) { | | 490 | + Local<v8::FunctionTemplate> t = FunctionTemplate::NewWithCFunctionOverloads( | | 491 | + isolate, | | 492 | + slow_callback, | | 493 | + Local<Value>(), | | 494 | + Local<v8::Signature>(), | | 495 | + 0, | | 496 | + v8::ConstructorBehavior::kThrow, | | 497 | + v8::SideEffectType::kHasSideEffect, | | 498 | + methods); | | 499 | + | | 500 | + // kInternalized strings are created in the old space. | | 501 | + const v8::NewStringType type = v8::NewStringType::kInternalized; | | 502 | + Local<v8::String> name_string = | | 503 | + v8::String::NewFromUtf8(isolate, name.data(), type, name.size()) | | 504 | + .ToLocalChecked(); | | 505 | + that->Set(name_string, t); | | 506 | +} | | 507 | + | | 508 | +void SetFastMethodNoSideEffect( | | 509 | + Isolate* isolate, | | 510 | + Local<Template> that, | | 511 | + const std::string_view name, | | 512 | + v8::FunctionCallback slow_callback, | | 513 | + const v8::MemorySpan<const v8::CFunction>& methods) { | | 514 | + Local<v8::FunctionTemplate> t = FunctionTemplate::NewWithCFunctionOverloads( | | 515 | + isolate, | | 516 | + slow_callback, | | 517 | + Local<Value>(), | | 518 | + Local<v8::Signature>(), | | 519 | + 0, | | 520 | + v8::ConstructorBehavior::kThrow, | | 521 | + v8::SideEffectType::kHasNoSideEffect, | | 522 | + methods); | | 523 | + | | 524 | + // kInternalized strings are created in the old space. | | 525 | + const v8::NewStringType type = v8::NewStringType::kInternalized; | | 526 | + Local<v8::String> name_string = | | 527 | + v8::String::NewFromUtf8(isolate, name.data(), type, name.size()) | | 528 | + .ToLocalChecked(); | | 529 | + that->Set(name_string, t); | | 530 | +} | | 531 | + | 485 | 532 | void SetMethodNoSideEffect(Local<v8::Context> context, | 486 | 533 | Local<v8::Object> that, | 487 | 534 | const std::string_view name, | |
Collapse file Copy file name to clipboardExpand all lines: src/util.h +11-1Lines changed: 11 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -890,6 +890,11 @@ void SetFastMethod(v8::Local<v8::Context> context, | 890 | 890 | const std::string_view name, | 891 | 891 | v8::FunctionCallback slow_callback, | 892 | 892 | const v8::CFunction* c_function); | | 893 | +void SetFastMethod(v8::Isolate* isolate, | | 894 | + v8::Local<v8::Template> that, | | 895 | + const std::string_view name, | | 896 | + v8::FunctionCallback slow_callback, | | 897 | + const v8::MemorySpan<const v8::CFunction>& methods); | 893 | 898 | void SetFastMethodNoSideEffect(v8::Isolate* isolate, | 894 | 899 | v8::Local<v8::Template> that, | 895 | 900 | const std::string_view name, | @@ -900,7 +905,12 @@ void SetFastMethodNoSideEffect(v8::Local<v8::Context> context, | 900 | 905 | const std::string_view name, | 901 | 906 | v8::FunctionCallback slow_callback, | 902 | 907 | const v8::CFunction* c_function); | 903 | | - | | 908 | +void SetFastMethodNoSideEffect( | | 909 | + v8::Isolate* isolate, | | 910 | + v8::Local<v8::Template> that, | | 911 | + const std::string_view name, | | 912 | + v8::FunctionCallback slow_callback, | | 913 | + const v8::MemorySpan<const v8::CFunction>& methods); | 904 | 914 | void SetProtoMethod(v8::Isolate* isolate, | 905 | 915 | v8::Local<v8::FunctionTemplate> that, | 906 | 916 | const std::string_view name, | |
|