eolian: turn db validation into separate API
This commit is contained in:
parent
c1afa1b6b5
commit
cdd4860520
|
@ -677,6 +677,9 @@ M.generate = function(fname, libname, fstream)
|
||||||
if not eolian.eo_file_parse(fname) then
|
if not eolian.eo_file_parse(fname) then
|
||||||
error("Failed parsing file: " .. fname)
|
error("Failed parsing file: " .. fname)
|
||||||
end
|
end
|
||||||
|
if not eolian.database_validate() then
|
||||||
|
error("Failed validating database.")
|
||||||
|
end
|
||||||
local sfn = fname:match(".*[\\/](.+)$") or fname
|
local sfn = fname:match(".*[\\/](.+)$") or fname
|
||||||
local klass = eolian.class_get_by_file(sfn)
|
local klass = eolian.class_get_by_file(sfn)
|
||||||
local tp = klass:type_get()
|
local tp = klass:type_get()
|
||||||
|
|
|
@ -358,6 +358,12 @@ int main(int argc, char **argv)
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!eolian_database_validate())
|
||||||
|
{
|
||||||
|
ERR("Error validating database.\n");
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
eo_filename_copy = strdup(eo_filename);
|
eo_filename_copy = strdup(eo_filename);
|
||||||
eo_file_basename = basename(eo_filename_copy);
|
eo_file_basename = basename(eo_filename_copy);
|
||||||
if (show)
|
if (show)
|
||||||
|
|
|
@ -219,6 +219,12 @@ database_load(options_type const& opts)
|
||||||
<< "Eolian failed parsing input files";
|
<< "Eolian failed parsing input files";
|
||||||
assert(false && "Error parsing input files");
|
assert(false && "Error parsing input files");
|
||||||
}
|
}
|
||||||
|
if (!::eolian_database_validate())
|
||||||
|
{
|
||||||
|
EINA_CXX_DOM_LOG_ERR(eolian_cxx::domain)
|
||||||
|
<< "Eolian failed validating database.";
|
||||||
|
assert(false && "Error validating database");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace eolian_cxx {
|
} // namespace eolian_cxx {
|
||||||
|
|
|
@ -138,6 +138,7 @@ ffi.cdef [[
|
||||||
Eina_Bool eolian_system_directory_scan();
|
Eina_Bool eolian_system_directory_scan();
|
||||||
Eina_Bool eolian_all_eo_files_parse();
|
Eina_Bool eolian_all_eo_files_parse();
|
||||||
Eina_Bool eolian_all_eot_files_parse();
|
Eina_Bool eolian_all_eot_files_parse();
|
||||||
|
Eina_Bool eolian_database_validate(void);
|
||||||
Eina_Bool eolian_show_class(const Eolian_Class *klass);
|
Eina_Bool eolian_show_class(const Eolian_Class *klass);
|
||||||
Eina_Bool eolian_show_typedef(const char *alias);
|
Eina_Bool eolian_show_typedef(const char *alias);
|
||||||
Eina_Bool eolian_show_struct(const char *name);
|
Eina_Bool eolian_show_struct(const char *name);
|
||||||
|
@ -304,6 +305,10 @@ M.all_eot_files_parse = function()
|
||||||
return eolian.eolian_all_eot_files_parse() ~= 0
|
return eolian.eolian_all_eot_files_parse() ~= 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
M.database_validate = function()
|
||||||
|
return eolian.eolian_databasE_validate() ~= 0
|
||||||
|
end
|
||||||
|
|
||||||
M.eot_file_parse = function(fname)
|
M.eot_file_parse = function(fname)
|
||||||
return eolian.eolian_eot_file_parse(fname) ~= 0
|
return eolian.eolian_eot_file_parse(fname) ~= 0
|
||||||
end
|
end
|
||||||
|
|
|
@ -290,6 +290,17 @@ EAPI Eina_Bool eolian_all_eo_files_parse();
|
||||||
*/
|
*/
|
||||||
EAPI Eina_Bool eolian_all_eot_files_parse();
|
EAPI Eina_Bool eolian_all_eot_files_parse();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief Validates the database, printing errors and warnings.
|
||||||
|
*
|
||||||
|
* @return EINA_TRUE on success, EINA_FALSE otherwise.
|
||||||
|
*
|
||||||
|
* Useful to catch type errors etc. early on.
|
||||||
|
*
|
||||||
|
* @ingroup Eolian
|
||||||
|
*/
|
||||||
|
EAPI Eina_Bool eolian_database_validate(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @brief Show information about a given class.
|
* @brief Show information about a given class.
|
||||||
*
|
*
|
||||||
|
|
|
@ -19,7 +19,6 @@ Eina_Hash *_filenames = NULL;
|
||||||
Eina_Hash *_tfilenames = NULL;
|
Eina_Hash *_tfilenames = NULL;
|
||||||
|
|
||||||
static int _database_init_count = 0;
|
static int _database_init_count = 0;
|
||||||
static int _parse_depth = 0;
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_hashlist_free(void *data)
|
_hashlist_free(void *data)
|
||||||
|
@ -160,7 +159,6 @@ eolian_eo_file_parse(const char *filepath)
|
||||||
const Eolian_Class *class = eolian_class_get_by_file(bfilename);
|
const Eolian_Class *class = eolian_class_get_by_file(bfilename);
|
||||||
const char *inherit_name;
|
const char *inherit_name;
|
||||||
Eolian_Implement *impl;
|
Eolian_Implement *impl;
|
||||||
++_parse_depth;
|
|
||||||
if (!class)
|
if (!class)
|
||||||
{
|
{
|
||||||
if (!eo_parser_database_fill(filepath, EINA_FALSE))
|
if (!eo_parser_database_fill(filepath, EINA_FALSE))
|
||||||
|
@ -207,15 +205,9 @@ eolian_eo_file_parse(const char *filepath)
|
||||||
}
|
}
|
||||||
eina_iterator_free(itr);
|
eina_iterator_free(itr);
|
||||||
|
|
||||||
--_parse_depth;
|
|
||||||
if (!_parse_depth && !database_validate())
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
_parse_depth = 0;
|
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
_parse_depth = 0;
|
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,3 +241,8 @@ eolian_all_eo_files_parse()
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EAPI Eina_Bool
|
||||||
|
eolian_database_validate(void)
|
||||||
|
{
|
||||||
|
return database_validate();
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue