eolian: simplify eolian_eo_file_parse

This also moves the ctor stuff into database_fill,
saving some loops when a class is already parsed.
This commit is contained in:
Daniel Kolesa 2015-05-22 16:53:21 +01:00
parent b339313e4b
commit 1ffdcda292
2 changed files with 38 additions and 47 deletions

View File

@ -212,6 +212,9 @@ _db_fill_class(Eolian_Class *cl)
Eina_Bool
eo_parser_database_fill(const char *filename, Eina_Bool eot)
{
Eolian_Constructor *ctor;
Eolian_Implement *impl;
Eina_Iterator *itr;
Eolian_Class *cl;
Eo_Lexer *ls;
@ -245,6 +248,36 @@ eo_parser_database_fill(const char *filename, Eina_Bool eot)
if (!_db_fill_class(cl))
goto error;
itr = eolian_class_implements_get(cl);
EINA_ITERATOR_FOREACH(itr, impl)
{
Eolian_Function_Type impl_type = EOLIAN_UNRESOLVED;
const Eolian_Function *impl_func = eolian_implement_function_get(impl, &impl_type);
if (!impl_func)
{
fprintf(stderr, "eolian: unable to find function '%s'\n",
eolian_implement_full_name_get(impl));
goto error;
}
else if (eolian_function_is_constructor(impl->foo_id, impl->klass))
database_function_constructor_add((Eolian_Function*)impl->foo_id, cl);
}
eina_iterator_free(itr);
itr = eolian_class_constructors_get(cl);
EINA_ITERATOR_FOREACH(itr, ctor)
{
const Eolian_Function *ctor_func = eolian_constructor_function_get(ctor);
if (!ctor_func)
{
fprintf(stderr, "eolian: unable to find function '%s'\n",
eolian_constructor_full_name_get(ctor));
goto error;
}
else
database_function_constructor_add((Eolian_Function*)ctor_func, ctor->klass);
}
eina_iterator_free(itr);
done:
if (eot)
eina_hash_set(_parsedeots, filename, (void *)EINA_TRUE);

View File

@ -216,61 +216,19 @@ eolian_eot_file_parse(const char *filepath)
EAPI Eina_Bool
eolian_eo_file_parse(const char *filepath)
{
Eina_Iterator *itr;
char *bfiledup, *bfilename;
if (_database_init_count <= 0)
return EINA_FALSE;
char *bfiledup = strdup(filepath);
char *bfilename = basename(bfiledup);
const Eolian_Class *class = eolian_class_get_by_file(bfilename);
Eolian_Implement *impl;
Eolian_Constructor *ctor;
if (!class)
{
if (!eo_parser_database_fill(filepath, EINA_FALSE))
{
free(bfiledup);
goto error;
}
class = eolian_class_get_by_file(bfilename);
}
else
bfiledup = strdup(filepath);
bfilename = basename(bfiledup);
if (!eolian_class_get_by_file(bfilename) && !eo_parser_database_fill(filepath, EINA_FALSE))
{
free(bfiledup);
return EINA_TRUE;
goto error;
}
free(bfiledup);
itr = eolian_class_implements_get(class);
EINA_ITERATOR_FOREACH(itr, impl)
{
Eolian_Function_Type impl_type = EOLIAN_UNRESOLVED;
const Eolian_Function *impl_func = eolian_implement_function_get(impl, &impl_type);
if (!impl_func)
{
fprintf(stderr, "eolian: unable to find function '%s'\n",
eolian_implement_full_name_get(impl));
goto error;
}
else if (eolian_function_is_constructor(impl->foo_id, impl->klass))
database_function_constructor_add((Eolian_Function*)impl->foo_id, class);
}
eina_iterator_free(itr);
itr = eolian_class_constructors_get(class);
EINA_ITERATOR_FOREACH(itr, ctor)
{
const Eolian_Function *ctor_func = eolian_constructor_function_get(ctor);
if (!ctor_func)
{
fprintf(stderr, "eolian: unable to find function '%s'\n",
eolian_constructor_full_name_get(ctor));
goto error;
}
else
database_function_constructor_add((Eolian_Function*)ctor_func, ctor->klass);
}
eina_iterator_free(itr);
return EINA_TRUE;
error: