eolian: simplify parsed checking

This commit is contained in:
Daniel Kolesa 2018-01-31 19:06:37 +01:00
parent f0877c9329
commit 8b1f2f34b4
3 changed files with 9 additions and 12 deletions

View File

@ -2243,13 +2243,11 @@ parse_chunk(Eo_Lexer *ls, Eina_Bool eot)
}
Eolian_Unit *
eo_parser_database_fill(Eolian_Unit *parent, const char *filename, Eina_Bool eot, Eolian_Class **fcl)
eo_parser_database_fill(Eolian_Unit *parent, const char *filename, Eina_Bool eot)
{
Eolian_Unit *ret = NULL;
Eolian_Class *cl = eina_hash_find(parent->state->parsed, filename);
if (cl)
if (eina_hash_find(parent->state->parsed, filename))
{
if (!eot && fcl) *fcl = cl;
const char *fsl = strrchr(filename, '/');
const char *bsl = strrchr(filename, '\\');
const char *fname = NULL;
@ -2280,6 +2278,7 @@ eo_parser_database_fill(Eolian_Unit *parent, const char *filename, Eina_Bool eot
parse_chunk(ls, eot);
if (eot) goto done;
Eolian_Class *cl;
if (!(cl = ls->tmp.kls))
{
_eolian_log("eolian: no class for file '%s'", filename);
@ -2291,11 +2290,9 @@ eo_parser_database_fill(Eolian_Unit *parent, const char *filename, Eina_Bool eot
eina_hash_set(ls->state->classes_f, cl->base.file, cl);
eolian_object_ref(&cl->base);
if (fcl) *fcl = cl;
done:
ret = ls->unit;
eina_hash_set(ls->state->parsed, filename, eot ? (void *)EINA_TRUE : cl);
eina_hash_set(ls->state->parsed, filename, (void *)EINA_TRUE);
eina_hash_add(parent->children, filename, ret);
eo_lexer_free(ls);

View File

@ -3,6 +3,6 @@
#include "eo_lexer.h"
Eolian_Unit *eo_parser_database_fill(Eolian_Unit *parent, const char *filename, Eina_Bool eot, Eolian_Class **cl);
Eolian_Unit *eo_parser_database_fill(Eolian_Unit *parent, const char *filename, Eina_Bool eot);
#endif /* __EO_PARSER_H__ */

View File

@ -673,11 +673,11 @@ _eolian_file_parse_nodep(Eolian_Unit *parent, const char *filepath)
if (!(eopath = eina_hash_find(is_eo ? parent->state->filenames_eo : parent->state->filenames_eot, filepath)))
{
char *vpath = eina_file_path_sanitize(filepath);
Eolian_Unit *ret = eo_parser_database_fill(parent, vpath, !is_eo, NULL);
Eolian_Unit *ret = eo_parser_database_fill(parent, vpath, !is_eo);
free(vpath);
return ret;
}
return eo_parser_database_fill(parent, eopath, !is_eo, NULL);
return eo_parser_database_fill(parent, eopath, !is_eo);
}
static Eina_Bool
@ -734,7 +734,7 @@ static Eina_Bool _tfile_parse(const Eina_Hash *hash EINA_UNUSED, const void *key
Parse_Data *pd = fdata;
Eolian_Unit *unit = NULL;
if (pd->ret)
unit = eo_parser_database_fill((Eolian_Unit *)pd->state, data, EINA_TRUE, NULL);
unit = eo_parser_database_fill((Eolian_Unit *)pd->state, data, EINA_TRUE);
pd->ret = !!unit;
if (pd->ret) pd->ret = _parse_deferred(unit);
return pd->ret;
@ -762,7 +762,7 @@ static Eina_Bool _file_parse(const Eina_Hash *hash EINA_UNUSED, const void *key
Parse_Data *pd = fdata;
Eolian_Unit *unit = NULL;
if (pd->ret)
unit = eo_parser_database_fill((Eolian_Unit *)pd->state, data, EINA_FALSE, NULL);
unit = eo_parser_database_fill((Eolian_Unit *)pd->state, data, EINA_FALSE);
pd->ret = !!unit;
if (pd->ret) pd->ret = _parse_deferred(unit);
return pd->ret;