felipealmeida pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=36405c6556fe81afe13062e908300c36d798f4c0
commit 36405c6556fe81afe13062e908300c36d798f4c0 Author: Felipe Magno de Almeida <[email protected]> Date: Wed Oct 8 21:09:19 2014 -0300 eolian-cxx: Fixed pointer dereferencing for Eolian types and constant propagation for C++ eina list containers With the addition of pointer types, the eolian C++ generator now has to dereference to get the base type which might be a complex type. --- src/bin/eolian_cxx/type_lookup.hh | 5 +++-- src/bin/eolian_cxx/type_lookup_table.cc | 3 ++- src/bindings/eina_cxx/eina_list.hh | 31 ++++++++++--------------------- src/bindings/eo_cxx/eo_cxx_interop.hh | 4 ++-- src/lib/eolian_cxx/eo_types.hh | 21 --------------------- src/lib/eolian_cxx/eo_validate.hh | 16 +++++++++++----- 6 files changed, 28 insertions(+), 52 deletions(-) diff --git a/src/bin/eolian_cxx/type_lookup.hh b/src/bin/eolian_cxx/type_lookup.hh index d366f5d..006201c 100644 --- a/src/bin/eolian_cxx/type_lookup.hh +++ b/src/bin/eolian_cxx/type_lookup.hh @@ -56,15 +56,16 @@ type_lookup(const Eolian_Type* type, lookup_table_type const& lut = type_lookup_table) { if (type == NULL) return { efl::eolian::void_type }; // XXX shouldn't + // assert(type != NULL); std::vector<Eolian_Type const*> types; types.push_back(type); - if (type_is_complex(*type)) + if (::eolian_type_type_get(type) == EOLIAN_TYPE_POINTER && type_is_complex(*eolian_type_base_type_get(type))) { efl::eina::iterator<Eolian_Type const> end; efl::eina::iterator<Eolian_Type const> it - (::eolian_type_subtypes_get(type)); + (::eolian_type_subtypes_get(eolian_type_base_type_get(type))); while(it != end) { if(Eolian_Type const* t = &*it) diff --git a/src/bin/eolian_cxx/type_lookup_table.cc b/src/bin/eolian_cxx/type_lookup_table.cc index 7c58618..2702225 100644 --- a/src/bin/eolian_cxx/type_lookup_table.cc +++ b/src/bin/eolian_cxx/type_lookup_table.cc @@ -21,11 +21,12 @@ type_lookup_table {"Eina_List *", eolian_type::complex_, false, "efl::eina::range_list", {"eina-cxx/eina_list.hh"}}, {"Eina_List *", eolian_type::complex_, true, "efl::eina::list", {"eina-cxx/eina_list.hh"}}, {"Eo *", eolian_type::simple_, true, "efl::eo::base", {"eo_base.hh"}}, + {"Eo *", eolian_type::simple_, false, "efl::eo::base", {"eo_base.hh"}}, //{"Evas_Object_Box_Layout", eolian_type::callback_, {"Evas.h"}}, {"Evas_Object *", eolian_type::simple_, false, "evas::object", {"canvas/evas_object.eo.hh"}}, {"char *", eolian_type::simple_, true, "std::unique_ptr<char*>", {"memory"}}, {"const Eina_Inlist *", eolian_type::complex_, false, "efl::eina::range_inlist", {"eina-cxx/eina_inlist.hh"}}, - {"const Eina_List *", eolian_type::complex_, false, "efl::eina::range_list", {"eina-cxx/eina_ptrlist.hh"}}, + {"const Eina_List *", eolian_type::complex_, false, "efl::eina::crange_list", {"eina-cxx/eina_ptrlist.hh"}}, {"const char *", eolian_type::simple_, false, "std::string", {"string"}} }; diff --git a/src/bindings/eina_cxx/eina_list.hh b/src/bindings/eina_cxx/eina_list.hh index 1a7aafb..b2b6745 100644 --- a/src/bindings/eina_cxx/eina_list.hh +++ b/src/bindings/eina_cxx/eina_list.hh @@ -191,6 +191,8 @@ public: typedef typename _base_type::const_reverse_iterator const_reverse_iterator; list& operator=(list&& other) = default; + list(list&& other) = default; + list() = default; using _base_type::_base_type; using _base_type::clear; @@ -437,25 +439,13 @@ public: typedef typename _base_type::const_pointer const_pointer; typedef typename _base_type::size_type size_type; typedef typename _base_type::difference_type difference_type; - typedef typename _base_type::clone_allocator_type clone_allocator_type; typedef typename _base_type::reverse_iterator reverse_iterator; typedef typename _base_type::const_reverse_iterator const_reverse_iterator; - range_list& operator=(range_list&& other) = default; - using _base_type::_base_type; - using _base_type::clear; using _base_type::size; using _base_type::empty; - using _base_type::get_clone_allocator; - using _base_type::push_back; - using _base_type::push_front; - using _base_type::pop_back; - using _base_type::pop_front; - using _base_type::insert; - using _base_type::erase; - using _base_type::assign; using _base_type::back; using _base_type::front; using _base_type::begin; @@ -466,21 +456,15 @@ public: using _base_type::cend; using _base_type::crbegin; using _base_type::crend; - using _base_type::ibegin; - using _base_type::iend; - using _base_type::cibegin; - using _base_type::ciend; using _base_type::swap; - using _base_type::max_size; using _base_type::native_handle; - using _base_type::accessor; }; template <typename T> class range_list<T, typename std::enable_if<std::is_base_of<efl::eo::base, T>::value>::type> - : range_ptr_list<Eo> + : range_ptr_list<typename std::conditional<std::is_const<T>::value, Eo const, Eo>::type> { - typedef range_ptr_list<Eo> _base_type; + typedef range_ptr_list<typename std::conditional<std::is_const<T>::value, Eo const, Eo>::type> _base_type; typedef range_list<T> _self_type; public: typedef T value_type; @@ -496,7 +480,9 @@ public: typedef std::reverse_iterator<iterator> reverse_iterator; typedef std::reverse_iterator<const_iterator> const_reverse_iterator; - explicit range_list(Eina_List* handle) + typedef typename _base_type::native_handle_type native_handle_type; + + explicit range_list(native_handle_type handle) : _base_type(handle) {} range_list() {} range_list(range_list<T> const& other) @@ -580,6 +566,9 @@ public: return rhs.size() == lhs.size() && std::equal(rhs.begin(), rhs.end(), lhs.begin()); } }; + +template <typename T> +using crange_list = range_list<typename std::add_const<T>::type>; } } diff --git a/src/bindings/eo_cxx/eo_cxx_interop.hh b/src/bindings/eo_cxx/eo_cxx_interop.hh index e7a7a3e..3e1d88b 100644 --- a/src/bindings/eo_cxx/eo_cxx_interop.hh +++ b/src/bindings/eo_cxx/eo_cxx_interop.hh @@ -128,10 +128,10 @@ struct traits }; template <typename T, typename ...Args> -inline efl::eina::range_list<T> +inline efl::eina::range_list<T const> to_cxx(const Eina_List* x, std::tuple<std::false_type, Args...>, tag< efl::eina::range_list<T> >) { - return efl::eina::list<T> {x}; + return efl::eina::range_list<T const> {x}; } template <typename T, typename ...Args> diff --git a/src/lib/eolian_cxx/eo_types.hh b/src/lib/eolian_cxx/eo_types.hh index 58d9fb4..3ce3e09 100644 --- a/src/lib/eolian_cxx/eo_types.hh +++ b/src/lib/eolian_cxx/eo_types.hh @@ -59,27 +59,6 @@ struct eolian_type assert(category == callback_); } - ~eolian_type() {} - - eolian_type(eolian_type const& other) - : native(other.native) - , category(other.category) - , is_own(other.is_own) - , binding(other.binding) - , includes(other.includes) - {} - - eolian_type& - operator=(eolian_type const& rhs) - { - native = rhs.native; - category = rhs.category; - is_own = rhs.is_own; - binding = rhs.binding; - includes = rhs.includes; - return *this; - } - std::string native; category_type category; bool is_own; diff --git a/src/lib/eolian_cxx/eo_validate.hh b/src/lib/eolian_cxx/eo_validate.hh index bca15c6..027c8fc 100644 --- a/src/lib/eolian_cxx/eo_validate.hh +++ b/src/lib/eolian_cxx/eo_validate.hh @@ -8,6 +8,8 @@ #include <cstdlib> #include "eo_types.hh" +#include <iostream> + namespace efl { namespace eolian { inline bool @@ -21,12 +23,16 @@ _is_valid(eolian_type_instance const& type) { // if (type.empty() || (*type.rbegin()).category == eolian_type::complex_) // return false; - for (auto rit = ++type.rbegin(), last = type.rend(); rit != last; ++rit) + for (auto rit = type.rbegin(), last = type.rend(); rit != last; ++rit) { - if ((*rit).binding.empty() || (*rit).category != eolian_type::complex_) - return false; - else if (rit != type.rbegin() && (*rit).category != eolian_type::complex_) - return false; + if ((*rit).binding.empty() && (*rit).category == eolian_type::complex_) + return false; + // else if (rit != type.rbegin() && (*rit).category != eolian_type::complex_) + // { + // std::cout << "begin " << (rit != type.rbegin()) << std::endl; + // std::cout << "category " << rit->category << std::endl; + // return false; + // } } return true; } --
