q66 pushed a commit to branch master.

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

commit e288f5160b2817e8e1713f58f35b0b0445107f90
Author: Daniel Kolesa <d.kol...@osg.samsung.com>
Date:   Thu Aug 10 12:12:38 2017 +0200

    eolian: change C type serialization API to account for returns
    
    This will allow proper handling of const.
---
 src/bin/eolian/docs.c              |  2 +-
 src/bin/eolian/headers.c           |  6 +++---
 src/bin/eolian/sources.c           | 14 +++++++-------
 src/bin/eolian/types.c             | 13 +++++++------
 src/lib/eolian/Eolian.h            | 10 +++++++++-
 src/lib/eolian/database_type_api.c |  2 +-
 6 files changed, 28 insertions(+), 19 deletions(-)

diff --git a/src/bin/eolian/docs.c b/src/bin/eolian/docs.c
index 2a293697c0..aa17975334 100644
--- a/src/bin/eolian/docs.c
+++ b/src/bin/eolian/docs.c
@@ -377,7 +377,7 @@ eo_gen_docs_event_gen(const Eolian_Unit *src, const 
Eolian_Event *ev,
    if (rt)
      {
         p = buf;
-        Eina_Stringshare *rts = eolian_type_c_type_get(rt);
+        Eina_Stringshare *rts = eolian_type_c_type_get(rt, 
EOLIAN_C_TYPE_DEFAULT);
         snprintf(buf, sizeof(buf), "@return %s", rts);
         eina_stringshare_del(rts);
      }
diff --git a/src/bin/eolian/headers.c b/src/bin/eolian/headers.c
index 1d11da860a..71d66f3d65 100644
--- a/src/bin/eolian/headers.c
+++ b/src/bin/eolian/headers.c
@@ -58,7 +58,7 @@ _gen_func(const Eolian_Unit *src, const Eolian_Function *fid,
    eina_strbuf_append(buf, legacy ? "EAPI " : "EOAPI ");
    if (rtp)
      {
-        Eina_Stringshare *rtps = eolian_type_c_type_get(rtp);
+        Eina_Stringshare *rtps = eolian_type_c_type_get(rtp, 
EOLIAN_C_TYPE_RETURN);
         eina_strbuf_append(buf, rtps);
         if (rtps[strlen(rtps) - 1] != '*')
           eina_strbuf_append_char(buf, ' ');
@@ -96,7 +96,7 @@ _gen_func(const Eolian_Unit *src, const Eolian_Function *fid,
         {
            const Eolian_Type *prt = eolian_parameter_type_get(pr);
            const char *prn = eolian_parameter_name_get(pr);
-           Eina_Stringshare *prtn = eolian_type_c_type_get(prt);
+           Eina_Stringshare *prtn = eolian_type_c_type_get(prt, 
EOLIAN_C_TYPE_PARAM);
            ++nidx;
            if (!first)
              eina_strbuf_append(buf, ", ");
@@ -130,7 +130,7 @@ _gen_func(const Eolian_Unit *src, const Eolian_Function 
*fid,
              const Eolian_Type *prt = eolian_parameter_type_get(pr);
              const Eolian_Typedecl *ptd = eolian_type_typedecl_get(prt);
              const char *prn = eolian_parameter_name_get(pr);
-             Eina_Stringshare *prtn = eolian_type_c_type_get(prt);
+             Eina_Stringshare *prtn = eolian_type_c_type_get(prt, 
EOLIAN_C_TYPE_PARAM);
 
              if (ptd && eolian_typedecl_type_get(ptd) == 
EOLIAN_TYPEDECL_FUNCTION_POINTER)
                {
diff --git a/src/bin/eolian/sources.c b/src/bin/eolian/sources.c
index d1ab3d5870..65957e816f 100644
--- a/src/bin/eolian/sources.c
+++ b/src/bin/eolian/sources.c
@@ -137,7 +137,7 @@ _append_defval(const Eolian_Unit *src, Eina_Strbuf *buf,
         free(sn);
         return;
      }
-   Eina_Stringshare *ctp = eolian_type_c_type_get(btp);
+   Eina_Stringshare *ctp = eolian_type_c_type_get(btp, EOLIAN_C_TYPE_DEFAULT);
    if (strchr(ctp, '*'))
      {
         eina_strbuf_append(buf, "NULL");
@@ -207,7 +207,7 @@ _gen_func(const Eolian_Unit *src, const Eolian_Class *cl,
         {
            const char *prn = eolian_parameter_name_get(pr);
            const Eolian_Type *pt = eolian_parameter_type_get(pr);
-           Eina_Stringshare *ptn = eolian_type_c_type_get(pt);
+           Eina_Stringshare *ptn = eolian_type_c_type_get(pt, 
EOLIAN_C_TYPE_PARAM);
 
            if (eina_strbuf_length_get(params))
              eina_strbuf_append(params, ", ");
@@ -245,7 +245,7 @@ _gen_func(const Eolian_Unit *src, const Eolian_Class *cl,
              const Eolian_Expression *dfv = 
eolian_parameter_default_value_get(pr);
              const char *prn = eolian_parameter_name_get(pr);
              const Eolian_Type *pt = eolian_parameter_type_get(pr);
-             Eina_Stringshare *ptn = eolian_type_c_type_get(pt);
+             Eina_Stringshare *ptn = eolian_type_c_type_get(pt, 
EOLIAN_C_TYPE_PARAM);
              const Eolian_Typedecl *ptd = eolian_type_typedecl_get(pt);
 
              Eina_Bool had_star = ptn[strlen(ptn) - 1] == '*';
@@ -317,7 +317,7 @@ _gen_func(const Eolian_Unit *src, const Eolian_Class *cl,
    if (impl_same_class && eolian_implement_is_pure_virtual(impl, ftype))
      impl_need = EINA_FALSE;
 
-   Eina_Stringshare *rtpn = rtp ? eolian_type_c_type_get(rtp)
+   Eina_Stringshare *rtpn = rtp ? eolian_type_c_type_get(rtp, 
EOLIAN_C_TYPE_RETURN)
                                 : eina_stringshare_add("void");
 
    char *cname = NULL, *cnamel = NULL, *ocnamel = NULL;
@@ -828,7 +828,7 @@ _gen_params(const Eolian_Function *fid, 
Eolian_Function_Type ftype,
         {
            const char *prn = eolian_parameter_name_get(pr);
            const Eolian_Type *pt = eolian_parameter_type_get(pr);
-           Eina_Stringshare *ptn = eolian_type_c_type_get(pt);
+           Eina_Stringshare *ptn = eolian_type_c_type_get(pt, 
EOLIAN_C_TYPE_PARAM);
 
            eina_strbuf_append(params, ", ");
            eina_strbuf_append(params, prn);
@@ -858,7 +858,7 @@ _gen_params(const Eolian_Function *fid, 
Eolian_Function_Type ftype,
              const char *prn = eolian_parameter_name_get(pr);
              const Eolian_Type *pt = eolian_parameter_type_get(pr);
              const Eolian_Typedecl *ptd = eolian_type_typedecl_get(pt);
-             Eina_Stringshare *ptn = eolian_type_c_type_get(pt);
+             Eina_Stringshare *ptn = eolian_type_c_type_get(pt, 
EOLIAN_C_TYPE_PARAM);
 
              if (ptd && eolian_typedecl_type_get(ptd) == 
EOLIAN_TYPEDECL_FUNCTION_POINTER)
                {
@@ -938,7 +938,7 @@ _gen_proto(const Eolian_Class *cl, const Eolian_Function 
*fid,
    eina_strbuf_append(buf, "EOLIAN static ");
    if (rtp)
      {
-        Eina_Stringshare *rtpn = eolian_type_c_type_get(rtp);
+        Eina_Stringshare *rtpn = eolian_type_c_type_get(rtp, 
EOLIAN_C_TYPE_RETURN);
         eina_strbuf_append(buf, rtpn);
         eina_stringshare_del(rtpn);
      }
diff --git a/src/bin/eolian/types.c b/src/bin/eolian/types.c
index 9baebed02a..c856d7abba 100644
--- a/src/bin/eolian/types.c
+++ b/src/bin/eolian/types.c
@@ -42,7 +42,8 @@ _type_generate(const Eolian_Unit *src, const Eolian_Typedecl 
*tp,
                 Eina_Stringshare *ct = NULL;
                 if (eolian_type_type_get(mtp) == EOLIAN_TYPE_STATIC_ARRAY)
                   {
-                     ct = 
eolian_type_c_type_get(eolian_type_base_type_get(mtp));
+                     ct = 
eolian_type_c_type_get(eolian_type_base_type_get(mtp),
+                                                 EOLIAN_C_TYPE_DEFAULT);
                      eina_strbuf_append_printf(buf, "  %s%s%s[%zu];",
                         ct, strchr(ct, '*') ? "" : " ",
                         eolian_typedecl_struct_field_name_get(memb),
@@ -50,7 +51,7 @@ _type_generate(const Eolian_Unit *src, const Eolian_Typedecl 
*tp,
                   }
                 else
                   {
-                     ct = eolian_type_c_type_get(mtp);
+                     ct = eolian_type_c_type_get(mtp, EOLIAN_C_TYPE_DEFAULT);
                      eina_strbuf_append_printf(buf, "  %s%s%s;",
                         ct, strchr(ct, '*') ? "" : " ",
                         eolian_typedecl_struct_field_name_get(memb));
@@ -145,7 +146,7 @@ _type_generate(const Eolian_Unit *src, const 
Eolian_Typedecl *tp,
              eina_strbuf_append(buf, "void ");
            else
              {
-                Eina_Stringshare *ct = eolian_type_c_type_get(rtp);
+                Eina_Stringshare *ct = eolian_type_c_type_get(rtp, 
EOLIAN_C_TYPE_RETURN);
                 eina_strbuf_append_printf(buf, "%s ", ct);
              }
 
@@ -162,7 +163,7 @@ _type_generate(const Eolian_Unit *src, const 
Eolian_Typedecl *tp,
              {
                 const Eolian_Typedecl *ptd = 
eolian_type_typedecl_get(eolian_parameter_type_get(param));
                 Eina_Stringshare *pn = eolian_parameter_name_get(param);
-                Eina_Stringshare *pt = 
eolian_type_c_type_get(eolian_parameter_type_get(param));
+                Eina_Stringshare *pt = 
eolian_type_c_type_get(eolian_parameter_type_get(param), EOLIAN_C_TYPE_PARAM);
 
                 if (!pn)
                   pn = ""; // FIXME add some kind of param1/param2 control for 
null?
@@ -221,7 +222,7 @@ _var_generate(const Eolian_Unit *src, const Eolian_Variable 
*vr, Eina_Bool legac
      }
    else
      {
-        Eina_Stringshare *ct = eolian_type_c_type_get(vt);
+        Eina_Stringshare *ct = eolian_type_c_type_get(vt, 
EOLIAN_C_TYPE_DEFAULT);
         eina_strbuf_append_printf(buf, "EWAPI extern %s %s;", ct, fn);
         eina_stringshare_del(ct);
      }
@@ -314,7 +315,7 @@ void eo_gen_types_source_gen(const Eolian_Unit *src,
         eina_str_toupper(&fn);
 
         const Eolian_Type *vt = eolian_variable_base_type_get(vr);
-        Eina_Stringshare *ct = eolian_type_c_type_get(vt);
+        Eina_Stringshare *ct = eolian_type_c_type_get(vt, 
EOLIAN_C_TYPE_DEFAULT);
         eina_strbuf_append_printf(buf, "EWAPI %s %s = ", ct, fn);
         eina_stringshare_del(ct);
         free(fn);
diff --git a/src/lib/eolian/Eolian.h b/src/lib/eolian/Eolian.h
index 8b19fd602b..9f99d361f1 100644
--- a/src/lib/eolian/Eolian.h
+++ b/src/lib/eolian/Eolian.h
@@ -236,6 +236,13 @@ typedef enum
 
 typedef enum
 {
+   EOLIAN_C_TYPE_DEFAULT = 0,
+   EOLIAN_C_TYPE_PARAM,
+   EOLIAN_C_TYPE_RETURN
+} Eolian_C_Type_Type;
+
+typedef enum
+{
    EOLIAN_EXPR_UNKNOWN = 0,
    EOLIAN_EXPR_INT,
    EOLIAN_EXPR_UINT,
@@ -1883,6 +1890,7 @@ EAPI Eina_Bool eolian_type_is_ptr(const Eolian_Type *tp);
  * @brief Get the full C type name of the given type.
  *
  * @param[in] tp the type.
+ * @param[in] ctype the context within which the C type string will be used.
  * @return The C type name assuming @c tp is not NULL.
  *
  * You're responsible for the stringshare.
@@ -1891,7 +1899,7 @@ EAPI Eina_Bool eolian_type_is_ptr(const Eolian_Type *tp);
  *
  * @ingroup Eolian
  */
-EAPI Eina_Stringshare *eolian_type_c_type_get(const Eolian_Type *tp);
+EAPI Eina_Stringshare *eolian_type_c_type_get(const Eolian_Type *tp, 
Eolian_C_Type_Type ctype);
 
 /*
  * @brief Get the name of the given type. For regular or complex types, this
diff --git a/src/lib/eolian/database_type_api.c 
b/src/lib/eolian/database_type_api.c
index bbc03fd17d..47d994e584 100644
--- a/src/lib/eolian/database_type_api.c
+++ b/src/lib/eolian/database_type_api.c
@@ -355,7 +355,7 @@ eolian_typedecl_is_extern(const Eolian_Typedecl *tp)
 }
 
 EAPI Eina_Stringshare *
-eolian_type_c_type_get(const Eolian_Type *tp)
+eolian_type_c_type_get(const Eolian_Type *tp, Eolian_C_Type_Type ctype 
EINA_UNUSED)
 {
    Eina_Stringshare *ret;
    Eina_Strbuf *buf;

-- 


Reply via email to