jackdanielz pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=d96c42917910ae12ca46a87b5e6c538502aa4a0d
commit d96c42917910ae12ca46a87b5e6c538502aa4a0d Author: Daniel Zaoui <[email protected]> Date: Mon Mar 10 13:19:24 2014 +0200 Eolian/Generator: support NULL pointers for return values. When an Eo operation returns a value, this one is stored in the last parameter as an out parameter. In case the caller doesn't set a pointer there, the storing will be done in a NULL pointer and will bring to a segfault. The generator has been modified to handle this case. Now, if the ret pointer is NULL, the value will not be returned. --- src/bin/eolian/eo1_generator.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/bin/eolian/eo1_generator.c b/src/bin/eolian/eo1_generator.c index f0075b6..3853a72 100644 --- a/src/bin/eolian/eo1_generator.c +++ b/src/bin/eolian/eo1_generator.c @@ -117,6 +117,7 @@ _eo_obj_@#class_@#func(Eo *obj, void *_pd, va_list *list@#list_unused)\n\ {\n\ @#list_vars\ @#ret_param_@#class_@#func(obj, _pd@#list_params);\n\ +@#return_ret\ }\n\ "; @@ -428,16 +429,19 @@ eo1_bind_func_generate(const char *classname, Eolian_Function funcid, Eolian_Fun ret_const?"const ":"", rettype, had_star?"":" "); Eina_Strbuf *ret_param = eina_strbuf_new(); - eina_strbuf_append_printf(ret_param, "*%s = ", retname); + if (rettype) eina_strbuf_append_printf(ret_param, "%s _%s = ", rettype, retname); eina_strbuf_replace_all(fbody, "@#ret_param", eina_strbuf_string_get(ret_param)); sprintf(tmpstr, "%s%s", ret_const?"const ":"", rettype); eina_strbuf_replace_all(fbody, "@#ret_type", tmpstr); + sprintf(tmpstr, " if (%s) *%s = _%s;\n", retname, retname, retname); + eina_strbuf_replace_all(fbody, "@#return_ret", tmpstr); eina_strbuf_free(ret_param); } else { eina_strbuf_replace_all(fbody, "@#ret_param", ""); eina_strbuf_replace_all(fbody, "@#ret_type", "void"); + eina_strbuf_replace_all(fbody, "@#return_ret", ""); } if (eina_list_count(eolian_parameters_list_get(funcid)) == 0 && --
