[pygobject] Add gi.CallableInfo.can_throw_gerror()



commit 9080215e862a73ddcce16476f4dc4492a88dd3f2
Author: Simon Feltman <sfeltman src gnome org>
Date:   Sat May 3 22:56:49 2014 -0700

    Add gi.CallableInfo.can_throw_gerror()
    
    Add static binding for g_callable_info_can_throw_gerror.

 gi/pygi-info.c           |   10 ++++++++++
 tests/test_repository.py |   16 ++++++++++++++++
 2 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/gi/pygi-info.c b/gi/pygi-info.c
index 5ce4337..43ee711 100644
--- a/gi/pygi-info.c
+++ b/gi/pygi-info.c
@@ -754,6 +754,15 @@ _wrap_g_callable_info_get_return_attribute (PyGIBaseInfo *self, PyObject *py_nam
     }
 }
 
+static PyObject *
+_wrap_g_callable_info_can_throw_gerror (PyGIBaseInfo *self)
+{
+    if (g_callable_info_can_throw_gerror (self->info))
+        Py_RETURN_TRUE;
+    else
+        Py_RETURN_FALSE;
+}
+
 static PyMethodDef _PyGICallableInfo_methods[] = {
     { "invoke", (PyCFunction) _wrap_g_callable_info_invoke, METH_VARARGS | METH_KEYWORDS },
     { "get_arguments", (PyCFunction) _wrap_g_callable_info_get_arguments, METH_NOARGS },
@@ -762,6 +771,7 @@ static PyMethodDef _PyGICallableInfo_methods[] = {
     { "may_return_null", (PyCFunction) _wrap_g_callable_info_may_return_null, METH_NOARGS },
     { "skip_return", (PyCFunction) _wrap_g_callable_info_skip_return, METH_NOARGS },
     { "get_return_attribute", (PyCFunction) _wrap_g_callable_info_get_return_attribute, METH_O },
+    { "can_throw_gerror", (PyCFunction) _wrap_g_callable_info_can_throw_gerror, METH_NOARGS },
     { NULL, NULL, 0 }
 };
 
diff --git a/tests/test_repository.py b/tests/test_repository.py
index 88132e6..6f62214 100644
--- a/tests/test_repository.py
+++ b/tests/test_repository.py
@@ -309,6 +309,22 @@ class Test(unittest.TestCase):
         self.assertEqual(vfunc.get_offset(), 0xFFFF)  # unknown offset
         self.assertEqual(vfunc.get_signal(), None)
 
+    def test_callable_can_throw_gerror(self):
+        info = repo.find_by_name('GIMarshallingTests', 'Object')
+        invoker = find_child_info(info, 'get_methods', 'vfunc_meth_with_error')
+        vfunc = find_child_info(info, 'get_vfuncs', 'vfunc_meth_with_err')
+
+        self.assertTrue(invoker.can_throw_gerror())
+        self.assertTrue(vfunc.can_throw_gerror())
+
+        # Test that args do not include the GError**
+        self.assertEqual(len(invoker.get_arguments()), 1)
+        self.assertEqual(len(vfunc.get_arguments()), 1)
+
+        # Sanity check method that does not throw.
+        invoker_no_throws = find_child_info(info, 'get_methods', 'method_int8_in')
+        self.assertFalse(invoker_no_throws.can_throw_gerror())
+
     def test_flags_double_registration_error(self):
         # a warning is printed for double registration and pygobject will
         # also raise a RuntimeError.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]