summaryrefslogtreecommitdiff
path: root/src/scripts
diff options
context:
space:
mode:
authorDave Andreoli <dave@gurumeditation.it>2018-03-17 10:01:24 +0100
committerDave Andreoli <dave@gurumeditation.it>2018-03-17 10:01:24 +0100
commit0a00e4cca1252a3d60e1a4257003f0add35ab1fb (patch)
tree7cf3ed596fd2f5a11fad082568022ef0842f3cde /src/scripts
parent1ab22e4f00b4f80ff6fba9b895dbe53221e343ea (diff)
Pyolian: new API eolian_object_unit_get
Also implemented __repr__ for Unit and State
Diffstat (limited to 'src/scripts')
-rw-r--r--src/scripts/pyolian/eolian.py10
-rw-r--r--src/scripts/pyolian/eolian_lib.py4
-rwxr-xr-xsrc/scripts/pyolian/test_eolian.py5
3 files changed, 19 insertions, 0 deletions
diff --git a/src/scripts/pyolian/eolian.py b/src/scripts/pyolian/eolian.py
index 56b79134c1..580cc1f951 100644
--- a/src/scripts/pyolian/eolian.py
+++ b/src/scripts/pyolian/eolian.py
@@ -312,6 +312,8 @@ class EolianBaseObject(object):
312### Main Eolian Unit ######################################################## 312### Main Eolian Unit ########################################################
313 313
314class Eolian_Unit(EolianBaseObject): 314class Eolian_Unit(EolianBaseObject):
315 def __repr__(self):
316 return "<eolian.Eolian_Unit '{0.file}'>".format(self)
315 317
316 @property 318 @property
317 def children(self): 319 def children(self):
@@ -404,6 +406,9 @@ class Eolian_State(Eolian_Unit):
404 if not _already_halted: # do not free after eolian_shutdown 406 if not _already_halted: # do not free after eolian_shutdown
405 lib.eolian_state_free(self._obj) 407 lib.eolian_state_free(self._obj)
406 408
409 def __repr__(self):
410 return "<eolian.Eolian_State, %d units loaded>" % len(list(self.units))
411
407 def file_parse(self, filepath): 412 def file_parse(self, filepath):
408 c_unit = lib.eolian_state_file_parse(self._obj, _str_to_bytes(filepath)) 413 c_unit = lib.eolian_state_file_parse(self._obj, _str_to_bytes(filepath))
409 return Eolian_Unit(c_unit) if c_unit else None 414 return Eolian_Unit(c_unit) if c_unit else None
@@ -573,6 +578,11 @@ class Object(EolianBaseObject):
573 return "<eolian.Object '{0.name}', {0.type!s}>".format(self) 578 return "<eolian.Object '{0.name}', {0.type!s}>".format(self)
574 579
575 @cached_property 580 @cached_property
581 def unit(self):
582 c_unit = lib.eolian_object_unit_get(self._obj)
583 return Eolian_Unit(c_unit) if c_unit else None
584
585 @cached_property
576 def name(self): 586 def name(self):
577 return _str_to_py(lib.eolian_object_name_get(self._obj)) 587 return _str_to_py(lib.eolian_object_name_get(self._obj))
578 588
diff --git a/src/scripts/pyolian/eolian_lib.py b/src/scripts/pyolian/eolian_lib.py
index 4b792657d2..8d3f830b57 100644
--- a/src/scripts/pyolian/eolian_lib.py
+++ b/src/scripts/pyolian/eolian_lib.py
@@ -196,6 +196,10 @@ lib.eolian_unit_globals_get.restype = c_void_p
196lib.eolian_object_type_get.argtypes = [c_void_p] 196lib.eolian_object_type_get.argtypes = [c_void_p]
197lib.eolian_object_type_get.restype = c_int 197lib.eolian_object_type_get.restype = c_int
198 198
199# EAPI const Eolian_Unit *eolian_object_unit_get(const Eolian_Object *obj);
200lib.eolian_object_unit_get.argtypes = [c_void_p,]
201lib.eolian_object_unit_get.restype = c_void_p
202
199# EAPI const char *eolian_object_file_get(const Eolian_Object *obj); 203# EAPI const char *eolian_object_file_get(const Eolian_Object *obj);
200lib.eolian_object_file_get.argtypes = [c_void_p] 204lib.eolian_object_file_get.argtypes = [c_void_p]
201lib.eolian_object_file_get.restype = c_char_p 205lib.eolian_object_file_get.restype = c_char_p
diff --git a/src/scripts/pyolian/test_eolian.py b/src/scripts/pyolian/test_eolian.py
index 5ce260eae5..39936bb42a 100755
--- a/src/scripts/pyolian/test_eolian.py
+++ b/src/scripts/pyolian/test_eolian.py
@@ -270,6 +270,11 @@ class TestEolianObject(unittest.TestCase):
270 self.assertIsInstance(obj, eolian.Class) 270 self.assertIsInstance(obj, eolian.Class)
271 self.assertEqual(obj.name, 'Efl.Ui.Frame') 271 self.assertEqual(obj.name, 'Efl.Ui.Frame')
272 272
273 def test_unit(self):
274 obj = eolian_db.object_by_name_get('Efl.Ui.Frame')
275 self.assertIsInstance(obj.unit, eolian.Eolian_Unit)
276 self.assertEqual(obj.unit.file, 'efl_ui_frame.eo')
277
273 def test_name(self): 278 def test_name(self):
274 obj = eolian_db.object_by_name_get('Efl.Ui.Frame') 279 obj = eolian_db.object_by_name_get('Efl.Ui.Frame')
275 self.assertEqual(obj.name, 'Efl.Ui.Frame') 280 self.assertEqual(obj.name, 'Efl.Ui.Frame')