Skip to content

Commit 840a2ea

Browse files
ofrobotsMylesBorins
authored andcommitted
test: fix warnings in addon tests
The legacy MakeCallback deprecation was resulting in compile time warnings in adddon tests. Fix them. Ref: #18632 PR-URL: #18810 Refs: #18632 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
1 parent eb9d0ba commit 840a2ea

File tree

5 files changed

+17
-10
lines changed

5 files changed

+17
-10
lines changed

test/addons/async-hello-world/binding.cc

+5-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ struct async_req {
1515
int output;
1616
v8::Isolate* isolate;
1717
v8::Persistent<v8::Function> callback;
18+
node::async_context context;
1819
};
1920

2021
void DoAsync(uv_work_t* r) {
@@ -47,14 +48,16 @@ void AfterAsync(uv_work_t* r) {
4748

4849
if (use_makecallback) {
4950
v8::Local<v8::Value> ret =
50-
node::MakeCallback(isolate, global, callback, 2, argv);
51+
node::MakeCallback(isolate, global, callback, 2, argv, req->context)
52+
.ToLocalChecked();
5153
// This should be changed to an empty handle.
5254
assert(!ret.IsEmpty());
5355
} else {
5456
callback->Call(global, 2, argv);
5557
}
5658

5759
// cleanup
60+
node::EmitAsyncDestroy(isolate, req->context);
5861
req->callback.Reset();
5962
delete req;
6063

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

7781
v8::Local<v8::Function> callback = v8::Local<v8::Function>::Cast(args[1]);
7882
req->callback.Reset(isolate, callback);

test/addons/callback-scope/binding.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ static v8::Persistent<v8::Promise::Resolver> persistent;
3636
static void Callback(uv_work_t* req, int ignored) {
3737
v8::Isolate* isolate = v8::Isolate::GetCurrent();
3838
v8::HandleScope scope(isolate);
39-
node::CallbackScope callback_scope(isolate, v8::Object::New(isolate), {0, 0});
39+
node::CallbackScope callback_scope(isolate, v8::Object::New(isolate),
40+
node::async_context{0, 0});
4041

4142
v8::Local<v8::Promise::Resolver> local =
4243
v8::Local<v8::Promise::Resolver>::New(isolate, persistent);

test/addons/make-callback-recurse/binding.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ void MakeCallback(const FunctionCallbackInfo<Value>& args) {
1919
Local<Object> recv = args[0].As<Object>();
2020
Local<Function> method = args[1].As<Function>();
2121

22-
node::MakeCallback(isolate, recv, method, 0, nullptr);
22+
node::MakeCallback(isolate, recv, method, 0, nullptr,
23+
node::async_context{0, 0});
2324
}
2425

2526
void Initialize(Local<Object> exports) {

test/addons/make-callback/binding.cc

+4-2
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ void MakeCallback(const v8::FunctionCallbackInfo<v8::Value>& args) {
1919
if (args[1]->IsFunction()) {
2020
auto method = args[1].As<v8::Function>();
2121
result =
22-
node::MakeCallback(isolate, recv, method, argv.size(), argv.data());
22+
node::MakeCallback(isolate, recv, method, argv.size(), argv.data(),
23+
node::async_context{0, 0}).ToLocalChecked();
2324
} else if (args[1]->IsString()) {
2425
auto method = args[1].As<v8::String>();
2526
result =
26-
node::MakeCallback(isolate, recv, method, argv.size(), argv.data());
27+
node::MakeCallback(isolate, recv, method, argv.size(), argv.data(),
28+
node::async_context{0, 0}).ToLocalChecked();
2729
} else {
2830
assert(0 && "unreachable");
2931
}

test/addons/repl-domain-abort/binding.cc

+4-5
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,10 @@ void Method(const FunctionCallbackInfo<Value>& args) {
3636
Boolean::New(isolate, true),
3737
Boolean::New(isolate, false)
3838
};
39-
Local<Value> ret = node::MakeCallback(isolate,
40-
isolate->GetCurrentContext()->Global(),
41-
args[0].As<Function>(),
42-
2,
43-
params);
39+
Local<Value> ret =
40+
node::MakeCallback(isolate, isolate->GetCurrentContext()->Global(),
41+
args[0].As<Function>(), 2, params,
42+
node::async_context{0, 0}).ToLocalChecked();
4443
assert(ret->IsTrue());
4544
}
4645

0 commit comments

Comments
 (0)