forked from enlightenment/efl
Pyolian: add APIs to retrieve units from a state
Also fixed a declaration error from previous commit
This commit is contained in:
parent
b7de65272f
commit
d176a37f32
|
@ -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 #################################################
|
||||
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue