mirror of https://github.com/nodejs/node.git
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 <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>pull/18810/merge
parent
197258bda7
commit
6ab288f3b8
|
@ -15,6 +15,7 @@ struct async_req {
|
||||||
int output;
|
int output;
|
||||||
v8::Isolate* isolate;
|
v8::Isolate* isolate;
|
||||||
v8::Persistent<v8::Function> callback;
|
v8::Persistent<v8::Function> callback;
|
||||||
|
node::async_context context;
|
||||||
};
|
};
|
||||||
|
|
||||||
void DoAsync(uv_work_t* r) {
|
void DoAsync(uv_work_t* r) {
|
||||||
|
@ -47,7 +48,8 @@ void AfterAsync(uv_work_t* r) {
|
||||||
|
|
||||||
if (use_makecallback) {
|
if (use_makecallback) {
|
||||||
v8::Local<v8::Value> ret =
|
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.
|
// This should be changed to an empty handle.
|
||||||
assert(!ret.IsEmpty());
|
assert(!ret.IsEmpty());
|
||||||
} else {
|
} else {
|
||||||
|
@ -55,6 +57,7 @@ void AfterAsync(uv_work_t* r) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// cleanup
|
// cleanup
|
||||||
|
node::EmitAsyncDestroy(isolate, req->context);
|
||||||
req->callback.Reset();
|
req->callback.Reset();
|
||||||
delete req;
|
delete req;
|
||||||
|
|
||||||
|
@ -73,6 +76,7 @@ void Method(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||||
req->input = args[0]->IntegerValue();
|
req->input = args[0]->IntegerValue();
|
||||||
req->output = 0;
|
req->output = 0;
|
||||||
req->isolate = isolate;
|
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]);
|
v8::Local<v8::Function> callback = v8::Local<v8::Function>::Cast(args[1]);
|
||||||
req->callback.Reset(isolate, callback);
|
req->callback.Reset(isolate, callback);
|
||||||
|
|
|
@ -36,7 +36,8 @@ static v8::Persistent<v8::Promise::Resolver> persistent;
|
||||||
static void Callback(uv_work_t* req, int ignored) {
|
static void Callback(uv_work_t* req, int ignored) {
|
||||||
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||||
v8::HandleScope scope(isolate);
|
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> local =
|
||||||
v8::Local<v8::Promise::Resolver>::New(isolate, persistent);
|
v8::Local<v8::Promise::Resolver>::New(isolate, persistent);
|
||||||
|
|
|
@ -19,7 +19,8 @@ void MakeCallback(const FunctionCallbackInfo<Value>& args) {
|
||||||
Local<Object> recv = args[0].As<Object>();
|
Local<Object> recv = args[0].As<Object>();
|
||||||
Local<Function> method = args[1].As<Function>();
|
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) {
|
void Initialize(Local<Object> exports) {
|
||||||
|
|
|
@ -19,11 +19,13 @@ void MakeCallback(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||||
if (args[1]->IsFunction()) {
|
if (args[1]->IsFunction()) {
|
||||||
auto method = args[1].As<v8::Function>();
|
auto method = args[1].As<v8::Function>();
|
||||||
result =
|
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()) {
|
} else if (args[1]->IsString()) {
|
||||||
auto method = args[1].As<v8::String>();
|
auto method = args[1].As<v8::String>();
|
||||||
result =
|
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 {
|
} else {
|
||||||
assert(0 && "unreachable");
|
assert(0 && "unreachable");
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,11 +36,10 @@ void Method(const FunctionCallbackInfo<Value>& args) {
|
||||||
Boolean::New(isolate, true),
|
Boolean::New(isolate, true),
|
||||||
Boolean::New(isolate, false)
|
Boolean::New(isolate, false)
|
||||||
};
|
};
|
||||||
Local<Value> ret = node::MakeCallback(isolate,
|
Local<Value> ret =
|
||||||
isolate->GetCurrentContext()->Global(),
|
node::MakeCallback(isolate, isolate->GetCurrentContext()->Global(),
|
||||||
args[0].As<Function>(),
|
args[0].As<Function>(), 2, params,
|
||||||
2,
|
node::async_context{0, 0}).ToLocalChecked();
|
||||||
params);
|
|
||||||
assert(ret->IsTrue());
|
assert(ret->IsTrue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue