summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2017-08-30 15:45:20 +0200
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2017-08-30 15:45:20 +0200
commit2071bbe8fb6efedef6cfa3ec1ad3df398c42727f (patch)
treef6777fc775e4a36abd4aeab512269b0f03db1374
parentaf6713ebb464fe264e553542c0a6cbf545e8052f (diff)
downloadefl-2071bbe8fb6efedef6cfa3ec1ad3df398c42727f.tar.gz
eolian: clean up and fix function pointer generation
Out/inout params are now correctly handled.
-rw-r--r--src/bin/eolian/headers.c16
-rw-r--r--src/bin/eolian/headers.h1
-rw-r--r--src/bin/eolian/types.c21
-rw-r--r--src/tests/eolian/data/function_types_ref.h2
4 files changed, 13 insertions, 27 deletions
diff --git a/src/bin/eolian/headers.c b/src/bin/eolian/headers.c
index a0c6879441..90fc1ea611 100644
--- a/src/bin/eolian/headers.c
+++ b/src/bin/eolian/headers.c
@@ -11,8 +11,8 @@ _get_add_star(Eolian_Function_Type ftype, Eolian_Parameter_Dir pdir)
return "";
}
-int
-eo_gen_type_c_params_gen(Eina_Strbuf *buf, Eolian_Function_Parameter *pr, Eolian_Function_Type ftype, int *rpid)
+static int
+_gen_param(Eina_Strbuf *buf, Eolian_Function_Parameter *pr, Eolian_Function_Type ftype, int *rpid)
{
const Eolian_Type *prt = eolian_parameter_type_get(pr);
const Eolian_Typedecl *ptd = eolian_type_typedecl_get(prt);
@@ -38,8 +38,8 @@ eo_gen_type_c_params_gen(Eina_Strbuf *buf, Eolian_Function_Parameter *pr, Eolian
return 1;
}
-static void
-_gen_params(Eina_Iterator *itr, Eina_Strbuf *buf, Eina_Strbuf **flagbuf, int *nidx, Eolian_Function_Type ftype)
+void
+eo_gen_params(Eina_Iterator *itr, Eina_Strbuf *buf, Eina_Strbuf **flagbuf, int *nidx, Eolian_Function_Type ftype)
{
Eolian_Function_Parameter *pr;
EINA_ITERATOR_FOREACH(itr, pr)
@@ -47,9 +47,9 @@ _gen_params(Eina_Iterator *itr, Eina_Strbuf *buf, Eina_Strbuf **flagbuf, int *ni
int rpid = 0;
if (*nidx)
eina_strbuf_append(buf, ", ");
- *nidx += eo_gen_type_c_params_gen(buf, pr, ftype, &rpid);
+ *nidx += _gen_param(buf, pr, ftype, &rpid);
- if (!eolian_parameter_is_nonull(pr))
+ if (!eolian_parameter_is_nonull(pr) || !flagbuf)
continue;
if (!*flagbuf)
@@ -139,7 +139,7 @@ _gen_func(const Eolian_Unit *src, const Eolian_Function *fid,
eina_strbuf_append(buf, "Eo *obj");
}
- _gen_params(eolian_property_keys_get(fid, ftype), buf, &flagbuf, &nidx, EOLIAN_PROPERTY);
+ eo_gen_params(eolian_property_keys_get(fid, ftype), buf, &flagbuf, &nidx, EOLIAN_PROPERTY);
if (!var_as_ret)
{
@@ -148,7 +148,7 @@ _gen_func(const Eolian_Unit *src, const Eolian_Function *fid,
itr = eolian_property_values_get(fid, ftype);
else
itr = eolian_function_parameters_get(fid);
- _gen_params(itr, buf, &flagbuf, &nidx, ftype);
+ eo_gen_params(itr, buf, &flagbuf, &nidx, ftype);
}
if (flagbuf)
diff --git a/src/bin/eolian/headers.h b/src/bin/eolian/headers.h
index e45d851da5..56e4b4ffdf 100644
--- a/src/bin/eolian/headers.h
+++ b/src/bin/eolian/headers.h
@@ -3,6 +3,7 @@
#include "main.h"
+void eo_gen_params(Eina_Iterator *itr, Eina_Strbuf *buf, Eina_Strbuf **flagbuf, int *nidx, Eolian_Function_Type ftype);
void eo_gen_header_gen(const Eolian_Unit *src, const Eolian_Class *cl, Eina_Strbuf *buf, Eina_Bool legacy);
#endif
diff --git a/src/bin/eolian/types.c b/src/bin/eolian/types.c
index c856d7abba..ec06c81869 100644
--- a/src/bin/eolian/types.c
+++ b/src/bin/eolian/types.c
@@ -1,4 +1,5 @@
#include "main.h"
+#include "headers.h"
#include "docs.h"
static Eina_Strbuf *
@@ -157,24 +158,8 @@ _type_generate(const Eolian_Unit *src, const Eolian_Typedecl *tp,
/* Parameters */
eina_strbuf_append(buf, "(void *data");
- Eina_Iterator *params = eolian_function_parameters_get(fid);
- const Eolian_Function_Parameter *param = NULL;
- EINA_ITERATOR_FOREACH(params, param)
- {
- const Eolian_Typedecl *ptd = eolian_type_typedecl_get(eolian_parameter_type_get(param));
- Eina_Stringshare *pn = eolian_parameter_name_get(param);
- Eina_Stringshare *pt = eolian_type_c_type_get(eolian_parameter_type_get(param), EOLIAN_C_TYPE_PARAM);
-
- if (!pn)
- pn = ""; // FIXME add some kind of param1/param2 control for null?
-
- if (ptd && eolian_typedecl_type_get(ptd) == EOLIAN_TYPEDECL_FUNCTION_POINTER)
- eina_strbuf_append_printf(buf, ", void *%s_data, %s %s, Eina_Free_Cb %s_free_cb",
- pn, pt, pn, pn);
- else
- eina_strbuf_append_printf(buf, ", %s %s", pt, pn);
-
- }
+ int nidx = 1;
+ eo_gen_params(eolian_function_parameters_get(fid), buf, NULL, &nidx, EOLIAN_FUNCTION_POINTER);
eina_strbuf_append(buf, ")");
break;
diff --git a/src/tests/eolian/data/function_types_ref.h b/src/tests/eolian/data/function_types_ref.h
index 2f534c7d69..fe7c57d906 100644
--- a/src/tests/eolian/data/function_types_ref.h
+++ b/src/tests/eolian/data/function_types_ref.h
@@ -8,7 +8,7 @@ typedef void (*VoidFunc)(void *data);
typedef const char * (*SimpleFunc)(void *data, int a, double b);
-typedef double (*ComplexFunc)(void *data, const char * c, const char * d);
+typedef double (*ComplexFunc)(void *data, const char *c, const char **d);
typedef void (*FuncAsArgFunc)(void *data, void *cb_data, VoidFunc cb, Eina_Free_Cb cb_free_cb, void *another_cb_data, SimpleFunc another_cb, Eina_Free_Cb another_cb_free_cb);