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)
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):
251 251
252 def __next__(self): 252 def __next__(self):
253 if not self._iter or not self._iter.value: 253 if not self._iter or not self._iter.value:
254 print("NULL Iterator... Error ?")
255 raise StopIteration 254 raise StopIteration
256 if not lib.eina_iterator_next(self._iter, byref(self._tmp)): 255 if not lib.eina_iterator_next(self._iter, byref(self._tmp)):
257 lib.eina_iterator_free(self._iter) 256 lib.eina_iterator_free(self._iter)
@@ -272,6 +271,12 @@ class EolianBaseObject(object):
272 raise TypeError('Invalid constructor of type: %s for class: %s' % ( 271 raise TypeError('Invalid constructor of type: %s for class: %s' % (
273 type(c_obj_pointer), self.__class__.__name__)) 272 type(c_obj_pointer), self.__class__.__name__))
274 273
274 def __eq__(self, other):
275 return self._obj.value == other._obj.value
276
277 def __hash__(self):
278 return self._obj.value
279
275 280
276### Main Eolian Unit ######################################################## 281### Main Eolian Unit ########################################################
277 282
@@ -504,6 +509,10 @@ class Class(EolianBaseObject):
504 return Iterator(_str_to_py, lib.eolian_class_namespaces_get(self._obj)) 509 return Iterator(_str_to_py, lib.eolian_class_namespaces_get(self._obj))
505 510
506 @property 511 @property
512 def namespace(self):
513 return '.'.join(self.namespaces)
514
515 @property
507 def file(self): 516 def file(self):
508 return _str_to_py(lib.eolian_class_file_get(self._obj)) 517 return _str_to_py(lib.eolian_class_file_get(self._obj))
509 518
@@ -660,7 +669,7 @@ class Function(EolianBaseObject):
660 @property 669 @property
661 def full_c_setter_name_legacy(self): 670 def full_c_setter_name_legacy(self):
662 return self.full_c_name_get(Eolian_Function_Type.PROP_SET, True) 671 return self.full_c_name_get(Eolian_Function_Type.PROP_SET, True)
663 672
664 @property 673 @property
665 def type(self): 674 def type(self):
666 return Eolian_Function_Type(lib.eolian_function_type_get(self._obj)) 675 return Eolian_Function_Type(lib.eolian_function_type_get(self._obj))
@@ -837,10 +846,10 @@ class Implement(EolianBaseObject):
837 c_cls = lib.eolian_implement_class_get(self._obj) 846 c_cls = lib.eolian_implement_class_get(self._obj)
838 return Class(c_cls) if c_cls else None 847 return Class(c_cls) if c_cls else None
839 848
840 def function_get(self, ftype=Eolian_Function_Type.UNRESOLVED): 849 @property
841 c_func = lib.eolian_implement_function_get(self._obj, ftype) 850 def function(self):
851 c_func = lib.eolian_implement_function_get(self._obj, None)
842 return Function(c_func) if c_func else None 852 return Function(c_func) if c_func else None
843 # TODO implement util properties for function_get
844 853
845 def documentation_get(self, ftype=Eolian_Function_Type.METHOD): 854 def documentation_get(self, ftype=Eolian_Function_Type.METHOD):
846 c_doc = lib.eolian_implement_documentation_get(self._obj, ftype) 855 c_doc = lib.eolian_implement_documentation_get(self._obj, ftype)
@@ -867,6 +876,17 @@ class Implement(EolianBaseObject):
867 def is_prop_get(self): 876 def is_prop_get(self):
868 return bool(lib.eolian_implement_is_prop_get(self._obj)) 877 return bool(lib.eolian_implement_is_prop_get(self._obj))
869 878
879 @property
880 def is_property(self):
881 return self.is_prop_get or self.is_prop_set
882
883 @property
884 def is_method(self):
885 return not self.is_property
886
887 def is_overridden(self, cls):
888 return cls.name == self.class_.name # TODO equality inside class
889
870 890
871class Type(EolianBaseObject): # OK (4 eolian issue) 891class Type(EolianBaseObject): # OK (4 eolian issue)
872 def __repr__(self): 892 def __repr__(self):
@@ -883,8 +903,11 @@ class Type(EolianBaseObject): # OK (4 eolian issue)
883 903
884 @property 904 @property
885 def namespaces(self): 905 def namespaces(self):
886 return Iterator(_str_to_py, 906 return Iterator(_str_to_py, lib.eolian_type_namespaces_get(self._obj))
887 lib.eolian_type_namespaces_get(self._obj)) 907
908 @property
909 def namespace(self):
910 return '.'.join(self.namespaces)
888 911
889 @property 912 @property
890 def free_func(self): 913 def free_func(self):
@@ -976,8 +999,11 @@ class Typedecl(EolianBaseObject): # OK (2 TODO)
976 999
977 @property 1000 @property
978 def namespaces(self): 1001 def namespaces(self):
979 return Iterator(_str_to_py, 1002 return Iterator(_str_to_py, lib.eolian_typedecl_namespaces_get(self._obj))
980 lib.eolian_typedecl_namespaces_get(self._obj)) 1003
1004 @property
1005 def namespace(self):
1006 return '.'.join(self.namespaces)
981 1007
982 @property 1008 @property
983 def free_func(self): 1009 def free_func(self):
@@ -1133,8 +1159,11 @@ class Variable(EolianBaseObject):
1133 1159
1134 @property 1160 @property
1135 def namespaces(self): 1161 def namespaces(self):
1136 return Iterator(_str_to_py, 1162 return Iterator(_str_to_py, lib.eolian_variable_namespaces_get(self._obj))
1137 lib.eolian_variable_namespaces_get(self._obj)) 1163
1164 @property
1165 def namespace(self):
1166 return '.'.join(self.namespaces)
1138 1167
1139 @property 1168 @property
1140 def type(self): 1169 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,]
269lib.eolian_implement_class_get.restype = c_void_p 269lib.eolian_implement_class_get.restype = c_void_p
270 270
271# EAPI const Eolian_Function *eolian_implement_function_get(const Eolian_Implement *impl, Eolian_Function_Type *func_type); 271# EAPI const Eolian_Function *eolian_implement_function_get(const Eolian_Implement *impl, Eolian_Function_Type *func_type);
272lib.eolian_implement_function_get.argtypes = [c_void_p, c_int] 272lib.eolian_implement_function_get.argtypes = [c_void_p, c_void_p]
273lib.eolian_implement_function_get.restype = c_void_p 273lib.eolian_implement_function_get.restype = c_void_p
274 274
275# EAPI const Eolian_Documentation *eolian_implement_documentation_get(const Eolian_Implement *impl, Eolian_Function_Type f_type); 275# 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')
23state = None 23state = None
24 24
25 25
26class TestBaseObject(unittest.TestCase):
27 def test_base_object_equality(self):
28 cls1 = state.class_get_by_name('Efl.Loop.Timer')
29 cls2 = state.class_get_by_file('efl_loop_timer.eo')
30 self.assertIsInstance(cls1, eolian.Class)
31 self.assertIsInstance(cls2, eolian.Class)
32 self.assertEqual(cls1, cls2)
33
34 enum1 = state.typedecl_enum_get_by_name('Efl.Ui.Focus.Direction')
35 enum2 = state.typedecl_enum_get_by_name('Efl.Ui.Focus.Direction')
36 self.assertIsInstance(enum1, eolian.Typedecl)
37 self.assertIsInstance(enum2, eolian.Typedecl)
38 self.assertEqual(enum1, enum2)
39
40
26class TestEolianUnit(unittest.TestCase): 41class TestEolianUnit(unittest.TestCase):
27 def test_file_listing(self): 42 def test_file_listing(self):
28 l = list(state.all_eo_file_paths) 43 l = list(state.all_eo_file_paths)
@@ -179,6 +194,7 @@ class TestEolianFunction(unittest.TestCase):
179 self.assertFalse(f.return_is_warn_unused(eolian.Eolian_Function_Type.METHOD)) 194 self.assertFalse(f.return_is_warn_unused(eolian.Eolian_Function_Type.METHOD))
180 self.assertFalse(f.object_is_const) 195 self.assertFalse(f.object_is_const)
181 self.assertEqual(f.class_.full_name, 'Efl.Loop.Timer') 196 self.assertEqual(f.class_.full_name, 'Efl.Loop.Timer')
197 self.assertIsInstance(f.implement, eolian.Implement)
182 198
183 def test_function_parameter(self): 199 def test_function_parameter(self):
184 cls = state.class_get_by_name('Efl.Loop.Timer') 200 cls = state.class_get_by_name('Efl.Loop.Timer')
@@ -202,7 +218,7 @@ class TestEolianImplement(unittest.TestCase):
202 self.assertIsInstance(im, eolian.Implement) 218 self.assertIsInstance(im, eolian.Implement)
203 self.assertEqual(im.full_name, 'Efl.Loop.Timer.delay') 219 self.assertEqual(im.full_name, 'Efl.Loop.Timer.delay')
204 self.assertIsInstance(im.class_, eolian.Class) 220 self.assertIsInstance(im.class_, eolian.Class)
205 self.assertIsInstance(im.function_get(), eolian.Function) # TODO is UNRESOLVED correct ? 221 self.assertIsInstance(im.function, eolian.Function)
206 self.assertIsInstance(im.documentation_get(), eolian.Documentation) # TODO is UNRESOLVED correct ? 222 self.assertIsInstance(im.documentation_get(), eolian.Documentation) # TODO is UNRESOLVED correct ?
207 self.assertFalse(im.is_auto()) 223 self.assertFalse(im.is_auto())
208 self.assertFalse(im.is_empty()) 224 self.assertFalse(im.is_empty())