forked from enlightenment/efl
eolian-cxx: Fix generation of complex types in C++ binding
Fixed generation of complex types in C++ binding, with tests. This problem came after the removal of the pointer types for top-level complex types.
This commit is contained in:
parent
8fd1656898
commit
6e23780bb1
|
@ -124,15 +124,21 @@ type_lookup(const Eolian_Type* type,
|
|||
std::vector<Eolian_Type const*> types;
|
||||
types.push_back(type);
|
||||
|
||||
if (::eolian_type_type_get(type) == EOLIAN_TYPE_POINTER && type_is_complex(*eolian_type_base_type_get(type)))
|
||||
if (::eolian_type_type_get(type) == EOLIAN_TYPE_COMPLEX/* && 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(eolian_type_base_type_get(type)));
|
||||
(::eolian_type_subtypes_get(type));
|
||||
while(it != end)
|
||||
{
|
||||
if(Eolian_Type const* t = &*it)
|
||||
types.push_back(t), ++it;
|
||||
{
|
||||
types.push_back
|
||||
( ::eolian_type_type_get(t) == EOLIAN_TYPE_POINTER ? ::eolian_type_base_type_get(t) /* remove this base type get when pointers are removed */
|
||||
: t
|
||||
);
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,8 +4,6 @@ namespace eolian_cxx {
|
|||
|
||||
using efl::eolian::eolian_type;
|
||||
|
||||
// Keep the table sorted!
|
||||
// This can help: cat type_lookup_table | LC_ALL=C sort
|
||||
const lookup_table_type
|
||||
type_lookup_table
|
||||
{
|
||||
|
@ -22,6 +20,9 @@ type_lookup_table
|
|||
{"Eina_List *", eolian_type::complex_, false, false, true, true, "::efl::eina::range_list", {"eina_list.hh"}},
|
||||
{"Eina_List *", eolian_type::complex_, false, true, true, true, "::efl::eina::list", {"eina_list.hh"}},
|
||||
{"const Eina_List *", eolian_type::complex_, true, false, true, true, "::efl::eina::crange_list", {"eina_list.hh"}},
|
||||
{"Eina_Array *", eolian_type::complex_, false, false, true, true, "::efl::eina::range_array", {"eina_array.hh"}},
|
||||
{"Eina_Array *", eolian_type::complex_, false, true, true, true, "::efl::eina::array", {"eina_array.hh"}},
|
||||
{"const Eina_Array *", eolian_type::complex_, true, false, true, true, "::efl::eina::crange_array", {"eina_array.hh"}},
|
||||
{"Eio_Filter_Direct_Cb", eolian_type::callback_, {"Eio.h"}},
|
||||
{"Eo *", eolian_type::simple_, false, true, true, false, "::efl::eo::concrete", {"eo_concrete.hh"}},
|
||||
{"Eo *", eolian_type::simple_, false, false, true, false, "::efl::eo::concrete", {"eo_concrete.hh"}},
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <eina_optional.hh>
|
||||
#include <eina_integer_sequence.hh>
|
||||
#include <eina_pp.hh>
|
||||
#include <eina_workarounds.hh>
|
||||
|
||||
/**
|
||||
* @page eina_cxx_main Eina C++ (BETA)
|
||||
|
|
|
@ -479,8 +479,6 @@ public:
|
|||
|
||||
typedef typename _base_type::native_handle_type native_handle_type;
|
||||
|
||||
range_array& operator=(range_array&& other) = default;
|
||||
|
||||
using _base_type::_base_type;
|
||||
using _base_type::size;
|
||||
using _base_type::empty;
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef EINA_CLONE_ALLOCATORS_HH_
|
||||
#define EINA_CLONE_ALLOCATORS_HH_
|
||||
|
||||
#include <eina_workarounds.hh>
|
||||
|
||||
#include <Eo.h>
|
||||
|
||||
#include <memory>
|
||||
|
@ -122,6 +124,18 @@ struct view_clone_allocator
|
|||
*/
|
||||
struct heap_no_copy_allocator
|
||||
{
|
||||
static void deallocate_clone(_Elm_Calendar_Mark const volatile*) {}
|
||||
static void deallocate_clone(_Elm_Calendar_Mark volatile*) {}
|
||||
static void deallocate_clone(_Elm_Calendar_Mark const*) {}
|
||||
static void deallocate_clone(_Elm_Calendar_Mark*) {}
|
||||
static void deallocate_clone(Elm_Gen_Item const volatile*) {}
|
||||
static void deallocate_clone(Elm_Gen_Item volatile*) {}
|
||||
static void deallocate_clone(Elm_Gen_Item const*) {}
|
||||
static void deallocate_clone(Elm_Gen_Item*) {}
|
||||
static void deallocate_clone(_Elm_Map_Overlay const volatile*) {}
|
||||
static void deallocate_clone(_Elm_Map_Overlay volatile*) {}
|
||||
static void deallocate_clone(_Elm_Map_Overlay const*) {}
|
||||
static void deallocate_clone(_Elm_Map_Overlay*) {}
|
||||
template <typename T>
|
||||
static void deallocate_clone(T* p)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
#ifndef EINA_WORKAROUNDS_HH_
|
||||
#define EINA_WORKAROUNDS_HH_
|
||||
|
||||
#include <eina_eo_concrete_fwd.hh>
|
||||
|
||||
#include <Eo.h>
|
||||
#include <type_traits>
|
||||
|
||||
struct _Elm_Calendar_Mark;
|
||||
struct Elm_Gen_Item;
|
||||
struct _Elm_Map_Overlay;
|
||||
|
||||
namespace std {
|
||||
|
||||
template <>
|
||||
struct is_base_of< ::efl::eo::concrete, _Elm_Calendar_Mark > : std::false_type {};
|
||||
template <>
|
||||
struct is_base_of< ::efl::eo::concrete, _Elm_Calendar_Mark const > : std::false_type {};
|
||||
template <>
|
||||
struct is_base_of< ::efl::eo::concrete, _Elm_Calendar_Mark volatile > : std::false_type {};
|
||||
template <>
|
||||
struct is_base_of< ::efl::eo::concrete, _Elm_Calendar_Mark const volatile > : std::false_type {};
|
||||
|
||||
template <>
|
||||
struct is_base_of< const ::efl::eo::concrete, _Elm_Calendar_Mark > : std::false_type {};
|
||||
template <>
|
||||
struct is_base_of< const ::efl::eo::concrete, _Elm_Calendar_Mark const > : std::false_type {};
|
||||
template <>
|
||||
struct is_base_of< const ::efl::eo::concrete, _Elm_Calendar_Mark volatile > : std::false_type {};
|
||||
template <>
|
||||
struct is_base_of< const ::efl::eo::concrete, _Elm_Calendar_Mark const volatile > : std::false_type {};
|
||||
|
||||
template <>
|
||||
struct is_base_of< ::efl::eo::concrete, Elm_Gen_Item > : std::false_type {};
|
||||
template <>
|
||||
struct is_base_of< ::efl::eo::concrete, Elm_Gen_Item const > : std::false_type {};
|
||||
template <>
|
||||
struct is_base_of< ::efl::eo::concrete, Elm_Gen_Item volatile > : std::false_type {};
|
||||
template <>
|
||||
struct is_base_of< ::efl::eo::concrete, Elm_Gen_Item const volatile > : std::false_type {};
|
||||
|
||||
template <>
|
||||
struct is_base_of< const ::efl::eo::concrete, Elm_Gen_Item > : std::false_type {};
|
||||
template <>
|
||||
struct is_base_of< const ::efl::eo::concrete, Elm_Gen_Item const > : std::false_type {};
|
||||
template <>
|
||||
struct is_base_of< const ::efl::eo::concrete, Elm_Gen_Item volatile > : std::false_type {};
|
||||
template <>
|
||||
struct is_base_of< const ::efl::eo::concrete, Elm_Gen_Item const volatile > : std::false_type {};
|
||||
|
||||
template <>
|
||||
struct is_base_of< ::efl::eo::concrete, _Elm_Map_Overlay > : std::false_type {};
|
||||
template <>
|
||||
struct is_base_of< ::efl::eo::concrete, _Elm_Map_Overlay const > : std::false_type {};
|
||||
template <>
|
||||
struct is_base_of< ::efl::eo::concrete, _Elm_Map_Overlay volatile > : std::false_type {};
|
||||
template <>
|
||||
struct is_base_of< ::efl::eo::concrete, _Elm_Map_Overlay const volatile > : std::false_type {};
|
||||
|
||||
template <>
|
||||
struct is_base_of< const ::efl::eo::concrete, _Elm_Map_Overlay > : std::false_type {};
|
||||
template <>
|
||||
struct is_base_of< const ::efl::eo::concrete, _Elm_Map_Overlay const > : std::false_type {};
|
||||
template <>
|
||||
struct is_base_of< const ::efl::eo::concrete, _Elm_Map_Overlay volatile > : std::false_type {};
|
||||
template <>
|
||||
struct is_base_of< const ::efl::eo::concrete, _Elm_Map_Overlay const volatile > : std::false_type {};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -303,6 +303,55 @@ to_cxx(Eina_List* x, std::tuple<std::true_type, Args...>, tag< eina::optional<ef
|
|||
return efl::eina::list<T> {x};
|
||||
}
|
||||
|
||||
template <typename T, typename ...Args>
|
||||
inline efl::eina::range_array<T const>
|
||||
to_cxx(const Eina_Array* x, std::tuple<std::false_type, Args...>, tag< efl::eina::range_array<T> >)
|
||||
{
|
||||
return efl::eina::range_array<T const> {x};
|
||||
}
|
||||
|
||||
template <typename T, typename ...Args>
|
||||
inline eina::optional<efl::eina::range_array<T const> >
|
||||
to_cxx(const Eina_Array* x, std::tuple<std::false_type, Args...>, tag< eina::optional<efl::eina::range_array<T> > >)
|
||||
{
|
||||
if (!x)
|
||||
return nullptr;
|
||||
return efl::eina::range_array<T const> {x};
|
||||
}
|
||||
|
||||
template <typename T, typename ...Args>
|
||||
inline efl::eina::range_array<T>
|
||||
to_cxx(Eina_Array* x, std::tuple<std::false_type, Args...>, tag< efl::eina::range_array<T> >)
|
||||
{
|
||||
return efl::eina::range_array<T>{x};
|
||||
}
|
||||
|
||||
template <typename T, typename ...Args>
|
||||
inline eina::optional<efl::eina::range_array<T> >
|
||||
to_cxx(Eina_Array* x, std::tuple<std::false_type, Args...>, tag< eina::optional<efl::eina::range_array<T> > >)
|
||||
{
|
||||
if (!x)
|
||||
return nullptr;
|
||||
return efl::eina::range_array<T>{x};
|
||||
}
|
||||
|
||||
template <typename T, typename ...Args>
|
||||
inline efl::eina::array<T>
|
||||
to_cxx(Eina_Array* x, std::tuple<std::true_type, Args...>, tag< efl::eina::array<T> >)
|
||||
{
|
||||
return efl::eina::array<T> {x};
|
||||
}
|
||||
|
||||
template <typename T, typename ...Args>
|
||||
inline eina::optional<efl::eina::array<T> >
|
||||
to_cxx(Eina_Array* x, std::tuple<std::true_type, Args...>, tag< eina::optional<efl::eina::array<T> > >)
|
||||
{
|
||||
if (!x)
|
||||
return nullptr;
|
||||
return efl::eina::array<T> {x};
|
||||
}
|
||||
|
||||
|
||||
inline eina::stringshare
|
||||
to_cxx(Eina_Stringshare const* x, const std::false_type, tag<eina::stringshare>)
|
||||
{
|
||||
|
|
|
@ -3,3 +3,26 @@
|
|||
|
||||
#include "complex.eo.h"
|
||||
#include "complex.eo.hh"
|
||||
|
||||
template <typename T>
|
||||
struct test1;
|
||||
|
||||
template <typename T, typename U>
|
||||
struct test1<void(T::*)(U) const>
|
||||
{
|
||||
static_assert(std::is_same<efl::eina::range_list<int>, U>::value, "Wrong type");
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct test2;
|
||||
|
||||
template <typename T, typename U>
|
||||
struct test2<U(T::*)() const>
|
||||
{
|
||||
static_assert(std::is_same<efl::eina::range_array<int>, U>::value, "Wrong type");
|
||||
};
|
||||
|
||||
test1<typeof( & nonamespace::Complex::foo )> foo;
|
||||
test2<typeof( & nonamespace::Complex::bar )> bar;
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue