From b3f6a3857a3eb85df20f1adc8d2e51856223bb0a Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Wed, 29 Jun 2016 20:20:54 +0200 Subject: [PATCH 1/9] src: extracting PipeConnectWrap and TCPConnectWrap to ConnectWrap This commit attempts to address one of the items in #4641 which is related to src/pipe_wrap.cc and src/tcp_wrap.cc. Currently both pipe_wrap.cc and tcp_wrap.cc contain a class that are almost identical. This commit extracts these parts into a separate class that both can share. --- node.gyp | 3 +++ src/connect_wrap-inl.h | 24 ++++++++++++++++++++++++ src/connect_wrap.cc | 23 +++++++++++++++++++++++ src/connect_wrap.h | 34 ++++++++++++++++++++++++++++++++++ src/pipe_wrap.cc | 31 ++++++------------------------- src/tcp_wrap.cc | 32 ++++++++------------------------ 6 files changed, 98 insertions(+), 49 deletions(-) create mode 100644 src/connect_wrap-inl.h create mode 100644 src/connect_wrap.cc create mode 100644 src/connect_wrap.h diff --git a/node.gyp b/node.gyp index e8b957267e9710..b2aec76efde68e 100644 --- a/node.gyp +++ b/node.gyp @@ -142,6 +142,7 @@ 'src/fs_event_wrap.cc', 'src/cares_wrap.cc', 'src/connection_wrap.cc', + 'src/connect_wrap.cc', 'src/handle_wrap.cc', 'src/js_stream.cc', 'src/node.cc', @@ -179,6 +180,8 @@ 'src/base-object.h', 'src/base-object-inl.h', 'src/connection_wrap.h', + 'src/connect_wrap.h', + 'src/connect_wrap-inl.h', 'src/debug-agent.h', 'src/env.h', 'src/env-inl.h', diff --git a/src/connect_wrap-inl.h b/src/connect_wrap-inl.h new file mode 100644 index 00000000000000..6499306e39a5c6 --- /dev/null +++ b/src/connect_wrap-inl.h @@ -0,0 +1,24 @@ +#ifndef SRC_CONNECT_WRAP_INL_H_ +#define SRC_CONNECT_WRAP_INL_H_ + +#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS + +#include "connect_wrap.h" +#include "util.h" +#include "util-inl.h" +#include "v8.h" + +namespace node { + +using v8::FunctionCallbackInfo; +using v8::Value; + +static inline void NewConnectWrap(const FunctionCallbackInfo& args) { + CHECK(args.IsConstructCall()); +} + +} // namespace node + +#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS + +#endif // SRC_CONNECT_WRAP_INL_H_ diff --git a/src/connect_wrap.cc b/src/connect_wrap.cc new file mode 100644 index 00000000000000..fc50291322ed28 --- /dev/null +++ b/src/connect_wrap.cc @@ -0,0 +1,23 @@ +#include "connect_wrap.h" + +#include "env.h" +#include "env-inl.h" +#include "req-wrap.h" +#include "req-wrap-inl.h" +#include "util.h" +#include "util-inl.h" + +namespace node { + +using v8::Local; +using v8::Object; + + +ConnectWrap::ConnectWrap(Environment* env, + Local req_wrap_obj, + AsyncWrap::ProviderType provider) : ReqWrap(env, req_wrap_obj, provider) { + Wrap(req_wrap_obj, this); +} + +} // namespace node + diff --git a/src/connect_wrap.h b/src/connect_wrap.h new file mode 100644 index 00000000000000..bd53bcbdcd6ce8 --- /dev/null +++ b/src/connect_wrap.h @@ -0,0 +1,34 @@ +#ifndef SRC_CONNECT_WRAP_H_ +#define SRC_CONNECT_WRAP_H_ + +#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS + +#include "env.h" +#include "req-wrap.h" +#include "async-wrap.h" +#include "v8.h" + +namespace node { + +using v8::FunctionCallbackInfo; +using v8::Local; +using v8::Object; +using v8::Value; + + +class ConnectWrap : public ReqWrap { + public: + ConnectWrap(Environment* env, + Local req_wrap_obj, + AsyncWrap::ProviderType provider); + + size_t self_size() const override { return sizeof(*this); } +}; + +static inline void NewConnectWrap(const FunctionCallbackInfo& args); + +} // namespace node + +#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS + +#endif // SRC_CONNECT_WRAP_H_ diff --git a/src/pipe_wrap.cc b/src/pipe_wrap.cc index 8baf04ba7cef6f..0beaa9df1e88c7 100644 --- a/src/pipe_wrap.cc +++ b/src/pipe_wrap.cc @@ -8,8 +8,8 @@ #include "node.h" #include "node_buffer.h" #include "node_wrap.h" -#include "req-wrap.h" -#include "req-wrap-inl.h" +#include "connect_wrap.h" +#include "connect_wrap-inl.h" #include "stream_wrap.h" #include "util-inl.h" #include "util.h" @@ -31,26 +31,6 @@ using v8::String; using v8::Value; -// TODO(bnoordhuis) share with TCPWrap? -class PipeConnectWrap : public ReqWrap { - public: - PipeConnectWrap(Environment* env, Local req_wrap_obj); - - size_t self_size() const override { return sizeof(*this); } -}; - - -PipeConnectWrap::PipeConnectWrap(Environment* env, Local req_wrap_obj) - : ReqWrap(env, req_wrap_obj, AsyncWrap::PROVIDER_PIPECONNECTWRAP) { - Wrap(req_wrap_obj, this); -} - - -static void NewPipeConnectWrap(const FunctionCallbackInfo& args) { - CHECK(args.IsConstructCall()); -} - - Local PipeWrap::Instantiate(Environment* env, AsyncWrap* parent) { EscapableHandleScope handle_scope(env->isolate()); CHECK_EQ(false, env->pipe_constructor_template().IsEmpty()); @@ -93,7 +73,7 @@ void PipeWrap::Initialize(Local target, // Create FunctionTemplate for PipeConnectWrap. Local cwt = - FunctionTemplate::New(env->isolate(), NewPipeConnectWrap); + FunctionTemplate::New(env->isolate(), NewConnectWrap); cwt->InstanceTemplate()->SetInternalFieldCount(1); cwt->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "PipeConnectWrap")); target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "PipeConnectWrap"), @@ -163,7 +143,7 @@ void PipeWrap::Listen(const FunctionCallbackInfo& args) { // TODO(bnoordhuis) Maybe share this with TCPWrap? void PipeWrap::AfterConnect(uv_connect_t* req, int status) { - PipeConnectWrap* req_wrap = static_cast(req->data); + ConnectWrap* req_wrap = static_cast(req->data); PipeWrap* wrap = static_cast(req->handle->data); CHECK_EQ(req_wrap->env(), wrap->env()); Environment* env = wrap->env(); @@ -226,7 +206,8 @@ void PipeWrap::Connect(const FunctionCallbackInfo& args) { Local req_wrap_obj = args[0].As(); node::Utf8Value name(env->isolate(), args[1]); - PipeConnectWrap* req_wrap = new PipeConnectWrap(env, req_wrap_obj); + ConnectWrap* req_wrap = new ConnectWrap(env, req_wrap_obj, + AsyncWrap::PROVIDER_PIPECONNECTWRAP); uv_pipe_connect(&req_wrap->req_, &wrap->handle_, *name, diff --git a/src/tcp_wrap.cc b/src/tcp_wrap.cc index 674c0592541b99..2937a53de4d710 100644 --- a/src/tcp_wrap.cc +++ b/src/tcp_wrap.cc @@ -6,8 +6,8 @@ #include "handle_wrap.h" #include "node_buffer.h" #include "node_wrap.h" -#include "req-wrap.h" -#include "req-wrap-inl.h" +#include "connect_wrap.h" +#include "connect_wrap-inl.h" #include "stream_wrap.h" #include "util.h" #include "util-inl.h" @@ -32,24 +32,6 @@ using v8::String; using v8::Value; -class TCPConnectWrap : public ReqWrap { - public: - TCPConnectWrap(Environment* env, Local req_wrap_obj); - size_t self_size() const override { return sizeof(*this); } -}; - - -TCPConnectWrap::TCPConnectWrap(Environment* env, Local req_wrap_obj) - : ReqWrap(env, req_wrap_obj, AsyncWrap::PROVIDER_TCPCONNECTWRAP) { - Wrap(req_wrap_obj, this); -} - - -static void NewTCPConnectWrap(const FunctionCallbackInfo& args) { - CHECK(args.IsConstructCall()); -} - - Local TCPWrap::Instantiate(Environment* env, AsyncWrap* parent) { EscapableHandleScope handle_scope(env->isolate()); CHECK_EQ(env->tcp_constructor_template().IsEmpty(), false); @@ -113,7 +95,7 @@ void TCPWrap::Initialize(Local target, // Create FunctionTemplate for TCPConnectWrap. Local cwt = - FunctionTemplate::New(env->isolate(), NewTCPConnectWrap); + FunctionTemplate::New(env->isolate(), NewConnectWrap); cwt->InstanceTemplate()->SetInternalFieldCount(1); cwt->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "TCPConnectWrap")); target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "TCPConnectWrap"), @@ -253,7 +235,7 @@ void TCPWrap::Listen(const FunctionCallbackInfo& args) { void TCPWrap::AfterConnect(uv_connect_t* req, int status) { - TCPConnectWrap* req_wrap = static_cast(req->data); + ConnectWrap* req_wrap = static_cast(req->data); TCPWrap* wrap = static_cast(req->handle->data); CHECK_EQ(req_wrap->env(), wrap->env()); Environment* env = wrap->env(); @@ -300,7 +282,8 @@ void TCPWrap::Connect(const FunctionCallbackInfo& args) { int err = uv_ip4_addr(*ip_address, port, &addr); if (err == 0) { - TCPConnectWrap* req_wrap = new TCPConnectWrap(env, req_wrap_obj); + ConnectWrap* req_wrap = new ConnectWrap(env, req_wrap_obj, + AsyncWrap::PROVIDER_TCPCONNECTWRAP); err = uv_tcp_connect(&req_wrap->req_, &wrap->handle_, reinterpret_cast(&addr), @@ -334,7 +317,8 @@ void TCPWrap::Connect6(const FunctionCallbackInfo& args) { int err = uv_ip6_addr(*ip_address, port, &addr); if (err == 0) { - TCPConnectWrap* req_wrap = new TCPConnectWrap(env, req_wrap_obj); + ConnectWrap* req_wrap = new ConnectWrap(env, req_wrap_obj, + AsyncWrap::PROVIDER_TCPCONNECTWRAP); err = uv_tcp_connect(&req_wrap->req_, &wrap->handle_, reinterpret_cast(&addr), From 877318fe631fad4e798c2d1d0939ead52580fa05 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Thu, 30 Jun 2016 21:12:24 +0200 Subject: [PATCH 2/9] Using FQN in header and removing static --- src/connect_wrap-inl.h | 5 +---- src/connect_wrap.h | 10 ++-------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/connect_wrap-inl.h b/src/connect_wrap-inl.h index 6499306e39a5c6..f9e1ea5f42a407 100644 --- a/src/connect_wrap-inl.h +++ b/src/connect_wrap-inl.h @@ -10,10 +10,7 @@ namespace node { -using v8::FunctionCallbackInfo; -using v8::Value; - -static inline void NewConnectWrap(const FunctionCallbackInfo& args) { +inline void NewConnectWrap(const v8::FunctionCallbackInfo& args) { CHECK(args.IsConstructCall()); } diff --git a/src/connect_wrap.h b/src/connect_wrap.h index bd53bcbdcd6ce8..2a81a4d7dcfef7 100644 --- a/src/connect_wrap.h +++ b/src/connect_wrap.h @@ -10,22 +10,16 @@ namespace node { -using v8::FunctionCallbackInfo; -using v8::Local; -using v8::Object; -using v8::Value; - - class ConnectWrap : public ReqWrap { public: ConnectWrap(Environment* env, - Local req_wrap_obj, + v8::Local req_wrap_obj, AsyncWrap::ProviderType provider); size_t self_size() const override { return sizeof(*this); } }; -static inline void NewConnectWrap(const FunctionCallbackInfo& args); +inline void NewConnectWrap(const v8::FunctionCallbackInfo& args); } // namespace node From b5bd15a7c8a6c43b8e5c6ad667259401f6fdf5cb Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Thu, 30 Jun 2016 21:21:24 +0200 Subject: [PATCH 3/9] Correcting line breaking to make it consistent. --- src/tcp_wrap.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tcp_wrap.cc b/src/tcp_wrap.cc index 2937a53de4d710..970fa976c6c971 100644 --- a/src/tcp_wrap.cc +++ b/src/tcp_wrap.cc @@ -282,8 +282,8 @@ void TCPWrap::Connect(const FunctionCallbackInfo& args) { int err = uv_ip4_addr(*ip_address, port, &addr); if (err == 0) { - ConnectWrap* req_wrap = new ConnectWrap(env, req_wrap_obj, - AsyncWrap::PROVIDER_TCPCONNECTWRAP); + ConnectWrap* req_wrap = + new ConnectWrap(env, req_wrap_obj, AsyncWrap::PROVIDER_TCPCONNECTWRAP); err = uv_tcp_connect(&req_wrap->req_, &wrap->handle_, reinterpret_cast(&addr), From f8e634b2a4df5aa73c25e498700d5a427c9466e0 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Thu, 30 Jun 2016 21:54:29 +0200 Subject: [PATCH 4/9] Replacing NewConnectWrap with lamda expression --- node.gyp | 1 - src/connect_wrap-inl.h | 21 --------------------- src/connect_wrap.h | 2 -- src/pipe_wrap.cc | 4 ++-- src/tcp_wrap.cc | 4 ++-- 5 files changed, 4 insertions(+), 28 deletions(-) delete mode 100644 src/connect_wrap-inl.h diff --git a/node.gyp b/node.gyp index b2aec76efde68e..5e0abfa73648e8 100644 --- a/node.gyp +++ b/node.gyp @@ -181,7 +181,6 @@ 'src/base-object-inl.h', 'src/connection_wrap.h', 'src/connect_wrap.h', - 'src/connect_wrap-inl.h', 'src/debug-agent.h', 'src/env.h', 'src/env-inl.h', diff --git a/src/connect_wrap-inl.h b/src/connect_wrap-inl.h deleted file mode 100644 index f9e1ea5f42a407..00000000000000 --- a/src/connect_wrap-inl.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef SRC_CONNECT_WRAP_INL_H_ -#define SRC_CONNECT_WRAP_INL_H_ - -#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS - -#include "connect_wrap.h" -#include "util.h" -#include "util-inl.h" -#include "v8.h" - -namespace node { - -inline void NewConnectWrap(const v8::FunctionCallbackInfo& args) { - CHECK(args.IsConstructCall()); -} - -} // namespace node - -#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS - -#endif // SRC_CONNECT_WRAP_INL_H_ diff --git a/src/connect_wrap.h b/src/connect_wrap.h index 2a81a4d7dcfef7..1203edb913cb3b 100644 --- a/src/connect_wrap.h +++ b/src/connect_wrap.h @@ -19,8 +19,6 @@ class ConnectWrap : public ReqWrap { size_t self_size() const override { return sizeof(*this); } }; -inline void NewConnectWrap(const v8::FunctionCallbackInfo& args); - } // namespace node #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS diff --git a/src/pipe_wrap.cc b/src/pipe_wrap.cc index 0beaa9df1e88c7..bdc480b1805eb4 100644 --- a/src/pipe_wrap.cc +++ b/src/pipe_wrap.cc @@ -9,7 +9,6 @@ #include "node_buffer.h" #include "node_wrap.h" #include "connect_wrap.h" -#include "connect_wrap-inl.h" #include "stream_wrap.h" #include "util-inl.h" #include "util.h" @@ -73,7 +72,8 @@ void PipeWrap::Initialize(Local target, // Create FunctionTemplate for PipeConnectWrap. Local cwt = - FunctionTemplate::New(env->isolate(), NewConnectWrap); + FunctionTemplate::New(env->isolate(), + [](const FunctionCallbackInfo& a){CHECK(a.IsConstructCall());}); cwt->InstanceTemplate()->SetInternalFieldCount(1); cwt->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "PipeConnectWrap")); target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "PipeConnectWrap"), diff --git a/src/tcp_wrap.cc b/src/tcp_wrap.cc index 970fa976c6c971..338bcee6ef3599 100644 --- a/src/tcp_wrap.cc +++ b/src/tcp_wrap.cc @@ -7,7 +7,6 @@ #include "node_buffer.h" #include "node_wrap.h" #include "connect_wrap.h" -#include "connect_wrap-inl.h" #include "stream_wrap.h" #include "util.h" #include "util-inl.h" @@ -95,7 +94,8 @@ void TCPWrap::Initialize(Local target, // Create FunctionTemplate for TCPConnectWrap. Local cwt = - FunctionTemplate::New(env->isolate(), NewConnectWrap); + FunctionTemplate::New(env->isolate(), + [](const FunctionCallbackInfo& a){CHECK(a.IsConstructCall());}); cwt->InstanceTemplate()->SetInternalFieldCount(1); cwt->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "TCPConnectWrap")); target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "TCPConnectWrap"), From 3defdd8414f869e4ddaa28cb31d4112a9a5b9f57 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Fri, 1 Jul 2016 12:46:10 +0200 Subject: [PATCH 5/9] Moving the lamda expression to a variable to improve readability --- src/pipe_wrap.cc | 8 +++++--- src/tcp_wrap.cc | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/pipe_wrap.cc b/src/pipe_wrap.cc index bdc480b1805eb4..c73498bf97bd4c 100644 --- a/src/pipe_wrap.cc +++ b/src/pipe_wrap.cc @@ -71,9 +71,11 @@ void PipeWrap::Initialize(Local target, env->set_pipe_constructor_template(t); // Create FunctionTemplate for PipeConnectWrap. - Local cwt = - FunctionTemplate::New(env->isolate(), - [](const FunctionCallbackInfo& a){CHECK(a.IsConstructCall());}); + auto constructor = [](const FunctionCallbackInfo& args) { + CHECK(args.IsConstructCall()); + }; + Local cwt = FunctionTemplate::New(env->isolate(), + constructor); cwt->InstanceTemplate()->SetInternalFieldCount(1); cwt->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "PipeConnectWrap")); target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "PipeConnectWrap"), diff --git a/src/tcp_wrap.cc b/src/tcp_wrap.cc index 338bcee6ef3599..30b71a5fd8762c 100644 --- a/src/tcp_wrap.cc +++ b/src/tcp_wrap.cc @@ -93,9 +93,11 @@ void TCPWrap::Initialize(Local target, env->set_tcp_constructor_template(t); // Create FunctionTemplate for TCPConnectWrap. - Local cwt = - FunctionTemplate::New(env->isolate(), - [](const FunctionCallbackInfo& a){CHECK(a.IsConstructCall());}); + auto constructor = [](const FunctionCallbackInfo& args) { + CHECK(args.IsConstructCall()); + }; + Local cwt = FunctionTemplate::New(env->isolate(), + constructor); cwt->InstanceTemplate()->SetInternalFieldCount(1); cwt->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "TCPConnectWrap")); target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "TCPConnectWrap"), From c45aa0603aa0bda05b02945c1e5c95f4bfb453ae Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Fri, 1 Jul 2016 12:51:41 +0200 Subject: [PATCH 6/9] Making the method parameters line up. --- src/connect_wrap.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/connect_wrap.h b/src/connect_wrap.h index 1203edb913cb3b..28d4872d7ed416 100644 --- a/src/connect_wrap.h +++ b/src/connect_wrap.h @@ -13,8 +13,8 @@ namespace node { class ConnectWrap : public ReqWrap { public: ConnectWrap(Environment* env, - v8::Local req_wrap_obj, - AsyncWrap::ProviderType provider); + v8::Local req_wrap_obj, + AsyncWrap::ProviderType provider); size_t self_size() const override { return sizeof(*this); } }; From b3032b0818026bb2411a45d214dbe3317e9d01f9 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Fri, 1 Jul 2016 14:24:07 +0200 Subject: [PATCH 7/9] Fixing lamnda body indentation and line break. --- src/pipe_wrap.cc | 6 +++--- src/tcp_wrap.cc | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pipe_wrap.cc b/src/pipe_wrap.cc index c73498bf97bd4c..98d46e94e2f00b 100644 --- a/src/pipe_wrap.cc +++ b/src/pipe_wrap.cc @@ -72,10 +72,10 @@ void PipeWrap::Initialize(Local target, // Create FunctionTemplate for PipeConnectWrap. auto constructor = [](const FunctionCallbackInfo& args) { - CHECK(args.IsConstructCall()); + CHECK(args.IsConstructCall()); }; - Local cwt = FunctionTemplate::New(env->isolate(), - constructor); + Local cwt = + FunctionTemplate::New(env->isolate(), constructor); cwt->InstanceTemplate()->SetInternalFieldCount(1); cwt->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "PipeConnectWrap")); target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "PipeConnectWrap"), diff --git a/src/tcp_wrap.cc b/src/tcp_wrap.cc index 30b71a5fd8762c..f23748e486a907 100644 --- a/src/tcp_wrap.cc +++ b/src/tcp_wrap.cc @@ -94,10 +94,10 @@ void TCPWrap::Initialize(Local target, // Create FunctionTemplate for TCPConnectWrap. auto constructor = [](const FunctionCallbackInfo& args) { - CHECK(args.IsConstructCall()); + CHECK(args.IsConstructCall()); }; - Local cwt = FunctionTemplate::New(env->isolate(), - constructor); + Local cwt = + FunctionTemplate::New(env->isolate(), constructor); cwt->InstanceTemplate()->SetInternalFieldCount(1); cwt->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "TCPConnectWrap")); target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "TCPConnectWrap"), From a19369f0814ddf95842adb857de8e63b2f5ab48d Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Fri, 1 Jul 2016 18:10:25 +0200 Subject: [PATCH 8/9] Fixing incorrect link breakage. --- src/pipe_wrap.cc | 4 ++-- src/tcp_wrap.cc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pipe_wrap.cc b/src/pipe_wrap.cc index 98d46e94e2f00b..d65734a07eaa67 100644 --- a/src/pipe_wrap.cc +++ b/src/pipe_wrap.cc @@ -208,8 +208,8 @@ void PipeWrap::Connect(const FunctionCallbackInfo& args) { Local req_wrap_obj = args[0].As(); node::Utf8Value name(env->isolate(), args[1]); - ConnectWrap* req_wrap = new ConnectWrap(env, req_wrap_obj, - AsyncWrap::PROVIDER_PIPECONNECTWRAP); + ConnectWrap* req_wrap = + new ConnectWrap(env, req_wrap_obj, AsyncWrap::PROVIDER_PIPECONNECTWRAP); uv_pipe_connect(&req_wrap->req_, &wrap->handle_, *name, diff --git a/src/tcp_wrap.cc b/src/tcp_wrap.cc index f23748e486a907..48892e81dacd66 100644 --- a/src/tcp_wrap.cc +++ b/src/tcp_wrap.cc @@ -319,8 +319,8 @@ void TCPWrap::Connect6(const FunctionCallbackInfo& args) { int err = uv_ip6_addr(*ip_address, port, &addr); if (err == 0) { - ConnectWrap* req_wrap = new ConnectWrap(env, req_wrap_obj, - AsyncWrap::PROVIDER_TCPCONNECTWRAP); + ConnectWrap* req_wrap = + new ConnectWrap(env, req_wrap_obj, AsyncWrap::PROVIDER_TCPCONNECTWRAP); err = uv_tcp_connect(&req_wrap->req_, &wrap->handle_, reinterpret_cast(&addr), From 952baf43170072971d5df95a2c2c6c7a27544792 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Fri, 1 Jul 2016 18:14:03 +0200 Subject: [PATCH 9/9] Using auto to improve readability. --- src/pipe_wrap.cc | 3 +-- src/tcp_wrap.cc | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/pipe_wrap.cc b/src/pipe_wrap.cc index d65734a07eaa67..e013811687f9d9 100644 --- a/src/pipe_wrap.cc +++ b/src/pipe_wrap.cc @@ -74,8 +74,7 @@ void PipeWrap::Initialize(Local target, auto constructor = [](const FunctionCallbackInfo& args) { CHECK(args.IsConstructCall()); }; - Local cwt = - FunctionTemplate::New(env->isolate(), constructor); + auto cwt = FunctionTemplate::New(env->isolate(), constructor); cwt->InstanceTemplate()->SetInternalFieldCount(1); cwt->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "PipeConnectWrap")); target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "PipeConnectWrap"), diff --git a/src/tcp_wrap.cc b/src/tcp_wrap.cc index 48892e81dacd66..92037d0d6838e6 100644 --- a/src/tcp_wrap.cc +++ b/src/tcp_wrap.cc @@ -96,8 +96,7 @@ void TCPWrap::Initialize(Local target, auto constructor = [](const FunctionCallbackInfo& args) { CHECK(args.IsConstructCall()); }; - Local cwt = - FunctionTemplate::New(env->isolate(), constructor); + auto cwt = FunctionTemplate::New(env->isolate(), constructor); cwt->InstanceTemplate()->SetInternalFieldCount(1); cwt->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "TCPConnectWrap")); target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "TCPConnectWrap"),