[pygobject] Make use of instance-argument annotations
- From: Christoph Reiter <creiter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] Make use of instance-argument annotations
- Date: Wed, 22 Mar 2017 08:32:49 +0000 (UTC)
commit fb0404c0bf08dedf657ce1384b283223b7192df1
Author: Christoph Reiter <creiter src gnome org>
Date: Tue Mar 21 14:03:47 2017 +0100
Make use of instance-argument annotations
Use g_callable_info_get_instance_ownership_transfer() instead
of hardcoding the transfer for instances.
get_instance_ownership_transfer() is available since 1.42.0, so no
version dependency bump is required.
https://bugzilla.gnome.org/show_bug.cgi?id=735076
gi/pygi-cache.c | 4 +++-
tests/test_everything.py | 9 +++++++++
2 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/gi/pygi-cache.c b/gi/pygi-cache.c
index 29ea400..a106742 100644
--- a/gi/pygi-cache.c
+++ b/gi/pygi-cache.c
@@ -975,14 +975,16 @@ _function_with_instance_cache_generate_args_cache_real (PyGICallableCache *calla
{
GIInterfaceInfo *interface_info;
PyGIArgCache *instance_cache;
+ GITransfer transfer;
interface_info = g_base_info_get_container ((GIBaseInfo *) callable_info);
+ transfer = g_callable_info_get_instance_ownership_transfer (callable_info);
instance_cache =
_arg_cache_new_for_interface (interface_info,
NULL,
NULL,
- GI_TRANSFER_NOTHING,
+ transfer,
PYGI_DIRECTION_FROM_PYTHON,
callable_cache);
diff --git a/tests/test_everything.py b/tests/test_everything.py
index 0b5cf6d..fae07e6 100644
--- a/tests/test_everything.py
+++ b/tests/test_everything.py
@@ -54,6 +54,15 @@ class RawGList(ctypes.Structure):
@unittest.skipUnless(has_cairo, 'built without cairo support')
+class TestInstanceTransfer(unittest.TestCase):
+
+ def test_main(self):
+ obj = Everything.TestObj()
+ for _ in range(10):
+ obj.instance_method_full()
+
+
+@unittest.skipUnless(has_cairo, 'built without cairo support')
class TestEverything(unittest.TestCase):
def test_bool(self):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]