eolian gen: switch from decl api to object api

This commit is contained in:
Daniel Kolesa 2018-03-08 19:57:55 +01:00
parent 2248131295
commit c7b44dfa2c
3 changed files with 24 additions and 22 deletions

View File

@ -22,10 +22,10 @@ static void
_generate_ref(const Eolian_Unit *src, const char *refn, Eina_Strbuf *wbuf,
Eina_Bool use_legacy)
{
const Eolian_Declaration *decl = eolian_declaration_get_by_name(src, refn);
const Eolian_Object *decl = eolian_unit_object_by_name_get(src, refn);
if (decl)
{
char *n = strdup(eolian_declaration_name_get(decl));
char *n = strdup(eolian_object_name_get(decl));
char *p = n;
while ((p = strchr(p, '.'))) *p = '_';
eina_strbuf_append(wbuf, n);

View File

@ -324,7 +324,7 @@ _write_header(const Eolian_State *eos, const Eolian_Unit *src, const char *ofnam
INF("generating header: %s (legacy: %d)", ofname, legacy);
Eina_Strbuf *buf = eina_strbuf_new();
eo_gen_types_header_gen(src, eolian_declarations_get_by_file(eos, ifname),
eo_gen_types_header_gen(src, eolian_state_objects_by_file_get(eos, ifname),
buf, EINA_TRUE, legacy);
buf = _include_guard(ifname, "TYPES", buf);
@ -360,7 +360,7 @@ _write_stub_header(const Eolian_State *eos, const Eolian_Unit *src, const char *
INF("generating stub header: %s", ofname);
Eina_Strbuf *buf = eina_strbuf_new();
eo_gen_types_header_gen(src, eolian_declarations_get_by_file(eos, ifname),
eo_gen_types_header_gen(src, eolian_state_objects_by_file_get(eos, ifname),
buf, EINA_FALSE, EINA_FALSE);
Eina_Strbuf *cltd = eo_gen_class_typedef_gen(eos, ifname);
@ -386,7 +386,7 @@ _write_source(const Eolian_State *eos, const char *ofname,
Eina_Strbuf *buf = eina_strbuf_new();
const Eolian_Class *cl = eolian_state_class_by_file_get(eos, ifname);
eo_gen_types_source_gen(eolian_declarations_get_by_file(eos, ifname), buf);
eo_gen_types_source_gen(eolian_state_objects_by_file_get(eos, ifname), buf);
eo_gen_source_gen(cl, buf);
if (cl || (eot && eina_strbuf_length_get(buf)))
{

View File

@ -207,14 +207,14 @@ void eo_gen_types_header_gen(const Eolian_Unit *src,
Eina_Iterator *itr, Eina_Strbuf *buf,
Eina_Bool full, Eina_Bool legacy)
{
const Eolian_Declaration *decl;
const Eolian_Object *decl;
EINA_ITERATOR_FOREACH(itr, decl)
{
Eolian_Declaration_Type dt = eolian_declaration_type_get(decl);
Eolian_Object_Type dt = eolian_object_type_get(decl);
if (dt == EOLIAN_DECL_VAR)
if (dt == EOLIAN_OBJECT_VARIABLE)
{
const Eolian_Variable *vr = eolian_declaration_variable_get(decl);
const Eolian_Variable *vr = (const Eolian_Variable *)decl;
if (!vr || eolian_variable_is_extern(vr))
continue;
@ -228,18 +228,20 @@ void eo_gen_types_header_gen(const Eolian_Unit *src,
continue;
}
if ((dt != EOLIAN_DECL_ALIAS) &&
(dt != EOLIAN_DECL_STRUCT) &&
(dt != EOLIAN_DECL_ENUM))
continue;
if (dt == EOLIAN_DECL_ENUM && !full)
if (dt != EOLIAN_OBJECT_TYPEDECL)
continue;
const Eolian_Typedecl *tp = eolian_declaration_data_type_get(decl);
if (!tp || eolian_typedecl_is_extern(tp))
const Eolian_Typedecl *tp = (const Eolian_Typedecl *)decl;
if (eolian_typedecl_is_extern(tp))
continue;
if (eolian_typedecl_type_get(tp) == EOLIAN_TYPEDECL_ALIAS)
Eolian_Typedecl_Type tpt = eolian_typedecl_type_get(tp);
if (tpt == EOLIAN_TYPEDECL_ENUM && !full)
continue;
if (tpt == EOLIAN_TYPEDECL_ALIAS)
{
const Eolian_Type *btp = eolian_typedecl_base_type_get(tp);
if (eolian_type_type_get(btp) == EOLIAN_TYPE_UNDEFINED)
@ -259,16 +261,16 @@ void eo_gen_types_header_gen(const Eolian_Unit *src,
void eo_gen_types_source_gen(Eina_Iterator *itr, Eina_Strbuf *buf)
{
const Eolian_Declaration *decl;
const Eolian_Object *decl;
EINA_ITERATOR_FOREACH(itr, decl)
{
Eolian_Declaration_Type dt = eolian_declaration_type_get(decl);
Eolian_Object_Type dt = eolian_object_type_get(decl);
if (dt != EOLIAN_DECL_VAR)
if (dt != EOLIAN_OBJECT_VARIABLE)
continue;
const Eolian_Variable *vr = eolian_declaration_variable_get(decl);
if (!vr || eolian_variable_is_extern(vr))
const Eolian_Variable *vr = (const Eolian_Variable *)decl;
if (eolian_variable_is_extern(vr))
continue;
if (eolian_variable_type_get(vr) == EOLIAN_VAR_CONSTANT)