diff options
author | Dave Andreoli <dave@gurumeditation.it> | 2018-03-17 10:19:28 +0100 |
---|---|---|
committer | Dave Andreoli <dave@gurumeditation.it> | 2018-03-17 10:19:28 +0100 |
commit | 6ef5f30a851d316a845a96cbb195cbf4d53fd58a (patch) | |
tree | 7989421bcd5f642f5c59f8e9e4623c10a9ae36ce /src/scripts | |
parent | 0a00e4cca1252a3d60e1a4257003f0add35ab1fb (diff) |
Pyolian: new API eolian_unit_state_get
Diffstat (limited to 'src/scripts')
-rw-r--r-- | src/scripts/pyolian/eolian.py | 13 | ||||
-rw-r--r-- | src/scripts/pyolian/eolian_lib.py | 4 | ||||
-rwxr-xr-x | src/scripts/pyolian/test_eolian.py | 5 |
3 files changed, 19 insertions, 3 deletions
diff --git a/src/scripts/pyolian/eolian.py b/src/scripts/pyolian/eolian.py index 580cc1f951..ec39443c9f 100644 --- a/src/scripts/pyolian/eolian.py +++ b/src/scripts/pyolian/eolian.py | |||
@@ -319,10 +319,15 @@ class Eolian_Unit(EolianBaseObject): | |||
319 | def children(self): | 319 | def children(self): |
320 | return Iterator(Eolian_Unit, lib.eolian_unit_children_get(self._obj)) | 320 | return Iterator(Eolian_Unit, lib.eolian_unit_children_get(self._obj)) |
321 | 321 | ||
322 | @property | 322 | @cached_property |
323 | def file(self): | 323 | def file(self): |
324 | return _str_to_py(lib.eolian_unit_file_get(self._obj)) | 324 | return _str_to_py(lib.eolian_unit_file_get(self._obj)) |
325 | 325 | ||
326 | @cached_property | ||
327 | def state(self): | ||
328 | c_state = lib.eolian_unit_state_get(self._obj) | ||
329 | return Eolian_State(c_state) if c_state else None | ||
330 | |||
326 | @property | 331 | @property |
327 | def objects(self): | 332 | def objects(self): |
328 | return Iterator(Object, lib.eolian_unit_objects_get(self._obj)) | 333 | return Iterator(Object, lib.eolian_unit_objects_get(self._obj)) |
@@ -399,8 +404,10 @@ class Eolian_Unit(EolianBaseObject): | |||
399 | 404 | ||
400 | 405 | ||
401 | class Eolian_State(Eolian_Unit): | 406 | class Eolian_State(Eolian_Unit): |
402 | def __init__(self): | 407 | def __init__(self, c_state=None): |
403 | self._obj = lib.eolian_state_new() # Eolian_State * | 408 | if c_state is None: |
409 | c_state = lib.eolian_state_new() # Eolian_State * | ||
410 | EolianBaseObject.__init__(self, c_state) | ||
404 | 411 | ||
405 | def __del__(self): | 412 | def __del__(self): |
406 | if not _already_halted: # do not free after eolian_shutdown | 413 | if not _already_halted: # do not free after eolian_shutdown |
diff --git a/src/scripts/pyolian/eolian_lib.py b/src/scripts/pyolian/eolian_lib.py index 8d3f830b57..5db2aaee8e 100644 --- a/src/scripts/pyolian/eolian_lib.py +++ b/src/scripts/pyolian/eolian_lib.py | |||
@@ -130,6 +130,10 @@ lib.eolian_state_enums_by_file_get.restype = c_void_p | |||
130 | lib.eolian_unit_children_get.argtypes = [c_void_p,] | 130 | lib.eolian_unit_children_get.argtypes = [c_void_p,] |
131 | lib.eolian_unit_children_get.restype = c_void_p | 131 | lib.eolian_unit_children_get.restype = c_void_p |
132 | 132 | ||
133 | # EAPI const Eolian_State *eolian_unit_state_get(const Eolian_Unit *unit); | ||
134 | lib.eolian_unit_state_get.argtypes = [c_void_p,] | ||
135 | lib.eolian_unit_state_get.restype = c_void_p | ||
136 | |||
133 | # EAPI const char *eolian_unit_file_get(const Eolian_Unit *unit); | 137 | # EAPI const char *eolian_unit_file_get(const Eolian_Unit *unit); |
134 | lib.eolian_unit_file_get.argtypes = [c_void_p,] | 138 | lib.eolian_unit_file_get.argtypes = [c_void_p,] |
135 | lib.eolian_unit_file_get.restype = c_char_p | 139 | lib.eolian_unit_file_get.restype = c_char_p |
diff --git a/src/scripts/pyolian/test_eolian.py b/src/scripts/pyolian/test_eolian.py index 39936bb42a..34fdbafbdf 100755 --- a/src/scripts/pyolian/test_eolian.py +++ b/src/scripts/pyolian/test_eolian.py | |||
@@ -87,6 +87,11 @@ class TestEolianState(unittest.TestCase): | |||
87 | 87 | ||
88 | 88 | ||
89 | class TestEolianUnit(unittest.TestCase): | 89 | class TestEolianUnit(unittest.TestCase): |
90 | def test_unit_get(self): | ||
91 | unit = eolian_db.unit_by_file_get('efl_ui_win.eo') | ||
92 | self.assertIsInstance(unit.state, eolian.Eolian_State) | ||
93 | self.assertEqual(unit.state, eolian_db) | ||
94 | |||
90 | def test_file_get(self): | 95 | def test_file_get(self): |
91 | unit = eolian_db.unit_by_file_get('efl_ui_win.eo') | 96 | unit = eolian_db.unit_by_file_get('efl_ui_win.eo') |
92 | self.assertIsInstance(unit, eolian.Eolian_Unit) | 97 | self.assertIsInstance(unit, eolian.Eolian_Unit) |