summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bin/eolian/docs.c2
-rw-r--r--src/bin/eolian/headers.c6
-rw-r--r--src/bin/eolian/sources.c14
-rw-r--r--src/bin/eolian/types.c13
-rw-r--r--src/lib/eolian/Eolian.h10
-rw-r--r--src/lib/eolian/database_type_api.c2
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,
377 if (rt) 377 if (rt)
378 { 378 {
379 p = buf; 379 p = buf;
380 Eina_Stringshare *rts = eolian_type_c_type_get(rt); 380 Eina_Stringshare *rts = eolian_type_c_type_get(rt, EOLIAN_C_TYPE_DEFAULT);
381 snprintf(buf, sizeof(buf), "@return %s", rts); 381 snprintf(buf, sizeof(buf), "@return %s", rts);
382 eina_stringshare_del(rts); 382 eina_stringshare_del(rts);
383 } 383 }
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,
58 eina_strbuf_append(buf, legacy ? "EAPI " : "EOAPI "); 58 eina_strbuf_append(buf, legacy ? "EAPI " : "EOAPI ");
59 if (rtp) 59 if (rtp)
60 { 60 {
61 Eina_Stringshare *rtps = eolian_type_c_type_get(rtp); 61 Eina_Stringshare *rtps = eolian_type_c_type_get(rtp, EOLIAN_C_TYPE_RETURN);
62 eina_strbuf_append(buf, rtps); 62 eina_strbuf_append(buf, rtps);
63 if (rtps[strlen(rtps) - 1] != '*') 63 if (rtps[strlen(rtps) - 1] != '*')
64 eina_strbuf_append_char(buf, ' '); 64 eina_strbuf_append_char(buf, ' ');
@@ -96,7 +96,7 @@ _gen_func(const Eolian_Unit *src, const Eolian_Function *fid,
96 { 96 {
97 const Eolian_Type *prt = eolian_parameter_type_get(pr); 97 const Eolian_Type *prt = eolian_parameter_type_get(pr);
98 const char *prn = eolian_parameter_name_get(pr); 98 const char *prn = eolian_parameter_name_get(pr);
99 Eina_Stringshare *prtn = eolian_type_c_type_get(prt); 99 Eina_Stringshare *prtn = eolian_type_c_type_get(prt, EOLIAN_C_TYPE_PARAM);
100 ++nidx; 100 ++nidx;
101 if (!first) 101 if (!first)
102 eina_strbuf_append(buf, ", "); 102 eina_strbuf_append(buf, ", ");
@@ -130,7 +130,7 @@ _gen_func(const Eolian_Unit *src, const Eolian_Function *fid,
130 const Eolian_Type *prt = eolian_parameter_type_get(pr); 130 const Eolian_Type *prt = eolian_parameter_type_get(pr);
131 const Eolian_Typedecl *ptd = eolian_type_typedecl_get(prt); 131 const Eolian_Typedecl *ptd = eolian_type_typedecl_get(prt);
132 const char *prn = eolian_parameter_name_get(pr); 132 const char *prn = eolian_parameter_name_get(pr);
133 Eina_Stringshare *prtn = eolian_type_c_type_get(prt); 133 Eina_Stringshare *prtn = eolian_type_c_type_get(prt, EOLIAN_C_TYPE_PARAM);
134 134
135 if (ptd && eolian_typedecl_type_get(ptd) == EOLIAN_TYPEDECL_FUNCTION_POINTER) 135 if (ptd && eolian_typedecl_type_get(ptd) == EOLIAN_TYPEDECL_FUNCTION_POINTER)
136 { 136 {
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,
137 free(sn); 137 free(sn);
138 return; 138 return;
139 } 139 }
140 Eina_Stringshare *ctp = eolian_type_c_type_get(btp); 140 Eina_Stringshare *ctp = eolian_type_c_type_get(btp, EOLIAN_C_TYPE_DEFAULT);
141 if (strchr(ctp, '*')) 141 if (strchr(ctp, '*'))
142 { 142 {
143 eina_strbuf_append(buf, "NULL"); 143 eina_strbuf_append(buf, "NULL");
@@ -207,7 +207,7 @@ _gen_func(const Eolian_Unit *src, const Eolian_Class *cl,
207 { 207 {
208 const char *prn = eolian_parameter_name_get(pr); 208 const char *prn = eolian_parameter_name_get(pr);
209 const Eolian_Type *pt = eolian_parameter_type_get(pr); 209 const Eolian_Type *pt = eolian_parameter_type_get(pr);
210 Eina_Stringshare *ptn = eolian_type_c_type_get(pt); 210 Eina_Stringshare *ptn = eolian_type_c_type_get(pt, EOLIAN_C_TYPE_PARAM);
211 211
212 if (eina_strbuf_length_get(params)) 212 if (eina_strbuf_length_get(params))
213 eina_strbuf_append(params, ", "); 213 eina_strbuf_append(params, ", ");
@@ -245,7 +245,7 @@ _gen_func(const Eolian_Unit *src, const Eolian_Class *cl,
245 const Eolian_Expression *dfv = eolian_parameter_default_value_get(pr); 245 const Eolian_Expression *dfv = eolian_parameter_default_value_get(pr);
246 const char *prn = eolian_parameter_name_get(pr); 246 const char *prn = eolian_parameter_name_get(pr);
247 const Eolian_Type *pt = eolian_parameter_type_get(pr); 247 const Eolian_Type *pt = eolian_parameter_type_get(pr);
248 Eina_Stringshare *ptn = eolian_type_c_type_get(pt); 248 Eina_Stringshare *ptn = eolian_type_c_type_get(pt, EOLIAN_C_TYPE_PARAM);
249 const Eolian_Typedecl *ptd = eolian_type_typedecl_get(pt); 249 const Eolian_Typedecl *ptd = eolian_type_typedecl_get(pt);
250 250
251 Eina_Bool had_star = ptn[strlen(ptn) - 1] == '*'; 251 Eina_Bool had_star = ptn[strlen(ptn) - 1] == '*';
@@ -317,7 +317,7 @@ _gen_func(const Eolian_Unit *src, const Eolian_Class *cl,
317 if (impl_same_class && eolian_implement_is_pure_virtual(impl, ftype)) 317 if (impl_same_class && eolian_implement_is_pure_virtual(impl, ftype))
318 impl_need = EINA_FALSE; 318 impl_need = EINA_FALSE;
319 319
320 Eina_Stringshare *rtpn = rtp ? eolian_type_c_type_get(rtp) 320 Eina_Stringshare *rtpn = rtp ? eolian_type_c_type_get(rtp, EOLIAN_C_TYPE_RETURN)
321 : eina_stringshare_add("void"); 321 : eina_stringshare_add("void");
322 322
323 char *cname = NULL, *cnamel = NULL, *ocnamel = NULL; 323 char *cname = NULL, *cnamel = NULL, *ocnamel = NULL;
@@ -828,7 +828,7 @@ _gen_params(const Eolian_Function *fid, Eolian_Function_Type ftype,
828 { 828 {
829 const char *prn = eolian_parameter_name_get(pr); 829 const char *prn = eolian_parameter_name_get(pr);
830 const Eolian_Type *pt = eolian_parameter_type_get(pr); 830 const Eolian_Type *pt = eolian_parameter_type_get(pr);
831 Eina_Stringshare *ptn = eolian_type_c_type_get(pt); 831 Eina_Stringshare *ptn = eolian_type_c_type_get(pt, EOLIAN_C_TYPE_PARAM);
832 832
833 eina_strbuf_append(params, ", "); 833 eina_strbuf_append(params, ", ");
834 eina_strbuf_append(params, prn); 834 eina_strbuf_append(params, prn);
@@ -858,7 +858,7 @@ _gen_params(const Eolian_Function *fid, Eolian_Function_Type ftype,
858 const char *prn = eolian_parameter_name_get(pr); 858 const char *prn = eolian_parameter_name_get(pr);
859 const Eolian_Type *pt = eolian_parameter_type_get(pr); 859 const Eolian_Type *pt = eolian_parameter_type_get(pr);
860 const Eolian_Typedecl *ptd = eolian_type_typedecl_get(pt); 860 const Eolian_Typedecl *ptd = eolian_type_typedecl_get(pt);
861 Eina_Stringshare *ptn = eolian_type_c_type_get(pt); 861 Eina_Stringshare *ptn = eolian_type_c_type_get(pt, EOLIAN_C_TYPE_PARAM);
862 862
863 if (ptd && eolian_typedecl_type_get(ptd) == EOLIAN_TYPEDECL_FUNCTION_POINTER) 863 if (ptd && eolian_typedecl_type_get(ptd) == EOLIAN_TYPEDECL_FUNCTION_POINTER)
864 { 864 {
@@ -938,7 +938,7 @@ _gen_proto(const Eolian_Class *cl, const Eolian_Function *fid,
938 eina_strbuf_append(buf, "EOLIAN static "); 938 eina_strbuf_append(buf, "EOLIAN static ");
939 if (rtp) 939 if (rtp)
940 { 940 {
941 Eina_Stringshare *rtpn = eolian_type_c_type_get(rtp); 941 Eina_Stringshare *rtpn = eolian_type_c_type_get(rtp, EOLIAN_C_TYPE_RETURN);
942 eina_strbuf_append(buf, rtpn); 942 eina_strbuf_append(buf, rtpn);
943 eina_stringshare_del(rtpn); 943 eina_stringshare_del(rtpn);
944 } 944 }
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,
42 Eina_Stringshare *ct = NULL; 42 Eina_Stringshare *ct = NULL;
43 if (eolian_type_type_get(mtp) == EOLIAN_TYPE_STATIC_ARRAY) 43 if (eolian_type_type_get(mtp) == EOLIAN_TYPE_STATIC_ARRAY)
44 { 44 {
45 ct = eolian_type_c_type_get(eolian_type_base_type_get(mtp)); 45 ct = eolian_type_c_type_get(eolian_type_base_type_get(mtp),
46 EOLIAN_C_TYPE_DEFAULT);
46 eina_strbuf_append_printf(buf, " %s%s%s[%zu];", 47 eina_strbuf_append_printf(buf, " %s%s%s[%zu];",
47 ct, strchr(ct, '*') ? "" : " ", 48 ct, strchr(ct, '*') ? "" : " ",
48 eolian_typedecl_struct_field_name_get(memb), 49 eolian_typedecl_struct_field_name_get(memb),
@@ -50,7 +51,7 @@ _type_generate(const Eolian_Unit *src, const Eolian_Typedecl *tp,
50 } 51 }
51 else 52 else
52 { 53 {
53 ct = eolian_type_c_type_get(mtp); 54 ct = eolian_type_c_type_get(mtp, EOLIAN_C_TYPE_DEFAULT);
54 eina_strbuf_append_printf(buf, " %s%s%s;", 55 eina_strbuf_append_printf(buf, " %s%s%s;",
55 ct, strchr(ct, '*') ? "" : " ", 56 ct, strchr(ct, '*') ? "" : " ",
56 eolian_typedecl_struct_field_name_get(memb)); 57 eolian_typedecl_struct_field_name_get(memb));
@@ -145,7 +146,7 @@ _type_generate(const Eolian_Unit *src, const Eolian_Typedecl *tp,
145 eina_strbuf_append(buf, "void "); 146 eina_strbuf_append(buf, "void ");
146 else 147 else
147 { 148 {
148 Eina_Stringshare *ct = eolian_type_c_type_get(rtp); 149 Eina_Stringshare *ct = eolian_type_c_type_get(rtp, EOLIAN_C_TYPE_RETURN);
149 eina_strbuf_append_printf(buf, "%s ", ct); 150 eina_strbuf_append_printf(buf, "%s ", ct);
150 } 151 }
151 152
@@ -162,7 +163,7 @@ _type_generate(const Eolian_Unit *src, const Eolian_Typedecl *tp,
162 { 163 {
163 const Eolian_Typedecl *ptd = eolian_type_typedecl_get(eolian_parameter_type_get(param)); 164 const Eolian_Typedecl *ptd = eolian_type_typedecl_get(eolian_parameter_type_get(param));
164 Eina_Stringshare *pn = eolian_parameter_name_get(param); 165 Eina_Stringshare *pn = eolian_parameter_name_get(param);
165 Eina_Stringshare *pt = eolian_type_c_type_get(eolian_parameter_type_get(param)); 166 Eina_Stringshare *pt = eolian_type_c_type_get(eolian_parameter_type_get(param), EOLIAN_C_TYPE_PARAM);
166 167
167 if (!pn) 168 if (!pn)
168 pn = ""; // FIXME add some kind of param1/param2 control for null? 169 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
221 } 222 }
222 else 223 else
223 { 224 {
224 Eina_Stringshare *ct = eolian_type_c_type_get(vt); 225 Eina_Stringshare *ct = eolian_type_c_type_get(vt, EOLIAN_C_TYPE_DEFAULT);
225 eina_strbuf_append_printf(buf, "EWAPI extern %s %s;", ct, fn); 226 eina_strbuf_append_printf(buf, "EWAPI extern %s %s;", ct, fn);
226 eina_stringshare_del(ct); 227 eina_stringshare_del(ct);
227 } 228 }
@@ -314,7 +315,7 @@ void eo_gen_types_source_gen(const Eolian_Unit *src,
314 eina_str_toupper(&fn); 315 eina_str_toupper(&fn);
315 316
316 const Eolian_Type *vt = eolian_variable_base_type_get(vr); 317 const Eolian_Type *vt = eolian_variable_base_type_get(vr);
317 Eina_Stringshare *ct = eolian_type_c_type_get(vt); 318 Eina_Stringshare *ct = eolian_type_c_type_get(vt, EOLIAN_C_TYPE_DEFAULT);
318 eina_strbuf_append_printf(buf, "EWAPI %s %s = ", ct, fn); 319 eina_strbuf_append_printf(buf, "EWAPI %s %s = ", ct, fn);
319 eina_stringshare_del(ct); 320 eina_stringshare_del(ct);
320 free(fn); 321 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
236 236
237typedef enum 237typedef enum
238{ 238{
239 EOLIAN_C_TYPE_DEFAULT = 0,
240 EOLIAN_C_TYPE_PARAM,
241 EOLIAN_C_TYPE_RETURN
242} Eolian_C_Type_Type;
243
244typedef enum
245{
239 EOLIAN_EXPR_UNKNOWN = 0, 246 EOLIAN_EXPR_UNKNOWN = 0,
240 EOLIAN_EXPR_INT, 247 EOLIAN_EXPR_INT,
241 EOLIAN_EXPR_UINT, 248 EOLIAN_EXPR_UINT,
@@ -1883,6 +1890,7 @@ EAPI Eina_Bool eolian_type_is_ptr(const Eolian_Type *tp);
1883 * @brief Get the full C type name of the given type. 1890 * @brief Get the full C type name of the given type.
1884 * 1891 *
1885 * @param[in] tp the type. 1892 * @param[in] tp the type.
1893 * @param[in] ctype the context within which the C type string will be used.
1886 * @return The C type name assuming @c tp is not NULL. 1894 * @return The C type name assuming @c tp is not NULL.
1887 * 1895 *
1888 * You're responsible for the stringshare. 1896 * You're responsible for the stringshare.
@@ -1891,7 +1899,7 @@ EAPI Eina_Bool eolian_type_is_ptr(const Eolian_Type *tp);
1891 * 1899 *
1892 * @ingroup Eolian 1900 * @ingroup Eolian
1893 */ 1901 */
1894EAPI Eina_Stringshare *eolian_type_c_type_get(const Eolian_Type *tp); 1902EAPI Eina_Stringshare *eolian_type_c_type_get(const Eolian_Type *tp, Eolian_C_Type_Type ctype);
1895 1903
1896/* 1904/*
1897 * @brief Get the name of the given type. For regular or complex types, this 1905 * @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)
355} 355}
356 356
357EAPI Eina_Stringshare * 357EAPI Eina_Stringshare *
358eolian_type_c_type_get(const Eolian_Type *tp) 358eolian_type_c_type_get(const Eolian_Type *tp, Eolian_C_Type_Type ctype EINA_UNUSED)
359{ 359{
360 Eina_Stringshare *ret; 360 Eina_Stringshare *ret;
361 Eina_Strbuf *buf; 361 Eina_Strbuf *buf;