Skip to content

Commit

Permalink
test: fix warnings in addon tests
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
ofrobots authored and MylesBorins committed Feb 21, 2018
1 parent 1c77929 commit dc45685
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
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

0 comments on commit dc45685

Please sign in to comment.