felipealmeida pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=17da4b5b9d8510ba1263e180b41f62ff5bedfe0f
commit 17da4b5b9d8510ba1263e180b41f62ff5bedfe0f Author: Felipe Magno de Almeida <fel...@expertisesolutions.com.br> Date: Thu Oct 20 04:52:18 2016 -0200 eo-cxx: Fix compilation and warnings in clang --- src/bindings/cxx/eina_cxx/eina_value.hh | 12 +++++-- src/bindings/cxx/eo_cxx/eo_cxx_interop.hh | 6 ++-- src/bindings/cxx/eo_cxx/eo_future.hh | 54 ++++++++++++++++-------------- src/bindings/cxx/eo_cxx/eo_promise_meta.hh | 1 + 4 files changed, 41 insertions(+), 32 deletions(-) diff --git a/src/bindings/cxx/eina_cxx/eina_value.hh b/src/bindings/cxx/eina_cxx/eina_value.hh index 947b5d4..a529ce2 100644 --- a/src/bindings/cxx/eina_cxx/eina_value.hh +++ b/src/bindings/cxx/eina_cxx/eina_value.hh @@ -338,8 +338,8 @@ public: * @brief Create an generic value storage holding the given argument. * @param v Value to be stored. */ - template <typename T> - value_view(T v, typename std::enable_if<_eina_value_traits<T>::is_specialized::value>::type* = 0) + template <typename T, typename Enable = typename std::enable_if<_eina_value_traits<T>::is_specialized::value>::type> + value_view(T v) { primitive_init(v); } @@ -462,6 +462,12 @@ public: return _raw; } + void reset(Eina_Value* v) + { + value_view tmp(v); + tmp.swap(*this); + } + /** * Type for a constant pointer to an @c Eina_Value_Type. * Describes the type of the data being stored. @@ -604,7 +610,7 @@ inline bool operator!=(value_view const& lhs, value_view const& rhs) /** * Store generic value */ -struct value : value_view +struct value : value_view { using value_view::value_view; diff --git a/src/bindings/cxx/eo_cxx/eo_cxx_interop.hh b/src/bindings/cxx/eo_cxx/eo_cxx_interop.hh index fc1793f..0545f25 100644 --- a/src/bindings/cxx/eo_cxx/eo_cxx_interop.hh +++ b/src/bindings/cxx/eo_cxx/eo_cxx_interop.hh @@ -147,7 +147,7 @@ void assign_out_impl(efl::eina::string_view* view, const char* string, Tag) template <typename Tag> void assign_out_impl(efl::eina::stringshare& to, const char* from, Tag) { - to = {from}; + to = from; } template <typename T> void assign_out_impl(T*& lhs, T& rhs, tag<T*, T>) // optional @@ -167,7 +167,7 @@ void assign_out_impl(eina::value& lhs, Eina_Value& rhs, Tag) Eina_Value* v = eina_value_new(EINA_VALUE_TYPE_CHAR); eina_value_flush(v); eina_value_copy(&rhs, v); - lhs = {v}; + lhs.reset(v); eina_value_flush(&rhs); } // This is a invalid use-case that is used in EFL. This leaks @@ -177,7 +177,7 @@ void assign_out_impl(eina::value_view& lhs, Eina_Value& rhs, Tag) Eina_Value* v = eina_value_new(EINA_VALUE_TYPE_CHAR); eina_value_flush(v); eina_value_copy(&rhs, v); - lhs = {v}; + lhs.reset(v); } template <typename T> void assign_out_impl(efl::eina::list<T>& lhs, Eina_List* rhs, tag<efl::eina::list<T>&, Eina_List*, true>) diff --git a/src/bindings/cxx/eo_cxx/eo_future.hh b/src/bindings/cxx/eo_cxx/eo_future.hh index fbab965..7ed77cf 100644 --- a/src/bindings/cxx/eo_cxx/eo_future.hh +++ b/src/bindings/cxx/eo_cxx/eo_future.hh @@ -34,15 +34,15 @@ struct wait_state Eina_Error error; }; -static void get_error_cb(void* data, Efl_Event const* event) -{ - struct wait_state<>* wait_state = static_cast<struct wait_state<>*>(data); +inline void get_error_cb(void* data, Efl_Event const* event) +{ + wait_state<>* wait_state_ = static_cast<wait_state<>*>(data); Efl_Future_Event_Failure* info = static_cast<Efl_Future_Event_Failure*>(event->info); - std::unique_lock<std::mutex> l(wait_state->mutex); - wait_state->error = info->error; - wait_state->has_failed = true; - wait_state->available = true; - wait_state->cv.notify_one(); + std::unique_lock<std::mutex> l(wait_state_->mutex); + wait_state_->error = info->error; + wait_state_->has_failed = true; + wait_state_->available = true; + wait_state_->cv.notify_one(); } struct shared_future_common @@ -103,10 +103,10 @@ struct shared_future_common } static void wait_success(void* data, Efl_Event const*) { - struct wait_state<>* wait_state = static_cast<struct wait_state<>*>(data); - std::unique_lock<std::mutex> l(wait_state->mutex); - wait_state->available = true; - wait_state->cv.notify_one(); + wait_state<>* wait_state_ = static_cast<wait_state<>*>(data); + std::unique_lock<std::mutex> l(wait_state_->mutex); + wait_state_->available = true; + wait_state_->cv.notify_one(); } typedef Efl_Future* native_handle_type; @@ -151,13 +151,13 @@ struct shared_future_1_type : shared_future_common static void get_success(void* data, Efl_Event const* event) { - struct wait_state<T>* wait_state = static_cast<struct wait_state<T>*>(data); + wait_state<T>* wait_state_ = static_cast<wait_state<T>*>(data); Efl_Future_Event_Success* info = static_cast<Efl_Future_Event_Success*>(event->info); - std::unique_lock<std::mutex> l(wait_state->mutex); - _impl::future_copy_traits<T>::copy(static_cast<T*>(static_cast<void*>(&wait_state->storage)), info); - wait_state->available = true; - wait_state->cv.notify_one(); + std::unique_lock<std::mutex> l(wait_state_->mutex); + _impl::future_copy_traits<T>::copy(static_cast<T*>(static_cast<void*>(&wait_state_->storage)), info); + wait_state_->available = true; + wait_state_->cv.notify_one(); } typedef shared_future_1_type<T, Progress> _self_type; @@ -197,13 +197,13 @@ struct shared_race_future_1_type : shared_future_common static void get_success(void* data, Efl_Event const* event) { - struct wait_state<T>* wait_state = static_cast<struct wait_state<T>*>(data); + wait_state<T>* wait_state_ = static_cast<wait_state<T>*>(data); Efl_Future_Event_Success* info = static_cast<Efl_Future_Event_Success*>(event->info); - std::unique_lock<std::mutex> l(wait_state->mutex); - _impl::future_copy_traits<T>::copy_race(static_cast<T*>(static_cast<void*>(&wait_state->storage)), info); - wait_state->available = true; - wait_state->cv.notify_one(); + std::unique_lock<std::mutex> l(wait_state_->mutex); + _impl::future_copy_traits<T>::copy_race(static_cast<T*>(static_cast<void*>(&wait_state_->storage)), info); + wait_state_->available = true; + wait_state_->cv.notify_one(); } typedef shared_race_future_1_type<T> _self_type; @@ -292,13 +292,13 @@ struct shared_future_varargs_type : shared_future_common static void get_success(void* data, Efl_Event const* event) { - struct wait_state<tuple_type>* wait_state = static_cast<struct wait_state<tuple_type>*>(data); + wait_state<tuple_type>* wait_state_ = static_cast<wait_state<tuple_type>*>(data); Efl_Future_Event_Success* info = static_cast<Efl_Future_Event_Success*>(event->info); Eina_Accessor* accessor = static_cast<Eina_Accessor*>(info->value); std::tuple<typename std::aligned_storage<sizeof(Args), alignof(Args)>::type...> storage_tuple; - _self_type::read_accessor<0u>(accessor, storage_tuple, wait_state, std::false_type()); + _self_type::read_accessor<0u>(accessor, storage_tuple, wait_state_, std::false_type()); } typedef shared_future_varargs_type<Args...> _self_type; @@ -477,11 +477,13 @@ shared_future = efl_future_then(pdata->future.native_handle(), raw_success_cb, raw_error_cb, nullptr, pdata); return shared_future<typename std::result_of<Success(Args...)>::type>{efl_ref(new_future)}; } - + +// TODO: template <typename...Args, typename F> void then(shared_future<Args...> future, F function) { - + static_cast<void>(future); + static_cast<void>(function); } template <typename...Args1, typename...Args2, typename...Futures> diff --git a/src/bindings/cxx/eo_cxx/eo_promise_meta.hh b/src/bindings/cxx/eo_cxx/eo_promise_meta.hh index aa2894f..4d42c20 100644 --- a/src/bindings/cxx/eo_cxx/eo_promise_meta.hh +++ b/src/bindings/cxx/eo_cxx/eo_promise_meta.hh @@ -248,6 +248,7 @@ typename std::enable_if<std::is_same<A0, void>::value>::type future_invoke(F f, Efl_Event const* event, std::integral_constant<bool, IsRace>) { Efl_Future_Event_Success* info = static_cast<Efl_Future_Event_Success*>(event->info); + static_cast<void>(info); try { f(); --