summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2018-01-16 16:36:45 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2018-01-16 16:39:05 +0100
commitd47610a7323dd357e57f26ca83014c7b39dd48e9 (patch)
treec218e79bd8519a7a567c68dd3386a2cffa94e340 /src/lib
parentdd2e579fecbe6ec4d1e0e7d46c82daff39be03c5 (diff)
eolian: do not require unit when stringifying types
As it is no longer necessary to pass unit when evaluating exprs, it is not necessary to pass it here either. Convert all the APIs to the new style and update all instances in our tree.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/eolian/Eolian.h6
-rw-r--r--src/lib/eolian/database_type.c28
-rw-r--r--src/lib/eolian/database_type_api.c9
-rw-r--r--src/lib/eolian/eolian_database.h4
-rw-r--r--src/lib/eolian_cxx/grammar/klass_def.hpp2
5 files changed, 21 insertions, 28 deletions
diff --git a/src/lib/eolian/Eolian.h b/src/lib/eolian/Eolian.h
index 9c6f2de9fe..2688dd71a8 100644
--- a/src/lib/eolian/Eolian.h
+++ b/src/lib/eolian/Eolian.h
@@ -1827,7 +1827,6 @@ EAPI Eina_Bool eolian_typedecl_is_extern(const Eolian_Typedecl *tp);
1827/* 1827/*
1828 * @brief Get the full C type name of the given type. 1828 * @brief Get the full C type name of the given type.
1829 * 1829 *
1830 * @param[in] unit the unit to look in
1831 * @param[in] tp the type declaration. 1830 * @param[in] tp the type declaration.
1832 * @return The C type name assuming @c tp is not NULL. 1831 * @return The C type name assuming @c tp is not NULL.
1833 * 1832 *
@@ -1837,7 +1836,7 @@ EAPI Eina_Bool eolian_typedecl_is_extern(const Eolian_Typedecl *tp);
1837 * 1836 *
1838 * @ingroup Eolian 1837 * @ingroup Eolian
1839 */ 1838 */
1840EAPI Eina_Stringshare *eolian_typedecl_c_type_get(const Eolian_Unit *unit, const Eolian_Typedecl *tp); 1839EAPI Eina_Stringshare *eolian_typedecl_c_type_get(const Eolian_Typedecl *tp);
1841 1840
1842/* 1841/*
1843 * @brief Get the name of the given type declaration. Keep in mind that the 1842 * @brief Get the name of the given type declaration. Keep in mind that the
@@ -2024,7 +2023,6 @@ EAPI Eina_Bool eolian_type_is_ptr(const Eolian_Type *tp);
2024/* 2023/*
2025 * @brief Get the full C type name of the given type. 2024 * @brief Get the full C type name of the given type.
2026 * 2025 *
2027 * @param[in] unit the unit to look in
2028 * @param[in] tp the type. 2026 * @param[in] tp the type.
2029 * @param[in] ctype the context within which the C type string will be used. 2027 * @param[in] ctype the context within which the C type string will be used.
2030 * @return The C type name assuming @c tp is not NULL. 2028 * @return The C type name assuming @c tp is not NULL.
@@ -2035,7 +2033,7 @@ EAPI Eina_Bool eolian_type_is_ptr(const Eolian_Type *tp);
2035 * 2033 *
2036 * @ingroup Eolian 2034 * @ingroup Eolian
2037 */ 2035 */
2038EAPI Eina_Stringshare *eolian_type_c_type_get(const Eolian_Unit *unit, const Eolian_Type *tp, Eolian_C_Type_Type ctype); 2036EAPI Eina_Stringshare *eolian_type_c_type_get(const Eolian_Type *tp, Eolian_C_Type_Type ctype);
2039 2037
2040/* 2038/*
2041 * @brief Get the name of the given type. For regular types, this is for 2039 * @brief Get the name of the given type. For regular types, this is for
diff --git a/src/lib/eolian/database_type.c b/src/lib/eolian/database_type.c
index 17651e6b39..178b8f8e05 100644
--- a/src/lib/eolian/database_type.c
+++ b/src/lib/eolian/database_type.c
@@ -103,7 +103,7 @@ _buf_add_suffix(Eina_Strbuf *buf, const char *suffix)
103} 103}
104 104
105void 105void
106database_type_to_str(const Eolian_Unit *src, const Eolian_Type *tp, 106database_type_to_str(const Eolian_Type *tp,
107 Eina_Strbuf *buf, const char *name, 107 Eina_Strbuf *buf, const char *name,
108 Eolian_C_Type_Type ctype) 108 Eolian_C_Type_Type ctype)
109{ 109{
@@ -111,7 +111,7 @@ database_type_to_str(const Eolian_Unit *src, const Eolian_Type *tp,
111 || tp->type == EOLIAN_TYPE_CLASS 111 || tp->type == EOLIAN_TYPE_CLASS
112 || tp->type == EOLIAN_TYPE_VOID) 112 || tp->type == EOLIAN_TYPE_VOID)
113 && tp->is_const 113 && tp->is_const
114 && ((ctype != EOLIAN_C_TYPE_RETURN) || database_type_is_ownable(src, tp))) 114 && ((ctype != EOLIAN_C_TYPE_RETURN) || database_type_is_ownable(NULL, tp)))
115 { 115 {
116 eina_strbuf_append(buf, "const "); 116 eina_strbuf_append(buf, "const ");
117 } 117 }
@@ -138,7 +138,7 @@ database_type_to_str(const Eolian_Unit *src, const Eolian_Type *tp,
138 else 138 else
139 { 139 {
140 /* handles arrays and pointers as they all serialize to pointers */ 140 /* handles arrays and pointers as they all serialize to pointers */
141 database_type_to_str(src, tp->base_type, buf, NULL, 141 database_type_to_str(tp->base_type, buf, NULL,
142 EOLIAN_C_TYPE_DEFAULT); 142 EOLIAN_C_TYPE_DEFAULT);
143 _buf_add_suffix(buf, "*"); 143 _buf_add_suffix(buf, "*");
144 if (tp->is_const && (ctype != EOLIAN_C_TYPE_RETURN)) 144 if (tp->is_const && (ctype != EOLIAN_C_TYPE_RETURN))
@@ -152,8 +152,7 @@ database_type_to_str(const Eolian_Unit *src, const Eolian_Type *tp,
152} 152}
153 153
154static void 154static void
155_stype_to_str(const Eolian_Unit *src, const Eolian_Typedecl *tp, 155_stype_to_str(const Eolian_Typedecl *tp, Eina_Strbuf *buf)
156 Eina_Strbuf *buf)
157{ 156{
158 Eolian_Struct_Type_Field *sf; 157 Eolian_Struct_Type_Field *sf;
159 Eina_List *l; 158 Eina_List *l;
@@ -170,7 +169,7 @@ _stype_to_str(const Eolian_Unit *src, const Eolian_Typedecl *tp,
170 eina_strbuf_append(buf, " { "); 169 eina_strbuf_append(buf, " { ");
171 EINA_LIST_FOREACH(tp->field_list, l, sf) 170 EINA_LIST_FOREACH(tp->field_list, l, sf)
172 { 171 {
173 database_type_to_str(src, sf->type, buf, sf->name, 172 database_type_to_str(sf->type, buf, sf->name,
174 EOLIAN_C_TYPE_DEFAULT); 173 EOLIAN_C_TYPE_DEFAULT);
175 eina_strbuf_append(buf, "; "); 174 eina_strbuf_append(buf, "; ");
176 } 175 }
@@ -178,8 +177,7 @@ _stype_to_str(const Eolian_Unit *src, const Eolian_Typedecl *tp,
178} 177}
179 178
180static void 179static void
181_etype_to_str(const Eolian_Unit *src, const Eolian_Typedecl *tp, 180_etype_to_str(const Eolian_Typedecl *tp, Eina_Strbuf *buf)
182 Eina_Strbuf *buf)
183{ 181{
184 Eolian_Enum_Type_Field *ef; 182 Eolian_Enum_Type_Field *ef;
185 Eina_List *l; 183 Eina_List *l;
@@ -226,8 +224,7 @@ _append_name(const Eolian_Typedecl *tp, Eina_Strbuf *buf)
226} 224}
227 225
228static void 226static void
229_atype_to_str(const Eolian_Unit *src, const Eolian_Typedecl *tp, 227_atype_to_str(const Eolian_Typedecl *tp, Eina_Strbuf *buf)
230 Eina_Strbuf *buf)
231{ 228{
232 eina_strbuf_append(buf, "typedef "); 229 eina_strbuf_append(buf, "typedef ");
233 230
@@ -244,26 +241,25 @@ _atype_to_str(const Eolian_Unit *src, const Eolian_Typedecl *tp,
244 241
245 Eina_Strbuf *fulln = eina_strbuf_new(); 242 Eina_Strbuf *fulln = eina_strbuf_new();
246 _append_name(tp, fulln); 243 _append_name(tp, fulln);
247 database_type_to_str(src, tp->base_type, buf, eina_strbuf_string_get(fulln), 244 database_type_to_str(tp->base_type, buf, eina_strbuf_string_get(fulln),
248 EOLIAN_C_TYPE_DEFAULT); 245 EOLIAN_C_TYPE_DEFAULT);
249 eina_strbuf_free(fulln); 246 eina_strbuf_free(fulln);
250} 247}
251 248
252void 249void
253database_typedecl_to_str(const Eolian_Unit *src, const Eolian_Typedecl *tp, 250database_typedecl_to_str(const Eolian_Typedecl *tp, Eina_Strbuf *buf)
254 Eina_Strbuf *buf)
255{ 251{
256 switch (tp->type) 252 switch (tp->type)
257 { 253 {
258 case EOLIAN_TYPEDECL_ALIAS: 254 case EOLIAN_TYPEDECL_ALIAS:
259 _atype_to_str(src, tp, buf); 255 _atype_to_str(tp, buf);
260 break; 256 break;
261 case EOLIAN_TYPEDECL_ENUM: 257 case EOLIAN_TYPEDECL_ENUM:
262 _etype_to_str(src, tp, buf); 258 _etype_to_str(tp, buf);
263 break; 259 break;
264 case EOLIAN_TYPEDECL_STRUCT: 260 case EOLIAN_TYPEDECL_STRUCT:
265 case EOLIAN_TYPEDECL_STRUCT_OPAQUE: 261 case EOLIAN_TYPEDECL_STRUCT_OPAQUE:
266 _stype_to_str(src, tp, buf); 262 _stype_to_str(tp, buf);
267 break; 263 break;
268 default: 264 default:
269 break; 265 break;
diff --git a/src/lib/eolian/database_type_api.c b/src/lib/eolian/database_type_api.c
index cb128910c7..510cae835d 100644
--- a/src/lib/eolian/database_type_api.c
+++ b/src/lib/eolian/database_type_api.c
@@ -338,27 +338,26 @@ eolian_typedecl_is_extern(const Eolian_Typedecl *tp)
338} 338}
339 339
340EAPI Eina_Stringshare * 340EAPI Eina_Stringshare *
341eolian_type_c_type_get(const Eolian_Unit *unit, const Eolian_Type *tp, 341eolian_type_c_type_get(const Eolian_Type *tp, Eolian_C_Type_Type ctype)
342 Eolian_C_Type_Type ctype)
343{ 342{
344 Eina_Stringshare *ret; 343 Eina_Stringshare *ret;
345 Eina_Strbuf *buf; 344 Eina_Strbuf *buf;
346 EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL); 345 EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
347 buf = eina_strbuf_new(); 346 buf = eina_strbuf_new();
348 database_type_to_str(unit, tp, buf, NULL, ctype); 347 database_type_to_str(tp, buf, NULL, ctype);
349 ret = eina_stringshare_add(eina_strbuf_string_get(buf)); 348 ret = eina_stringshare_add(eina_strbuf_string_get(buf));
350 eina_strbuf_free(buf); 349 eina_strbuf_free(buf);
351 return ret; 350 return ret;
352} 351}
353 352
354EAPI Eina_Stringshare * 353EAPI Eina_Stringshare *
355eolian_typedecl_c_type_get(const Eolian_Unit *unit, const Eolian_Typedecl *tp) 354eolian_typedecl_c_type_get(const Eolian_Typedecl *tp)
356{ 355{
357 Eina_Stringshare *ret; 356 Eina_Stringshare *ret;
358 Eina_Strbuf *buf; 357 Eina_Strbuf *buf;
359 EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL); 358 EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL);
360 buf = eina_strbuf_new(); 359 buf = eina_strbuf_new();
361 database_typedecl_to_str(unit, tp, buf); 360 database_typedecl_to_str(tp, buf);
362 ret = eina_stringshare_add(eina_strbuf_string_get(buf)); 361 ret = eina_stringshare_add(eina_strbuf_string_get(buf));
363 eina_strbuf_free(buf); 362 eina_strbuf_free(buf);
364 return ret; 363 return ret;
diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h
index 166511a264..d6393a9462 100644
--- a/src/lib/eolian/eolian_database.h
+++ b/src/lib/eolian/eolian_database.h
@@ -341,8 +341,8 @@ void database_enum_add(Eolian *state, Eolian_Typedecl *tp);
341void database_type_del(Eolian_Type *tp); 341void database_type_del(Eolian_Type *tp);
342void database_typedecl_del(Eolian_Typedecl *tp); 342void database_typedecl_del(Eolian_Typedecl *tp);
343 343
344void database_type_to_str(const Eolian_Unit *src, const Eolian_Type *tp, Eina_Strbuf *buf, const char *name, Eolian_C_Type_Type ctype); 344void database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name, Eolian_C_Type_Type ctype);
345void database_typedecl_to_str(const Eolian_Unit *src, const Eolian_Typedecl *tp, Eina_Strbuf *buf); 345void database_typedecl_to_str(const Eolian_Typedecl *tp, Eina_Strbuf *buf);
346 346
347Eolian_Typedecl *database_type_decl_find(const Eolian_Unit *src, const Eolian_Type *tp); 347Eolian_Typedecl *database_type_decl_find(const Eolian_Unit *src, const Eolian_Type *tp);
348 348
diff --git a/src/lib/eolian_cxx/grammar/klass_def.hpp b/src/lib/eolian_cxx/grammar/klass_def.hpp
index c59b39af73..ee9fccbf39 100644
--- a/src/lib/eolian_cxx/grammar/klass_def.hpp
+++ b/src/lib/eolian_cxx/grammar/klass_def.hpp
@@ -339,7 +339,7 @@ type_def const void_ {attributes::regular_type_def{"void", {qualifier_info::is_n
339 339
340inline void type_def::set(Eolian_Type const* eolian_type, Eolian_Unit const* unit, Eolian_C_Type_Type ctype) 340inline void type_def::set(Eolian_Type const* eolian_type, Eolian_Unit const* unit, Eolian_C_Type_Type ctype)
341{ 341{
342 c_type = ::eolian_type_c_type_get(unit, eolian_type, ctype); 342 c_type = ::eolian_type_c_type_get(eolian_type, ctype);
343 // ::eina_stringshare_del(stringshare); // this crashes 343 // ::eina_stringshare_del(stringshare); // this crashes
344 Eolian_Type const* stp = eolian_type_base_type_get(eolian_type); 344 Eolian_Type const* stp = eolian_type_base_type_get(eolian_type);
345 has_own = !!::eolian_type_is_owned(eolian_type); 345 has_own = !!::eolian_type_is_owned(eolian_type);