From 840a2ea8e3b44b31443264935c1b83b8516f69ac Mon Sep 17 00:00:00 2001 From: Ali Ijaz Sheikh Date: Thu, 15 Feb 2018 18:39:49 -0800 Subject: [PATCH] test: fix warnings in addon tests The legacy MakeCallback deprecation was resulting in compile time warnings in adddon tests. Fix them. Ref: https://github.com/nodejs/node/pull/18632 PR-URL: https://github.com/nodejs/node/pull/18810 Refs: https://github.com/nodejs/node/pull/18632 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Michael Dawson --- test/addons/async-hello-world/binding.cc | 6 +++++- test/addons/callback-scope/binding.cc | 3 ++- test/addons/make-callback-recurse/binding.cc | 3 ++- test/addons/make-callback/binding.cc | 6 ++++-- test/addons/repl-domain-abort/binding.cc | 9 ++++----- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/test/addons/async-hello-world/binding.cc b/test/addons/async-hello-world/binding.cc index 5b3a800709f7d7..d4b74ed831f512 100644 --- a/test/addons/async-hello-world/binding.cc +++ b/test/addons/async-hello-world/binding.cc @@ -15,6 +15,7 @@ struct async_req { int output; v8::Isolate* isolate; v8::Persistent callback; + node::async_context context; }; void DoAsync(uv_work_t* r) { @@ -47,7 +48,8 @@ void AfterAsync(uv_work_t* r) { if (use_makecallback) { v8::Local 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 { @@ -55,6 +57,7 @@ void AfterAsync(uv_work_t* r) { } // cleanup + node::EmitAsyncDestroy(isolate, req->context); req->callback.Reset(); delete req; @@ -73,6 +76,7 @@ void Method(const v8::FunctionCallbackInfo& args) { req->input = args[0]->IntegerValue(); req->output = 0; req->isolate = isolate; + req->context = node::EmitAsyncInit(isolate, v8::Object::New(isolate), "test"); v8::Local callback = v8::Local::Cast(args[1]); req->callback.Reset(isolate, callback); diff --git a/test/addons/callback-scope/binding.cc b/test/addons/callback-scope/binding.cc index 52ffe8e91f6dce..3b69d2d5725a8f 100644 --- a/test/addons/callback-scope/binding.cc +++ b/test/addons/callback-scope/binding.cc @@ -36,7 +36,8 @@ static v8::Persistent 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 local = v8::Local::New(isolate, persistent); diff --git a/test/addons/make-callback-recurse/binding.cc b/test/addons/make-callback-recurse/binding.cc index d1f9070f8a2a79..3fe3212ee3c8f5 100644 --- a/test/addons/make-callback-recurse/binding.cc +++ b/test/addons/make-callback-recurse/binding.cc @@ -19,7 +19,8 @@ void MakeCallback(const FunctionCallbackInfo& args) { Local recv = args[0].As(); Local method = args[1].As(); - node::MakeCallback(isolate, recv, method, 0, nullptr); + node::MakeCallback(isolate, recv, method, 0, nullptr, + node::async_context{0, 0}); } void Initialize(Local exports) { diff --git a/test/addons/make-callback/binding.cc b/test/addons/make-callback/binding.cc index 13daf21cff07ae..86ed203b98d8d9 100644 --- a/test/addons/make-callback/binding.cc +++ b/test/addons/make-callback/binding.cc @@ -19,11 +19,13 @@ void MakeCallback(const v8::FunctionCallbackInfo& args) { if (args[1]->IsFunction()) { auto method = args[1].As(); 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(); 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"); } diff --git a/test/addons/repl-domain-abort/binding.cc b/test/addons/repl-domain-abort/binding.cc index d2f7560048fd46..3e716443540229 100644 --- a/test/addons/repl-domain-abort/binding.cc +++ b/test/addons/repl-domain-abort/binding.cc @@ -36,11 +36,10 @@ void Method(const FunctionCallbackInfo& args) { Boolean::New(isolate, true), Boolean::New(isolate, false) }; - Local ret = node::MakeCallback(isolate, - isolate->GetCurrentContext()->Global(), - args[0].As(), - 2, - params); + Local ret = + node::MakeCallback(isolate, isolate->GetCurrentContext()->Global(), + args[0].As(), 2, params, + node::async_context{0, 0}).ToLocalChecked(); assert(ret->IsTrue()); }