src: replace IsConstructCalls with lambda

I've added a deprecation notice as the functions are public, but not
sure if this is correct or the format of the deprecation notice.

PR-URL: https://github.com/nodejs/node/pull/12533
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
Daniel Bevenius 2017-04-20 12:15:36 +02:00
parent cf68280ce1
commit 8eb7790a88
2 changed files with 6 additions and 10 deletions

View File

@ -53,10 +53,6 @@ class ShutdownWrap : public ReqWrap<uv_shutdown_t>,
Wrap(req_wrap_obj, this); Wrap(req_wrap_obj, this);
} }
static void NewShutdownWrap(const v8::FunctionCallbackInfo<v8::Value>& args) {
CHECK(args.IsConstructCall());
}
static ShutdownWrap* from_req(uv_shutdown_t* req) { static ShutdownWrap* from_req(uv_shutdown_t* req) {
return ContainerOf(&ShutdownWrap::req_, req); return ContainerOf(&ShutdownWrap::req_, req);
} }
@ -83,10 +79,6 @@ class WriteWrap: public ReqWrap<uv_write_t>,
size_t self_size() const override { return storage_size_; } size_t self_size() const override { return storage_size_; }
static void NewWriteWrap(const v8::FunctionCallbackInfo<v8::Value>& args) {
CHECK(args.IsConstructCall());
}
static WriteWrap* from_req(uv_write_t* req) { static WriteWrap* from_req(uv_write_t* req) {
return ContainerOf(&WriteWrap::req_, req); return ContainerOf(&WriteWrap::req_, req);
} }

View File

@ -59,15 +59,19 @@ void StreamWrap::Initialize(Local<Object> target,
Local<Context> context) { Local<Context> context) {
Environment* env = Environment::GetCurrent(context); Environment* env = Environment::GetCurrent(context);
auto is_construct_call_callback =
[](const FunctionCallbackInfo<Value>& args) {
CHECK(args.IsConstructCall());
};
Local<FunctionTemplate> sw = Local<FunctionTemplate> sw =
FunctionTemplate::New(env->isolate(), ShutdownWrap::NewShutdownWrap); FunctionTemplate::New(env->isolate(), is_construct_call_callback);
sw->InstanceTemplate()->SetInternalFieldCount(1); sw->InstanceTemplate()->SetInternalFieldCount(1);
sw->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "ShutdownWrap")); sw->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "ShutdownWrap"));
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "ShutdownWrap"), target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "ShutdownWrap"),
sw->GetFunction()); sw->GetFunction());
Local<FunctionTemplate> ww = Local<FunctionTemplate> ww =
FunctionTemplate::New(env->isolate(), WriteWrap::NewWriteWrap); FunctionTemplate::New(env->isolate(), is_construct_call_callback);
ww->InstanceTemplate()->SetInternalFieldCount(1); ww->InstanceTemplate()->SetInternalFieldCount(1);
ww->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "WriteWrap")); ww->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "WriteWrap"));
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "WriteWrap"), target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "WriteWrap"),