test: add permission fast api test · nodejs/node@bf86fab · GitHub
Skip to content

Commit bf86fab

Browse files
jasnelladuh95
authored andcommitted
test: add permission fast api test
Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: #65158 Reviewed-By: Xuguang Mei <meixuguang@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
1 parent 3a47f1f commit bf86fab

4 files changed

Lines changed: 101 additions & 6 deletions

File tree

src/permission/permission.cc

Lines changed: 32 additions & 6 deletions

src/util.cc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,31 @@ void SetFastMethodNoSideEffect(
468468
that->Set(name_string, t);
469469
}
470470

471+
void SetFastMethodNoSideEffect(
472+
Local<v8::Context> context,
473+
Local<v8::Object> that,
474+
const std::string_view name,
475+
v8::FunctionCallback slow_callback,
476+
const v8::MemorySpan<const v8::CFunction>& methods) {
477+
Isolate* isolate = Isolate::GetCurrent();
478+
Local<v8::Function> function = FunctionTemplate::NewWithCFunctionOverloads(
479+
isolate,
480+
slow_callback,
481+
Local<Value>(),
482+
Local<v8::Signature>(),
483+
0,
484+
v8::ConstructorBehavior::kThrow,
485+
v8::SideEffectType::kHasNoSideEffect,
486+
methods)
487+
->GetFunction(context)
488+
.ToLocalChecked();
489+
const v8::NewStringType type = v8::NewStringType::kInternalized;
490+
Local<v8::String> name_string =
491+
v8::String::NewFromUtf8(isolate, name.data(), type, name.size())
492+
.ToLocalChecked();
493+
that->Set(context, name_string, function).Check();
494+
}
495+
471496
void SetMethodNoSideEffect(Local<v8::Context> context,
472497
Local<v8::Object> that,
473498
const std::string_view name,

src/util.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,12 @@ void SetFastMethodNoSideEffect(
912912
const std::string_view name,
913913
v8::FunctionCallback slow_callback,
914914
const v8::MemorySpan<const v8::CFunction>& methods);
915+
void SetFastMethodNoSideEffect(
916+
v8::Local<v8::Context> context,
917+
v8::Local<v8::Object> that,
918+
const std::string_view name,
919+
v8::FunctionCallback slow_callback,
920+
const v8::MemorySpan<const v8::CFunction>& methods);
915921
void SetProtoMethod(v8::Isolate* isolate,
916922
v8::Local<v8::FunctionTemplate> that,
917923
const std::string_view name,
Lines changed: 38 additions & 0 deletions

0 commit comments

Comments
 (0)