summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Andreoli <dave@gurumeditation.it>2018-01-16 20:53:20 +0100
committerDave Andreoli <dave@gurumeditation.it>2018-01-16 20:53:20 +0100
commit9160bfe901c5ec18e18f25998b1dcad1f77a3902 (patch)
treef4524adc00eee75aa3209b1cc2ab403d91e99986
parent1af649d57b18dfae89dcf4f79043eaf2bb8ce824 (diff)
Pyolian: fix and tests for recent changes
q66: please leave the pyolian updating work to me, it's harder for me to fix wrong stuff instead of just implement myself ;)
-rw-r--r--src/scripts/pyolian/eolian.py25
-rw-r--r--src/scripts/pyolian/eolian_lib.py4
-rwxr-xr-xsrc/scripts/pyolian/test_eolian.py15
3 files changed, 38 insertions, 6 deletions
diff --git a/src/scripts/pyolian/eolian.py b/src/scripts/pyolian/eolian.py
index 9ac479807f..291865bdf4 100644
--- a/src/scripts/pyolian/eolian.py
+++ b/src/scripts/pyolian/eolian.py
@@ -283,7 +283,7 @@ class EolianBaseObject(object):
283 if c_obj_pointer is None: 283 if c_obj_pointer is None:
284 return super().__new__(cls) 284 return super().__new__(cls)
285 285
286 # cache based on the c pointer value (assume the eolian db is stabe) 286 # cache based on the c pointer value (assume the eolian db is stable)
287 if isinstance(c_obj_pointer, c_void_p): 287 if isinstance(c_obj_pointer, c_void_p):
288 key = c_obj_pointer.value 288 key = c_obj_pointer.value
289 elif isinstance(c_obj_pointer, int): 289 elif isinstance(c_obj_pointer, int):
@@ -1059,9 +1059,23 @@ class Type(EolianBaseObject):
1059 def builtin_type(self): 1059 def builtin_type(self):
1060 return Eolian_Type_Builtin_Type(lib.eolian_type_builtin_type_get(self._obj)) 1060 return Eolian_Type_Builtin_Type(lib.eolian_type_builtin_type_get(self._obj))
1061 1061
1062 def c_type_get(self, ctype):
1063 s = lib.eolian_type_c_type_get(self._obj, ctype)
1064 ret = _str_to_py(s)
1065 lib.eina_stringshare_del(c_void_p(s))
1066 return ret
1067
1062 @cached_property 1068 @cached_property
1063 def c_type(self): 1069 def c_type_default(self):
1064 return _str_to_py(lib.eolian_type_c_type_get(self._obj)) 1070 return self.c_type_get(Eolian_C_Type_Type.DEFAULT)
1071
1072 @cached_property
1073 def c_type_param(self):
1074 return self.c_type_get(Eolian_C_Type_Type.PARAM)
1075
1076 @cached_property
1077 def c_type_return(self):
1078 return self.c_type_get(Eolian_C_Type_Type.RETURN)
1065 1079
1066 @cached_property 1080 @cached_property
1067 def typedecl(self): 1081 def typedecl(self):
@@ -1127,7 +1141,10 @@ class Typedecl(EolianBaseObject):
1127 1141
1128 @cached_property 1142 @cached_property
1129 def c_type(self): 1143 def c_type(self):
1130 return _str_to_py(lib.eolian_typedecl_c_type_get(self._obj)) 1144 s = lib.eolian_typedecl_c_type_get(self._obj)
1145 ret = _str_to_py(s)
1146 lib.eina_stringshare_del(c_void_p(s))
1147 return ret
1131 1148
1132 @property 1149 @property
1133 def namespaces(self): 1150 def namespaces(self):
diff --git a/src/scripts/pyolian/eolian_lib.py b/src/scripts/pyolian/eolian_lib.py
index 42bea97c56..78b3a70d94 100644
--- a/src/scripts/pyolian/eolian_lib.py
+++ b/src/scripts/pyolian/eolian_lib.py
@@ -506,7 +506,7 @@ lib.eolian_typedecl_is_extern.restype = c_bool
506 506
507# EAPI Eina_Stringshare *eolian_typedecl_c_type_get(const Eolian_Typedecl *tp); 507# EAPI Eina_Stringshare *eolian_typedecl_c_type_get(const Eolian_Typedecl *tp);
508lib.eolian_typedecl_c_type_get.argtypes = [c_void_p,] 508lib.eolian_typedecl_c_type_get.argtypes = [c_void_p,]
509lib.eolian_typedecl_c_type_get.restype = None 509lib.eolian_typedecl_c_type_get.restype = c_void_p # Stringshare TO BE FREED
510 510
511# EAPI Eina_Stringshare *eolian_typedecl_name_get(const Eolian_Typedecl *tp); 511# EAPI Eina_Stringshare *eolian_typedecl_name_get(const Eolian_Typedecl *tp);
512lib.eolian_typedecl_name_get.argtypes = [c_void_p,] 512lib.eolian_typedecl_name_get.argtypes = [c_void_p,]
@@ -573,7 +573,7 @@ lib.eolian_type_is_ptr.argtypes = [c_void_p,]
573lib.eolian_type_is_ptr.restype = c_bool 573lib.eolian_type_is_ptr.restype = c_bool
574 574
575# EAPI Eina_Stringshare *eolian_type_c_type_get(const Eolian_Type *tp, Eolian_C_Type_Type ctype); 575# EAPI Eina_Stringshare *eolian_type_c_type_get(const Eolian_Type *tp, Eolian_C_Type_Type ctype);
576lib.eolian_type_c_type_get.argtypes = [c_void_p,] 576lib.eolian_type_c_type_get.argtypes = [c_void_p, c_int]
577lib.eolian_type_c_type_get.restype = c_void_p # Stringshare TO BE FREED 577lib.eolian_type_c_type_get.restype = c_void_p # Stringshare TO BE FREED
578 578
579# EAPI Eina_Stringshare *eolian_type_name_get(const Eolian_Type *tp); 579# EAPI Eina_Stringshare *eolian_type_name_get(const Eolian_Type *tp);
diff --git a/src/scripts/pyolian/test_eolian.py b/src/scripts/pyolian/test_eolian.py
index a73fe5ac16..56a12967de 100755
--- a/src/scripts/pyolian/test_eolian.py
+++ b/src/scripts/pyolian/test_eolian.py
@@ -410,6 +410,7 @@ class TestEolianTypedecl(unittest.TestCase):
410 self.assertIsNone(td.function_pointer) # TODO find a better test 410 self.assertIsNone(td.function_pointer) # TODO find a better test
411 self.assertFalse(td.is_extern) 411 self.assertFalse(td.is_extern)
412 self.assertEqual(len(list(td.enum_fields)), 3) 412 self.assertEqual(len(list(td.enum_fields)), 3)
413 self.assertEqual(td.c_type, 'enum Efl_Net_Http_Version { v1_0 = 100, v1_1 = 101, v2_0 = 200 }')
413 414
414 def test_typedecl_enum_field(self): 415 def test_typedecl_enum_field(self):
415 td = state.typedecl_enum_get_by_name('Efl.Net.Http.Version') 416 td = state.typedecl_enum_get_by_name('Efl.Net.Http.Version')
@@ -433,6 +434,7 @@ class TestEolianTypedecl(unittest.TestCase):
433 self.assertIsNone(td.function_pointer) # TODO find a better test 434 self.assertIsNone(td.function_pointer) # TODO find a better test
434 self.assertFalse(td.is_extern) 435 self.assertFalse(td.is_extern)
435 self.assertEqual(len(list(td.struct_fields)), 4) 436 self.assertEqual(len(list(td.struct_fields)), 4)
437 self.assertEqual(td.c_type, 'struct Efl_Gfx_Color32 { uint8_t r; uint8_t g; uint8_t b; uint8_t a; }')
436 438
437 def test_typedecl_struct_field(self): 439 def test_typedecl_struct_field(self):
438 td = state.typedecl_struct_get_by_name('Efl.Gfx.Color32') 440 td = state.typedecl_struct_get_by_name('Efl.Gfx.Color32')
@@ -450,6 +452,7 @@ class TestEolianTypedecl(unittest.TestCase):
450 self.assertEqual(alias.full_name, 'Eina.Error') 452 self.assertEqual(alias.full_name, 'Eina.Error')
451 self.assertIsInstance(alias.aliased_base, eolian.Type) 453 self.assertIsInstance(alias.aliased_base, eolian.Type)
452 self.assertEqual(alias.aliased_base.name, 'int') 454 self.assertEqual(alias.aliased_base.name, 'int')
455 self.assertEqual(alias.c_type, 'typedef int Eina_Error')
453 456
454 457
455class TestEolianType(unittest.TestCase): 458class TestEolianType(unittest.TestCase):
@@ -474,6 +477,10 @@ class TestEolianType(unittest.TestCase):
474 self.assertIsNone(t.class_) 477 self.assertIsNone(t.class_)
475 self.assertEqual(t, t.aliased_base) # TODO find a better test 478 self.assertEqual(t, t.aliased_base) # TODO find a better test
476 479
480 self.assertEqual(t.c_type_default, 'double') # TODO find a better test
481 self.assertEqual(t.c_type_param, 'double')
482 self.assertEqual(t.c_type_return, 'double')
483
477 def test_type_regular(self): 484 def test_type_regular(self):
478 cls = state.class_get_by_name('Efl.Gfx') 485 cls = state.class_get_by_name('Efl.Gfx')
479 func = cls.function_get_by_name('geometry') 486 func = cls.function_get_by_name('geometry')
@@ -490,6 +497,10 @@ class TestEolianType(unittest.TestCase):
490 self.assertIsNone(t.class_) 497 self.assertIsNone(t.class_)
491 self.assertEqual(t, t.aliased_base) 498 self.assertEqual(t, t.aliased_base)
492 499
500 self.assertEqual(t.c_type_default, 'Eina_Rect') # TODO find a better test
501 self.assertEqual(t.c_type_param, 'Eina_Rect')
502 self.assertEqual(t.c_type_return, 'Eina_Rect')
503
493 td = t.typedecl 504 td = t.typedecl
494 self.assertIsInstance(td, eolian.Typedecl) 505 self.assertIsInstance(td, eolian.Typedecl)
495 self.assertEqual(td.full_name, 'Eina.Rect') 506 self.assertEqual(td.full_name, 'Eina.Rect')
@@ -509,6 +520,10 @@ class TestEolianType(unittest.TestCase):
509 self.assertEqual(t.free_func, 'efl_del') 520 self.assertEqual(t.free_func, 'efl_del')
510 self.assertEqual(t, t.aliased_base) 521 self.assertEqual(t, t.aliased_base)
511 522
523 self.assertEqual(t.c_type_default, 'Efl_Gfx *') # TODO find a better test
524 self.assertEqual(t.c_type_param, 'Efl_Gfx *')
525 self.assertEqual(t.c_type_return, 'Efl_Gfx *')
526
512 cls = t.class_ 527 cls = t.class_
513 self.assertIsInstance(cls, eolian.Class) 528 self.assertIsInstance(cls, eolian.Class)
514 self.assertEqual(cls.full_name, 'Efl.Gfx') 529 self.assertEqual(cls.full_name, 'Efl.Gfx')