diff --git a/src/bindings/cxx/eina_cxx/eina_value.hh b/src/bindings/cxx/eina_cxx/eina_value.hh index 947b5d4672..a529ce23a7 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 - value_view(T v, typename std::enable_if<_eina_value_traits::is_specialized::value>::type* = 0) + template ::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 fc1793fb67..0545f255ff 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 void assign_out_impl(efl::eina::stringshare& to, const char* from, Tag) { - to = {from}; + to = from; } template void assign_out_impl(T*& lhs, T& rhs, tag) // 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 void assign_out_impl(efl::eina::list& lhs, Eina_List* rhs, tag&, Eina_List*, true>) diff --git a/src/bindings/cxx/eo_cxx/eo_future.hh b/src/bindings/cxx/eo_cxx/eo_future.hh index fbab9657c2..7ed77cf016 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*>(data); +inline void get_error_cb(void* data, Efl_Event const* event) +{ + wait_state<>* wait_state_ = static_cast*>(data); Efl_Future_Event_Failure* info = static_cast(event->info); - std::unique_lock 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 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*>(data); - std::unique_lock l(wait_state->mutex); - wait_state->available = true; - wait_state->cv.notify_one(); + wait_state<>* wait_state_ = static_cast*>(data); + std::unique_lock 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* wait_state = static_cast*>(data); + wait_state* wait_state_ = static_cast*>(data); Efl_Future_Event_Success* info = static_cast(event->info); - std::unique_lock l(wait_state->mutex); - _impl::future_copy_traits::copy(static_cast(static_cast(&wait_state->storage)), info); - wait_state->available = true; - wait_state->cv.notify_one(); + std::unique_lock l(wait_state_->mutex); + _impl::future_copy_traits::copy(static_cast(static_cast(&wait_state_->storage)), info); + wait_state_->available = true; + wait_state_->cv.notify_one(); } typedef shared_future_1_type _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* wait_state = static_cast*>(data); + wait_state* wait_state_ = static_cast*>(data); Efl_Future_Event_Success* info = static_cast(event->info); - std::unique_lock l(wait_state->mutex); - _impl::future_copy_traits::copy_race(static_cast(static_cast(&wait_state->storage)), info); - wait_state->available = true; - wait_state->cv.notify_one(); + std::unique_lock l(wait_state_->mutex); + _impl::future_copy_traits::copy_race(static_cast(static_cast(&wait_state_->storage)), info); + wait_state_->available = true; + wait_state_->cv.notify_one(); } typedef shared_race_future_1_type _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* wait_state = static_cast*>(data); + wait_state* wait_state_ = static_cast*>(data); Efl_Future_Event_Success* info = static_cast(event->info); Eina_Accessor* accessor = static_cast(info->value); std::tuple::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 _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::type>{efl_ref(new_future)}; } - + +// TODO: template void then(shared_future future, F function) { - + static_cast(future); + static_cast(function); } template diff --git a/src/bindings/cxx/eo_cxx/eo_promise_meta.hh b/src/bindings/cxx/eo_cxx/eo_promise_meta.hh index aa2894fd2c..4d42c20fec 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::value>::type future_invoke(F f, Efl_Event const* event, std::integral_constant) { Efl_Future_Event_Success* info = static_cast(event->info); + static_cast(info); try { f();