eolian: Fix struct database registration.
authorLauro Moura <lauromoura@expertisesolutions.com.br>
Thu, 28 Feb 2019 10:47:37 +0000 (11:47 +0100)
committerWonki Kim <wonki_.kim@samsung.com>
Fri, 8 Mar 2019 11:49:36 +0000 (20:49 +0900)
Summary:
It was mistankely swapping regular and inlist structs when registering
after parsing, causing functions like eolian_state_structs_by_file_get
to return wrong data, breaking C# bindings.

Also added a simple test.

Reviewers: q66, bu5hm4n, zmike, cedric, felipealmeida, segfaultxavi

Reviewed By: segfaultxavi

Subscribers: segfaultxavi, cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D8047

src/lib/eolian/database_type.c
src/tests/eolian/eolian_parsing.c

index d629a44..7db0fe2 100644 (file)
@@ -53,8 +53,8 @@ database_struct_add(Eolian_Unit *unit, Eolian_Typedecl *tp, Eina_Bool is_inlist)
      {
         EOLIAN_OBJECT_ADD(unit, tp->base.name, tp, structs);
      }
-   Eina_Hash *sh = is_inlist ? unit->state->staging.structs_f
-                             : unit->state->staging.inlists_f;
+   Eina_Hash *sh = is_inlist ? unit->state->staging.inlists_f
+                             : unit->state->staging.structs_f;
    eina_hash_set(sh, tp->base.file, eina_list_append
                 ((Eina_List*)eina_hash_find(sh, tp->base.file), tp));
    database_object_add(unit, &tp->base);
index 53ffbe6..3d2b4db 100644 (file)
@@ -686,6 +686,7 @@ EFL_START_TEST(eolian_struct)
    const Eolian_Unit *unit;
    const char *type_name;
    const char *file;
+   Eina_Iterator *structs;
 
    Eolian_State *eos = eolian_state_new();
 
@@ -697,6 +698,9 @@ EFL_START_TEST(eolian_struct)
    fail_if(!(class = eolian_unit_class_by_name_get(unit, "Struct")));
    fail_if(!eolian_class_function_by_name_get(class, "foo", EOLIAN_METHOD));
 
+   fail_if(!(structs = eolian_state_structs_by_file_get(eos, "struct.eo")));
+   eina_iterator_free(structs);
+
    /* named struct */
    fail_if(!(tdl = eolian_unit_struct_by_name_get(unit, "Named")));
    fail_if(!(type_name = eolian_typedecl_short_name_get(tdl)));