eolian: use just filename (not path) for eolian_class_get_by_file

This commit is contained in:
Daniel Kolesa 2014-07-23 17:15:00 +01:00
parent 68282f8c42
commit 315d5de11d
8 changed files with 33 additions and 18 deletions

View File

@ -327,7 +327,9 @@ int main(int argc, char **argv)
{
EINA_LIST_FOREACH(files4gen, itr, filename)
{
class = eolian_class_get_by_file(filename);
char *bn = eina_file_path_basename(filename, NULL);
class = eolian_class_get_by_file(bn);
free(bn);
if (class) eolian_show_class(class);
}
}
@ -338,7 +340,9 @@ int main(int argc, char **argv)
goto end;
}
class = eolian_class_get_by_file(eina_list_data_get(files4gen));
char *bn = eina_file_path_basename(eina_list_data_get(files4gen), NULL);
class = eolian_class_get_by_file(bn);
free(bn);
if (gen_opt)
{

View File

@ -30,7 +30,10 @@ ctor_t const ctor = {};
inline const Eolian_Class*
class_from_file(std::string const& file)
{
return ::eolian_class_get_by_file(file.c_str());
char *bn = eina_file_path_basename(file.c_str(), NULL);
const Eolian_Class *cl = ::eolian_class_get_by_file(bn);
free(bn);
return cl;
}
inline std::string

View File

@ -297,9 +297,9 @@ EAPI void eolian_show_all();
EAPI const Eolian_Class *eolian_class_get_by_name(const char *class_name);
/*
* @brief Gets a class by its location (.eo file)
* @brief Gets a class by its filename (name.eo)
*
* @param[in] file_name filename where the class is stored.
* @param[in] file_name the filename
* @return the class stored in the file
*
* @ingroup Eolian

View File

@ -370,13 +370,13 @@ _db_fill_events(Eolian_Class *cl, Eo_Class_Def *kls)
}
static Eina_Bool
_db_fill_class(Eo_Class_Def *kls, const char *filename)
_db_fill_class(Eo_Class_Def *kls)
{
Eolian_Class *cl = database_class_add(kls->name, kls->type);
const char *s;
Eina_List *l;
database_class_file_set(cl, filename);
database_class_file_set(cl, kls->file);
if (kls->comment)
{
@ -453,7 +453,7 @@ eo_parser_database_fill(const char *filename, Eina_Bool eot)
switch (nd->type)
{
case NODE_CLASS:
if (!_db_fill_class(nd->def_class, filename))
if (!_db_fill_class(nd->def_class))
goto error;
break;
default:

View File

@ -100,6 +100,8 @@ eo_definitions_class_def_free(Eo_Class_Def *kls)
if (kls->name)
eina_stringshare_del(kls->name);
if (kls->file)
eina_stringshare_del(kls->file);
if (kls->comment)
eina_stringshare_del(kls->comment);
if (kls->legacy_prefix)

View File

@ -79,6 +79,7 @@ typedef struct _Eo_Method_Def
typedef struct _Eo_Class_Def
{
Eina_Stringshare *name;
Eina_Stringshare *file;
Eolian_Class_Type type;
Eina_Stringshare *comment;
Eina_Stringshare *legacy_prefix;

View File

@ -126,12 +126,9 @@ append_node(Eo_Lexer *ls, int type, void *def)
static const char *
get_filename(Eo_Lexer *ls)
{
char *s = strdup(ls->source);
Eina_Array *arr = eina_file_split(s);
const char *file = eina_stringshare_add(eina_array_data_get(arr,
eina_array_count_get(arr) - 1));
char *s = eina_file_path_basename(ls->source, NULL);
const char *file = eina_stringshare_add(s);
free(s);
eina_array_free(arr);
return file;
}
@ -1131,6 +1128,7 @@ parse_class(Eo_Lexer *ls, Eina_Bool allow_ctors, Eolian_Class_Type type)
parse_name(ls, buf);
ls->tmp.kls->name = eina_stringshare_add(eina_strbuf_string_get(buf));
pop_strbuf(ls);
ls->tmp.kls->file = get_filename(ls);
if (ls->t.token != '{')
{
line = ls->line_number;

View File

@ -133,19 +133,26 @@ EAPI Eina_Bool
eolian_eo_file_parse(const char *filepath)
{
Eina_Iterator *itr;
const Eolian_Class *class = eolian_class_get_by_file(filepath);
char *bfilename = eina_file_path_basename(filepath, NULL);
const Eolian_Class *class = eolian_class_get_by_file(bfilename);
const char *inherit_name;
Eolian_Implement *impl;
if (!class)
{
if (!eo_parser_database_fill(filepath, EINA_FALSE)) return EINA_FALSE;
class = eolian_class_get_by_file(filepath);
if (!eo_parser_database_fill(filepath, EINA_FALSE))
{
free(bfilename);
return EINA_FALSE;
}
class = eolian_class_get_by_file(bfilename);
if (!class)
{
ERR("No class for file %s", filepath);
ERR("No class for file %s", bfilename);
free(bfilename);
return EINA_FALSE;
}
}
free(bfilename);
itr = eolian_class_inherits_get(class);
EINA_ITERATOR_FOREACH(itr, inherit_name)
{
@ -153,6 +160,7 @@ eolian_eo_file_parse(const char *filepath)
{
char *filename = _eolian_class_to_filename(inherit_name);
filepath = eina_hash_find(_filenames, filename);
free(filename);
if (!filepath)
{
ERR("Unable to find a file for class %s", inherit_name);
@ -164,7 +172,6 @@ eolian_eo_file_parse(const char *filepath)
ERR("Unable to find class %s", inherit_name);
return EINA_FALSE;
}
free(filename);
}
}
eina_iterator_free(itr);