diff options
author | Daniel Zaoui <daniel.zaoui@samsung.com> | 2014-03-10 13:19:24 +0200 |
---|---|---|
committer | Daniel Zaoui <daniel.zaoui@samsung.com> | 2014-03-10 15:07:05 +0200 |
commit | d96c42917910ae12ca46a87b5e6c538502aa4a0d (patch) | |
tree | 897440320114dfad4dcc6b83315ab89c20392c17 /src/bin/eolian/eo1_generator.c | |
parent | 4e33fd16e2e819eb8d0db828b66cf5a0889b2581 (diff) |
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.
Diffstat (limited to 'src/bin/eolian/eo1_generator.c')
-rw-r--r-- | src/bin/eolian/eo1_generator.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/bin/eolian/eo1_generator.c b/src/bin/eolian/eo1_generator.c index f0075b615d..3853a7219c 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\ | |||
117 | {\n\ | 117 | {\n\ |
118 | @#list_vars\ | 118 | @#list_vars\ |
119 | @#ret_param_@#class_@#func(obj, _pd@#list_params);\n\ | 119 | @#ret_param_@#class_@#func(obj, _pd@#list_params);\n\ |
120 | @#return_ret\ | ||
120 | }\n\ | 121 | }\n\ |
121 | "; | 122 | "; |
122 | 123 | ||
@@ -428,16 +429,19 @@ eo1_bind_func_generate(const char *classname, Eolian_Function funcid, Eolian_Fun | |||
428 | ret_const?"const ":"", | 429 | ret_const?"const ":"", |
429 | rettype, had_star?"":" "); | 430 | rettype, had_star?"":" "); |
430 | Eina_Strbuf *ret_param = eina_strbuf_new(); | 431 | Eina_Strbuf *ret_param = eina_strbuf_new(); |
431 | eina_strbuf_append_printf(ret_param, "*%s = ", retname); | 432 | if (rettype) eina_strbuf_append_printf(ret_param, "%s _%s = ", rettype, retname); |
432 | eina_strbuf_replace_all(fbody, "@#ret_param", eina_strbuf_string_get(ret_param)); | 433 | eina_strbuf_replace_all(fbody, "@#ret_param", eina_strbuf_string_get(ret_param)); |
433 | sprintf(tmpstr, "%s%s", ret_const?"const ":"", rettype); | 434 | sprintf(tmpstr, "%s%s", ret_const?"const ":"", rettype); |
434 | eina_strbuf_replace_all(fbody, "@#ret_type", tmpstr); | 435 | eina_strbuf_replace_all(fbody, "@#ret_type", tmpstr); |
436 | sprintf(tmpstr, " if (%s) *%s = _%s;\n", retname, retname, retname); | ||
437 | eina_strbuf_replace_all(fbody, "@#return_ret", tmpstr); | ||
435 | eina_strbuf_free(ret_param); | 438 | eina_strbuf_free(ret_param); |
436 | } | 439 | } |
437 | else | 440 | else |
438 | { | 441 | { |
439 | eina_strbuf_replace_all(fbody, "@#ret_param", ""); | 442 | eina_strbuf_replace_all(fbody, "@#ret_param", ""); |
440 | eina_strbuf_replace_all(fbody, "@#ret_type", "void"); | 443 | eina_strbuf_replace_all(fbody, "@#ret_type", "void"); |
444 | eina_strbuf_replace_all(fbody, "@#return_ret", ""); | ||
441 | } | 445 | } |
442 | 446 | ||
443 | if (eina_list_count(eolian_parameters_list_get(funcid)) == 0 && | 447 | if (eina_list_count(eolian_parameters_list_get(funcid)) == 0 && |