felipealmeida pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=6e23780bb13fdc16a2034d01bf3fc06a2355fbee

commit 6e23780bb13fdc16a2034d01bf3fc06a2355fbee
Author: Felipe Magno de Almeida <[email protected]>
Date:   Mon May 23 17:34:50 2016 -0300

    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.
---
 src/bin/eolian_cxx/type_lookup.hh                  | 12 +++-
 src/bin/eolian_cxx/type_lookup_table.cc            |  5 +-
 src/bindings/cxx/eina_cxx/Eina.hh                  |  1 +
 src/bindings/cxx/eina_cxx/eina_array.hh            |  2 -
 src/bindings/cxx/eina_cxx/eina_clone_allocators.hh | 14 +++++
 src/bindings/cxx/eina_cxx/eina_workarounds.hh      | 71 ++++++++++++++++++++++
 src/bindings/cxx/eo_cxx/eo_cxx_interop.hh          | 49 +++++++++++++++
 src/tests/eolian_cxx/complex_cxx.cc                | 23 +++++++
 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 57d7c94..37e4ff7 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,
    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;
+               }
           }
      }
 
diff --git a/src/bin/eolian_cxx/type_lookup_table.cc 
b/src/bin/eolian_cxx/type_lookup_table.cc
index 55a8e69..046b8b8 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 {
 
 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"}},
diff --git a/src/bindings/cxx/eina_cxx/Eina.hh 
b/src/bindings/cxx/eina_cxx/Eina.hh
index 8f54628..cb413f4 100644
--- a/src/bindings/cxx/eina_cxx/Eina.hh
+++ b/src/bindings/cxx/eina_cxx/Eina.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)
diff --git a/src/bindings/cxx/eina_cxx/eina_array.hh 
b/src/bindings/cxx/eina_cxx/eina_array.hh
index 7c8e798..2c5cdb1 100644
--- a/src/bindings/cxx/eina_cxx/eina_array.hh
+++ b/src/bindings/cxx/eina_cxx/eina_array.hh
@@ -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;
diff --git a/src/bindings/cxx/eina_cxx/eina_clone_allocators.hh 
b/src/bindings/cxx/eina_cxx/eina_clone_allocators.hh
index 76ff620..3af9336 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 @@
 #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)
   {
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 0000000..635bf23
--- /dev/null
+++ b/src/bindings/cxx/eina_cxx/eina_workarounds.hh
@@ -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
diff --git a/src/bindings/cxx/eo_cxx/eo_cxx_interop.hh 
b/src/bindings/cxx/eo_cxx/eo_cxx_interop.hh
index 1e35d0c..a588b5b 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
    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>)
 {
diff --git a/src/tests/eolian_cxx/complex_cxx.cc 
b/src/tests/eolian_cxx/complex_cxx.cc
index 60b76c4..8b8d5e6 100644
--- a/src/tests/eolian_cxx/complex_cxx.cc
+++ b/src/tests/eolian_cxx/complex_cxx.cc
@@ -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;
+
+  

-- 


Reply via email to