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; 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 Eina_Bool
eo_parser_database_fill(const char *filename, Eina_Bool eot) eo_parser_database_fill(const char *filename, Eina_Bool eot)
{ {
@ -470,21 +458,21 @@ nodeloop:
goto error; goto error;
break; break;
case NODE_TYPEDEF: case NODE_TYPEDEF:
{ if (!database_type_add(nd->def_typedef))
Eolian_Typedef *def = nd->def_typedef; {
nd->def_typedef = NULL; ERR("Redefinition of typedef %s\n", nd->def_typedef->alias);
if (!_db_fill_type(def))
goto error; goto error;
break; }
} nd->def_typedef = NULL;
break;
case NODE_STRUCT: case NODE_STRUCT:
{ if (!database_struct_add(nd->def_struct))
Eolian_Type *def = nd->def_struct; {
nd->def_struct = NULL; ERR("Redefinition of struct %s\n", nd->def_struct->name);
if (!_db_fill_struct(def))
goto error; goto error;
break; }
} nd->def_struct = NULL;
break;
default: default:
break; break;
} }

View File

@ -36,22 +36,18 @@ database_typedef_del(Eolian_Typedef *def)
Eina_Bool Eina_Bool
database_type_add(Eolian_Typedef *def) database_type_add(Eolian_Typedef *def)
{ {
if (_types) if (!_types) return EINA_FALSE;
{ if (eina_hash_find(_types, def->alias)) return EINA_FALSE;
eina_hash_set(_types, def->alias, def); eina_hash_set(_types, def->alias, def);
return EINA_TRUE; return EINA_TRUE;
}
return EINA_FALSE;
} }
Eina_Bool database_struct_add(Eolian_Type *tp) Eina_Bool database_struct_add(Eolian_Type *tp)
{ {
if (_structs) if (!_structs) return EINA_FALSE;
{ if (eina_hash_find(_structs, tp->name)) return EINA_FALSE;
eina_hash_set(_structs, tp->name, tp); eina_hash_set(_structs, tp->name, tp);
return EINA_TRUE; return EINA_TRUE;
}
return EINA_FALSE;
} }
static void static void