aboutsummaryrefslogtreecommitdiffstats
path: root/src/scripts/pyolian
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/pyolian
parentPyolian: fix tests wrt name/short_name/full_name API changes (diff)
downloadefl-0a00e4cca1252a3d60e1a4257003f0add35ab1fb.tar.gz
Pyolian: new API eolian_object_unit_get
Also implemented __repr__ for Unit and State
Diffstat (limited to 'src/scripts/pyolian')
-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):
### Main Eolian Unit ########################################################
class Eolian_Unit(EolianBaseObject):
+ def __repr__(self):
+ return "<eolian.Eolian_Unit '{0.file}'>".format(self)
@property
def children(self):
@@ -404,6 +406,9 @@ class Eolian_State(Eolian_Unit):
if not _already_halted: # do not free after eolian_shutdown
lib.eolian_state_free(self._obj)
+ def __repr__(self):
+ return "<eolian.Eolian_State, %d units loaded>" % len(list(self.units))
+
def file_parse(self, filepath):
c_unit = lib.eolian_state_file_parse(self._obj, _str_to_bytes(filepath))
return Eolian_Unit(c_unit) if c_unit else None
@@ -573,6 +578,11 @@ class Object(EolianBaseObject):
return "<eolian.Object '{0.name}', {0.type!s}>".format(self)
@cached_property
+ def unit(self):
+ c_unit = lib.eolian_object_unit_get(self._obj)
+ return Eolian_Unit(c_unit) if c_unit else None
+
+ @cached_property
def name(self):
return _str_to_py(lib.eolian_object_name_get(self._obj))
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
lib.eolian_object_type_get.argtypes = [c_void_p]
lib.eolian_object_type_get.restype = c_int
+# EAPI const Eolian_Unit *eolian_object_unit_get(const Eolian_Object *obj);
+lib.eolian_object_unit_get.argtypes = [c_void_p,]
+lib.eolian_object_unit_get.restype = c_void_p
+
# EAPI const char *eolian_object_file_get(const Eolian_Object *obj);
lib.eolian_object_file_get.argtypes = [c_void_p]
lib.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):
self.assertIsInstance(obj, eolian.Class)
self.assertEqual(obj.name, 'Efl.Ui.Frame')
+ def test_unit(self):
+ obj = eolian_db.object_by_name_get('Efl.Ui.Frame')
+ self.assertIsInstance(obj.unit, eolian.Eolian_Unit)
+ self.assertEqual(obj.unit.file, 'efl_ui_frame.eo')
+
def test_name(self):
obj = eolian_db.object_by_name_get('Efl.Ui.Frame')
self.assertEqual(obj.name, 'Efl.Ui.Frame')