summaryrefslogtreecommitdiff
path: root/src/bin/eolian
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-01-15 18:13:43 +0100
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-01-16 14:40:13 +0100
commit5a11fd858768be6243d06b51dea837aa0b9f66e7 (patch)
tree071183c2fef628db908dd993af11988bc795d0fe /src/bin/eolian
parent2b1285c9db454a4f389daf3eda8eb672c7d5ab5e (diff)
eolian_gen: void out keys depending on how they are setted
this avoid warings about keys not beeing used in the fallback function. Reviewed-by: Daniel Kolesa <daniel@octaforge.org> Differential Revision: https://phab.enlightenment.org/D7630
Diffstat (limited to 'src/bin/eolian')
-rw-r--r--src/bin/eolian/sources.c87
1 files changed, 52 insertions, 35 deletions
diff --git a/src/bin/eolian/sources.c b/src/bin/eolian/sources.c
index 900b702..d80ca74 100644
--- a/src/bin/eolian/sources.c
+++ b/src/bin/eolian/sources.c
@@ -267,6 +267,50 @@ _generate_iterative_free(Eina_Strbuf **buf, const Eolian_Type *type, const Eolia
267 eina_strbuf_free(iter_param); 267 eina_strbuf_free(iter_param);
268} 268}
269 269
270static int
271_gen_function_param_fallback(Eina_Iterator *itr, Eina_Strbuf *fallback_free_ownership, Eina_Strbuf *param_call)
272{
273 Eolian_Function_Parameter *pr;
274 int owners = 0;
275
276 EINA_ITERATOR_FOREACH(itr, pr)
277 {
278 const Eolian_Type *type, *inner_type;
279
280 type = eolian_parameter_type_get(pr);
281 inner_type = eolian_type_base_type_get(type);
282
283 //check if they should be freed or just ignored
284 if (!eolian_type_is_owned(type) || eolian_parameter_direction_get(pr) == EOLIAN_OUT_PARAM)
285 {
286 eina_strbuf_append_printf(fallback_free_ownership, " (void)%s;\n", eolian_parameter_name_get(pr));
287 continue;
288 }
289
290 owners ++;
291
292 eina_strbuf_reset(param_call);
293
294 if (eolian_parameter_direction_get(pr) == EOLIAN_INOUT_PARAM)
295 eina_strbuf_append_char(param_call, '*');
296 eina_strbuf_append(param_call, eolian_parameter_name_get(pr));
297
298 //check if we might want to free or handle the children
299 if (!inner_type || !eolian_type_is_owned(inner_type))
300 {
301 _generate_normal_free(&fallback_free_ownership, type, param_call, "");
302 }
303 else if (inner_type && eolian_type_is_owned(inner_type))
304 {
305 _generate_iterative_free(&fallback_free_ownership, type, inner_type, pr, param_call);
306 }
307 }
308 eina_iterator_free(itr);
309
310 return owners;
311}
312
313
270static void 314static void
271_gen_func(const Eolian_Class *cl, const Eolian_Function *fid, 315_gen_func(const Eolian_Class *cl, const Eolian_Function *fid,
272 Eolian_Function_Type ftype, Eina_Strbuf *buf, 316 Eolian_Function_Type ftype, Eina_Strbuf *buf,
@@ -356,50 +400,23 @@ _gen_func(const Eolian_Class *cl, const Eolian_Function *fid,
356 else 400 else
357 { 401 {
358 Eina_Iterator *itr; 402 Eina_Iterator *itr;
359 Eolian_Function_Parameter *pr;
360 int owners = 0; 403 int owners = 0;
361 Eina_Strbuf *param_call; 404 Eina_Strbuf *param_call;
362 405
363 param_call = eina_strbuf_new(); 406 param_call = eina_strbuf_new();
364 407
365 if (is_prop) 408 if (is_prop)
366 itr = eolian_property_values_get(fid, ftype); 409 {
410 itr = eolian_property_values_get(fid, ftype);
411 owners += _gen_function_param_fallback(itr, fallback_free_ownership, param_call);
412 itr = eolian_property_keys_get(fid, ftype);
413 owners += _gen_function_param_fallback(itr, fallback_free_ownership, param_call);
414 }
367 else 415 else
368 itr = eolian_function_parameters_get(fid);
369
370 EINA_ITERATOR_FOREACH(itr, pr)
371 { 416 {
372 const Eolian_Type *type, *inner_type; 417 itr = eolian_function_parameters_get(fid);
373 418 owners += _gen_function_param_fallback(itr, fallback_free_ownership, param_call);
374 type = eolian_parameter_type_get(pr);
375 inner_type = eolian_type_base_type_get(type);
376
377 //check if they should be freed or just ignored
378 if (!eolian_type_is_owned(type) || eolian_parameter_direction_get(pr) == EOLIAN_OUT_PARAM)
379 {
380 eina_strbuf_append_printf(fallback_free_ownership, " (void)%s;\n", eolian_parameter_name_get(pr));
381 continue;
382 }
383
384 owners ++;
385
386 eina_strbuf_reset(param_call);
387
388 if (eolian_parameter_direction_get(pr) == EOLIAN_INOUT_PARAM)
389 eina_strbuf_append_char(param_call, '*');
390 eina_strbuf_append(param_call, eolian_parameter_name_get(pr));
391
392 //check if we might want to free or handle the children
393 if (!inner_type || !eolian_type_is_owned(inner_type))
394 {
395 _generate_normal_free(&fallback_free_ownership, type, param_call, "");
396 }
397 else if (inner_type && eolian_type_is_owned(inner_type))
398 {
399 _generate_iterative_free(&fallback_free_ownership, type, inner_type, pr, param_call);
400 }
401 } 419 }
402 eina_iterator_free(itr);
403 420
404 if (owners == 0) 421 if (owners == 0)
405 { 422 {