eolian: merge eo_file_parse and eot_file_parse

This commit is contained in:
Daniel Kolesa 2015-05-22 17:32:21 +01:00
parent d559952117
commit a7dea04b26
8 changed files with 40 additions and 68 deletions

View File

@ -397,14 +397,7 @@ int main(int argc, char **argv)
is_eo = eina_str_has_suffix(eo_filename, EO_SUFFIX);
if (!is_eo && !eina_str_has_suffix(eo_filename, EOT_SUFFIX))
{
ERR("The input file %s doesn't have a correct extension (.eo/.eot).\n", eo_filename);
goto end;
}
if ((is_eo && !eolian_eo_file_parse(eo_filename)) ||
(!is_eo && !eolian_eot_file_parse(eo_filename)))
if (!eolian_file_parse(eo_filename))
{
ERR("Error during parsing file %s\n", eo_filename);
goto end;

View File

@ -230,7 +230,7 @@ database_load(options_type const& opts)
}
if (!opts.in_file.empty())
{
if (!::eolian_eo_file_parse(opts.in_file.c_str()))
if (!::eolian_file_parse(opts.in_file.c_str()))
{
EINA_CXX_DOM_LOG_ERR(eolian_cxx::domain)
<< "Failed parsing: " << opts.in_file << ".";

View File

@ -166,8 +166,7 @@ ffi.cdef [[
EOLIAN_UNOP_BNOT, /* ~ int */
} Eolian_Unary_Operator;
Eina_Bool eolian_eo_file_parse(const char *filename);
Eina_Bool eolian_eot_file_parse(const char *filepath);
Eina_Bool eolian_file_parse(const char *filepath);
Eina_Iterator *eolian_all_eo_file_paths_get(void);
Eina_Iterator *eolian_all_eot_file_paths_get(void);
Eina_Iterator *eolian_all_eo_files_get(void);
@ -358,12 +357,12 @@ M.system_directory_scan = function()
return eolian.eolian_system_directory_scan() ~= 0
end
M.all_eo_files_parse = function()
return eolian.eolian_all_eo_files_parse() ~= 0
M.file_parse = function(fpath)
return eolian.eolian_file_parse(fpath) ~= 0
end
M.eo_file_parse = function(fname)
return eolian.eolian_eo_file_parse(fname) ~= 0
M.all_eo_files_parse = function()
return eolian.eolian_all_eo_files_parse() ~= 0
end
M.all_eot_files_parse = function()
@ -390,10 +389,6 @@ M.database_validate = function()
return eolian.eolian_database_validate() ~= 0
end
M.eot_file_parse = function(fname)
return eolian.eolian_eot_file_parse(fname) ~= 0
end
M.show_class = function(klass)
return eolian.eolian_show_class(klass) ~= 0
end

View File

@ -303,27 +303,13 @@ typedef enum
} Eolian_Unary_Operator;
/*
* @brief Parse a given .eo file and fill the database.
* @brief Parse the given .eo or .eot file and fill the database.
*
* During parsing, the class described into the .eo file is created with
* all the information related to this class.
*
* @param[in] filename Name of the file to parse.
* @see eolian_eot_file_parse
* @param[in] filepath Path to the file to parse.
*
* @ingroup Eolian
*/
EAPI Eina_Bool eolian_eo_file_parse(const char *filename);
/*
* @brief Parse a given .eot file and fill the database.
*
* @param[in] filename Name of the file to parse.
* @see eolian_eo_file_parse
*
* @ingroup Eolian
*/
EAPI Eina_Bool eolian_eot_file_parse(const char *filepath);
EAPI Eina_Bool eolian_file_parse(const char *filepath);
/*
* @brief Get an iterator to all .eo file names with paths.

View File

@ -676,7 +676,7 @@ _parse_dep(Eo_Lexer *ls, const char *fname, const char *name)
snprintf(buf, sizeof(buf), "cyclic dependency '%s'", name);
eo_lexer_syntax_error(ls, buf);
}
if (!eolian_eo_file_parse(fname))
if (!eo_parser_database_fill(fname, EINA_FALSE))
{
char buf[PATH_MAX];
eo_lexer_context_restore(ls);

View File

@ -206,25 +206,24 @@ database_class_name_validate(const char *class_name, const Eolian_Class **cl)
}
EAPI Eina_Bool
eolian_eot_file_parse(const char *filepath)
eolian_file_parse(const char *filepath)
{
Eina_Bool is_eo;
if (_database_init_count <= 0)
return EINA_FALSE;
return eo_parser_database_fill(filepath, EINA_TRUE);
}
EAPI Eina_Bool
eolian_eo_file_parse(const char *filepath)
{
if (_database_init_count <= 0)
return EINA_FALSE;
return eo_parser_database_fill(filepath, EINA_FALSE);
is_eo = eina_str_has_suffix(filepath, EO_SUFFIX);
if (!is_eo && !eina_str_has_suffix(filepath, EOT_SUFFIX))
{
fprintf(stderr, "eolian: file '%s' doesn't have a correct extension\n", filepath);
return EINA_FALSE;
}
return eo_parser_database_fill(filepath, !is_eo);
}
static Eina_Bool _tfile_parse(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED, void *data, void *fdata)
{
Eina_Bool *ret = fdata;
if (*ret) *ret = eolian_eot_file_parse(data);
if (*ret) *ret = eo_parser_database_fill(data, EINA_TRUE);
return *ret;
}
@ -243,7 +242,7 @@ eolian_all_eot_files_parse()
static Eina_Bool _file_parse(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED, void *data, void *fdata)
{
Eina_Bool *ret = fdata;
if (*ret) *ret = eolian_eo_file_parse(data);
if (*ret) *ret = eo_parser_database_fill(data, EINA_FALSE);
return *ret;
}

View File

@ -689,7 +689,7 @@ M.system_directory_scan = function()
end
M.generate = function(fname, fstream)
if not eolian.eo_file_parse(fname) then
if not eolian.file_parse(fname) then
error("Failed parsing file: " .. fname)
end
if not eolian.database_validate() then

View File

@ -22,7 +22,7 @@ START_TEST(eolian_namespaces)
eolian_init();
/* Parsing */
fail_if(!eolian_directory_scan(PACKAGE_DATA_DIR"/data"));
fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/nmsp1_class1.eo"));
fail_if(!eolian_file_parse(PACKAGE_DATA_DIR"/data/nmsp1_class1.eo"));
/* Classes existence */
fail_if(!(class11 = eolian_class_get_by_name("nmsp1.class1")));
@ -105,7 +105,7 @@ START_TEST(eolian_events)
eolian_init();
/* Parsing */
fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/events.eo"));
fail_if(!eolian_file_parse(PACKAGE_DATA_DIR"/data/events.eo"));
/* Class */
fail_if(!(class = eolian_class_get_by_name("Events")));
@ -151,7 +151,7 @@ START_TEST(eolian_override)
eolian_init();
/* Parsing */
fail_if(!eolian_directory_scan(PACKAGE_DATA_DIR"/data"));
fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/override.eo"));
fail_if(!eolian_file_parse(PACKAGE_DATA_DIR"/data/override.eo"));
/* Class */
fail_if(!(class = eolian_class_get_by_name("Override")));
@ -257,12 +257,11 @@ END_TEST
START_TEST(eolian_consts)
{
const Eolian_Function *fid = NULL;
const Eolian_Function_Parameter *param = NULL;
const Eolian_Class *class;
eolian_init();
/* Parsing */
fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/consts.eo"));
fail_if(!eolian_file_parse(PACKAGE_DATA_DIR"/data/consts.eo"));
fail_if(!(class = eolian_class_get_by_name("Consts")));
/* Method */
@ -286,7 +285,7 @@ START_TEST(eolian_ctor_dtor)
eolian_init();
/* Parsing */
fail_if(!eolian_directory_scan(PACKAGE_DATA_DIR"/data"));
fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/ctor_dtor.eo"));
fail_if(!eolian_file_parse(PACKAGE_DATA_DIR"/data/ctor_dtor.eo"));
fail_if(!(class = eolian_class_get_by_name("Ctor_Dtor")));
fail_if(!(base = eolian_class_get_by_name("Base")));
@ -348,7 +347,7 @@ START_TEST(eolian_typedef)
eolian_init();
/* Parsing */
fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/typedef.eo"));
fail_if(!eolian_file_parse(PACKAGE_DATA_DIR"/data/typedef.eo"));
/* Check that the class Dummy is still readable */
fail_if(!(class = eolian_class_get_by_name("Typedef")));
@ -417,7 +416,7 @@ START_TEST(eolian_complex_type)
eolian_init();
/* Parsing */
fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/complex_type.eo"));
fail_if(!eolian_file_parse(PACKAGE_DATA_DIR"/data/complex_type.eo"));
fail_if(!(class = eolian_class_get_by_name("Complex_Type")));
/* Properties return type */
@ -501,7 +500,7 @@ START_TEST(eolian_scope)
eolian_init();
/* Parsing */
fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/scope.eo"));
fail_if(!eolian_file_parse(PACKAGE_DATA_DIR"/data/scope.eo"));
fail_if(!(class = eolian_class_get_by_name("Scope")));
/* Property scope */
@ -538,7 +537,7 @@ START_TEST(eolian_simple_parsing)
eolian_init();
/* Parsing */
fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/class_simple.eo"));
fail_if(!eolian_file_parse(PACKAGE_DATA_DIR"/data/class_simple.eo"));
fail_if(!(class = eolian_class_get_by_name("Class_Simple")));
fail_if(eolian_class_get_by_file("class_simple.eo") != class);
fail_if(strcmp(eolian_class_file_get(class), "class_simple.eo"));
@ -679,7 +678,7 @@ START_TEST(eolian_struct)
eolian_init();
/* Parsing */
fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/struct.eo"));
fail_if(!eolian_file_parse(PACKAGE_DATA_DIR"/data/struct.eo"));
/* Check that the class Dummy is still readable */
fail_if(!(class = eolian_class_get_by_name("Struct")));
@ -735,7 +734,7 @@ START_TEST(eolian_extern)
eolian_init();
/* Parsing */
fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/extern.eo"));
fail_if(!eolian_file_parse(PACKAGE_DATA_DIR"/data/extern.eo"));
/* Check that the class Dummy is still readable */
fail_if(!(class = eolian_class_get_by_name("Extern")));
@ -773,7 +772,7 @@ START_TEST(eolian_var)
eolian_init();
/* Parsing */
fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/var.eo"));
fail_if(!eolian_file_parse(PACKAGE_DATA_DIR"/data/var.eo"));
/* Check that the class Dummy is still readable */
fail_if(!(class = eolian_class_get_by_name("Var")));
@ -839,7 +838,7 @@ START_TEST(eolian_enum)
eolian_init();
/* Parsing */
fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/enum.eo"));
fail_if(!eolian_file_parse(PACKAGE_DATA_DIR"/data/enum.eo"));
/* Check that the class Dummy is still readable */
fail_if(!(class = eolian_class_get_by_name("Enum")));
@ -931,7 +930,7 @@ START_TEST(eolian_class_funcs)
eolian_init();
/* Parsing */
fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/class_funcs.eo"));
fail_if(!eolian_file_parse(PACKAGE_DATA_DIR"/data/class_funcs.eo"));
fail_if(!(class = eolian_class_get_by_name("Class_Funcs")));
/* Class properties */
@ -966,7 +965,7 @@ START_TEST(eolian_free_func)
eolian_init();
/* Parsing */
fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/free_func.eo"));
fail_if(!eolian_file_parse(PACKAGE_DATA_DIR"/data/free_func.eo"));
/* Check that the class Dummy is still readable */
fail_if(!(class = eolian_class_get_by_name("Free_Func")));
@ -1012,7 +1011,7 @@ START_TEST(eolian_null)
eolian_init();
/* Parsing */
fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/null.eo"));
fail_if(!eolian_file_parse(PACKAGE_DATA_DIR"/data/null.eo"));
fail_if(!(class = eolian_class_get_by_name("Null")));
fail_if(!(func = eolian_class_function_get_by_name(class, "foo", EOLIAN_METHOD)));
@ -1059,7 +1058,7 @@ START_TEST(eolian_import)
fail_if(!eolian_directory_scan(PACKAGE_DATA_DIR"/data"));
fail_if(!eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/import.eo"));
fail_if(!eolian_file_parse(PACKAGE_DATA_DIR"/data/import.eo"));
fail_if(!(class = eolian_class_get_by_name("Import")));
fail_if(!(type = eolian_type_alias_get_by_name("Imported")));