felipealmeida pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=4222cd3f50042452893bc24e85376f3c1b4ce748

commit 4222cd3f50042452893bc24e85376f3c1b4ce748
Author: Vitor Sousa <vitorsousasi...@gmail.com>
Date:   Tue Dec 30 21:18:40 2014 -0200

    eolian_cxx: Fix compilation of inheritance from Eolian generated classes
    
    Updated the code for the "inheritance helper" functions and classes
    to be in conformance with the new wrapper architecture.
    
    Member variable "parents" of efl::eo::eo_class struct was split in two
    member variables, "ancestors" and "parents", the former containing all
    Eo class ancestors and the later only the direct bases.
    Changed all required files accordingly.
    
    Check to avoid using biding string when the parameter is @out now matches
    any variation of "char".
    
    Add default constructor to efl::eo::concrete in order to allow it to be
    NULL initialized in the "inheritance helper" classes.
    
    Removed conflicting parent_set member function in the efl::eo::inherit
    class.
    
    Removed the "inheritance_extension_function" generator since it is no
    longer used.
---
 src/bin/eolian_cxx/convert.cc                      |  14 ++-
 src/bin/eolian_cxx/eolian_wrappers.hh              |   2 +-
 src/bindings/eo_cxx/eo_concrete.hh                 |   9 ++
 src/bindings/eo_cxx/eo_cxx_interop.hh              |   8 ++
 src/bindings/eo_cxx/eo_inherit.hh                  |   6 -
 src/bindings/eo_cxx/eo_private.hh                  |   7 +-
 src/lib/eolian_cxx/eo_types.hh                     |   5 +-
 .../grammar/eo_class_constructors_generator.hh     |   6 +-
 src/lib/eolian_cxx/grammar/eo_class_generator.hh   |   2 +-
 .../grammar/inheritance_base_generator.hh          | 131 +++------------------
 .../eolian_cxx/eolian_cxx_test_inheritance.cc      |   2 +-
 src/tests/eolian_cxx/simple.eo                     |   4 +-
 12 files changed, 59 insertions(+), 137 deletions(-)

diff --git a/src/bin/eolian_cxx/convert.cc b/src/bin/eolian_cxx/convert.cc
index 2fa45b5..fab4c16 100644
--- a/src/bin/eolian_cxx/convert.cc
+++ b/src/bin/eolian_cxx/convert.cc
@@ -24,7 +24,7 @@ namespace eolian_cxx {
 extern efl::eina::log_domain domain;
 
 void
-add_parent_recursive(const char* klass_name, std::set<std::string>& parents)
+add_ancestor_recursive(const char* klass_name, std::set<std::string>& ancestor)
 {
    if (!klass_name)
      return;
@@ -36,14 +36,14 @@ add_parent_recursive(const char* klass_name, 
std::set<std::string>& parents)
         return;
      }
 
-   parents.insert(class_format_cxx(safe_lower(klass_name)));
+   ancestor.insert(class_format_cxx(safe_lower(klass_name)));
 
    Eina_Iterator* inheritances = ::eolian_class_inherits_get(klass);
    void* curr = 0;
 
    EINA_ITERATOR_FOREACH(inheritances, curr)
      {
-        add_parent_recursive(static_cast<const char*>(curr), parents);
+        add_ancestor_recursive(static_cast<const char*>(curr), ancestor);
      }
    eina_iterator_free(inheritances);
 }
@@ -182,15 +182,17 @@ convert_eolian_inheritances(efl::eolian::eo_class& cls, 
Eolian_Class const& klas
      ::eolian_class_inherits_get(&klass);
    void *curr;
 
-   std::set<std::string> parents;
+   std::set<std::string> ancestors;
 
    EINA_ITERATOR_FOREACH(inheritances, curr)
      {
-        add_parent_recursive(static_cast<const char*>(curr), parents);
+        const char* klass_name = static_cast<const char*>(curr);
+        cls.parents.push_back(class_format_cxx(safe_lower(klass_name)));
+        add_ancestor_recursive(klass_name, ancestors);
      }
    eina_iterator_free(inheritances);
 
-   cls.parents.assign(parents.begin(), parents.end());
+   cls.ancestors.assign(ancestors.begin(), ancestors.end());
 }
 
 void
