eolian: check for typedef and struct redefinitions

This commit is contained in:
Daniel Kolesa 2014-07-21 11:22:49 +01:00
parent 9f0bcdf707
commit 9262a82ed3
2 changed files with 20 additions and 36 deletions

View 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;
}

View 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