summaryrefslogtreecommitdiff
path: root/src/bin/eolian
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2019-07-03 14:45:02 +0200
committerDaniel Kolesa <d.kolesa@samsung.com>2019-07-08 16:06:42 +0200
commit38223ed693b8ab1f48d6fc0180056bbe3f608a32 (patch)
tree0b7fdef127d20c0d757ecc1ca547efc82f7def4b /src/bin/eolian
parent9c249d0467aa4a174dffe2a8292fb66c6c5f4228 (diff)
eolian_gen: remove reliance on builtin freefuncs
Diffstat (limited to 'src/bin/eolian')
-rw-r--r--src/bin/eolian/sources.c44
1 files changed, 42 insertions, 2 deletions
diff --git a/src/bin/eolian/sources.c b/src/bin/eolian/sources.c
index d729b63..d060eed 100644
--- a/src/bin/eolian/sources.c
+++ b/src/bin/eolian/sources.c
@@ -150,10 +150,50 @@ _append_defval(Eina_Strbuf *buf, const Eolian_Expression *exp, const Eolian_Type
150 eina_strbuf_append(buf, "0"); 150 eina_strbuf_append(buf, "0");
151} 151}
152 152
153static const char *
154_free_func_get(const Eolian_Type *type)
155{
156 const Eolian_Type *ab = eolian_type_aliased_base_get(type);
157 switch (eolian_type_builtin_type_get(ab))
158 {
159 /* simple types */
160 case EOLIAN_TYPE_BUILTIN_MSTRING:
161 return "free";
162 case EOLIAN_TYPE_BUILTIN_STRINGSHARE:
163 return "eina_stringshare_del";
164 case EOLIAN_TYPE_BUILTIN_ANY_VALUE:
165 return "eina_value_flush";
166 case EOLIAN_TYPE_BUILTIN_ANY_VALUE_PTR:
167 return "eina_value_free";
168 /* complex types */
169 case EOLIAN_TYPE_BUILTIN_ACCESSOR:
170 return "eina_accessor_free";
171 case EOLIAN_TYPE_BUILTIN_ARRAY:
172 return "eina_array_free";
173 case EOLIAN_TYPE_BUILTIN_FUTURE:
174 return "(void)";
175 case EOLIAN_TYPE_BUILTIN_ITERATOR:
176 return "eina_iterator_free";
177 case EOLIAN_TYPE_BUILTIN_HASH:
178 return "eina_hash_free";
179 case EOLIAN_TYPE_BUILTIN_LIST:
180 return "eina_list_free";
181 /* class and user types */
182 case EOLIAN_TYPE_BUILTIN_INVALID:
183 if (eolian_type_type_get(ab) == EOLIAN_TYPE_CLASS)
184 return "efl_del";
185 else
186 return eolian_type_free_func_get(ab);
187 /* no free func */
188 default:
189 return NULL;
190 }
191}
192
153static void 193static void
154_generate_normal_free(Eina_Strbuf **buf, const Eolian_Type *type, const Eina_Strbuf *parameter, const char *additional_intention) 194_generate_normal_free(Eina_Strbuf **buf, const Eolian_Type *type, const Eina_Strbuf *parameter, const char *additional_intention)
155{ 195{
156 const char *free_func = eolian_type_free_func_get(type); 196 const char *free_func = _free_func_get(type);
157 if (!free_func) 197 if (!free_func)
158 { 198 {
159 printf("No free type %s\n", eolian_type_short_name_get(type)); 199 printf("No free type %s\n", eolian_type_short_name_get(type));
@@ -230,7 +270,7 @@ _generate_iterative_free(Eina_Strbuf **buf, const Eolian_Type *type, const Eolia
230 { 270 {
231 eina_strbuf_append_printf(*buf," eina_hash_free_cb_set("); 271 eina_strbuf_append_printf(*buf," eina_hash_free_cb_set(");
232 eina_strbuf_append_buffer(*buf, param); 272 eina_strbuf_append_buffer(*buf, param);
233 eina_strbuf_append_printf(*buf, ",%s);\n",eolian_type_free_func_get(inner_type)); 273 eina_strbuf_append_printf(*buf, ",%s);\n",_free_func_get(inner_type));
234 eina_strbuf_append_printf(*buf," eina_hash_free("); 274 eina_strbuf_append_printf(*buf," eina_hash_free(");
235 eina_strbuf_append_buffer(*buf, param); 275 eina_strbuf_append_buffer(*buf, param);
236 eina_strbuf_append(*buf, ");\n"); 276 eina_strbuf_append(*buf, ");\n");