forked from enlightenment/efl
eolian gen: generate a separate file with legacy implementations
If legacy implementations are generated, eolian_gen now creates a separate file for them and includes it. The file name convention for that is <.c file name without ext>.legacy.<.c file name ext> or <.c file name>.legacy.c if it has no ext, so for example foo.eo.c becomes foo.eo.legacy.c and foo becomes foo.legacy.c. The file is generated assuming there are any legacy APIs contained inside the .eo file.
This commit is contained in:
parent
95d414549b
commit
b6b7317f4e
|
@ -159,6 +159,7 @@ tests/eolian/data/struct_ref.h \
|
|||
tests/eolian/data/struct_ref_stub.h \
|
||||
tests/eolian/data/owning.eo.c \
|
||||
tests/eolian/data/class_simple_ref.c \
|
||||
tests/eolian/data/class_simple_ref.legacy.c \
|
||||
tests/eolian/data/override_ref.c \
|
||||
tests/eolian/data/class_simple_ref_eo.h \
|
||||
tests/eolian/data/class_simple_ref_legacy.h \
|
||||
|
|
|
@ -396,21 +396,48 @@ _write_source(const Eolian_State *eos, const char *ofname,
|
|||
{
|
||||
INF("generating source: %s", ofname);
|
||||
Eina_Strbuf *buf = eina_strbuf_new();
|
||||
Eina_Strbuf *lbuf = eina_strbuf_new();
|
||||
Eina_Strbuf *oflname = eina_strbuf_new();
|
||||
Eina_Bool ret = EINA_FALSE;
|
||||
|
||||
const char *lext = strrchr(ofname, '.');
|
||||
if (!lext)
|
||||
{
|
||||
eina_strbuf_append(oflname, ofname);
|
||||
eina_strbuf_append(oflname, ".legacy.c");
|
||||
}
|
||||
else
|
||||
{
|
||||
eina_strbuf_append_length(oflname, ofname, strlen(ofname) - strlen(lext));
|
||||
eina_strbuf_append(oflname, ".legacy");
|
||||
eina_strbuf_append(oflname, lext);
|
||||
}
|
||||
const char *lfname = eina_strbuf_string_get(oflname);
|
||||
{
|
||||
const char *p1 = strrchr(lfname, '/');
|
||||
const char *p2 = strrchr(lfname, '\\');
|
||||
lfname = (p1 || p2) ? ((p1 > p2) ? (p1 + 1) : (p2 + 1)) : lfname;
|
||||
}
|
||||
const Eolian_Class *cl = eolian_state_class_by_file_get(eos, ifname);
|
||||
eo_gen_types_source_gen(eolian_state_objects_by_file_get(eos, ifname), buf);
|
||||
eo_gen_source_gen(cl, buf);
|
||||
eo_gen_source_gen(cl, buf, lbuf, lfname);
|
||||
if (cl || (eot && eina_strbuf_length_get(buf)))
|
||||
{
|
||||
if (_write_file(ofname, buf))
|
||||
if (!_write_file(ofname, buf))
|
||||
goto done;
|
||||
if (eina_strbuf_length_get(lbuf))
|
||||
{
|
||||
eina_strbuf_free(buf);
|
||||
return EINA_TRUE;
|
||||
if (!_write_file(eina_strbuf_string_get(oflname), lbuf))
|
||||
goto done;
|
||||
}
|
||||
ret = EINA_TRUE;
|
||||
}
|
||||
|
||||
done:
|
||||
eina_strbuf_free(buf);
|
||||
return EINA_FALSE;
|
||||
eina_strbuf_free(lbuf);
|
||||
eina_strbuf_free(oflname);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
|
|
|
@ -1091,7 +1091,8 @@ _gen_initializer(const Eolian_Class *cl, Eina_Strbuf *buf, Eina_Hash *refh)
|
|||
}
|
||||
|
||||
void
|
||||
eo_gen_source_gen(const Eolian_Class *cl, Eina_Strbuf *buf)
|
||||
eo_gen_source_gen(const Eolian_Class *cl, Eina_Strbuf *buf, Eina_Strbuf *lbuf,
|
||||
const char *lfname)
|
||||
{
|
||||
if (!cl)
|
||||
return;
|
||||
|
@ -1122,8 +1123,6 @@ eo_gen_source_gen(const Eolian_Class *cl, Eina_Strbuf *buf)
|
|||
eina_iterator_free(itr);
|
||||
}
|
||||
|
||||
Eina_Strbuf *lbuf = eina_strbuf_new();
|
||||
|
||||
/* Eolian_Function -> Eolian_Function_Type
|
||||
* maps which parts of which functions are qualified for reflection
|
||||
*/
|
||||
|
@ -1236,10 +1235,9 @@ eo_gen_source_gen(const Eolian_Class *cl, Eina_Strbuf *buf)
|
|||
/* terminate inherits */
|
||||
eina_strbuf_append(buf, ", NULL);\n");
|
||||
|
||||
/* append legacy if there */
|
||||
eina_strbuf_append(buf, eina_strbuf_string_get(lbuf));
|
||||
|
||||
eina_strbuf_free(lbuf);
|
||||
/* append legacy include if there */
|
||||
if (eina_strbuf_length_get(lbuf))
|
||||
eina_strbuf_append_printf(buf, "\n#include \"%s\"\n", lfname);
|
||||
|
||||
/* and we're done */
|
||||
free(cnamel);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "main.h"
|
||||
|
||||
void eo_gen_source_gen(const Eolian_Class *cl, Eina_Strbuf *buf);
|
||||
void eo_gen_source_gen(const Eolian_Class *cl, Eina_Strbuf *buf, Eina_Strbuf *lbuf, const char *lfname);
|
||||
void eo_gen_impl_gen(const Eolian_Class *cl, Eina_Strbuf *buf);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -88,14 +88,4 @@ static const Efl_Class_Description _class_simple_class_desc = {
|
|||
|
||||
EFL_DEFINE_CLASS(class_simple_class_get, &_class_simple_class_desc, NULL, NULL);
|
||||
|
||||
EAPI void
|
||||
evas_object_simple_b_set(Class_Simple *obj)
|
||||
{
|
||||
efl_canvas_object_simple_b_set(obj);
|
||||
}
|
||||
|
||||
EAPI int *
|
||||
evas_object_simple_bar(Class_Simple *obj, int x)
|
||||
{
|
||||
return efl_canvas_object_simple_bar(obj, x);
|
||||
}
|
||||
#include "eolian_class_simple.eo.legacy.c"
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
|
||||
EAPI void
|
||||
evas_object_simple_b_set(Class_Simple *obj)
|
||||
{
|
||||
efl_canvas_object_simple_b_set(obj);
|
||||
}
|
||||
|
||||
EAPI int *
|
||||
evas_object_simple_bar(Class_Simple *obj, int x)
|
||||
{
|
||||
return efl_canvas_object_simple_bar(obj, x);
|
||||
}
|
|
@ -141,6 +141,7 @@ EFL_START_TEST(eolian_default_values_generation)
|
|||
_remove_ref(output_filepath, "eo.c");
|
||||
fail_if(0 != _eolian_gen_execute(TESTS_SRC_DIR"/data/class_simple.eo", "-gc", output_filepath));
|
||||
fail_if(!_files_compare(TESTS_SRC_DIR"/data/class_simple_ref.c", output_filepath, "eo.c"));
|
||||
fail_if(!_files_compare(TESTS_SRC_DIR"/data/class_simple_ref.legacy.c", output_filepath, "eo.legacy.c"));
|
||||
}
|
||||
EFL_END_TEST
|
||||
|
||||
|
|
Loading…
Reference in New Issue