davemds pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=d176a37f32b47208aea57bb7fdf9934c4287d25a
commit d176a37f32b47208aea57bb7fdf9934c4287d25a Author: Dave Andreoli <[email protected]> Date: Wed Feb 28 14:18:45 2018 +0100 Pyolian: add APIs to retrieve units from a state Also fixed a declaration error from previous commit --- src/scripts/pyolian/eolian.py | 8 ++++++++ src/scripts/pyolian/eolian_lib.py | 12 ++++++++++-- src/scripts/pyolian/test_eolian.py | 19 +++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/scripts/pyolian/eolian.py b/src/scripts/pyolian/eolian.py index 6a5cdb0cfe..0243a7f1bb 100644 --- a/src/scripts/pyolian/eolian.py +++ b/src/scripts/pyolian/eolian.py @@ -483,6 +483,14 @@ class Eolian_State(Eolian_Unit): def all_eot_files_parse(self): return bool(lib.eolian_state_all_eot_files_parse(self._obj)) + def unit_by_file_get(self, file_name): + c_unit = lib.eolian_state_unit_by_file_get(self._obj, _str_to_bytes(file_name)) + return Eolian_Unit(c_unit) if c_unit else None + + @property + def units(self): + return Iterator(Eolian_Unit, lib.eolian_state_units_get(self._obj)) + ### Namespace Utility Class ################################################# diff --git a/src/scripts/pyolian/eolian_lib.py b/src/scripts/pyolian/eolian_lib.py index 5f45c0c73d..e86929e773 100644 --- a/src/scripts/pyolian/eolian_lib.py +++ b/src/scripts/pyolian/eolian_lib.py @@ -85,6 +85,14 @@ lib.eolian_state_all_eo_files_parse.restype = c_bool lib.eolian_state_all_eot_files_parse.argtypes = [c_void_p,] lib.eolian_state_all_eot_files_parse.restype = c_bool +# EAPI const Eolian_Unit *eolian_state_unit_by_file_get(const Eolian_State *state, const char *file_name); +lib.eolian_state_unit_by_file_get.argtypes = [c_void_p, c_char_p] +lib.eolian_state_unit_by_file_get.restype = c_void_p + +# EAPI Eina_Iterator *eolian_state_units_get(const Eolian_State *state); +lib.eolian_state_units_get.argtypes = [c_void_p,] +lib.eolian_state_units_get.restype = c_void_p + # EAPI Eina_Iterator *eolian_declarations_get_by_file(const Eolian_State *state, const char *fname); lib.eolian_declarations_get_by_file.argtypes = [c_void_p, c_char_p] lib.eolian_declarations_get_by_file.restype = c_void_p @@ -96,8 +104,8 @@ lib.eolian_unit_children_get.argtypes = [c_void_p,] lib.eolian_unit_children_get.restype = c_void_p # EAPI const char *eolian_unit_file_get(const Eolian_Unit *unit); -lib.eolian_unit_children_get.argtypes = [c_void_p,] -lib.eolian_unit_children_get.restype = c_char_p +lib.eolian_unit_file_get.argtypes = [c_void_p,] +lib.eolian_unit_file_get.restype = c_char_p # EAPI const Eolian_Class *eolian_class_get_by_name(const Eolian_Unit *unit, const char *class_name); lib.eolian_class_get_by_name.argtypes = [c_void_p, c_char_p] diff --git a/src/scripts/pyolian/test_eolian.py b/src/scripts/pyolian/test_eolian.py index f02b782c51..b53ae26caf 100755 --- a/src/scripts/pyolian/test_eolian.py +++ b/src/scripts/pyolian/test_eolian.py @@ -52,7 +52,26 @@ class TestBaseObject(unittest.TestCase): self.assertNotEqual(cls1, enum1) +class TestEolianState(unittest.TestCase): + def test_unit_getters(self): + count = 0 + for unit in eolian_db.units: + self.assertIsInstance(unit, eolian.Eolian_Unit) + self.assertTrue(unit.file.endswith(('.eo', '.eot'))) + count += 1 + self.assertGreater(count, 500) + + unit = eolian_db.unit_by_file_get('efl_ui_win.eo') + self.assertIsInstance(unit, eolian.Eolian_Unit) + self.assertEqual(unit.file, 'efl_ui_win.eo') + + class TestEolianUnit(unittest.TestCase): + def test_file_get(self): + unit = eolian_db.unit_by_file_get('efl_ui_win.eo') + self.assertIsInstance(unit, eolian.Eolian_Unit) + self.assertEqual(unit.file, 'efl_ui_win.eo') + def test_children_listing(self): l = list(eolian_db.children) self.assertGreater(len(l), 500) --