diff --git a/src/bin/eolian_cxx/eolian_wrappers.hh 
b/src/bin/eolian_cxx/eolian_wrappers.hh
index 6b0211e..4771739 100644
--- a/src/bin/eolian_cxx/eolian_wrappers.hh
+++ b/src/bin/eolian_cxx/eolian_wrappers.hh
@@ -348,7 +348,7 @@ parameter_type(Eolian_Function_Parameter const& parameter,
    assert(!type.empty());
    if (parameter_is_out(parameter))
      {
-        if (type.front().native == "char *")
+        if (type.front().native.find("char") != std::string::npos)
           type = { efl::eolian::type_to_native(type) };
         type.is_out = true;
         type.front().native += "*";
diff --git a/src/bindings/eo_cxx/eo_concrete.hh 
b/src/bindings/eo_cxx/eo_concrete.hh
index d92fe7b..cd72dd7 100644
--- a/src/bindings/eo_cxx/eo_concrete.hh
+++ b/src/bindings/eo_cxx/eo_concrete.hh
@@ -47,6 +47,15 @@ struct concrete
    {
    }
 
+
+   /// @brief Default constructor.
+   ///
+   /// Constructs a NULL initialized efl::eo::concrete object.
+   ///
+   concrete() : _eo_raw(nullptr)
+   {
+   }
+
    /// @brief Class destructor.
    ///
    ~concrete()
diff --git a/src/bindings/eo_cxx/eo_cxx_interop.hh 
b/src/bindings/eo_cxx/eo_cxx_interop.hh
index b0ca1ed..ddf4375 100644
--- a/src/bindings/eo_cxx/eo_cxx_interop.hh
+++ b/src/bindings/eo_cxx/eo_cxx_interop.hh
@@ -108,6 +108,14 @@ to_cxx(Eo* x, std::tuple<std::false_type>, tag<T>)
    return T(::eo_ref(x));
 }
 
+template <typename T>
+inline T
+to_cxx(Eo** x, std::tuple<std::false_type>, tag<T>)
+{
+   static_assert(sizeof(Eo*) == sizeof(typename std::remove_pointer<T>::type), 
"");
+   return static_cast<T>((static_cast<void*>(x)));
+}
+
 #ifdef _EVAS_H
 template <typename T>
 Evas_Object_Textblock_Node_Format *
diff --git a/src/bindings/eo_cxx/eo_inherit.hh 
b/src/bindings/eo_cxx/eo_inherit.hh
index c04e3ce..d4512a9 100644
--- a/src/bindings/eo_cxx/eo_inherit.hh
+++ b/src/bindings/eo_cxx/eo_inherit.hh
@@ -105,12 +105,6 @@ struct inherit
    ///
    Eo_Class const* _eo_class() const { return _eo_cls; }
 
-   template <typename T>
-   void parent_set(T& p_)
-   {
-      detail::parent_set(_eo_raw, p_._eo_ptr());
-   }
-
    Eo* _release()
    {
       Eo* tmp = _eo_raw;
diff --git a/src/bindings/eo_cxx/eo_private.hh 
b/src/bindings/eo_cxx/eo_private.hh
index 7640890..344b1c5 100644
--- a/src/bindings/eo_cxx/eo_private.hh
+++ b/src/bindings/eo_cxx/eo_private.hh
@@ -7,6 +7,7 @@
 #define EFL_CXX_EO_PRIVATE_HH
 
 #include "eo_ops.hh"
+#include "eo_concrete.hh"
 
 namespace efl { namespace eo { namespace detail {
 
@@ -87,7 +88,7 @@ Eo_Class const* do_eo_class_new(Eo_Class_Description& 
class_desc)
 template <typename T> struct operation_description_class_size;
 
 template<>
-struct operation_description_class_size<efl::eo::base> { static const int 
value = 0; };
+struct operation_description_class_size<efl::eo::concrete> { static const int 
value = 0; };
 
 /// @internal
 ///
@@ -134,7 +135,7 @@ namespace detail {
 template <typename T> struct operations;
 
 template <>
-struct operations<efl::eo::base> { template <typename T> struct type {}; };
+struct operations<efl::eo::concrete> { template <typename T> struct type {}; };
 
 /// @internal
 ///
@@ -163,7 +164,7 @@ struct Inherit_Private_Data
 
 namespace efl { namespace eo { namespace detail {
 template <typename T>
-int initialize_operation_description(efl::eo::detail::tag<efl::eo::base>
+int initialize_operation_description(efl::eo::detail::tag<efl::eo::concrete>
                                  , Eo_Op_Description* ops)
 {
    (void)ops;
diff --git a/src/lib/eolian_cxx/eo_types.hh b/src/lib/eolian_cxx/eo_types.hh
index 42abe39..4fa79a4 100644
--- a/src/lib/eolian_cxx/eo_types.hh
+++ b/src/lib/eolian_cxx/eo_types.hh
@@ -14,7 +14,7 @@ struct eo_parameter;
 struct eo_function;
 struct eo_event;
 
-typedef std::vector<std::string> parents_container_type;
+typedef std::vector<std::string> ancestors_container_type;
 typedef std::vector<std::string> includes_container_type;
 typedef std::vector<eo_constructor> constructors_container_type;
 typedef std::vector<eo_function> functions_container_type;
@@ -215,7 +215,8 @@ struct eo_class
    eo_class_type type;
    std::string name;
    std::string eo_name;
-   parents_container_type parents;
+   ancestors_container_type parents;
+   ancestors_container_type ancestors;
    constructors_container_type constructors;
    functions_container_type functions;
    events_container_type events;
diff --git a/src/lib/eolian_cxx/grammar/eo_class_constructors_generator.hh 
b/src/lib/eolian_cxx/grammar/eo_class_constructors_generator.hh
index 9ffed75..42d5776 100644
--- a/src/lib/eolian_cxx/grammar/eo_class_constructors_generator.hh
+++ b/src/lib/eolian_cxx/grammar/eo_class_constructors_generator.hh
@@ -41,9 +41,9 @@ operator<<(std::ostream& out, class_inheritance const& x)
 {
    eo_class const& cls = x._cls;
 
-   parents_container_type::const_iterator it,
-     first = cls.parents.cbegin(),
-     last = cls.parents.cend();
+   ancestors_container_type::const_iterator it,
+     first = cls.ancestors.cbegin(),
+     last = cls.ancestors.cend();
    for (it = first; it != last; ++it)
      {
         out << tab(2) << ", ::" << abstract_namespace << "::" << *it << endl;
diff --git a/src/lib/eolian_cxx/grammar/eo_class_generator.hh 
b/src/lib/eolian_cxx/grammar/eo_class_generator.hh
index 57dc739..1abf1ba 100644
--- a/src/lib/eolian_cxx/grammar/eo_class_generator.hh
+++ b/src/lib/eolian_cxx/grammar/eo_class_generator.hh
@@ -151,7 +151,7 @@ struct address_of_inheritance
 inline std::ostream&
 operator<<(std::ostream& out, address_of_inheritance const& x)
 {
-   for (std::string const& parent : x._cls.parents)
+   for (std::string const& parent : x._cls.ancestors)
      {
         out << tab(2) << ", ::" << abstract_namespace << "::" << parent << "::"
             << x._struct_name << "<" << x._struct_name << ">" << endl;
diff --git a/src/lib/eolian_cxx/grammar/inheritance_base_generator.hh 
b/src/lib/eolian_cxx/grammar/inheritance_base_generator.hh
index 9e10e50..30ee36d 100644
--- a/src/lib/eolian_cxx/grammar/inheritance_base_generator.hh
+++ b/src/lib/eolian_cxx/grammar/inheritance_base_generator.hh
@@ -65,12 +65,8 @@ struct inheritance_operations_description
 inline std::ostream&
 operator<<(std::ostream& out, inheritance_operations_description const& x)
 {
-   extensions_container_type::const_iterator it, first, last;
    std::string s;
 
-   first = x._cls.extensions.begin();
-   last = x._cls.extensions.end();
-
    out << "template <typename T>"
        << endl << "int 
initialize_operation_description(::efl::eo::detail::tag<"
        << full_name(x._cls) << ">" << endl
@@ -84,21 +80,13 @@ operator<<(std::ostream& out, 
inheritance_operations_description const& x)
         out << inheritance_operation(x._cls, i);
      }
 
-   out << tab(1)
-       << "initialize_operation_description<T>(efl::eo::detail::tag<"
-       << x._cls.parent
-       << ">(), &ops["
-       << x._cls.functions.size() << "]);" << endl;
-
-   s += " + operation_description_class_size<" + x._cls.parent + ">::value";
-
-   for (it = first; it != last; ++it)
+   for (std::string const& parent : x._cls.parents)
      {
         out << tab(1)
-            << "initialize_operation_description<T>(efl::eo::detail::tag<"
-            << *it << ">(), &ops[" << x._cls.functions.size() << s << "]);" << 
endl;
+            << "initialize_operation_description<T>(::efl::eo::detail::tag<::"
+            << parent << ">(), &ops[" << x._cls.functions.size() << s << "]);" 
<< endl;
 
-        s += " + operation_description_class_size< " + *it + ">::value";
+        s += " + operation_description_class_size<::" + parent + ">::value";
      }
 
    out << tab(1) << "return 0;" << endl
@@ -168,21 +156,16 @@ struct inheritance_base_operations_size
 inline std::ostream&
 operator<<(std::ostream& out, inheritance_base_operations_size const& x)
 {
-   extensions_container_type::const_iterator it, first = 
x._cls.extensions.begin();
-   extensions_container_type::const_iterator last = x._cls.extensions.end();
-   first = x._cls.extensions.begin();
-
    out << "template<>"
        << endl << "struct operation_description_class_size< "
        << full_name(x._cls) << " >" << endl
        << "{" << endl
        << tab(1) << "static const int value = "
-       << x._cls.functions.size()
-       << " + operation_description_class_size<" << class_name(x._cls.parent) 
<< ">::value";
+       << x._cls.functions.size();
 
-   for (it = first; it != last; ++it)
+   for (std::string const& parent : x._cls.parents)
      {
-        out << " + operation_description_class_size< " << *it << " >::value";
+        out << " + operation_description_class_size<::" << parent << " 
>::value";
      }
 
    out << ";" << endl
@@ -205,14 +188,14 @@ inline std::ostream&
 operator<<(std::ostream& out, inheritance_base_operations_extensions const& x)
 {
    eo_class const& cls = x._cls;
-   extensions_container_type::const_iterator it, first = 
cls.extensions.begin();
-   extensions_container_type::const_iterator last = cls.extensions.end();
+   ancestors_container_type::const_iterator it, first = cls.parents.begin();
+   ancestors_container_type::const_iterator last = cls.parents.end();
 
-   out << endl << tab(3) << ": operations< " << class_name(cls.parent) << " 
>::template type<T>";
    for (it = first; it != last; ++it)
      {
-        out << "," << endl << tab(3)
-            << "operations< " << *it
+        out << endl
+            << tab(3) << (it == first ? ": " : ", ")
+            << "virtual operations< ::" << *it
             << " >::template type<T>";
      }
 
@@ -247,12 +230,12 @@ operator<<(std::ostream& out, 
inheritance_base_operations_function const& x)
    if (!is_void)
      out << tab(3) << func.ret.front().native << " _tmp_ret = {};"  << endl;
 
-   out << callbacks_heap_alloc("static_cast<T*>(this)->_eo_ptr()", 
func.params, 3)
+   out << callbacks_heap_alloc("dynamic_cast<T*>(this)->_eo_ptr()", 
func.params, 3)
        << endl;
 
    out << tab(3)
-       << "eo_do_super(static_cast<T*>(this)->_eo_ptr()," << endl
-       << tab(5) << "static_cast<T*>(this)->_eo_class()," << endl
+       << "eo_do_super(dynamic_cast<T*>(this)->_eo_ptr()," << endl
+       << tab(5) << "dynamic_cast<T*>(this)->_eo_class()," << endl
        << tab(5) << function_call(func) << ");" << endl;
 
    if (!is_void)
@@ -325,10 +308,10 @@ operator<<(std::ostream& out, 
inheritance_call_constructors const& x)
      {
         eo_constructor const& ctor = *it;
         out << "inline void" << endl
-            << "call_constructor(tag< "
+            << "call_constructor(::efl::eo::detail::tag< "
             << full_name(x._cls) << " >" << endl
             << tab(5) << ", Eo* eo, Eo_Class const* cls EINA_UNUSED," << endl
-            << tab(5) << "args_class<"
+            << tab(5) << "::efl::eo::detail::args_class<"
             << full_name(x._cls)
             << ", ::std::tuple<"
             << parameters_types(ctor.params)
@@ -343,10 +326,10 @@ operator<<(std::ostream& out, 
inheritance_call_constructors const& x)
      }
 
    out << "inline void" << endl
-       << "call_constructor(tag< "
+       << "call_constructor(::efl::eo::detail::tag< "
        << full_name(x._cls) << " >" << endl
        << tab(5) << ", Eo* eo, Eo_Class const* cls EINA_UNUSED," << endl
-       << tab(5) << "args_class<"
+       << tab(5) << "::efl::eo::detail::args_class<"
        << full_name(x._cls)
        << ", ::std::tuple<::efl::eo::parent_type> > const& args)" << endl
        << "{" << endl
@@ -357,81 +340,6 @@ operator<<(std::ostream& out, 
inheritance_call_constructors const& x)
    return out;
 }
 
-struct inheritance_extension_function
-{
-   eo_function const& _func;
-   inheritance_extension_function(eo_function const& func) : _func(func) {}
-};
-
-inline std::ostream&
-operator<<(std::ostream& out, inheritance_extension_function const& x)
-{
-   out << template_parameters_declaration(x._func.params, 1);
-
-   bool is_void = function_is_void(x._func);
-   out << tab(2)
-       << reinterpret_type(x._func.ret) << " "
-       << x._func.name << "("
-       << parameters_declaration(x._func.params)
-       << ")" << endl
-       << tab(2) << "{" << endl;
-
-   if (!is_void)
-     {
-        out << tab(3) << x._func.ret.front().native << " _tmp_ret = {};"  << 
endl;
-     }
-
-   out << callbacks_heap_alloc("static_cast<U*>(this)->_eo_ptr()", 
x._func.params, 2)
-       << endl;
-
-   out << tab(3) << "eo_do(static_cast<U*>(this)->_eo_ptr(), "
-       << function_call(x._func) << ");" << endl;
-
-   if (!function_is_void(x._func))
-     out << tab(4) << "return " << to_cxx(x._func.ret, "_tmp_ret") << ";" << 
endl;
-   out << tab(2) << "}" << endl
-       << endl;
-
-   return out;
-}
-
-struct inheritance_extension
-{
-   eo_class const& _cls;
-   inheritance_extension(eo_class const& cls) : _cls(cls) {}
-};
-
-inline std::ostream&
-operator<<(std::ostream& out, inheritance_extension const& x)
-{
-   full_name const cls(x._cls);
-   out << "template<>" << endl
-       << "struct extension_inheritance< "
-       << cls << ">" << endl
-       << "{" << endl
-       << tab(1) << "template <typename U>" << endl
-       << tab(1) << "struct type" << endl
-       << tab(1) << "{" << endl
-       << tab(2) << "operator " << cls << "() const" << endl
-       << tab(2) << "{" << endl
-       << tab(3) << "return " << cls
-       << "(eo_ref(static_cast<U const*>(this)->_eo_ptr()));" << endl
-       << tab(2) << "}" << endl
-       << endl;
-   functions_container_type::const_iterator it,
-     first = x._cls.functions.begin(),
-     last = x._cls.functions.end();
-   for (it = first; it != last; ++it)
-     {
-        out << inheritance_extension_function(*it);
-     }
-   out << events(x._cls, true);
-   out << tab(1) << "};" << endl
-       << "};" << endl
-       << endl;
-   return out;
-}
-
 struct inheritance_eo_class_getter
 {
    eo_class const& _cls;
@@ -460,7 +368,6 @@ eo_inheritance_detail_generator(std::ostream& out, eo_class 
const& cls)
        << inheritance_base_operations_size(cls)
        << inheritance_operations_description(cls)
        << inheritance_call_constructors(cls)
-       << inheritance_extension(cls)
        << inheritance_eo_class_getter(cls)
        <<  "} } }" << endl;
 }
diff --git a/src/tests/eolian_cxx/eolian_cxx_test_inheritance.cc 
b/src/tests/eolian_cxx/eolian_cxx_test_inheritance.cc
index 1930717..1337135 100644
--- a/src/tests/eolian_cxx/eolian_cxx_test_inheritance.cc
+++ b/src/tests/eolian_cxx/eolian_cxx_test_inheritance.cc
@@ -14,7 +14,7 @@ struct bar
 : efl::eo::inherit<bar, simple>
 {
   bar()
-    : inherit_base()
+    : inherit_base(efl::eo::parent = nullptr)
   {}
 
   bool simple_get()
diff --git a/src/tests/eolian_cxx/simple.eo b/src/tests/eolian_cxx/simple.eo
index 764adb7..a35ec3a 100644
--- a/src/tests/eolian_cxx/simple.eo
+++ b/src/tests/eolian_cxx/simple.eo
@@ -4,13 +4,13 @@ class Simple (Eo.Base)
    data: null;
    methods {
       simple_get {
-         return bool;
+         return: bool;
       }
       name_get {
          params {
             @out const(char)* name;
          }
-         return bool;
+         return: bool;
       }
    }
    implements {

-- 


Reply via email to