summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2019-01-29 18:04:05 +0100
committerDaniel Kolesa <d.kolesa@samsung.com>2019-02-28 01:09:02 +0100
commit70e8e86cc74efe610bda99c4bad0cee577a35272 (patch)
tree388444d4cb3e2858442e17e1dfcb8a2f6b3a4ce1
parentc2ccdec78749ceed7504eb9f1d3d4100184c1119 (diff)
eolian_gen: remove usage of freefuncs from builtins
The freefuncs for builtin containers are now generator-specific matter. Freefuncs still apply for user types.
-rw-r--r--src/bin/eolian/sources.c96
1 files changed, 81 insertions, 15 deletions
diff --git a/src/bin/eolian/sources.c b/src/bin/eolian/sources.c
index e7a461255d..c1de6b433e 100644
--- a/src/bin/eolian/sources.c
+++ b/src/bin/eolian/sources.c
@@ -151,25 +151,87 @@ _append_defval(Eina_Strbuf *buf, const Eolian_Expression *exp, const Eolian_Type
151} 151}
152 152
153static void 153static void
154_generate_normal_free(Eina_Strbuf **buf, const Eolian_Type *type, const Eina_Strbuf *parameter, const char *additional_intention) 154_write_free_call(Eina_Strbuf *buf, const char *ffunc, const Eina_Strbuf *param, const char *indent)
155{ 155{
156 const char *free_func = eolian_type_free_func_get(type); 156 eina_strbuf_append_printf(buf," %s%s(", indent, ffunc);
157 if (!free_func) 157 eina_strbuf_append_buffer(buf, param);
158 eina_strbuf_append(buf, ");\n");
159}
160
161static const char *
162_get_free_func(const Eolian_Type *type)
163{
164 if (eolian_type_class_get(type))
165 return "efl_del";
166 switch (eolian_type_builtin_type_get(type))
158 { 167 {
159 printf("No free type %s\n", eolian_type_short_name_get(type)); 168 case EOLIAN_TYPE_BUILTIN_ACCESSOR:
160 return; 169 return "eina_accessor_free";
170 case EOLIAN_TYPE_BUILTIN_ARRAY:
171 return "eina_array_free";
172 case EOLIAN_TYPE_BUILTIN_FUTURE:
173 return NULL;
174 case EOLIAN_TYPE_BUILTIN_ITERATOR:
175 return "eina_iterator_free";
176 case EOLIAN_TYPE_BUILTIN_HASH:
177 return "eina_hash_free";
178 case EOLIAN_TYPE_BUILTIN_LIST:
179 return "eina_list_free";
180 case EOLIAN_TYPE_BUILTIN_INARRAY:
181 return "eina_inarray_free";
182 case EOLIAN_TYPE_BUILTIN_INLIST:
183 return NULL;
184 case EOLIAN_TYPE_BUILTIN_ANY_VALUE:
185 return "eina_value_flush";
186 case EOLIAN_TYPE_BUILTIN_ANY_VALUE_PTR:
187 return "eina_value_free";
188 case EOLIAN_TYPE_BUILTIN_STRINGSHARE:
189 return "eina_stringshare_del";
190 default:
191 break;
161 } 192 }
193 /* mstrings and custom types */
194 return eolian_type_free_func_get(type);
195}
162 196
163 if (eolian_type_builtin_type_get(type) == EOLIAN_TYPE_BUILTIN_HASH) 197static void
198_generate_normal_free(Eina_Strbuf **buf, const Eolian_Type *type, const Eina_Strbuf *param, const char *indent)
199{
200 const Eolian_Type *btype = eolian_type_aliased_base_get(type);
201 Eolian_Type_Builtin_Type t = eolian_type_builtin_type_get(btype);
202 switch (t)
164 { 203 {
204 case EOLIAN_TYPE_BUILTIN_FUTURE:
205 _write_free_call(*buf, "(void)", param, indent); break;
206 case EOLIAN_TYPE_BUILTIN_HASH:
165 eina_strbuf_append_printf(*buf," eina_hash_free_cb_set("); 207 eina_strbuf_append_printf(*buf," eina_hash_free_cb_set(");
166 eina_strbuf_append_buffer(*buf, parameter); 208 eina_strbuf_append_buffer(*buf, param);
167 eina_strbuf_append(*buf, ",NULL);\n"); 209 eina_strbuf_append(*buf, ",NULL);\n");
210 _write_free_call(*buf, "eina_hash_free", param, indent);
211 break;
212 case EOLIAN_TYPE_BUILTIN_INLIST:
213 _write_free_call(*buf, "(void)", param, indent); break;
214 case EOLIAN_TYPE_BUILTIN_ACCESSOR:
215 case EOLIAN_TYPE_BUILTIN_ARRAY:
216 case EOLIAN_TYPE_BUILTIN_ITERATOR:
217 case EOLIAN_TYPE_BUILTIN_LIST:
218 case EOLIAN_TYPE_BUILTIN_INARRAY:
219 case EOLIAN_TYPE_BUILTIN_ANY_VALUE:
220 case EOLIAN_TYPE_BUILTIN_ANY_VALUE_PTR:
221 case EOLIAN_TYPE_BUILTIN_STRINGSHARE:
222 default:
223 {
224 const char *ffunc = _get_free_func(type);
225 if (!ffunc)
226 {
227 printf("eolian: no free function for type %s",
228 eolian_type_short_name_get(type));
229 break;
230 }
231 _write_free_call(*buf, ffunc, param, indent);
232 break;
233 }
168 } 234 }
169
170 eina_strbuf_append_printf(*buf," %s%s(", additional_intention, free_func);
171 eina_strbuf_append_buffer(*buf, parameter);
172 eina_strbuf_append(*buf, ");\n");
173} 235}
174 236
175static void 237static void
@@ -220,6 +282,7 @@ _generate_iterative_free(Eina_Strbuf **buf, const Eolian_Type *type, const Eolia
220 eina_strbuf_append_buffer(*buf, iter_param); 282 eina_strbuf_append_buffer(*buf, iter_param);
221 eina_strbuf_append(*buf, ")\n"); 283 eina_strbuf_append(*buf, ")\n");
222 _generate_loop_content(buf, inner_type, iter_param); 284 _generate_loop_content(buf, inner_type, iter_param);
285 _write_free_call(*buf, "eina_inarray_free", param, "");
223 } 286 }
224 else if (t == EOLIAN_TYPE_BUILTIN_INLIST) 287 else if (t == EOLIAN_TYPE_BUILTIN_INLIST)
225 { 288 {
@@ -238,6 +301,7 @@ _generate_iterative_free(Eina_Strbuf **buf, const Eolian_Type *type, const Eolia
238 eina_strbuf_append_buffer(*buf, iter_param); 301 eina_strbuf_append_buffer(*buf, iter_param);
239 eina_strbuf_append(*buf, ")\n"); 302 eina_strbuf_append(*buf, ")\n");
240 _generate_loop_content(buf, inner_type, iter_param); 303 _generate_loop_content(buf, inner_type, iter_param);
304 _write_free_call(*buf, "eina_iterator_free", param, "");
241 } 305 }
242 else if (t == EOLIAN_TYPE_BUILTIN_ACCESSOR) 306 else if (t == EOLIAN_TYPE_BUILTIN_ACCESSOR)
243 { 307 {
@@ -248,12 +312,13 @@ _generate_iterative_free(Eina_Strbuf **buf, const Eolian_Type *type, const Eolia
248 eina_strbuf_append_buffer(*buf, iter_param); 312 eina_strbuf_append_buffer(*buf, iter_param);
249 eina_strbuf_append(*buf, ")\n"); 313 eina_strbuf_append(*buf, ")\n");
250 _generate_loop_content(buf, inner_type, iter_param); 314 _generate_loop_content(buf, inner_type, iter_param);
315 _write_free_call(*buf, "eina_accessor_free", param, "");
251 } 316 }
252 else if (t == EOLIAN_TYPE_BUILTIN_HASH) 317 else if (t == EOLIAN_TYPE_BUILTIN_HASH)
253 { 318 {
254 eina_strbuf_append_printf(*buf," eina_hash_free_cb_set("); 319 eina_strbuf_append_printf(*buf," eina_hash_free_cb_set(");
255 eina_strbuf_append_buffer(*buf, param); 320 eina_strbuf_append_buffer(*buf, param);
256 eina_strbuf_append_printf(*buf, ",%s);\n",eolian_type_free_func_get(inner_type)); 321 eina_strbuf_append_printf(*buf, ",%s);\n",_get_free_func(type));
257 eina_strbuf_append_printf(*buf," eina_hash_free("); 322 eina_strbuf_append_printf(*buf," eina_hash_free(");
258 eina_strbuf_append_buffer(*buf, param); 323 eina_strbuf_append_buffer(*buf, param);
259 eina_strbuf_append(*buf, ");\n"); 324 eina_strbuf_append(*buf, ");\n");
@@ -290,7 +355,8 @@ _gen_function_param_fallback(Eina_Iterator *itr, Eina_Strbuf *fallback_free_owne
290 const Eolian_Type *type, *inner_type; 355 const Eolian_Type *type, *inner_type;
291 356
292 type = eolian_parameter_type_get(pr); 357 type = eolian_parameter_type_get(pr);
293 inner_type = eolian_type_base_type_get(type); 358 const Eolian_Type *btype = eolian_type_aliased_base_get(type);
359 inner_type = eolian_type_base_type_get(btype);
294 360
295 //check if they should be freed or just ignored 361 //check if they should be freed or just ignored
296 if (!eolian_type_is_owned(type) || eolian_parameter_direction_get(pr) == EOLIAN_OUT_PARAM) 362 if (!eolian_type_is_owned(type) || eolian_parameter_direction_get(pr) == EOLIAN_OUT_PARAM)
@@ -310,11 +376,11 @@ _gen_function_param_fallback(Eina_Iterator *itr, Eina_Strbuf *fallback_free_owne
310 //check if we might want to free or handle the children 376 //check if we might want to free or handle the children
311 if (!inner_type || !eolian_type_is_owned(inner_type)) 377 if (!inner_type || !eolian_type_is_owned(inner_type))
312 { 378 {
313 _generate_normal_free(&fallback_free_ownership, type, param_call, ""); 379 _generate_normal_free(&fallback_free_ownership, btype, param_call, "");
314 } 380 }
315 else if (inner_type && eolian_type_is_owned(inner_type)) 381 else if (inner_type && eolian_type_is_owned(inner_type))
316 { 382 {
317 _generate_iterative_free(&fallback_free_ownership, type, inner_type, pr, param_call); 383 _generate_iterative_free(&fallback_free_ownership, btype, inner_type, pr, param_call);
318 } 384 }
319 } 385 }
320 eina_iterator_free(itr); 386 eina_iterator_free(itr);