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.
This commit is contained in:
Felipe Magno de Almeida 2014-10-08 21:09:19 -03:00
parent 101c13d582
commit 36405c6556
6 changed files with 28 additions and 52 deletions

View File

@ -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)

View File

@ -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"}}
};

View File

@ -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>;
} }

View File

@ -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>

View File

@ -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;

View File

@ -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;
}