From 5ec8493f90c10c555fde723bc55ba303602fbdfe Mon Sep 17 00:00:00 2001 From: Lauro Moura Date: Thu, 28 Feb 2019 11:47:37 +0100 Subject: [PATCH] eolian: Fix struct database registration. 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 | 4 ++-- src/tests/eolian/eolian_parsing.c | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib/eolian/database_type.c b/src/lib/eolian/database_type.c index d629a44..7db0fe2 100644 --- a/src/lib/eolian/database_type.c +++ b/src/lib/eolian/database_type.c @@ -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); diff --git a/src/tests/eolian/eolian_parsing.c b/src/tests/eolian/eolian_parsing.c index 53ffbe6..3d2b4db 100644 --- a/src/tests/eolian/eolian_parsing.c +++ b/src/tests/eolian/eolian_parsing.c @@ -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))); -- 2.7.4