Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: replace IsConstructCall functions with lamda #12384

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 7 additions & 18 deletions src/cares_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,6 @@ GetAddrInfoReqWrap::GetAddrInfoReqWrap(Environment* env,
}


void NewGetAddrInfoReqWrap(const FunctionCallbackInfo<Value>& args) {
CHECK(args.IsConstructCall());
}


class GetNameInfoReqWrap : public ReqWrap<uv_getnameinfo_t> {
public:
GetNameInfoReqWrap(Environment* env, Local<Object> req_wrap_obj);
Expand All @@ -134,16 +129,6 @@ GetNameInfoReqWrap::GetNameInfoReqWrap(Environment* env,
}


void NewGetNameInfoReqWrap(const FunctionCallbackInfo<Value>& args) {
CHECK(args.IsConstructCall());
}


void NewQueryReqWrap(const FunctionCallbackInfo<Value>& args) {
CHECK(args.IsConstructCall());
}


int cmp_ares_tasks(const node_ares_task* a, const node_ares_task* b) {
if (a->sock < b->sock)
return -1;
Expand Down Expand Up @@ -1400,24 +1385,28 @@ void Initialize(Local<Object> target,
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "AI_V4MAPPED"),
Integer::New(env->isolate(), AI_V4MAPPED));

auto is_construct_call_callback =
[](const FunctionCallbackInfo<Value>& args) {
CHECK(args.IsConstructCall());
};
Local<FunctionTemplate> aiw =
FunctionTemplate::New(env->isolate(), NewGetAddrInfoReqWrap);
FunctionTemplate::New(env->isolate(), is_construct_call_callback);
aiw->InstanceTemplate()->SetInternalFieldCount(1);
aiw->SetClassName(
FIXED_ONE_BYTE_STRING(env->isolate(), "GetAddrInfoReqWrap"));
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "GetAddrInfoReqWrap"),
aiw->GetFunction());

Local<FunctionTemplate> niw =
FunctionTemplate::New(env->isolate(), NewGetNameInfoReqWrap);
FunctionTemplate::New(env->isolate(), is_construct_call_callback);
niw->InstanceTemplate()->SetInternalFieldCount(1);
niw->SetClassName(
FIXED_ONE_BYTE_STRING(env->isolate(), "GetNameInfoReqWrap"));
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "GetNameInfoReqWrap"),
niw->GetFunction());

Local<FunctionTemplate> qrw =
FunctionTemplate::New(env->isolate(), NewQueryReqWrap);
FunctionTemplate::New(env->isolate(), is_construct_call_callback);
qrw->InstanceTemplate()->SetInternalFieldCount(1);
qrw->SetClassName(
FIXED_ONE_BYTE_STRING(env->isolate(), "QueryReqWrap"));
Expand Down