davemds pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=9160bfe901c5ec18e18f25998b1dcad1f77a3902

commit 9160bfe901c5ec18e18f25998b1dcad1f77a3902
Author: Dave Andreoli <d...@gurumeditation.it>
Date:   Tue Jan 16 20:53:20 2018 +0100

    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 ;)
---
 src/scripts/pyolian/eolian.py      | 25 +++++++++++++++++++++----
 src/scripts/pyolian/eolian_lib.py  |  4 ++--
 src/scripts/pyolian/test_eolian.py | 15 +++++++++++++++
 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):
         if c_obj_pointer is None:
             return super().__new__(cls)
 
-        # cache based on the c pointer value (assume the eolian db is stabe)
+        # cache based on the c pointer value (assume the eolian db is stable)
         if isinstance(c_obj_pointer, c_void_p):
             key = c_obj_pointer.value
         elif isinstance(c_obj_pointer, int):
@@ -1059,9 +1059,23 @@ class Type(EolianBaseObject):
     def builtin_type(self):
         return 
Eolian_Type_Builtin_Type(lib.eolian_type_builtin_type_get(self._obj))
 
+    def c_type_get(self, ctype):
+        s = lib.eolian_type_c_type_get(self._obj, ctype)
+        ret = _str_to_py(s)
+        lib.eina_stringshare_del(c_void_p(s))
+        return ret
+
     @cached_property
-    def c_type(self):
-        return _str_to_py(lib.eolian_type_c_type_get(self._obj))
+    def c_type_default(self):
+        return self.c_type_get(Eolian_C_Type_Type.DEFAULT)
+
+    @cached_property
+    def c_type_param(self):
+        return self.c_type_get(Eolian_C_Type_Type.PARAM)
+
+    @cached_property
+    def c_type_return(self):
+        return self.c_type_get(Eolian_C_Type_Type.RETURN)
 
     @cached_property
     def typedecl(self):
@@ -1127,7 +1141,10 @@ class Typedecl(EolianBaseObject):
 
     @cached_property
     def c_type(self):
-        return _str_to_py(lib.eolian_typedecl_c_type_get(self._obj))
+        s = lib.eolian_typedecl_c_type_get(self._obj)
+        ret = _str_to_py(s)
+        lib.eina_stringshare_del(c_void_p(s))
+        return ret
 
     @property
     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
 
 # EAPI Eina_Stringshare *eolian_typedecl_c_type_get(const Eolian_Typedecl *tp);
 lib.eolian_typedecl_c_type_get.argtypes = [c_void_p,]
-lib.eolian_typedecl_c_type_get.restype = None
+lib.eolian_typedecl_c_type_get.restype = c_void_p  # Stringshare TO BE FREED
 
 # EAPI Eina_Stringshare *eolian_typedecl_name_get(const Eolian_Typedecl *tp);
 lib.eolian_typedecl_name_get.argtypes = [c_void_p,]
@@ -573,7 +573,7 @@ lib.eolian_type_is_ptr.argtypes = [c_void_p,]
 lib.eolian_type_is_ptr.restype = c_bool
 
 # EAPI Eina_Stringshare *eolian_type_c_type_get(const Eolian_Type *tp, 
Eolian_C_Type_Type ctype);
-lib.eolian_type_c_type_get.argtypes = [c_void_p,]
+lib.eolian_type_c_type_get.argtypes = [c_void_p, c_int]
 lib.eolian_type_c_type_get.restype = c_void_p  # Stringshare TO BE FREED
 
 # 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):
         self.assertIsNone(td.function_pointer)  # TODO find a better test
         self.assertFalse(td.is_extern)
         self.assertEqual(len(list(td.enum_fields)), 3)
+        self.assertEqual(td.c_type, 'enum Efl_Net_Http_Version { v1_0 = 100, 
v1_1 = 101, v2_0 = 200 }')
 
     def test_typedecl_enum_field(self):
         td = state.typedecl_enum_get_by_name('Efl.Net.Http.Version')
@@ -433,6 +434,7 @@ class TestEolianTypedecl(unittest.TestCase):
         self.assertIsNone(td.function_pointer)  # TODO find a better test
         self.assertFalse(td.is_extern)
         self.assertEqual(len(list(td.struct_fields)), 4)
+        self.assertEqual(td.c_type, 'struct Efl_Gfx_Color32 { uint8_t r; 
uint8_t g; uint8_t b; uint8_t a; }')
 
     def test_typedecl_struct_field(self):
         td = state.typedecl_struct_get_by_name('Efl.Gfx.Color32')
@@ -450,6 +452,7 @@ class TestEolianTypedecl(unittest.TestCase):
         self.assertEqual(alias.full_name, 'Eina.Error')
         self.assertIsInstance(alias.aliased_base, eolian.Type)
         self.assertEqual(alias.aliased_base.name, 'int')
+        self.assertEqual(alias.c_type, 'typedef int Eina_Error')
 
 
 class TestEolianType(unittest.TestCase):
@@ -474,6 +477,10 @@ class TestEolianType(unittest.TestCase):
         self.assertIsNone(t.class_)
         self.assertEqual(t, t.aliased_base)  # TODO find a better test
 
+        self.assertEqual(t.c_type_default, 'double')  # TODO find a better test
+        self.assertEqual(t.c_type_param, 'double')
+        self.assertEqual(t.c_type_return, 'double')
+
     def test_type_regular(self):
         cls = state.class_get_by_name('Efl.Gfx')
         func = cls.function_get_by_name('geometry')
@@ -490,6 +497,10 @@ class TestEolianType(unittest.TestCase):
         self.assertIsNone(t.class_)
         self.assertEqual(t, t.aliased_base)
 
+        self.assertEqual(t.c_type_default, 'Eina_Rect')  # TODO find a better 
test
+        self.assertEqual(t.c_type_param, 'Eina_Rect')
+        self.assertEqual(t.c_type_return, 'Eina_Rect')
+
         td = t.typedecl
         self.assertIsInstance(td, eolian.Typedecl)
         self.assertEqual(td.full_name, 'Eina.Rect')
@@ -509,6 +520,10 @@ class TestEolianType(unittest.TestCase):
         self.assertEqual(t.free_func, 'efl_del')
         self.assertEqual(t, t.aliased_base)
 
+        self.assertEqual(t.c_type_default, 'Efl_Gfx *')  # TODO find a better 
test
+        self.assertEqual(t.c_type_param, 'Efl_Gfx *')
+        self.assertEqual(t.c_type_return, 'Efl_Gfx *')
+
         cls = t.class_
         self.assertIsInstance(cls, eolian.Class)
         self.assertEqual(cls.full_name, 'Efl.Gfx')

-- 


Reply via email to