eolian: update generation of op funcs

This commit is contained in:
Daniel Kolesa 2016-08-24 17:43:38 +01:00 committed by Tom Hacohen
parent e0a95a96c9
commit f92a67e191
1 changed files with 20 additions and 12 deletions

View File

@ -19,7 +19,14 @@ static Eina_Hash *_funcs_params_init = NULL;
static const char static const char
tmpl_eo_ops_desc[] = "\ tmpl_eo_ops_desc[] = "\
static const Efl_Op_Description _@#class_op_desc[] = {@#list_op\n};\n\n"; static Eina_Bool\n\
_@#class_class_initializer(Efl_Class *klass)\n\
{\n\
EFL_OBJECT_OVERRIDE_OPS_DEFINE(ops,@#list_op\n\
);\n\
\n\
return efl_class_functions_set(klass, &ops);\n\
}\n\n";
static const char static const char
tmpl_eo_src[] = "\ tmpl_eo_src[] = "\
@ -32,8 +39,8 @@ static const Efl_Class_Description _@#class_class_desc = {\n\
EO_VERSION,\n\ EO_VERSION,\n\
\"@#Class\",\n\ \"@#Class\",\n\
@#type_class,\n\ @#type_class,\n\
@#eo_class_desc_ops,\n\
@#SizeOfData,\n\ @#SizeOfData,\n\
@#init_name,\n\
@#ctor_name,\n\ @#ctor_name,\n\
@#dtor_name\n\ @#dtor_name\n\
};\n\ };\n\
@ -882,26 +889,27 @@ eo_source_end_generate(const Eolian_Class *class, Eina_Strbuf *buf)
if (eina_strbuf_length_get(tmpbuf) == 0) eina_strbuf_append(tmpbuf, "NULL, "); if (eina_strbuf_length_get(tmpbuf) == 0) eina_strbuf_append(tmpbuf, "NULL, ");
eina_strbuf_replace_all(str_end, "@#list_inherit", eina_strbuf_string_get(tmpbuf)); eina_strbuf_replace_all(str_end, "@#list_inherit", eina_strbuf_string_get(tmpbuf));
eina_strbuf_reset(tmpbuf);
if (eina_strbuf_length_get(str_op)) if (eina_strbuf_length_get(str_op))
{ {
size_t stroplen = eina_strbuf_length_get(str_op);
if (eina_strbuf_string_get(str_op)[stroplen - 1] == ',')
eina_strbuf_remove(str_op, stroplen - 1, stroplen);
Eina_Strbuf *ops_desc = eina_strbuf_new(); Eina_Strbuf *ops_desc = eina_strbuf_new();
_template_fill(ops_desc, tmpl_eo_ops_desc, class, NULL, 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(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_replace_all(str_end, "@#ops_desc", eina_strbuf_string_get(ops_desc));
eina_strbuf_free(ops_desc); eina_strbuf_free(ops_desc);
_template_fill(tmpbuf, eina_strbuf_reset(tmpbuf);
"EFL_CLASS_DESCRIPTION_OPS(_@#class_op_desc)", _template_fill(tmpbuf, "_@#class_class_initializer", class, NULL, NULL, EINA_TRUE);
class, NULL, NULL, EINA_TRUE); eina_strbuf_replace_all(str_end, "@#init_name", eina_strbuf_string_get(tmpbuf));
} }
else else
{ {
eina_strbuf_replace_all(str_end, "@#ops_desc", ""); eina_strbuf_replace_all(str_end, "@#ops_desc", "");
eina_strbuf_append_printf(tmpbuf, "EFL_CLASS_DESCRIPTION_NOOPS()"); eina_strbuf_replace_all(str_end, "@#init_name", "NULL");
} }
eina_strbuf_replace_all(str_end, "@#functions_body", eina_strbuf_string_get(str_bodyf)); eina_strbuf_replace_all(str_end, "@#functions_body", eina_strbuf_string_get(str_bodyf));
eina_strbuf_replace_all(str_end, "@#eo_class_desc_ops", eina_strbuf_string_get(tmpbuf));
const char *data_type = eolian_class_data_type_get(class); const char *data_type = eolian_class_data_type_get(class);
if (data_type && !strcmp(data_type, "null")) if (data_type && !strcmp(data_type, "null"))