eolian: make eolian_file_parse return unit

This commit is contained in:
Daniel Kolesa 2017-05-16 16:13:15 +02:00
parent 91411c5389
commit 7da0549970
4 changed files with 12 additions and 9 deletions

View File

@ -28,6 +28,7 @@ ffi.cdef [[
typedef struct _Eolian_Declaration Eolian_Declaration;
typedef struct _Eolian_Documentation Eolian_Documentation;
typedef struct _Eolian_Value Eolian_Value;
typedef struct _Eolian_Unit Eolian_Unit;
typedef enum
{
@ -217,7 +218,7 @@ ffi.cdef [[
const char *text, *text_end;
} Eolian_Doc_Token;
Eina_Bool eolian_file_parse(const char *filepath);
const Eolian_Unit *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);
@ -448,7 +449,7 @@ M.system_directory_scan = function()
end
M.file_parse = function(fpath)
return eolian.eolian_file_parse(fpath) ~= 0
return eolian.eolian_file_parse(fpath)
end
M.all_eo_files_parse = function()

View File

@ -384,13 +384,13 @@ typedef struct _Eolian_Doc_Token
* If it's a filename, it must be scanned for first.
*
* @param[in] filepath Path to the file to parse.
* @return EINA_TRUE on success, EINA_FALSE on failure.
* @return The unit corresponding to the parsed file or NULL.
*
* @see eolian_directory_scan
*
* @ingroup Eolian
*/
EAPI Eina_Bool eolian_file_parse(const char *filepath);
EAPI const Eolian_Unit *eolian_file_parse(const char *filepath);
/*
* @brief Get an iterator to all .eo file names with paths.

View File

@ -687,12 +687,14 @@ _eolian_file_parse_nodep(const char *filepath)
return eo_parser_database_fill(eopath, !is_eo);
}
EAPI Eina_Bool
static Eolian_Unit unit_tmp;
EAPI const Eolian_Unit *
eolian_file_parse(const char *filepath)
{
const char *dep;
if (!_eolian_file_parse_nodep(filepath))
return EINA_FALSE;
return NULL;
/* parse doc dependencies (deferred eo files) */
Eina_Iterator *itr = eina_hash_iterator_data_new(_defereos);
EINA_ITERATOR_FOREACH(itr, dep)
@ -701,12 +703,12 @@ eolian_file_parse(const char *filepath)
{
eina_iterator_free(itr);
eina_hash_free_buckets(_defereos);
return EINA_FALSE;
return NULL;
}
}
eina_iterator_free(itr);
eina_hash_free_buckets(_defereos);
return EINA_TRUE;
return &unit_tmp;
}
static Eina_Bool _tfile_parse(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED, void *data, void *fdata)

View File

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