eolian: make eolian_file_parse return unit
authorDaniel Kolesa <d.kolesa@osg.samsung.com>
Tue, 16 May 2017 14:13:15 +0000 (16:13 +0200)
committerDaniel Kolesa <d.kolesa@osg.samsung.com>
Tue, 30 May 2017 15:15:53 +0000 (17:15 +0200)
src/bindings/luajit/eolian.lua
src/lib/eolian/Eolian.h
src/lib/eolian/eolian_database.c
src/scripts/elua/modules/lualian.lua

index 0079928..d98e047 100644 (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()
index e882f2e..630b0b4 100644 (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.
index b86b115..afd52df 100644 (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)
index f04779f..e8e6af5 100644 (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