tasn pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=2c48b3212a326758bfdbbe2f6bd6f292dcc1cd33

commit 2c48b3212a326758bfdbbe2f6bd6f292dcc1cd33
Author: Vitor Sousa <vitorsousasi...@gmail.com>
Date:   Tue May 12 11:45:16 2015 -0300

    eolian_cxx: Fix @beta on generated bindings for C++
---
 src/bin/eolian_cxx/convert.cc                      |   3 +
 src/bin/eolian_cxx/eolian_wrappers.hh              |   7 ++
 src/lib/eolian_cxx/eo_types.hh                     |   2 +
 .../grammar/eo_class_scope_guard_generator.hh      |   4 +
 .../grammar/inheritance_base_generator.hh          | 100 ++++++++++-----------
 5 files changed, 63 insertions(+), 53 deletions(-)

diff --git a/src/bin/eolian_cxx/convert.cc b/src/bin/eolian_cxx/convert.cc
index 4d03c8f..4f92b97 100644
--- a/src/bin/eolian_cxx/convert.cc
+++ b/src/bin/eolian_cxx/convert.cc
@@ -142,6 +142,7 @@ _convert_property_set_to_function(Eolian_Class const& klass,
      {
        efl::eolian::eo_function::regular_,
        function_scope(prop_),
+       function_is_beta(prop_),
        function_name(prop_) + "_set",
        function_impl(prop_) + "_set",
        function_return_type(prop_, eolian_cxx::setter),
@@ -170,6 +171,7 @@ _convert_property_get_to_function(Eolian_Class const& klass,
      {
        efl::eolian::eo_function::regular_,
        function_scope(prop_),
+       function_is_beta(prop_),
        function_name(prop_) + "_get",
        function_impl(prop_) + "_get",
        function_return_type(prop_, eolian_cxx::getter),
@@ -218,6 +220,7 @@ _convert_function(Eolian_Class const& klass, 
Eolian_Function const& func)
    return {
      function_type(func),
      function_scope(func),
+     function_is_beta(func),
      function_name(func),
      function_impl(func),
      function_return_type(func),
diff --git a/src/bin/eolian_cxx/eolian_wrappers.hh 
b/src/bin/eolian_cxx/eolian_wrappers.hh
index 5b6579e..0dd9890 100644
--- a/src/bin/eolian_cxx/eolian_wrappers.hh
+++ b/src/bin/eolian_cxx/eolian_wrappers.hh
@@ -204,6 +204,12 @@ function_is_constructor(Eolian_Class const& cls, 
Eolian_Function const& func)
    return ::eolian_function_is_constructor(&func, &cls);
 }
 
+inline bool
+function_is_beta(Eolian_Function const& func)
+{
+   return ::eolian_function_is_beta(&func);
+}
+
 inline efl::eolian::eolian_scope
 function_scope(Eolian_Function const& func)
 {
@@ -403,6 +409,7 @@ event_create(Eolian_Class const& klass, const Eolian_Event 
*event_)
         std::transform(name_.begin(), name_.end(), name_.begin(),
                        [](int c) { return c != ',' ? c : '_'; });
         event.scope = eolian_scope_cxx(::eolian_event_scope_get(event_));
+        event.is_beta = (::eolian_event_is_beta(event_) != EINA_FALSE);
         event.name = normalize_spaces(name_);
         event.eo_name = safe_upper
           (find_replace(class_full_name(klass), ".", "_") + "_EVENT_" + 
event.name);
diff --git a/src/lib/eolian_cxx/eo_types.hh b/src/lib/eolian_cxx/eo_types.hh
index 843c2fa..431ba05 100644
--- a/src/lib/eolian_cxx/eo_types.hh
+++ b/src/lib/eolian_cxx/eo_types.hh
@@ -285,6 +285,7 @@ struct eo_function
      };
    eo_function_type type;
    eolian_scope scope;
+   bool is_beta;
    std::string name;
    std::string impl;
    eolian_type_instance ret;
@@ -297,6 +298,7 @@ struct eo_event
    eo_event() : scope(eolian_scope::public_) {}
   
    eolian_scope scope;
+   bool is_beta;
    std::string name;
    std::string eo_name;
    //parameters_container_type params; // XXX desirable.
diff --git a/src/lib/eolian_cxx/grammar/eo_class_scope_guard_generator.hh 
b/src/lib/eolian_cxx/grammar/eo_class_scope_guard_generator.hh
index 9d545c3..5915c38 100644
--- a/src/lib/eolian_cxx/grammar/eo_class_scope_guard_generator.hh
+++ b/src/lib/eolian_cxx/grammar/eo_class_scope_guard_generator.hh
@@ -29,6 +29,8 @@ operator<<(std::ostream& out, _scope_guard_head<T> const& x)
    assert(x._e.scope != eolian_scope::private_);
    if (x._e.scope == eolian_scope::protected_)
      out << "#ifdef " << name_upper(x._cls) << "_PROTECTED" << endl;
+   if (x._e.is_beta)
+     out << "#ifdef " << name_upper(x._cls) << "_BETA" << endl;
    return out;
 }
 
@@ -53,6 +55,8 @@ operator<<(std::ostream& out, _scope_guard_tail<T> const& x)
 {
    if (x._e.scope == eolian_scope::protected_)
      out << "#endif" << endl;
+   if (x._e.is_beta)
+     out << "#endif" << endl;
    return out;
 }
 
diff --git a/src/lib/eolian_cxx/grammar/inheritance_base_generator.hh 
b/src/lib/eolian_cxx/grammar/inheritance_base_generator.hh
index e134729..ed993f0 100644
--- a/src/lib/eolian_cxx/grammar/inheritance_base_generator.hh
+++ b/src/lib/eolian_cxx/grammar/inheritance_base_generator.hh
@@ -31,26 +31,27 @@ struct inheritance_operation
 {
    eo_class const& _cls;
    eo_function const& _func;
-   functions_container_type::size_type _idx;
-   inheritance_operation(eo_class const& cls, eo_function const& func, 
functions_container_type::size_type idx)
-     : _cls(cls), _func(func), _idx(idx)
+   inheritance_operation(eo_class const& cls, eo_function const& func)
+     : _cls(cls), _func(func)
    {}
 };
 
 inline std::ostream&
 operator<<(std::ostream& out, inheritance_operation const& x)
 {
-   assert(x._idx < x._cls.functions.size());
    eo_function const& func = x._func;
-   out << tab(1)
-       << "ops[" << x._idx << "].func = reinterpret_cast<void*>(& ::"
+   out << scope_guard_head(x._cls, func)
+       << tab(1)
+       << "ops[i].func = reinterpret_cast<void*>(& ::"
        << _ns_as_prefix(x._cls) << "_"
        << x._cls.name << "_" << func.name << "_wrapper<T>);" << endl
-       << tab(1) << "ops[" << x._idx << "].api_func = 
reinterpret_cast<void*>(& ::"
+       << tab(1) << "ops[i].api_func = reinterpret_cast<void*>(& ::"
        << func.impl << ");" << endl
-       << tab(1) << "ops[" << x._idx << "].op = EO_OP_OVERRIDE;" << endl
-       << tab(1) << "ops[" << x._idx << "].op_type = EO_OP_TYPE_REGULAR;" << 
endl // XXX class ops
-       << tab(1) << "ops[" << x._idx << "].doc = NULL;" << endl
+       << tab(1) << "ops[i].op = EO_OP_OVERRIDE;" << endl
+       << tab(1) << "ops[i].op_type = EO_OP_TYPE_REGULAR;" << endl // XXX 
class ops
+       << tab(1) << "ops[i].doc = NULL;" << endl
+       << tab(1) << "++i;" << endl
+       << scope_guard_tail(x._cls, func)
        << endl;
    return out;
 }
@@ -74,23 +75,13 @@ operator<<(std::ostream& out, 
inheritance_operations_description const& x)
        << tab(11)
        << ", Eo_Op_Description* ops)" << endl
        << "{" << endl
+       << tab(1) << "int i = 0;" << endl
+       << tab(1) << "(void)i;" << endl
        << tab(1) << "(void)ops;" << endl;
 
-   auto funcs = x._cls.functions;
-   auto part = std::stable_partition(funcs.begin(), funcs.end(), 
[](eo_function const& f){ return f.scope == eolian_scope::public_; });
-
-   functions_container_type::size_type op_idx = 0;
-   for (auto it = funcs.begin(); it != part; ++it, ++op_idx)
+   for (auto const& f : x._cls.functions)
      {
-        out << inheritance_operation(x._cls, *it, op_idx);
-     }
-
-   if (part != funcs.end())
-     {
-        out << scope_guard_head(x._cls, *part);
-        for (auto it = part; it != funcs.end(); ++it, ++op_idx)
-          out << inheritance_operation(x._cls, *it, op_idx);
-        out << scope_guard_tail(x._cls, *part);
+        out << inheritance_operation(x._cls, f);
      }
 
    for (std::string const& parent : x._cls.parents)
@@ -167,25 +158,50 @@ operator<<(std::ostream& out, inheritance_wrappers const& 
x)
 struct inheritance_base_operations_size
 {
    eo_class const& _cls;
-   functions_container_type const& _funcs;
-   inheritance_base_operations_size(eo_class const& cls, 
functions_container_type const& funcs)
-     : _cls(cls), _funcs(funcs)
+   inheritance_base_operations_size(eo_class const& cls)
+     : _cls(cls)
    {}
 };
 
 inline std::ostream&
 operator<<(std::ostream& out, inheritance_base_operations_size const& x)
 {
+   int pcted = 0;
+   int beta = 0;
+   int pcted_beta = 0;
+
+   auto funcs = x._cls.functions;
+
+   for (auto const& f : funcs)
+     {
+        if (f.is_beta && f.scope != eolian_scope::public_)
+          ++pcted_beta;
+        if (f.scope != eolian_scope::public_)
+          ++pcted;
+        if (f.is_beta)
+          ++beta;
+     }
+   auto all = funcs.size();
+
    out << "template<>"
        << endl << "struct operation_description_class_size< "
        << full_name(x._cls) << " >" << endl
        << "{" << endl
-       << tab(1) << "static constexpr int value = "
-       << x._funcs.size();
+       << tab(1) << "static constexpr int value = " << endl
+       << "#if defined(" << name_upper(x._cls) << "_PROTECTED)"
+       << " && defined(" << name_upper(x._cls) << "_BETA)" << endl
+       << tab(2) << all << endl
+       << "#elif defined(" << name_upper(x._cls) << "_PROTECTED)" << endl
+       << tab(2) << (all - beta) << endl
+       << "#elif defined(" << name_upper(x._cls) << "_BETA)" << endl
+       << tab(2) << (all - pcted) << endl
+       << "#else" << endl
+       << tab(2) << (all + pcted_beta - beta - pcted) << endl
+       << "#endif" << endl;
 
    for (std::string const& parent : x._cls.parents)
      {
-        out << " + operation_description_class_size<::" << parent << " 
>::value";
+        out << tab(2) << "+ operation_description_class_size<::" << parent << 
" >::value";
      }
 
    out << ";" << endl
@@ -195,28 +211,6 @@ operator<<(std::ostream& out, 
inheritance_base_operations_size const& x)
    return out;
 }
 
-struct inheritance_base_operations_size_scopes
-{
-   eo_class const& _cls;
-   inheritance_base_operations_size_scopes(eo_class const& cls)
-     : _cls(cls)
-   {}
-};
-
-inline std::ostream&
-operator<<(std::ostream& out, inheritance_base_operations_size_scopes const& x)
-{
-   auto funcs = x._cls.functions;
-   auto part = std::stable_partition(funcs.begin(), funcs.end(), 
[](eo_function const& f){ return f.scope == eolian_scope::public_; });
-
-   out << "#ifdef " << name_upper(x._cls) << "_PROTECTED" << endl
-       << inheritance_base_operations_size(x._cls, funcs)
-       << "#else" << endl
-       << inheritance_base_operations_size(x._cls, {funcs.begin(), part})
-       << "#endif" << endl << endl;
-   return out;
-}
-
 struct inheritance_base_operations_extensions
 {
    eo_class const& _cls;
@@ -341,7 +335,7 @@ eo_inheritance_detail_generator(std::ostream& out, eo_class 
const& cls)
      out << inheritance_wrappers(cls)
          << "namespace efl { namespace eo { namespace detail {" << endl << endl
          << inheritance_base_operations(cls) << endl
-         << inheritance_base_operations_size_scopes(cls)
+         << inheritance_base_operations_size(cls)
          << inheritance_operations_description(cls)
          << inheritance_eo_class_getter(cls)
          <<  "} } }" << endl;

-- 


Reply via email to