Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 840a2ea

Browse filesBrowse 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 <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
1 parent eb9d0ba commit 840a2ea
Copy full SHA for 840a2ea

File tree

Expand file treeCollapse file tree

5 files changed

+17
-10
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

5 files changed

+17
-10
lines changed
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: test/addons/async-hello-world/binding.cc
+5-1Lines changed: 5 additions & 1 deletion
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);
Collapse file

‎test/addons/callback-scope/binding.cc‎

Copy file name to clipboardExpand all lines: test/addons/callback-scope/binding.cc
+2-1Lines changed: 2 additions & 1 deletion
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);
Collapse file

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

Copy file name to clipboardExpand all lines: test/addons/make-callback-recurse/binding.cc
+2-1Lines changed: 2 additions & 1 deletion
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) {
Collapse file

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

Copy file name to clipboardExpand all lines: test/addons/make-callback/binding.cc
+4-2Lines changed: 4 additions & 2 deletions
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
}
Collapse file

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

Copy file name to clipboardExpand all lines: test/addons/repl-domain-abort/binding.cc
+4-5Lines changed: 4 additions & 5 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.