summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2016-05-23 17:34:50 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2016-05-23 17:34:50 -0300
commit6e23780bb13fdc16a2034d01bf3fc06a2355fbee (patch)
tree1d1a308ff088503f7bb8b23b65e429f2e830e2dd
parent8fd1656898c26f547bb76ef86da2827e447ecb3b (diff)
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.
-rw-r--r--src/bin/eolian_cxx/type_lookup.hh12
-rw-r--r--src/bin/eolian_cxx/type_lookup_table.cc5
-rw-r--r--src/bindings/cxx/eina_cxx/Eina.hh1
-rw-r--r--src/bindings/cxx/eina_cxx/eina_array.hh2
-rw-r--r--src/bindings/cxx/eina_cxx/eina_clone_allocators.hh14
-rw-r--r--src/bindings/cxx/eina_cxx/eina_workarounds.hh71
-rw-r--r--src/bindings/cxx/eo_cxx/eo_cxx_interop.hh49
-rw-r--r--src/tests/eolian_cxx/complex_cxx.cc23
8 files changed, 170 insertions, 7 deletions
diff --git a/src/bin/eolian_cxx/type_lookup.hh b/src/bin/eolian_cxx/type_lookup.hh
index 57d7c940b6..37e4ff7b33 100644
--- a/src/bin/eolian_cxx/type_lookup.hh
+++ b/src/bin/eolian_cxx/type_lookup.hh
@@ -124,15 +124,21 @@ type_lookup(const Eolian_Type* type,
124 std::vector<Eolian_Type const*> types; 124 std::vector<Eolian_Type const*> types;
125 types.push_back(type); 125 types.push_back(type);
126 126
127 if (::eolian_type_type_get(type) == EOLIAN_TYPE_POINTER && type_is_complex(*eolian_type_base_type_get(type))) 127 if (::eolian_type_type_get(type) == EOLIAN_TYPE_COMPLEX/* && type_is_complex(*eolian_type_base_type_get(type))*/)
128 { 128 {
129 efl::eina::iterator<Eolian_Type const> end; 129 efl::eina::iterator<Eolian_Type const> end;
130 efl::eina::iterator<Eolian_Type const> it 130 efl::eina::iterator<Eolian_Type const> it
131 (::eolian_type_subtypes_get(eolian_type_base_type_get(type))); 131 (::eolian_type_subtypes_get(type));
132 while(it != end) 132 while(it != end)
133 { 133 {
134 if(Eolian_Type const* t = &*it) 134 if(Eolian_Type const* t = &*it)
135 types.push_back(t), ++it; 135 {
136 types.push_back
137 ( ::eolian_type_type_get(t) == EOLIAN_TYPE_POINTER ? ::eolian_type_base_type_get(t) /* remove this base type get when pointers are removed */
138 : t
139 );
140 ++it;
141 }
136 } 142 }
137 } 143 }
138 144
diff --git a/src/bin/eolian_cxx/type_lookup_table.cc b/src/bin/eolian_cxx/type_lookup_table.cc
index 55a8e6968a..046b8b8744 100644
--- a/src/bin/eolian_cxx/type_lookup_table.cc
+++ b/src/bin/eolian_cxx/type_lookup_table.cc
@@ -4,8 +4,6 @@ namespace eolian_cxx {
4 4
5using efl::eolian::eolian_type; 5using efl::eolian::eolian_type;
6 6
7// Keep the table sorted!
8// This can help: cat type_lookup_table | LC_ALL=C sort
9const lookup_table_type 7const lookup_table_type
10type_lookup_table 8type_lookup_table
11{ 9{
@@ -22,6 +20,9 @@ type_lookup_table
22 {"Eina_List *", eolian_type::complex_, false, false, true, true, "::efl::eina::range_list", {"eina_list.hh"}}, 20 {"Eina_List *", eolian_type::complex_, false, false, true, true, "::efl::eina::range_list", {"eina_list.hh"}},
23 {"Eina_List *", eolian_type::complex_, false, true, true, true, "::efl::eina::list", {"eina_list.hh"}}, 21 {"Eina_List *", eolian_type::complex_, false, true, true, true, "::efl::eina::list", {"eina_list.hh"}},
24 {"const Eina_List *", eolian_type::complex_, true, false, true, true, "::efl::eina::crange_list", {"eina_list.hh"}}, 22 {"const Eina_List *", eolian_type::complex_, true, false, true, true, "::efl::eina::crange_list", {"eina_list.hh"}},
23 {"Eina_Array *", eolian_type::complex_, false, false, true, true, "::efl::eina::range_array", {"eina_array.hh"}},
24 {"Eina_Array *", eolian_type::complex_, false, true, true, true, "::efl::eina::array", {"eina_array.hh"}},
25 {"const Eina_Array *", eolian_type::complex_, true, false, true, true, "::efl::eina::crange_array", {"eina_array.hh"}},
25 {"Eio_Filter_Direct_Cb", eolian_type::callback_, {"Eio.h"}}, 26 {"Eio_Filter_Direct_Cb", eolian_type::callback_, {"Eio.h"}},
26 {"Eo *", eolian_type::simple_, false, true, true, false, "::efl::eo::concrete", {"eo_concrete.hh"}}, 27 {"Eo *", eolian_type::simple_, false, true, true, false, "::efl::eo::concrete", {"eo_concrete.hh"}},
27 {"Eo *", eolian_type::simple_, false, false, true, false, "::efl::eo::concrete", {"eo_concrete.hh"}}, 28 {"Eo *", eolian_type::simple_, false, false, true, false, "::efl::eo::concrete", {"eo_concrete.hh"}},
diff --git a/src/bindings/cxx/eina_cxx/Eina.hh b/src/bindings/cxx/eina_cxx/Eina.hh
index 8f5462892e..cb413f49c8 100644
--- a/src/bindings/cxx/eina_cxx/Eina.hh
+++ b/src/bindings/cxx/eina_cxx/Eina.hh
@@ -23,6 +23,7 @@
23#include <eina_optional.hh> 23#include <eina_optional.hh>
24#include <eina_integer_sequence.hh> 24#include <eina_integer_sequence.hh>
25#include <eina_pp.hh> 25#include <eina_pp.hh>
26#include <eina_workarounds.hh>
26 27
27/** 28/**
28 * @page eina_cxx_main Eina C++ (BETA) 29 * @page eina_cxx_main Eina C++ (BETA)
diff --git a/src/bindings/cxx/eina_cxx/eina_array.hh b/src/bindings/cxx/eina_cxx/eina_array.hh
index 7c8e7985d0..2c5cdb103e 100644
--- a/src/bindings/cxx/eina_cxx/eina_array.hh
+++ b/src/bindings/cxx/eina_cxx/eina_array.hh
@@ -479,8 +479,6 @@ public:
479 479
480 typedef typename _base_type::native_handle_type native_handle_type; 480 typedef typename _base_type::native_handle_type native_handle_type;
481 481
482 range_array& operator=(range_array&& other) = default;
483
484 using _base_type::_base_type; 482 using _base_type::_base_type;
485 using _base_type::size; 483 using _base_type::size;
486 using _base_type::empty; 484 using _base_type::empty;
diff --git a/src/bindings/cxx/eina_cxx/eina_clone_allocators.hh b/src/bindings/cxx/eina_cxx/eina_clone_allocators.hh
index 76ff620f98..3af9336fc5 100644
--- a/src/bindings/cxx/eina_cxx/eina_clone_allocators.hh
+++ b/src/bindings/cxx/eina_cxx/eina_clone_allocators.hh
@@ -1,6 +1,8 @@
1#ifndef EINA_CLONE_ALLOCATORS_HH_ 1#ifndef EINA_CLONE_ALLOCATORS_HH_
2#define EINA_CLONE_ALLOCATORS_HH_ 2#define EINA_CLONE_ALLOCATORS_HH_
3 3
4#include <eina_workarounds.hh>
5
4#include <Eo.h> 6#include <Eo.h>
5 7
6#include <memory> 8#include <memory>
@@ -122,6 +124,18 @@ struct view_clone_allocator
122 */ 124 */
123struct heap_no_copy_allocator 125struct heap_no_copy_allocator
124{ 126{
127 static void deallocate_clone(_Elm_Calendar_Mark const volatile*) {}
128 static void deallocate_clone(_Elm_Calendar_Mark volatile*) {}
129 static void deallocate_clone(_Elm_Calendar_Mark const*) {}
130 static void deallocate_clone(_Elm_Calendar_Mark*) {}
131 static void deallocate_clone(Elm_Gen_Item const volatile*) {}
132 static void deallocate_clone(Elm_Gen_Item volatile*) {}
133 static void deallocate_clone(Elm_Gen_Item const*) {}
134 static void deallocate_clone(Elm_Gen_Item*) {}
135 static void deallocate_clone(_Elm_Map_Overlay const volatile*) {}
136 static void deallocate_clone(_Elm_Map_Overlay volatile*) {}
137 static void deallocate_clone(_Elm_Map_Overlay const*) {}
138 static void deallocate_clone(_Elm_Map_Overlay*) {}
125 template <typename T> 139 template <typename T>
126 static void deallocate_clone(T* p) 140 static void deallocate_clone(T* p)
127 { 141 {
diff --git a/src/bindings/cxx/eina_cxx/eina_workarounds.hh b/src/bindings/cxx/eina_cxx/eina_workarounds.hh
new file mode 100644
index 0000000000..635bf235ff
--- /dev/null
+++ b/src/bindings/cxx/eina_cxx/eina_workarounds.hh
@@ -0,0 +1,71 @@
1#ifndef EINA_WORKAROUNDS_HH_
2#define EINA_WORKAROUNDS_HH_
3
4#include <eina_eo_concrete_fwd.hh>
5
6#include <Eo.h>
7#include <type_traits>
8
9struct _Elm_Calendar_Mark;
10struct Elm_Gen_Item;
11struct _Elm_Map_Overlay;
12
13namespace std {
14
15template <>
16struct is_base_of< ::efl::eo::concrete, _Elm_Calendar_Mark > : std::false_type {};
17template <>
18struct is_base_of< ::efl::eo::concrete, _Elm_Calendar_Mark const > : std::false_type {};
19template <>
20struct is_base_of< ::efl::eo::concrete, _Elm_Calendar_Mark volatile > : std::false_type {};
21template <>
22struct is_base_of< ::efl::eo::concrete, _Elm_Calendar_Mark const volatile > : std::false_type {};
23
24template <>
25struct is_base_of< const ::efl::eo::concrete, _Elm_Calendar_Mark > : std::false_type {};
26template <>
27struct is_base_of< const ::efl::eo::concrete, _Elm_Calendar_Mark const > : std::false_type {};
28template <>
29struct is_base_of< const ::efl::eo::concrete, _Elm_Calendar_Mark volatile > : std::false_type {};
30template <>
31struct is_base_of< const ::efl::eo::concrete, _Elm_Calendar_Mark const volatile > : std::false_type {};
32
33template <>
34struct is_base_of< ::efl::eo::concrete, Elm_Gen_Item > : std::false_type {};
35template <>
36struct is_base_of< ::efl::eo::concrete, Elm_Gen_Item const > : std::false_type {};
37template <>
38struct is_base_of< ::efl::eo::concrete, Elm_Gen_Item volatile > : std::false_type {};
39template <>
40struct is_base_of< ::efl::eo::concrete, Elm_Gen_Item const volatile > : std::false_type {};
41
42template <>
43struct is_base_of< const ::efl::eo::concrete, Elm_Gen_Item > : std::false_type {};
44template <>
45struct is_base_of< const ::efl::eo::concrete, Elm_Gen_Item const > : std::false_type {};
46template <>
47struct is_base_of< const ::efl::eo::concrete, Elm_Gen_Item volatile > : std::false_type {};
48template <>
49struct is_base_of< const ::efl::eo::concrete, Elm_Gen_Item const volatile > : std::false_type {};
50
51template <>
52struct is_base_of< ::efl::eo::concrete, _Elm_Map_Overlay > : std::false_type {};
53template <>
54struct is_base_of< ::efl::eo::concrete, _Elm_Map_Overlay const > : std::false_type {};
55template <>
56struct is_base_of< ::efl::eo::concrete, _Elm_Map_Overlay volatile > : std::false_type {};
57template <>
58struct is_base_of< ::efl::eo::concrete, _Elm_Map_Overlay const volatile > : std::false_type {};
59
60template <>
61struct is_base_of< const ::efl::eo::concrete, _Elm_Map_Overlay > : std::false_type {};
62template <>
63struct is_base_of< const ::efl::eo::concrete, _Elm_Map_Overlay const > : std::false_type {};
64template <>
65struct is_base_of< const ::efl::eo::concrete, _Elm_Map_Overlay volatile > : std::false_type {};
66template <>
67struct is_base_of< const ::efl::eo::concrete, _Elm_Map_Overlay const volatile > : std::false_type {};
68
69}
70
71#endif
diff --git a/src/bindings/cxx/eo_cxx/eo_cxx_interop.hh b/src/bindings/cxx/eo_cxx/eo_cxx_interop.hh
index 1e35d0c942..a588b5b8e1 100644
--- a/src/bindings/cxx/eo_cxx/eo_cxx_interop.hh
+++ b/src/bindings/cxx/eo_cxx/eo_cxx_interop.hh
@@ -303,6 +303,55 @@ to_cxx(Eina_List* x, std::tuple<std::true_type, Args...>, tag< eina::optional<ef
303 return efl::eina::list<T> {x}; 303 return efl::eina::list<T> {x};
304} 304}
305 305
306template <typename T, typename ...Args>
307inline efl::eina::range_array<T const>
308to_cxx(const Eina_Array* x, std::tuple<std::false_type, Args...>, tag< efl::eina::range_array<T> >)
309{
310 return efl::eina::range_array<T const> {x};
311}
312
313template <typename T, typename ...Args>
314inline eina::optional<efl::eina::range_array<T const> >
315to_cxx(const Eina_Array* x, std::tuple<std::false_type, Args...>, tag< eina::optional<efl::eina::range_array<T> > >)
316{
317 if (!x)
318 return nullptr;
319 return efl::eina::range_array<T const> {x};
320}
321
322template <typename T, typename ...Args>
323inline efl::eina::range_array<T>
324to_cxx(Eina_Array* x, std::tuple<std::false_type, Args...>, tag< efl::eina::range_array<T> >)
325{
326 return efl::eina::range_array<T>{x};
327}
328
329template <typename T, typename ...Args>
330inline eina::optional<efl::eina::range_array<T> >
331to_cxx(Eina_Array* x, std::tuple<std::false_type, Args...>, tag< eina::optional<efl::eina::range_array<T> > >)
332{
333 if (!x)
334 return nullptr;
335 return efl::eina::range_array<T>{x};
336}
337
338template <typename T, typename ...Args>
339inline efl::eina::array<T>
340to_cxx(Eina_Array* x, std::tuple<std::true_type, Args...>, tag< efl::eina::array<T> >)
341{
342 return efl::eina::array<T> {x};
343}
344
345template <typename T, typename ...Args>
346inline eina::optional<efl::eina::array<T> >
347to_cxx(Eina_Array* x, std::tuple<std::true_type, Args...>, tag< eina::optional<efl::eina::array<T> > >)
348{
349 if (!x)
350 return nullptr;
351 return efl::eina::array<T> {x};
352}
353
354
306inline eina::stringshare 355inline eina::stringshare
307to_cxx(Eina_Stringshare const* x, const std::false_type, tag<eina::stringshare>) 356to_cxx(Eina_Stringshare const* x, const std::false_type, tag<eina::stringshare>)
308{ 357{
diff --git a/src/tests/eolian_cxx/complex_cxx.cc b/src/tests/eolian_cxx/complex_cxx.cc
index 60b76c4337..8b8d5e6286 100644
--- a/src/tests/eolian_cxx/complex_cxx.cc
+++ b/src/tests/eolian_cxx/complex_cxx.cc
@@ -3,3 +3,26 @@
3 3
4#include "complex.eo.h" 4#include "complex.eo.h"
5#include "complex.eo.hh" 5#include "complex.eo.hh"
6
7template <typename T>
8struct test1;
9
10template <typename T, typename U>
11struct test1<void(T::*)(U) const>
12{
13 static_assert(std::is_same<efl::eina::range_list<int>, U>::value, "Wrong type");
14};
15
16template <typename T>
17struct test2;
18
19template <typename T, typename U>
20struct test2<U(T::*)() const>
21{
22 static_assert(std::is_same<efl::eina::range_array<int>, U>::value, "Wrong type");
23};
24
25test1<typeof( & nonamespace::Complex::foo )> foo;
26test2<typeof( & nonamespace::Complex::bar )> bar;
27
28