summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Andreoli <dave@gurumeditation.it>2018-01-01 07:27:15 +0100
committerDave Andreoli <dave@gurumeditation.it>2018-01-01 08:37:13 +0100
commitdd97383887c2439f5edfc5651bee45a27b9af5d9 (patch)
treeb0f90cb34cffda84c99175835a5bed7982c81846
parent77fba4119b194eba5fb7b242fdeb4cf68e02959e (diff)
downloadefl-dd97383887c2439f5edfc5651bee45a27b9af5d9.tar.gz
Pyolian: a fix and some new utils
-rw-r--r--src/scripts/pyolian/eolian.py51
-rw-r--r--src/scripts/pyolian/eolian_lib.py2
-rwxr-xr-xsrc/scripts/pyolian/test_eolian.py18
3 files changed, 58 insertions, 13 deletions
diff --git a/src/scripts/pyolian/eolian.py b/src/scripts/pyolian/eolian.py
index 8a3d21f00a..ced4934f2e 100644
--- a/src/scripts/pyolian/eolian.py
+++ b/src/scripts/pyolian/eolian.py
@@ -251,7 +251,6 @@ class Iterator(object):
def __next__(self):
if not self._iter or not self._iter.value:
- print("NULL Iterator... Error ?")
raise StopIteration
if not lib.eina_iterator_next(self._iter, byref(self._tmp)):
lib.eina_iterator_free(self._iter)
@@ -272,6 +271,12 @@ class EolianBaseObject(object):
raise TypeError('Invalid constructor of type: %s for class: %s' % (
type(c_obj_pointer), self.__class__.__name__))
+ def __eq__(self, other):
+ return self._obj.value == other._obj.value
+
+ def __hash__(self):
+ return self._obj.value
+
### Main Eolian Unit ########################################################
@@ -504,6 +509,10 @@ class Class(EolianBaseObject):
return Iterator(_str_to_py, lib.eolian_class_namespaces_get(self._obj))
@property
+ def namespace(self):
+ return '.'.join(self.namespaces)
+
+ @property
def file(self):
return _str_to_py(lib.eolian_class_file_get(self._obj))
@@ -660,7 +669,7 @@ class Function(EolianBaseObject):
@property
def full_c_setter_name_legacy(self):
return self.full_c_name_get(Eolian_Function_Type.PROP_SET, True)
-
+
@property
def type(self):
return Eolian_Function_Type(lib.eolian_function_type_get(self._obj))
@@ -837,10 +846,10 @@ class Implement(EolianBaseObject):
c_cls = lib.eolian_implement_class_get(self._obj)
return Class(c_cls) if c_cls else None
- def function_get(self, ftype=Eolian_Function_Type.UNRESOLVED):
- c_func = lib.eolian_implement_function_get(self._obj, ftype)
+ @property
+ def function(self):
+ c_func = lib.eolian_implement_function_get(self._obj, None)
return Function(c_func) if c_func else None
- # TODO implement util properties for function_get
def documentation_get(self, ftype=Eolian_Function_Type.METHOD):
c_doc = lib.eolian_implement_documentation_get(self._obj, ftype)
@@ -867,6 +876,17 @@ class Implement(EolianBaseObject):
def is_prop_get(self):
return bool(lib.eolian_implement_is_prop_get(self._obj))
+ @property
+ def is_property(self):
+ return self.is_prop_get or self.is_prop_set
+
+ @property
+ def is_method(self):
+ return not self.is_property
+
+ def is_overridden(self, cls):
+ return cls.name == self.class_.name # TODO equality inside class
+
class Type(EolianBaseObject): # OK (4 eolian issue)
def __repr__(self):
@@ -883,8 +903,11 @@ class Type(EolianBaseObject): # OK (4 eolian issue)
@property
def namespaces(self):
- return Iterator(_str_to_py,
- lib.eolian_type_namespaces_get(self._obj))
+ return Iterator(_str_to_py, lib.eolian_type_namespaces_get(self._obj))
+
+ @property
+ def namespace(self):
+ return '.'.join(self.namespaces)
@property
def free_func(self):
@@ -976,8 +999,11 @@ class Typedecl(EolianBaseObject): # OK (2 TODO)
@property
def namespaces(self):
- return Iterator(_str_to_py,
- lib.eolian_typedecl_namespaces_get(self._obj))
+ return Iterator(_str_to_py, lib.eolian_typedecl_namespaces_get(self._obj))
+
+ @property
+ def namespace(self):
+ return '.'.join(self.namespaces)
@property
def free_func(self):
@@ -1133,8 +1159,11 @@ class Variable(EolianBaseObject):
@property
def namespaces(self):
- return Iterator(_str_to_py,
- lib.eolian_variable_namespaces_get(self._obj))
+ return Iterator(_str_to_py, lib.eolian_variable_namespaces_get(self._obj))
+
+ @property
+ def namespace(self):
+ return '.'.join(self.namespaces)
@property
def type(self):
diff --git a/src/scripts/pyolian/eolian_lib.py b/src/scripts/pyolian/eolian_lib.py
index 5553d066ee..a330853dbd 100644
--- a/src/scripts/pyolian/eolian_lib.py
+++ b/src/scripts/pyolian/eolian_lib.py
@@ -269,7 +269,7 @@ lib.eolian_implement_class_get.argtypes = [c_void_p,]
lib.eolian_implement_class_get.restype = c_void_p
# EAPI const Eolian_Function *eolian_implement_function_get(const Eolian_Implement *impl, Eolian_Function_Type *func_type);
-lib.eolian_implement_function_get.argtypes = [c_void_p, c_int]
+lib.eolian_implement_function_get.argtypes = [c_void_p, c_void_p]
lib.eolian_implement_function_get.restype = c_void_p
# EAPI const Eolian_Documentation *eolian_implement_documentation_get(const Eolian_Implement *impl, Eolian_Function_Type f_type);
diff --git a/src/scripts/pyolian/test_eolian.py b/src/scripts/pyolian/test_eolian.py
index fa9869d93b..24b76c5686 100755
--- a/src/scripts/pyolian/test_eolian.py
+++ b/src/scripts/pyolian/test_eolian.py
@@ -23,6 +23,21 @@ SCAN_FOLDER = os.path.join(root_path, 'src', 'lib')
state = None
+class TestBaseObject(unittest.TestCase):
+ def test_base_object_equality(self):
+ cls1 = state.class_get_by_name('Efl.Loop.Timer')
+ cls2 = state.class_get_by_file('efl_loop_timer.eo')
+ self.assertIsInstance(cls1, eolian.Class)
+ self.assertIsInstance(cls2, eolian.Class)
+ self.assertEqual(cls1, cls2)
+
+ enum1 = state.typedecl_enum_get_by_name('Efl.Ui.Focus.Direction')
+ enum2 = state.typedecl_enum_get_by_name('Efl.Ui.Focus.Direction')
+ self.assertIsInstance(enum1, eolian.Typedecl)
+ self.assertIsInstance(enum2, eolian.Typedecl)
+ self.assertEqual(enum1, enum2)
+
+
class TestEolianUnit(unittest.TestCase):
def test_file_listing(self):
l = list(state.all_eo_file_paths)
@@ -179,6 +194,7 @@ class TestEolianFunction(unittest.TestCase):
self.assertFalse(f.return_is_warn_unused(eolian.Eolian_Function_Type.METHOD))
self.assertFalse(f.object_is_const)
self.assertEqual(f.class_.full_name, 'Efl.Loop.Timer')
+ self.assertIsInstance(f.implement, eolian.Implement)
def test_function_parameter(self):
cls = state.class_get_by_name('Efl.Loop.Timer')
@@ -202,7 +218,7 @@ class TestEolianImplement(unittest.TestCase):
self.assertIsInstance(im, eolian.Implement)
self.assertEqual(im.full_name, 'Efl.Loop.Timer.delay')
self.assertIsInstance(im.class_, eolian.Class)
- self.assertIsInstance(im.function_get(), eolian.Function) # TODO is UNRESOLVED correct ?
+ self.assertIsInstance(im.function, eolian.Function)
self.assertIsInstance(im.documentation_get(), eolian.Documentation) # TODO is UNRESOLVED correct ?
self.assertFalse(im.is_auto())
self.assertFalse(im.is_empty())