From bdfd36d661983a8e2290ca7ae532449886fd732e Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Mon, 27 Jun 2016 09:24:50 +0200 Subject: [PATCH] renaming --- src/uvw/check.hpp | 4 ++-- src/uvw/resource.hpp | 24 ++++++++++++------------ src/uvw/stream.hpp | 4 ++-- src/uvw/tcp.hpp | 8 ++++---- src/uvw/timer.hpp | 4 ++-- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/uvw/check.hpp b/src/uvw/check.hpp index a04cd0d1..58d1129d 100644 --- a/src/uvw/check.hpp +++ b/src/uvw/check.hpp @@ -29,8 +29,8 @@ public: } void start(std::function cb) noexcept { - using CB = Callback; - auto func = CB::on<&Check::startCallback>(*this, cb); + using CBF = CallbackFactory; + auto func = CBF::on<&Check::startCallback>(*this, cb); auto err = uv_check_start(get(), func); if(err) { cb(UVWError{err}, *this); } } diff --git a/src/uvw/resource.hpp b/src/uvw/resource.hpp index 220f1f71..9dbaa89a 100644 --- a/src/uvw/resource.hpp +++ b/src/uvw/resource.hpp @@ -29,11 +29,11 @@ void* get(uv_connect_t *conn) { return conn->handle->data; } template -struct UVCallback; +struct UVCallbackFactory; template -struct UVCallback { +struct UVCallbackFactory { template &, H, Args...)> static auto once(T &, std::function); @@ -55,7 +55,7 @@ private: template class Resource: public std::enable_shared_from_this { template - friend struct details::UVCallback; + friend struct details::UVCallbackFactory; static void closeCallback(T &t, std::function &cb, uv_handle_t*) { cb(UVWError{}, t); @@ -63,7 +63,7 @@ class Resource: public std::enable_shared_from_this { protected: template - using Callback = details::UVCallback; + using CallbackFactory = details::UVCallbackFactory; template explicit Resource(HandleType, std::shared_ptr r) @@ -94,8 +94,8 @@ public: bool referenced() const noexcept { return !(uv_has_ref(get()) == 0); } void close(std::function cb) noexcept { - using CB = Callback; - auto func = CB::template once<&Resource::closeCallback>(*static_cast(this), std::move(cb)); + using CBF = CallbackFactory; + auto func = CBF::template once<&Resource::closeCallback>(*static_cast(this), std::move(cb)); uv_close(get(), func); } @@ -112,27 +112,27 @@ namespace details { template template &, H, Args...)> -auto UVCallback::once(T &ref, std::function cb) { +auto UVCallbackFactory::once(T &ref, std::function cb) { Resource &res = ref; res.callback = std::move(cb); res.leak = res.shared_from_this(); res.template get()->data = static_cast(&ref); - return &UVCallback::protoOnce; + return &UVCallbackFactory::protoOnce; } template template &, H, Args...)> -auto UVCallback::on(T &ref, std::function cb) { +auto UVCallbackFactory::on(T &ref, std::function cb) { Resource &res = ref; res.callback = std::move(cb); res.leak = res.shared_from_this(); res.template get()->data = static_cast(&ref); - return &UVCallback::protoOn; + return &UVCallbackFactory::protoOn; } template template &, H, Args...)> -void UVCallback::protoOnce(H handle, Args... args) { +void UVCallbackFactory::protoOnce(H handle, Args... args) { T &ref = *(static_cast(details::get(handle))); std::shared_ptr ptr = std::static_pointer_cast(ref.leak); auto cb = std::move(ref.callback); @@ -142,7 +142,7 @@ void UVCallback::protoOnce(H handle, Args... args) { template template &, H, Args...)> -void UVCallback::protoOn(H handle, Args... args) { +void UVCallbackFactory::protoOn(H handle, Args... args) { T &ref = *(static_cast(details::get(handle))); F(ref, ref.callback, handle, std::forward(args)...); } diff --git a/src/uvw/stream.hpp b/src/uvw/stream.hpp index a22d4b77..2bf1ffa0 100644 --- a/src/uvw/stream.hpp +++ b/src/uvw/stream.hpp @@ -22,8 +22,8 @@ public: // TODO shutdown void listen(int backlog, std::function cb) noexcept { - using CB = typename Resource::template Callback; - auto func = CB::on<&Stream::listenCallback>(*static_cast(this), cb); + using CBF = typename Resource::template CallbackFactory; + auto func = CBF::on<&Stream::listenCallback>(*static_cast(this), cb); auto err = uv_listen(this->template get(), backlog, func); if(err) { cb(UVWError{err}, *static_cast(this)); } } diff --git a/src/uvw/tcp.hpp b/src/uvw/tcp.hpp index 88783b3c..59b53e69 100644 --- a/src/uvw/tcp.hpp +++ b/src/uvw/tcp.hpp @@ -64,8 +64,8 @@ template<> void Tcp::connect(std::string ip, int port, std::function cb) noexcept { sockaddr_in addr; uv_ip4_addr(ip.c_str(), port, &addr); - using CB = Callback; - auto func = CB::template once<&Tcp::connectCallback>(*this, cb); + using CBF = CallbackFactory; + auto func = CBF::template once<&Tcp::connectCallback>(*this, cb); auto err = uv_tcp_connect(conn.get(), get(), reinterpret_cast(&addr), func); if(err) { cb(UVWError{err}, *this); } } @@ -75,8 +75,8 @@ template<> void Tcp::connect(std::string ip, int port, std::function cb) noexcept { sockaddr_in6 addr; uv_ip6_addr(ip.c_str(), port, &addr); - using CB = Callback; - auto func = CB::template once<&Tcp::connectCallback>(*this, cb); + using CBF = CallbackFactory; + auto func = CBF::template once<&Tcp::connectCallback>(*this, cb); auto err = uv_tcp_connect(conn.get(), get(), reinterpret_cast(&addr), func); if(err) { cb(UVWError{err}, *this); } } diff --git a/src/uvw/timer.hpp b/src/uvw/timer.hpp index 63030c14..2dd2170b 100644 --- a/src/uvw/timer.hpp +++ b/src/uvw/timer.hpp @@ -33,8 +33,8 @@ public: } void start(const Time &timeout, const Time &rep, std::function cb) noexcept { - using CB = Callback; - auto func = CB::on<&Timer::startCallback>(*this, cb); + using CBF = CallbackFactory; + auto func = CBF::on<&Timer::startCallback>(*this, cb); auto err = uv_timer_start(get(), func, timeout.count(), rep.count()); if(err) { cb(UVWError{err}, *this); } }