From 7513d2c9abbf3c8f941dcc3d48df70476915a615 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Thu, 20 Apr 2017 12:15:36 +0200 Subject: [PATCH 1/2] 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. --- src/stream_base.h | 6 ++++-- src/stream_wrap.cc | 8 ++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/stream_base.h b/src/stream_base.h index 35929750bfbc54..71b9f7cac41c2e 100644 --- a/src/stream_base.h +++ b/src/stream_base.h @@ -53,9 +53,10 @@ class ShutdownWrap : public ReqWrap, Wrap(req_wrap_obj, this); } + NODE_DEPRECATED("Use lambda expression instead", static void NewShutdownWrap(const v8::FunctionCallbackInfo& args) { CHECK(args.IsConstructCall()); - } + }) static ShutdownWrap* from_req(uv_shutdown_t* req) { return ContainerOf(&ShutdownWrap::req_, req); @@ -83,9 +84,10 @@ class WriteWrap: public ReqWrap, size_t self_size() const override { return storage_size_; } + NODE_DEPRECATED("Use lambda expression instead", static void NewWriteWrap(const v8::FunctionCallbackInfo& args) { CHECK(args.IsConstructCall()); - } + }) static WriteWrap* from_req(uv_write_t* req) { return ContainerOf(&WriteWrap::req_, req); diff --git a/src/stream_wrap.cc b/src/stream_wrap.cc index 099151fdb71c35..83c375b54b8a75 100644 --- a/src/stream_wrap.cc +++ b/src/stream_wrap.cc @@ -59,15 +59,19 @@ void StreamWrap::Initialize(Local target, Local context) { Environment* env = Environment::GetCurrent(context); + auto is_construct_call_callback = + [](const FunctionCallbackInfo& args) { + CHECK(args.IsConstructCall()); + }; Local sw = - FunctionTemplate::New(env->isolate(), ShutdownWrap::NewShutdownWrap); + FunctionTemplate::New(env->isolate(), is_construct_call_callback); sw->InstanceTemplate()->SetInternalFieldCount(1); sw->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "ShutdownWrap")); target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "ShutdownWrap"), sw->GetFunction()); Local ww = - FunctionTemplate::New(env->isolate(), WriteWrap::NewWriteWrap); + FunctionTemplate::New(env->isolate(), is_construct_call_callback); ww->InstanceTemplate()->SetInternalFieldCount(1); ww->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "WriteWrap")); target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "WriteWrap"), From a43eb344e84b4bd78d2e6fb0f8b46811e3d9aa1a Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Thu, 20 Apr 2017 13:25:05 +0200 Subject: [PATCH 2/2] remove functions instead of deprecating --- src/stream_base.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/stream_base.h b/src/stream_base.h index 71b9f7cac41c2e..e2ef8d8d396b87 100644 --- a/src/stream_base.h +++ b/src/stream_base.h @@ -53,11 +53,6 @@ class ShutdownWrap : public ReqWrap, Wrap(req_wrap_obj, this); } - NODE_DEPRECATED("Use lambda expression instead", - static void NewShutdownWrap(const v8::FunctionCallbackInfo& args) { - CHECK(args.IsConstructCall()); - }) - static ShutdownWrap* from_req(uv_shutdown_t* req) { return ContainerOf(&ShutdownWrap::req_, req); } @@ -84,11 +79,6 @@ class WriteWrap: public ReqWrap, size_t self_size() const override { return storage_size_; } - NODE_DEPRECATED("Use lambda expression instead", - static void NewWriteWrap(const v8::FunctionCallbackInfo& args) { - CHECK(args.IsConstructCall()); - }) - static WriteWrap* from_req(uv_write_t* req) { return ContainerOf(&WriteWrap::req_, req); }