q66 pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=165921ec040f427875fc0b32b1f03d4a45efd25e

commit 165921ec040f427875fc0b32b1f03d4a45efd25e
Author: Lauro Moura <lauromo...@expertisesolutions.com.br>
Date:   Mon Sep 9 18:10:02 2019 +0200

    eolian_cxx: Add support for @by_ref
    
    Summary:
    It will coexist with `eolian_type_is_ptr` while we phase out the latter.
    
    Fixes: T8211
    
    Depends on D9866
    
    Reviewers: q66, felipealmeida
    
    Reviewed By: q66
    
    Subscribers: cedric, #reviewers, #committers
    
    Tags: #efl
    
    Differential Revision: https://phab.enlightenment.org/D9867
---
 src/lib/eolian_cxx/grammar/klass_def.hpp     | 72 +++++++++++++++++++++-------
 src/lib/eolian_cxx/grammar/qualifier_def.hpp |  4 +-
 2 files changed, 56 insertions(+), 20 deletions(-)

diff --git a/src/lib/eolian_cxx/grammar/klass_def.hpp 
b/src/lib/eolian_cxx/grammar/klass_def.hpp
index fbd8779e0f..4de294e836 100644
--- a/src/lib/eolian_cxx/grammar/klass_def.hpp
+++ b/src/lib/eolian_cxx/grammar/klass_def.hpp
@@ -372,6 +372,12 @@ namespace value_ownership
     const bool unmoved = false;
 };
 
+namespace is_by
+{
+    const bool reference = true;
+    const bool value = false;
+};
+
 // type_def represents a type where it is used, like a method parameter or a 
struc field, in contrast to more
 // specifict types like struct_def, class_def, function_def, which represents 
a declaration of a type.
 struct type_def
@@ -389,11 +395,11 @@ struct type_def
    type_def(variant_type original_type, std::string c_type, bool has_own, bool 
is_ptr, bool is_beta, std::string doc_summary)
      : original_type(original_type), c_type(c_type), has_own(has_own), 
is_ptr(is_ptr), is_beta(is_beta), doc_summary(doc_summary) {}
 
-   type_def(Eolian_Type const* eolian_type, Eolian_Unit const* unit, 
Eolian_C_Type_Type ctype, bool is_moved)
+   type_def(Eolian_Type const* eolian_type, Eolian_Unit const* unit, 
std::string const& ctype, bool is_moved, bool is_reference)
    {
-     set(eolian_type, unit, ctype, is_moved);
+     set(eolian_type, unit, ctype, is_moved, is_reference);
    }
-   void set(Eolian_Type const* eolian_type, Eolian_Unit const* unit, 
Eolian_C_Type_Type ctype, bool is_moved);
+   void set(Eolian_Type const* eolian_type, Eolian_Unit const* unit, 
std::string const & ctype, bool is_moved, bool is_reference);
    void set(Eolian_Expression_Type eolian_exp_type);
 
    friend inline bool operator<(type_def const& lhs, type_def const& rhs)
@@ -433,14 +439,15 @@ inline bool operator!=(type_def const& lhs, type_def 
const& rhs)
 
 type_def const void_ {attributes::regular_type_def{"void", 
{qualifier_info::is_none, {}}, {}}, "void", false, false, false, ""};
 
