Pyolian: new API eolian_object_unit_get
Also implemented __repr__ for Unit and State
This commit is contained in:
parent
1ab22e4f00
commit
0a00e4cca1
|
@ -312,6 +312,8 @@ class EolianBaseObject(object):
|
||||||
### Main Eolian Unit ########################################################
|
### Main Eolian Unit ########################################################
|
||||||
|
|
||||||
class Eolian_Unit(EolianBaseObject):
|
class Eolian_Unit(EolianBaseObject):
|
||||||
|
def __repr__(self):
|
||||||
|
return "<eolian.Eolian_Unit '{0.file}'>".format(self)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def children(self):
|
def children(self):
|
||||||
|
@ -404,6 +406,9 @@ class Eolian_State(Eolian_Unit):
|
||||||
if not _already_halted: # do not free after eolian_shutdown
|
if not _already_halted: # do not free after eolian_shutdown
|
||||||
lib.eolian_state_free(self._obj)
|
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):
|
def file_parse(self, filepath):
|
||||||
c_unit = lib.eolian_state_file_parse(self._obj, _str_to_bytes(filepath))
|
c_unit = lib.eolian_state_file_parse(self._obj, _str_to_bytes(filepath))
|
||||||
return Eolian_Unit(c_unit) if c_unit else None
|
return Eolian_Unit(c_unit) if c_unit else None
|
||||||
|
@ -572,6 +577,11 @@ class Object(EolianBaseObject):
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<eolian.Object '{0.name}', {0.type!s}>".format(self)
|
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
|
@cached_property
|
||||||
def name(self):
|
def name(self):
|
||||||
return _str_to_py(lib.eolian_object_name_get(self._obj))
|
return _str_to_py(lib.eolian_object_name_get(self._obj))
|
||||||
|
|
|
@ -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.argtypes = [c_void_p]
|
||||||
lib.eolian_object_type_get.restype = c_int
|
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);
|
# 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.argtypes = [c_void_p]
|
||||||
lib.eolian_object_file_get.restype = c_char_p
|
lib.eolian_object_file_get.restype = c_char_p
|
||||||
|
|
|
@ -270,6 +270,11 @@ class TestEolianObject(unittest.TestCase):
|
||||||
self.assertIsInstance(obj, eolian.Class)
|
self.assertIsInstance(obj, eolian.Class)
|
||||||
self.assertEqual(obj.name, 'Efl.Ui.Frame')
|
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):
|
def test_name(self):
|
||||||
obj = eolian_db.object_by_name_get('Efl.Ui.Frame')
|
obj = eolian_db.object_by_name_get('Efl.Ui.Frame')
|
||||||
self.assertEqual(obj.name, 'Efl.Ui.Frame')
|
self.assertEqual(obj.name, 'Efl.Ui.Frame')
|
||||||
|
|
Loading…
Reference in New Issue