eolian_gen: use new is_move APIs to check ownership transfers

This commit is contained in:
Daniel Kolesa 2019-09-02 15:05:34 +02:00
parent 595a0c0b2f
commit 2377a2c667
2 changed files with 9 additions and 6 deletions

View File

@ -35,7 +35,7 @@ _gen_param(Eina_Strbuf *buf, Eolian_Function_Parameter *pr,
eina_strbuf_append(buf, _get_add_star(ftype, eolian_parameter_direction_get(pr))); eina_strbuf_append(buf, _get_add_star(ftype, eolian_parameter_direction_get(pr)));
eina_strbuf_append(buf, prn); eina_strbuf_append(buf, prn);
eina_stringshare_del(prtn); eina_stringshare_del(prtn);
if (eolian_type_is_owned(eolian_parameter_type_get(pr))) if (eolian_parameter_is_move(pr))
eina_strbuf_append(buf, " EFL_TRANSFER_OWNERSHIP"); eina_strbuf_append(buf, " EFL_TRANSFER_OWNERSHIP");
*rpid = 0; *rpid = 0;
return 1; return 1;
@ -82,13 +82,16 @@ _gen_func(const Eolian_State *state, const Eolian_Function *fid,
Eina_Bool var_as_ret = EINA_FALSE; Eina_Bool var_as_ret = EINA_FALSE;
const Eolian_Type *rtp = eolian_function_return_type_get(fid, ftype); const Eolian_Type *rtp = eolian_function_return_type_get(fid, ftype);
Eina_Bool return_move = eolian_function_return_is_move(fid, ftype);
if (ftype == EOLIAN_PROP_GET && !rtp) if (ftype == EOLIAN_PROP_GET && !rtp)
{ {
void *d1, *d2; void *d1, *d2;
Eina_Iterator *itr = eolian_property_values_get(fid, ftype); Eina_Iterator *itr = eolian_property_values_get(fid, ftype);
if (eina_iterator_next(itr, &d1) && !eina_iterator_next(itr, &d2)) if (eina_iterator_next(itr, &d1) && !eina_iterator_next(itr, &d2))
{ {
rtp = eolian_parameter_type_get((Eolian_Function_Parameter *)d1); Eolian_Function_Parameter *pr = (Eolian_Function_Parameter *)d1;
rtp = eolian_parameter_type_get(pr);
return_move = eolian_parameter_is_move(pr);
var_as_ret = EINA_TRUE; var_as_ret = EINA_TRUE;
} }
eina_iterator_free(itr); eina_iterator_free(itr);
@ -168,7 +171,7 @@ _gen_func(const Eolian_State *state, const Eolian_Function *fid,
flagbuf = eina_strbuf_new(); flagbuf = eina_strbuf_new();
eina_strbuf_prepend(flagbuf, " EINA_WARN_UNUSED_RESULT"); eina_strbuf_prepend(flagbuf, " EINA_WARN_UNUSED_RESULT");
} }
if (rtp && eolian_type_is_owned(rtp)) if (return_move)
eina_strbuf_append(buf, " EFL_TRANSFER_OWNERSHIP"); eina_strbuf_append(buf, " EFL_TRANSFER_OWNERSHIP");
if (flagbuf) if (flagbuf)
{ {

View File

@ -314,7 +314,7 @@ _gen_function_param_fallback(Eina_Iterator *itr, Eina_Strbuf *fallback_free_owne
inner_type = eolian_type_base_type_get(type); inner_type = eolian_type_base_type_get(type);
//check if they should be freed or just ignored //check if they should be freed or just ignored
if (!eolian_type_is_owned(type) || eolian_parameter_direction_get(pr) == EOLIAN_OUT_PARAM) if (!eolian_parameter_is_move(pr) || eolian_parameter_direction_get(pr) == EOLIAN_OUT_PARAM)
{ {
eina_strbuf_append_printf(fallback_free_ownership, " (void)%s;\n", eolian_parameter_name_get(pr)); eina_strbuf_append_printf(fallback_free_ownership, " (void)%s;\n", eolian_parameter_name_get(pr));
continue; continue;
@ -329,11 +329,11 @@ _gen_function_param_fallback(Eina_Iterator *itr, Eina_Strbuf *fallback_free_owne
eina_strbuf_append(param_call, eolian_parameter_name_get(pr)); eina_strbuf_append(param_call, eolian_parameter_name_get(pr));
//check if we might want to free or handle the children //check if we might want to free or handle the children
if (!inner_type || !eolian_type_is_owned(inner_type)) if (!inner_type || !eolian_type_is_move(inner_type))
{ {
_generate_normal_free(&fallback_free_ownership, type, param_call, ""); _generate_normal_free(&fallback_free_ownership, type, param_call, "");
} }
else if (inner_type && eolian_type_is_owned(inner_type)) else if (inner_type && eolian_type_is_move(inner_type))
{ {
_generate_iterative_free(&fallback_free_ownership, type, inner_type, pr, param_call); _generate_iterative_free(&fallback_free_ownership, type, inner_type, pr, param_call);
} }