-inline void type_def::set(Eolian_Type const* eolian_type, Eolian_Unit const* 
unit, Eolian_C_Type_Type ctype, bool is_moved)
+inline void type_def::set(Eolian_Type const* eolian_type, Eolian_Unit const* 
unit, std::string const& ctype, bool is_moved, bool is_reference)
 {
-   c_type = ::eolian_type_c_type_get(eolian_type, ctype);
+   c_type = ctype;
    is_value_type = ('*' != c_type.back());
    // ::eina_stringshare_del(stringshare); // this crashes
    Eolian_Type const* stp = eolian_type_base_type_get(eolian_type);
    has_own = is_moved;
-   is_ptr = !!::eolian_type_is_ptr(eolian_type);
+
+   is_ptr = is_reference || eolian_type_is_ptr(eolian_type);
 
    Eolian_Typedecl const* decl = eolian_type_typedecl_get(eolian_type);
    is_beta = decl && eolian_object_is_beta(EOLIAN_OBJECT(decl));
@@ -452,7 +459,7 @@ inline void type_def::set(Eolian_Type const* eolian_type, 
Eolian_Unit const* uni
    switch( ::eolian_type_type_get(eolian_type))
      {
      case EOLIAN_TYPE_VOID:
-       original_type = attributes::regular_type_def{"void", 
{qualifiers(eolian_type, is_moved), {}}, {}};
+       original_type = attributes::regular_type_def{"void", 
{qualifiers(eolian_type, is_moved, is_ptr), {}}, {}};
        break;
      case EOLIAN_TYPE_REGULAR:
        if (!stp)
@@ -474,15 +481,19 @@ inline void type_def::set(Eolian_Type const* eolian_type, 
Eolian_Unit const* uni
            for(efl::eina::iterator<const char> namespace_iterator( 
::eolian_type_namespaces_get(eolian_type))
                  , namespace_last; namespace_iterator != namespace_last; 
++namespace_iterator)
              namespaces.push_back(&*namespace_iterator);
-           original_type = {regular_type_def{ 
::eolian_type_short_name_get(eolian_type), {qualifiers(eolian_type, is_moved), 
{}}, namespaces, type_type, is_undefined}};
+           original_type = {regular_type_def{ 
::eolian_type_short_name_get(eolian_type), {qualifiers(eolian_type, is_moved, 
is_ptr), {}}, namespaces, type_type, is_undefined}};
          }
        else
          {
            complex_type_def complex
-            {{::eolian_type_short_name_get(eolian_type), 
{qualifiers(eolian_type, is_moved), {}}, {}}, {}};
+            {{::eolian_type_short_name_get(eolian_type), 
{qualifiers(eolian_type, is_moved, is_ptr), {}}, {}}, {}};
            while (stp)
              {
-                complex.subtypes.push_back({stp, unit, EOLIAN_C_TYPE_DEFAULT, 
eolian_type_is_move(stp)});
+                complex.subtypes.push_back({stp
+                                            , unit
+                                            , ::eolian_type_c_type_get(stp, 
EOLIAN_C_TYPE_DEFAULT)
+                                            , eolian_type_is_move(stp)
+                                            , is_by::value});
                 stp = eolian_type_next_type_get(stp);
              }
            original_type = complex;
@@ -491,7 +502,7 @@ inline void type_def::set(Eolian_Type const* eolian_type, 
Eolian_Unit const* uni
      case EOLIAN_TYPE_CLASS:
        {
           Eolian_Class const* klass = eolian_type_class_get(eolian_type);
-          original_type = klass_name(klass, {qualifiers(eolian_type, 
is_moved), {}});
+          original_type = klass_name(klass, {qualifiers(eolian_type, is_moved, 
is_ptr), {}});
        }
        break;
      default:
@@ -540,7 +551,12 @@ struct alias_def
        is_undefined = true;
      else
        {
-          base_type = type_def(::eolian_typedecl_base_type_get(alias_obj), 
unit, EOLIAN_C_TYPE_DEFAULT, value_ownership::unmoved);
+          auto eolian_type = ::eolian_typedecl_base_type_get(alias_obj);
+          base_type = type_def(eolian_type
+                               , unit
+                               , ::eolian_type_c_type_get(eolian_type, 
EOLIAN_C_TYPE_DEFAULT)
+                               , value_ownership::unmoved
+                               , is_by::value);
           is_undefined = false;
        }
 
@@ -593,7 +609,11 @@ struct parameter_def
                 documentation_def documentation, Eolian_Unit const* unit)
     : direction(std::move(direction)), type(std::move(type)), 
param_name(std::move(param_name)), documentation(documentation), unit(unit) {}
   parameter_def(Eolian_Function_Parameter const* param, Eolian_Unit const* 
unit)
-    : type( ::eolian_parameter_type_get(param), unit, EOLIAN_C_TYPE_PARAM, 
eolian_parameter_is_move(param))
+    : type( ::eolian_parameter_type_get(param)
+            , unit
+            , eolian_parameter_c_type_get(param, EINA_FALSE)
+            , eolian_parameter_is_move(param)
+            , eolian_parameter_is_by_ref(param))
     , param_name( ::eolian_parameter_name_get(param)), unit(unit)
   {
      Eolian_Parameter_Dir direction = ::eolian_parameter_direction_get(param);
@@ -747,7 +767,11 @@ struct function_def
     return_documentation = eolian_function_return_documentation_get(function, 
type);
     scope = static_cast<member_scope>(eolian_function_scope_get(function, 
type));
     if(r_type)
-      return_type.set(r_type, unit, EOLIAN_C_TYPE_RETURN, 
eolian_function_return_is_move(function, type));
+      return_type.set(r_type
+                      , unit
+                      , eolian_function_return_c_type_get(function, type)
+                      , eolian_function_return_is_move(function, type)
+                      , eolian_function_return_is_by_ref(function, type));
      if(type == EOLIAN_METHOD || type == EOLIAN_FUNCTION_POINTER)
        {
           for(efl::eina::iterator<Eolian_Function_Parameter> param_iterator ( 
::eolian_function_parameters_get(function))
@@ -1003,7 +1027,11 @@ struct variable_def
   variable_def(Eolian_Variable const* variable, Eolian_Unit const* unit)
         : name(::eolian_variable_short_name_get(variable))
         , full_name(::eolian_variable_name_get(variable))
-        , base_type(::eolian_variable_base_type_get(variable), unit, 
::EOLIAN_C_TYPE_DEFAULT, value_ownership::unmoved)
+        , base_type(::eolian_variable_base_type_get(variable)
+                    , unit
+                    , 
::eolian_type_c_type_get(eolian_variable_base_type_get(variable), 
::EOLIAN_C_TYPE_DEFAULT)
+                    , value_ownership::unmoved
+                    , is_by::value)
         , documentation(::eolian_variable_documentation_get(variable))
         , 
type(static_cast<variable_type>(::eolian_variable_type_get(variable)))
         , expression_value()
@@ -1087,7 +1115,12 @@ struct event_def
 
   event_def(Eolian_Event const* event, Eolian_Class const* cls, Eolian_Unit 
const* unit)
     : klass(cls, {attributes::qualifier_info::is_none, std::string()})
-    , type( ::eolian_event_type_get(event) ? 
eina::optional<type_def>{{::eolian_event_type_get(event), unit, 
EOLIAN_C_TYPE_DEFAULT, value_ownership::unmoved}} : eina::optional<type_def>{})
+    , type( ::eolian_event_type_get(event) ? 
eina::optional<type_def>{{::eolian_event_type_get(event)
+                                                                       , unit
+                                                                       , 
::eolian_type_c_type_get(::eolian_event_type_get(event), EOLIAN_C_TYPE_DEFAULT)
+                                                                       , 
value_ownership::unmoved
+                                                                       , 
is_by::value}
+             } : eina::optional<type_def>{})
     , name( ::eolian_event_name_get(event))
     , c_name( ::eolian_event_c_macro_get(event))
     , beta( ::eolian_event_is_beta(event))
@@ -1552,8 +1585,11 @@ struct struct_field_def
   {
      name = eolian_typedecl_struct_field_name_get(struct_field);
      try {
-        type.set(eolian_typedecl_struct_field_type_get(struct_field), unit, 
EOLIAN_C_TYPE_DEFAULT
-                , eolian_typedecl_struct_field_is_move(struct_field));
+        type.set(eolian_typedecl_struct_field_type_get(struct_field)
+                , unit
+                , eolian_typedecl_struct_field_c_type_get(struct_field)
+                , eolian_typedecl_struct_field_is_move(struct_field)
+                , eolian_typedecl_struct_field_is_by_ref(struct_field));
      } catch(std::runtime_error const&) { /* Silently skip pointer fields*/ }
      documentation = 
::eolian_typedecl_struct_field_documentation_get(struct_field);
   }
diff --git a/src/lib/eolian_cxx/grammar/qualifier_def.hpp 
b/src/lib/eolian_cxx/grammar/qualifier_def.hpp
index cab3ca8667..0823010437 100644
--- a/src/lib/eolian_cxx/grammar/qualifier_def.hpp
+++ b/src/lib/eolian_cxx/grammar/qualifier_def.hpp
@@ -72,11 +72,11 @@ inline qualifier_bool operator^(qualifier_bool lhs, 
qualifier_info rhs)
   return lhs;
 }
 
-inline qualifier_info qualifiers(Eolian_Type const* type, bool is_moved)
+inline qualifier_info qualifiers(Eolian_Type const* type, bool is_moved, bool 
is_by_ref)
 {
   qualifier_info is_own = is_moved ? qualifier_info::is_own : 
qualifier_info::is_none;
   qualifier_info is_const = ::eolian_type_is_const(type) ? 
qualifier_info::is_const : qualifier_info::is_none;
-  qualifier_info is_ref = ::eolian_type_is_ptr(type) ? qualifier_info::is_ref 
: qualifier_info::is_none;
+  qualifier_info is_ref = is_by_ref ? qualifier_info::is_ref : 
qualifier_info::is_none;
   return is_own | is_const | is_ref;
 }
         

-- 


Reply via email to