Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix warnings in addon tests #18810

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion test/addons/async-hello-world/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ struct async_req {
int output;
v8::Isolate* isolate;
v8::Persistent<v8::Function> callback;
node::async_context context;
};

void DoAsync(uv_work_t* r) {
Expand Down Expand Up @@ -47,14 +48,16 @@ void AfterAsync(uv_work_t* r) {

if (use_makecallback) {
v8::Local<v8::Value> ret =
node::MakeCallback(isolate, global, callback, 2, argv);
node::MakeCallback(isolate, global, callback, 2, argv, req->context)
.ToLocalChecked();
// This should be changed to an empty handle.
assert(!ret.IsEmpty());
} else {
callback->Call(global, 2, argv);
}

// cleanup
node::EmitAsyncDestroy(isolate, req->context);
req->callback.Reset();
delete req;

Expand All @@ -73,6 +76,7 @@ void Method(const v8::FunctionCallbackInfo<v8::Value>& args) {
req->input = args[0]->IntegerValue();
req->output = 0;
req->isolate = isolate;
req->context = node::EmitAsyncInit(isolate, v8::Object::New(isolate), "test");

v8::Local<v8::Function> callback = v8::Local<v8::Function>::Cast(args[1]);
req->callback.Reset(isolate, callback);
Expand Down
3 changes: 2 additions & 1 deletion test/addons/callback-scope/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ static v8::Persistent<v8::Promise::Resolver> persistent;
static void Callback(uv_work_t* req, int ignored) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::HandleScope scope(isolate);
node::CallbackScope callback_scope(isolate, v8::Object::New(isolate), {0, 0});
node::CallbackScope callback_scope(isolate, v8::Object::New(isolate),
node::async_context{0, 0});

v8::Local<v8::Promise::Resolver> local =
v8::Local<v8::Promise::Resolver>::New(isolate, persistent);
Expand Down
3 changes: 2 additions & 1 deletion test/addons/make-callback-recurse/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ void MakeCallback(const FunctionCallbackInfo<Value>& args) {
Local<Object> recv = args[0].As<Object>();
Local<Function> method = args[1].As<Function>();

node::MakeCallback(isolate, recv, method, 0, nullptr);
node::MakeCallback(isolate, recv, method, 0, nullptr,
node::async_context{0, 0});
}

void Initialize(Local<Object> exports) {
Expand Down
6 changes: 4 additions & 2 deletions test/addons/make-callback/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ void MakeCallback(const v8::FunctionCallbackInfo<v8::Value>& args) {
if (args[1]->IsFunction()) {
auto method = args[1].As<v8::Function>();
result =
node::MakeCallback(isolate, recv, method, argv.size(), argv.data());
node::MakeCallback(isolate, recv, method, argv.size(), argv.data(),
node::async_context{0, 0}).ToLocalChecked();
} else if (args[1]->IsString()) {
auto method = args[1].As<v8::String>();
result =
node::MakeCallback(isolate, recv, method, argv.size(), argv.data());
node::MakeCallback(isolate, recv, method, argv.size(), argv.data(),
node::async_context{0, 0}).ToLocalChecked();
} else {
assert(0 && "unreachable");
}
Expand Down
9 changes: 4 additions & 5 deletions test/addons/repl-domain-abort/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@ void Method(const FunctionCallbackInfo<Value>& args) {
Boolean::New(isolate, true),
Boolean::New(isolate, false)
};
Local<Value> ret = node::MakeCallback(isolate,
isolate->GetCurrentContext()->Global(),
args[0].As<Function>(),
2,
params);
Local<Value> ret =
node::MakeCallback(isolate, isolate->GetCurrentContext()->Global(),
args[0].As<Function>(), 2, params,
node::async_context{0, 0}).ToLocalChecked();
assert(ret->IsTrue());
}

Expand Down