jackdanielz pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=233650ed9d4d17a3f2b9bda4eccfa0982c821029
commit 233650ed9d4d17a3f2b9bda4eccfa0982c821029 Author: Daniel Zaoui <[email protected]> Date: Sun Jun 8 11:57:31 2014 +0300 Eolian/Generator: concentrate the function name calculation to one place. Instead of having the calculation (class name + function name + set/get) in many places in the code, it is now in one place and accessible via a function environment structure. --- src/bin/eolian/common_funcs.c | 57 ++++++++++++++++++++++++---- src/bin/eolian/common_funcs.h | 13 ++++++- src/bin/eolian/eo_generator.c | 76 +++++++++++++++++++++---------------- src/bin/eolian/legacy_generator.c | 80 ++++++++++----------------------------- 4 files changed, 122 insertions(+), 104 deletions(-) diff --git a/src/bin/eolian/common_funcs.c b/src/bin/eolian/common_funcs.c index 8b6b203..de58280 100644 --- a/src/bin/eolian/common_funcs.c +++ b/src/bin/eolian/common_funcs.c @@ -48,29 +48,70 @@ _class_env_create(const Eolian_Class class, const char *over_classname, _eolian_ } void -_class_func_names_fill(const Eolian_Class class EINA_UNUSED, const char *over_classname EINA_UNUSED, const char *funcname) +_class_func_env_create(const Eolian_Class class, const char *funcname, Eolian_Function_Type ftype, _eolian_class_func_vars *env) { char *p; - if (funcname) + const char *suffix = ""; + const char *legacy = NULL; + Eolian_Function funcid = eolian_class_function_find_by_name(class, funcname, ftype); + if (ftype == EOLIAN_PROP_GET) + { + suffix = "_get"; + legacy = eolian_function_data_get(funcid, EOLIAN_LEGACY_GET); + } + if (ftype == EOLIAN_PROP_SET) + { + suffix = "_set"; + legacy = eolian_function_data_get(funcid, EOLIAN_LEGACY_SET); + } + if (!legacy) legacy = eolian_function_data_get(funcid, EOLIAN_LEGACY); + + _eolian_class_vars tmp_env; + _class_env_create(class, NULL, &tmp_env); + + p = strncpy(env->upper_func, funcname, PATH_MAX - 1); + eina_str_toupper(&p); + + sprintf(p = env->upper_eo_func, "%s_%s%s", tmp_env.upper_eo_prefix, funcname, suffix); + eina_str_toupper(&p); + + sprintf(p = env->lower_eo_func, "%s_%s%s", tmp_env.lower_eo_prefix, funcname, suffix); + eina_str_tolower(&p); + + env->legacy_func[0] = '\0'; + if (legacy && !strcmp(legacy, "null")) goto end; + if (legacy) { - strncpy(capfunc, funcname, sizeof(capfunc) - 1); - p = capfunc; - eina_str_toupper(&p); + sprintf(p = env->legacy_func, "%s", legacy); + goto end; } + + legacy = eolian_class_legacy_prefix_get(class); + if (legacy && !strcmp(legacy, "null")) goto end; + + sprintf(env->legacy_func, "%s_%s%s", legacy?legacy:tmp_env.lower_classname, funcname, suffix); + +end: + return; } void _template_fill(Eina_Strbuf *buf, const char *templ, const Eolian_Class class, const char *classname, const char *funcname, Eina_Bool reset) { _eolian_class_vars tmp_env; + _eolian_class_func_vars tmp_func_env; _class_env_create(class, classname, &tmp_env); - _class_func_names_fill(NULL, NULL, funcname); + if (funcname) + _class_func_env_create(class, funcname, EOLIAN_UNRESOLVED, &tmp_func_env); if (buf) { if (reset) eina_strbuf_reset(buf); if (templ) eina_strbuf_append(buf, templ); - if (funcname) eina_strbuf_replace_all(buf, "@#func", funcname); - eina_strbuf_replace_all(buf, "@#FUNC", capfunc); + if (funcname) + { + eina_strbuf_replace_all(buf, "@#func", funcname); + eina_strbuf_replace_all(buf, "@#FUNC", tmp_func_env.upper_func); + } eina_strbuf_replace_all(buf, "@#Class", tmp_env.full_classname); eina_strbuf_replace_all(buf, "@#class", tmp_env.lower_classname); eina_strbuf_replace_all(buf, "@#CLASS", tmp_env.upper_classname); diff --git a/src/bin/eolian/common_funcs.h b/src/bin/eolian/common_funcs.h index b9956b6..ff98d7d 100644 --- a/src/bin/eolian/common_funcs.h +++ b/src/bin/eolian/common_funcs.h @@ -44,6 +44,16 @@ typedef struct char lower_classname[PATH_MAX]; }_eolian_class_vars; +typedef struct +{ + char upper_func[PATH_MAX]; + + char upper_eo_func[PATH_MAX]; + char lower_eo_func[PATH_MAX]; + + char legacy_func[PATH_MAX]; +}_eolian_class_func_vars; + void _template_fill(Eina_Strbuf *buf, const char *templ, const Eolian_Class class, const char *classname, const char *funcname, Eina_Bool reset); char *_nextline(char *str, unsigned int lines); @@ -54,7 +64,6 @@ char *_source_desc_get(const char *str); void _class_env_create(const Eolian_Class class, const char *over_classname, _eolian_class_vars *env); -void _class_func_names_fill(const Eolian_Class class, const char *classname, const char *funcname); +void _class_func_env_create(const Eolian_Class class, const char *funcname, Eolian_Function_Type ftype EINA_UNUSED, _eolian_class_func_vars *env); -char capfunc[0xFF]; #endif diff --git a/src/bin/eolian/eo_generator.c b/src/bin/eolian/eo_generator.c index da4cb35..1eab486 100644 --- a/src/bin/eolian/eo_generator.c +++ b/src/bin/eolian/eo_generator.c @@ -62,7 +62,7 @@ const Eo_Class *@#class_class_get(void) EINA_CONST;\n\ static const char tmpl_eo_funcdef_doxygen[] = "\ /**\n\ - * @def @#eoprefix_@#func\n\ + * @def %s\n\ *\n\ @#desc\n\ *\n\ @@ -72,9 +72,6 @@ tmpl_eo_funcdef_doxygen[] = "\ */\n"; static const char -tmpl_eo_funcdef[] = "EAPI @#rettype @#eoprefix_@#func(@#full_params);\n"; - -static const char tmpl_eo_pardesc[] =" * @param[%s] %s %s\n"; #if 0 @@ -85,6 +82,7 @@ tmpl_eo_retdesc[] =" * @return %s\n"; static Eina_Bool eo_fundef_generate(const Eolian_Class class, Eolian_Function func, Eolian_Function_Type ftype, Eina_Strbuf *functext) { + _eolian_class_func_vars func_env; const char *str_dir[] = {"in", "out", "inout"}; const Eina_List *l; void *data; @@ -96,6 +94,7 @@ eo_fundef_generate(const Eolian_Class class, Eolian_Function func, Eolian_Functi Eina_Bool ret_const = EINA_FALSE; Eolian_Function_Scope scope = eolian_function_scope_get(func); + _class_func_env_create(class, eolian_function_name_get(func), ftype, &func_env); char *fsuffix = ""; rettype = eolian_function_return_type_get(func, ftype); if (ftype == EOLIAN_PROP_GET) @@ -122,15 +121,14 @@ eo_fundef_generate(const Eolian_Class class, Eolian_Function func, Eolian_Functi Eina_Strbuf *str_func = eina_strbuf_new(); if (scope == EOLIAN_SCOPE_PROTECTED) eina_strbuf_append_printf(str_func, "#ifdef %s_PROTECTED\n", class_env.upper_classname); - _template_fill(str_func, tmpl_eo_funcdef_doxygen, class, NULL, funcname, EINA_FALSE); - _template_fill(str_func, tmpl_eo_funcdef, class, NULL, funcname, EINA_FALSE); + + eina_strbuf_append_printf(str_func, tmpl_eo_funcdef_doxygen, func_env.lower_eo_func); + eina_strbuf_append_printf(str_func, "EAPI @#rettype %s(@#full_params);\n", func_env.lower_eo_func); + if (scope == EOLIAN_SCOPE_PROTECTED) eina_strbuf_append_printf(str_func, "#endif\n"); eina_strbuf_append_printf(str_func, "\n"); - eina_strbuf_replace_all(str_func, "@#EOPREFIX", class_env.upper_eo_prefix); - eina_strbuf_replace_all(str_func, "@#eoprefix", class_env.lower_eo_prefix); - Eina_Strbuf *linedesc = eina_strbuf_new(); eina_strbuf_append(linedesc, funcdesc ? funcdesc : "No description supplied."); if (eina_strbuf_length_get(linedesc)) @@ -226,8 +224,8 @@ Eina_Bool eo_header_generate(const Eolian_Class class, Eina_Strbuf *buf) { const Eolian_Function_Type ftype_order[] = {EOLIAN_CTOR, EOLIAN_PROPERTY, EOLIAN_METHOD}; - const Eina_List *l; - void *data; + const Eina_List *itr; + Eolian_Function fid; char *tmpstr = malloc(0x1FF); Eina_Strbuf * str_hdr = eina_strbuf_new(); @@ -247,7 +245,7 @@ eo_header_generate(const Eolian_Class class, Eina_Strbuf *buf) eina_strbuf_append(buf, eina_strbuf_string_get(linedesc)); eina_strbuf_free(linedesc); - _template_fill(str_hdr, tmpl_eo_obj_header, class, NULL, "", EINA_TRUE); + _template_fill(str_hdr, tmpl_eo_obj_header, class, NULL, NULL, EINA_TRUE); eina_strbuf_replace_all(str_hdr, "@#EOPREFIX", class_env.upper_eo_prefix); eina_strbuf_replace_all(str_hdr, "@#eoprefix", class_env.lower_eo_prefix); @@ -257,7 +255,7 @@ eo_header_generate(const Eolian_Class class, Eina_Strbuf *buf) Eina_Strbuf *tmpbuf = eina_strbuf_new(); Eolian_Event event; - EINA_LIST_FOREACH(eolian_class_events_list_get(class), l, event) + EINA_LIST_FOREACH(eolian_class_events_list_get(class), itr, event) { const char *evname = NULL; const char *evdesc = NULL; @@ -270,32 +268,34 @@ eo_header_generate(const Eolian_Class class, Eina_Strbuf *buf) eina_strbuf_prepend(tmpbuf," * "); eina_strbuf_append_printf(str_ev, "\n/**\n%s\n */\n", eina_strbuf_string_get(tmpbuf)); - _template_fill(tmpbuf, "@#CLASS_EVENT_@#FUNC", class, NULL, evname, EINA_TRUE); + eina_strbuf_reset(tmpbuf); + eina_strbuf_append_printf(tmpbuf, "%s_EVENT_%s", class_env.upper_classname, evname); eina_strbuf_replace_all(tmpbuf, ",", "_"); - const char* s = eina_strbuf_string_get(tmpbuf); + char* s = (char *)eina_strbuf_string_get(tmpbuf); + eina_str_toupper(&s); eina_strbuf_append_printf(str_ev, "#define %s (&(_%s))\n", s, s); eina_strbuf_append_printf(str_extrn_ev, "EAPI extern const Eo_Event_Description _%s;\n", s); } int i; for (i = 0; i < 3; i++) - EINA_LIST_FOREACH(eolian_class_functions_list_get(class, ftype_order[i]), l, data) + EINA_LIST_FOREACH(eolian_class_functions_list_get(class, ftype_order[i]), itr, fid) { - const Eolian_Function_Type ftype = eolian_function_type_get((Eolian_Function)data); + const Eolian_Function_Type ftype = eolian_function_type_get(fid); Eina_Bool prop_read = (ftype == EOLIAN_PROPERTY || ftype == EOLIAN_PROP_GET ) ? EINA_TRUE : EINA_FALSE ; Eina_Bool prop_write = (ftype == EOLIAN_PROPERTY || ftype == EOLIAN_PROP_SET ) ? EINA_TRUE : EINA_FALSE ; if (!prop_read && !prop_write) { - eo_fundef_generate(class, (Eolian_Function)data, EOLIAN_UNRESOLVED, str_hdr); + eo_fundef_generate(class, fid, EOLIAN_UNRESOLVED, str_hdr); } if (prop_write) { - eo_fundef_generate(class, (Eolian_Function)data, EOLIAN_PROP_SET, str_hdr); + eo_fundef_generate(class, fid, EOLIAN_PROP_SET, str_hdr); } if (prop_read) { - eo_fundef_generate(class, (Eolian_Function)data, EOLIAN_PROP_GET, str_hdr); + eo_fundef_generate(class, fid, EOLIAN_PROP_GET, str_hdr); } } @@ -316,6 +316,7 @@ eo_header_generate(const Eolian_Class class, Eina_Strbuf *buf) static Eina_Bool eo_bind_func_generate(const Eolian_Class class, Eolian_Function funcid, Eolian_Function_Type ftype, Eina_Strbuf *buf, _eolian_class_vars *impl_env) { + _eolian_class_func_vars func_env; const char *suffix = ""; Eina_Bool var_as_ret = EINA_FALSE; const char *rettype = NULL; @@ -408,11 +409,11 @@ eo_bind_func_generate(const Eolian_Class class, Eolian_Function funcid, Eolian_F eina_list_count(eolian_property_keys_list_get(funcid)) || (!var_as_ret && eina_list_count(eolian_parameters_list_get(funcid)) != 0); Eina_Bool ret_is_void = (!rettype || !strcmp(rettype, "void")); + _class_func_env_create(class, eolian_function_name_get(funcid), ftype, &func_env); eina_strbuf_append_printf(eo_func_decl, - "EAPI EO_%sFUNC_BODY%s(%s_%s%s", + "EAPI EO_%sFUNC_BODY%s(%s", ret_is_void?"VOID_":"", has_params?"V":"", - class_env.lower_eo_prefix, eolian_function_name_get(funcid), - suffix); + func_env.lower_eo_func); if (!ret_is_void) { const char *dflt_ret_val = @@ -463,15 +464,16 @@ static Eina_Bool eo_op_desc_generate(const Eolian_Class class, Eolian_Function fid, Eolian_Function_Type ftype, const char *desc, Eina_Strbuf *buf) { + _eolian_class_func_vars func_env; const char *funcname = eolian_function_name_get(fid); const char *suffix = ""; eina_strbuf_reset(buf); - _class_func_names_fill(class, NULL, funcname); + _class_func_env_create(class, funcname, ftype, &func_env); if (ftype == EOLIAN_PROP_GET) suffix = "_get"; if (ftype == EOLIAN_PROP_SET) suffix = "_set"; Eina_Bool is_virtual_pure = eolian_function_is_virtual_pure(fid, ftype); - eina_strbuf_append_printf(buf, "\n EO_OP_FUNC(%s_%s%s, ", class_env.lower_eo_prefix, funcname, suffix); + eina_strbuf_append_printf(buf, "\n EO_OP_FUNC(%s, ", func_env.lower_eo_func); if (!is_virtual_pure) eina_strbuf_append_printf(buf, "_%s_%s%s, \"%s\"),", class_env.lower_classname, funcname, suffix, desc); else @@ -494,10 +496,14 @@ eo_source_beginning_generate(const Eolian_Class class, Eina_Strbuf *buf) const char *evname; const char *evdesc; char *evdesc_line1; + char *p; + eina_strbuf_reset(str_ev); eolian_class_event_information_get(event, &evname, NULL, &evdesc); evdesc_line1 = _source_desc_get(evdesc); - _template_fill(str_ev, "@#CLASS_EVENT_@#FUNC", class, NULL, evname, EINA_TRUE); + eina_strbuf_append_printf(str_ev, "%s_EVENT_%s", class_env.upper_classname, evname); + p = (char *)eina_strbuf_string_get(str_ev); + eina_str_toupper(&p); eina_strbuf_replace_all(str_ev, ",", "_"); eina_strbuf_append_printf(tmpbuf, @@ -562,7 +568,7 @@ eo_source_end_generate(const Eolian_Class class, Eina_Strbuf *buf) eina_strbuf_reset(tmpbuf); if (eolian_class_ctor_enable_get(class)) - _template_fill(tmpbuf, "_@#class_class_constructor", class, NULL, "", EINA_TRUE); + _template_fill(tmpbuf, "_@#class_class_constructor", class, NULL, NULL, EINA_TRUE); else eina_strbuf_append_printf(tmpbuf, "NULL"); eina_strbuf_replace_all(str_end, "@#ctor_name", eina_strbuf_string_get(tmpbuf)); @@ -572,7 +578,7 @@ eo_source_end_generate(const Eolian_Class class, Eina_Strbuf *buf) { eina_strbuf_replace_all(str_end, "@#dtor_func", eina_strbuf_string_get(tmpbuf)); eina_strbuf_reset(tmpbuf); - _template_fill(tmpbuf, "_@#class_class_destructor", class, NULL, "", EINA_TRUE); + _template_fill(tmpbuf, "_@#class_class_destructor", class, NULL, NULL, EINA_TRUE); eina_strbuf_replace_all(str_end, "@#dtor_name", eina_strbuf_string_get(tmpbuf)); } else @@ -690,9 +696,13 @@ eo_source_end_generate(const Eolian_Class class, Eina_Strbuf *buf) EINA_LIST_FOREACH(eolian_class_events_list_get(class), itr, event) { const char *evname; + char *p; + eina_strbuf_reset(tmpbuf); eolian_class_event_information_get(event, &evname, NULL, NULL); - _template_fill(tmpbuf, "@#CLASS_EVENT_@#FUNC", class, NULL, evname, EINA_TRUE); + eina_strbuf_append_printf(tmpbuf, "%s_EVENT_%s", class_env.upper_classname, evname); + p = (char *)eina_strbuf_string_get(tmpbuf); + eina_str_toupper(&p); eina_strbuf_replace_all(tmpbuf, ",", "_"); eina_strbuf_append_printf(str_ev, "\n %s,", eina_strbuf_string_get(tmpbuf)); } @@ -701,7 +711,7 @@ eo_source_end_generate(const Eolian_Class class, Eina_Strbuf *buf) if (eina_strbuf_length_get(str_ev)) { Eina_Strbuf *events_desc = eina_strbuf_new(); - _template_fill(events_desc, tmpl_events_desc, class, NULL, "", EINA_TRUE); + _template_fill(events_desc, tmpl_events_desc, class, NULL, NULL, EINA_TRUE); eina_strbuf_replace_all(events_desc, "@#list_evdesc", eina_strbuf_string_get(str_ev)); eina_strbuf_replace_all(str_end, "@#events_desc", eina_strbuf_string_get(events_desc)); eina_strbuf_free(events_desc); @@ -731,7 +741,7 @@ eo_source_end_generate(const Eolian_Class class, Eina_Strbuf *buf) if (eina_strbuf_length_get(str_op)) { Eina_Strbuf *ops_desc = eina_strbuf_new(); - _template_fill(ops_desc, tmpl_eo_ops_desc, class, NULL, "", EINA_TRUE); + _template_fill(ops_desc, tmpl_eo_ops_desc, class, NULL, NULL, EINA_TRUE); eina_strbuf_replace_all(ops_desc, "@#list_op", eina_strbuf_string_get(str_op)); eina_strbuf_replace_all(str_end, "@#ops_desc", eina_strbuf_string_get(ops_desc)); eina_strbuf_free(ops_desc); @@ -782,10 +792,10 @@ eo_source_generate(const Eolian_Class class, Eina_Strbuf *buf) Eina_Strbuf *str_bodyf = eina_strbuf_new(); - if (!eo_source_beginning_generate(class, buf)) goto end; - _class_env_create(class, NULL, &class_env); + if (!eo_source_beginning_generate(class, buf)) goto end; + //Properties EINA_LIST_FOREACH(eolian_class_functions_list_get(class, EOLIAN_PROPERTY), itr, fn) { diff --git a/src/bin/eolian/legacy_generator.c b/src/bin/eolian/legacy_generator.c index 2c33c49..a8f8d20 100644 --- a/src/bin/eolian/legacy_generator.c +++ b/src/bin/eolian/legacy_generator.c @@ -11,13 +11,13 @@ static _eolian_class_vars class_env; static const char tmpl_eapi_funcdef[] = "\n\ /**\n\ - * @def @#class_@#func\n\ + * @def %s\n\ *\n\ @#desc\n\ *\n\ @#list_desc_param\ */\n\ -EAPI @#type_return@#class_@#func(@#is_constEo *obj@#params)@#flags;\n\ +EAPI @#type_return%s(@#is_constEo *obj@#params)@#flags;\n\ "; /*@#CLASS_CHECK(obj) @#check_ret;\n\*/ @@ -25,10 +25,10 @@ static const char tmpl_eapi_body[] ="\ \n\ EAPI @#ret_type\n\ -@#eapi_prefix_@#func(@#is_constEo *obj@#full_params)\n\ +@#eapi_func(@#is_constEo *obj@#full_params)\n\ {\n\ @#ret_init_val\ - eo_do((Eo *) obj, @#eo_ret_assign@#eoprefix_@#func(@#eo_params));\n\ + eo_do((Eo *) obj, @#eo_ret_assign@#eo_func(@#eo_params));\n\ return @#ret_val;\n\ }\n\ "; @@ -36,19 +36,19 @@ static const char tmpl_eapi_body_void[] ="\ \n\ EAPI void\n\ -@#eapi_prefix_@#func(@#is_constEo *obj@#full_params)\n\ +@#eapi_func(@#is_constEo *obj@#full_params)\n\ {\n\ - eo_do((Eo *) obj, @#eoprefix_@#func(@#eo_params));\n\ + eo_do((Eo *) obj, @#eo_func(@#eo_params));\n\ }\n\ "; static void _eapi_decl_func_generate(Eolian_Class class, Eolian_Function funcid, Eolian_Function_Type ftype, Eina_Strbuf *buf) { - //TODO return value + _eolian_class_func_vars func_env; + const char *funcname = eolian_function_name_get(funcid); const char *suffix = ""; const char *rettype = NULL; - const char *func_lpref = NULL; Eina_Bool var_as_ret = EINA_FALSE; Eina_Bool add_star = EINA_FALSE; Eina_Bool ret_const = EINA_FALSE; @@ -62,13 +62,12 @@ _eapi_decl_func_generate(Eolian_Class class, Eolian_Function funcid, Eolian_Func Eina_Strbuf *fparam = eina_strbuf_new(); Eina_Strbuf *descparam = eina_strbuf_new(); - _class_func_names_fill(class, NULL, NULL); + _class_func_env_create(class, funcname, ftype, &func_env); rettype = eolian_function_return_type_get(funcid, ftype); if (ftype == EOLIAN_PROP_GET) { suffix = "_get"; add_star = EINA_TRUE; - func_lpref = eolian_function_data_get(funcid, EOLIAN_LEGACY_GET); if (!rettype) { l = eolian_parameters_list_get(funcid); @@ -82,29 +81,10 @@ _eapi_decl_func_generate(Eolian_Class class, Eolian_Function funcid, Eolian_Func } } - if (ftype == EOLIAN_PROP_SET) - { - suffix = "_set"; - func_lpref = eolian_function_data_get(funcid, EOLIAN_LEGACY_SET); - } - - func_lpref = (func_lpref) ? func_lpref : eolian_function_data_get(funcid, EOLIAN_LEGACY); - if (func_lpref && !strcmp(func_lpref, "null")) goto end; + if (ftype == EOLIAN_PROP_SET) suffix = "_set"; - if (func_lpref) - { - _template_fill(fbody, tmpl_eapi_funcdef, NULL, "@#class", "@#func", EINA_FALSE); - eina_strbuf_replace_all (fbody, "@#class_@#func", func_lpref); - } - else - { - func_lpref = eolian_class_legacy_prefix_get(class); - if (func_lpref && !strcmp(func_lpref, "null")) goto end; - - if (!func_lpref) func_lpref = class_env.lower_classname; - sprintf (tmpstr, "%s%s", eolian_function_name_get(funcid), suffix); - _template_fill(fbody, tmpl_eapi_funcdef, NULL, func_lpref, tmpstr, EINA_FALSE); - } + if (func_env.legacy_func[0] == '\0') goto end; + eina_strbuf_append_printf(fbody, tmpl_eapi_funcdef, func_env.legacy_func, func_env.legacy_func); sprintf (tmpstr, "comment%s", suffix); const char *desc = eolian_function_description_get(funcid, tmpstr); @@ -210,10 +190,8 @@ end: static void _eapi_func_generate(const Eolian_Class class, Eolian_Function funcid, Eolian_Function_Type ftype, Eina_Strbuf *buf) { - //TODO return value + _eolian_class_func_vars func_env; char tmpstr[0xFF]; - const char *suffix = ""; - const char *func_lpref = NULL; Eina_Bool var_as_ret = EINA_FALSE; const char *rettype = NULL; const char *retname = NULL; @@ -225,14 +203,13 @@ _eapi_func_generate(const Eolian_Class class, Eolian_Function funcid, Eolian_Fun Eina_Strbuf *fparam = eina_strbuf_new(); Eina_Strbuf *eoparam = eina_strbuf_new(); + _class_func_env_create(class, eolian_function_name_get(funcid), ftype, &func_env); rettype = eolian_function_return_type_get(funcid, ftype); if (rettype && !strcmp(rettype, "void")) ret_is_void = EINA_TRUE; retname = "ret"; if (ftype == EOLIAN_PROP_GET) { - suffix = "_get"; add_star = EINA_TRUE; - func_lpref = eolian_function_data_get(funcid, EOLIAN_LEGACY_GET); if (!rettype) { const Eina_List *l = eolian_parameters_list_get(funcid); @@ -245,35 +222,16 @@ _eapi_func_generate(const Eolian_Class class, Eolian_Function funcid, Eolian_Fun } } } - if (ftype == EOLIAN_PROP_SET) - { - suffix = "_set"; - func_lpref = eolian_function_data_get(funcid, EOLIAN_LEGACY_SET); - } - func_lpref = (func_lpref) ? func_lpref : eolian_function_data_get(funcid, EOLIAN_LEGACY); - if (func_lpref && !strcmp(func_lpref, "null")) goto end; + if (func_env.legacy_func[0] == '\0') goto end; if (rettype && (!ret_is_void)) - _template_fill(fbody, tmpl_eapi_body, class, NULL, NULL, EINA_FALSE); + eina_strbuf_append(fbody, tmpl_eapi_body); else - _template_fill(fbody, tmpl_eapi_body_void, class, NULL, NULL, EINA_FALSE); - eina_strbuf_replace_all(fbody, "@#eoprefix", class_env.lower_eo_prefix); - - if (func_lpref) - eina_strbuf_replace_all(fbody, "@#eapi_prefix_@#func", func_lpref); - else - { - func_lpref = eolian_class_legacy_prefix_get(class); - if (func_lpref && !strcmp(func_lpref, "null")) goto end; - - if (func_lpref) eina_strbuf_replace_all(fbody, "@#eapi_prefix", func_lpref); - else - eina_strbuf_replace_all(fbody, "@#eapi_prefix", class_env.lower_classname); - } + eina_strbuf_append(fbody, tmpl_eapi_body_void); - sprintf (tmpstr, "%s%s", eolian_function_name_get(funcid), suffix); - eina_strbuf_replace_all(fbody, "@#func", tmpstr); + eina_strbuf_replace_all(fbody, "@#eapi_func", func_env.legacy_func); + eina_strbuf_replace_all(fbody, "@#eo_func", func_env.lower_eo_func); const Eina_List *l; void *data; --
