eolian: check for typedef and struct redefinitions
authorDaniel Kolesa <d.kolesa@samsung.com>
Mon, 21 Jul 2014 10:22:49 +0000 (11:22 +0100)
committerDaniel Kolesa <d.kolesa@samsung.com>
Mon, 21 Jul 2014 10:22:49 +0000 (11:22 +0100)
src/lib/eolian/database_fill.c
src/lib/eolian/database_type.c

index c26271f..6da91b8 100644 (file)
@@ -410,18 +410,6 @@ _db_fill_class(Eo_Class_Def *kls, const char *filename)
    return EINA_TRUE;
 }
 
-static Eina_Bool
-_db_fill_type(Eolian_Typedef *type_def)
-{
-   return database_type_add(type_def);
-}
-
-static Eina_Bool
-_db_fill_struct(Eolian_Type *struct_def)
-{
-   return database_struct_add(struct_def);
-}
-
 Eina_Bool
 eo_parser_database_fill(const char *filename, Eina_Bool eot)
 {
@@ -470,21 +458,21 @@ nodeloop:
                goto error;
              break;
            case NODE_TYPEDEF:
-             {
-                Eolian_Typedef *def = nd->def_typedef;
-                nd->def_typedef = NULL;
-                if (!_db_fill_type(def))
+             if (!database_type_add(nd->def_typedef))
+               {
+                  ERR("Redefinition of typedef %s\n", nd->def_typedef->alias);
                   goto error;
-                break;
-             }
+               }
+             nd->def_typedef = NULL;
+             break;
            case NODE_STRUCT:
-             {
-                Eolian_Type *def = nd->def_struct;
-                nd->def_struct = NULL;
-                if (!_db_fill_struct(def))
+             if (!database_struct_add(nd->def_struct))
+               {
+                  ERR("Redefinition of struct %s\n", nd->def_struct->name);
                   goto error;
-                break;
-             }
+               }
+             nd->def_struct = NULL;
+             break;
            default:
              break;
           }
index da5a176..187185c 100644 (file)
@@ -36,22 +36,18 @@ database_typedef_del(Eolian_Typedef *def)
 Eina_Bool
 database_type_add(Eolian_Typedef *def)
 {
-   if (_types)
-     {
-        eina_hash_set(_types, def->alias, def);
-        return EINA_TRUE;
-     }
-   return EINA_FALSE;
+   if (!_types) return EINA_FALSE;
+   if (eina_hash_find(_types, def->alias)) return EINA_FALSE;
+   eina_hash_set(_types, def->alias, def);
+   return EINA_TRUE;
 }
 
 Eina_Bool database_struct_add(Eolian_Type *tp)
 {
-   if (_structs)
-     {
-        eina_hash_set(_structs, tp->name, tp);
-        return EINA_TRUE;
-     }
-   return EINA_FALSE;
+   if (!_structs) return EINA_FALSE;
+   if (eina_hash_find(_structs, tp->name)) return EINA_FALSE;
+   eina_hash_set(_structs, tp->name, tp);
+   return EINA_TRUE;
 }
 
 static void