[pygobject] pygi-struct-marshal: perform boxed copy ...



commit 9978b521450d9b2a038d48492550dcab49c7b113
Author: Mathieu Duponchelle <mathieu centricular com>
Date:   Fri Feb 16 00:49:25 2018 +0100

    pygi-struct-marshal: perform boxed copy ...
    
    when the cleanup marshaller will not be called, that is when
    marshalling something that is not actually an argument.
    
    Fixes #164

 gi/pygi-struct-marshal.c | 48 ++++++++++++++++++++++++++++++++----------------
 1 file changed, 32 insertions(+), 16 deletions(-)
---
diff --git a/gi/pygi-struct-marshal.c b/gi/pygi-struct-marshal.c
index 44797e75..75896a86 100644
--- a/gi/pygi-struct-marshal.c
+++ b/gi/pygi-struct-marshal.c
@@ -364,15 +364,14 @@ arg_foreign_from_py_cleanup (PyGIInvokeState *state,
     }
 }
 
-
-PyObject *
-pygi_arg_struct_to_py_marshal (GIArgument *arg,
-                               GIInterfaceInfo *interface_info,
-                               GType g_type,
-                               PyObject *py_type,
-                               GITransfer transfer,
-                               gboolean is_allocated,
-                               gboolean is_foreign)
+static PyObject *
+pygi_arg_struct_to_py_marshaller (GIArgument *arg,
+                                  GIInterfaceInfo *interface_info,
+                                  GType g_type,
+                                  PyObject *py_type,
+                                  GITransfer transfer,
+                                  gboolean is_allocated,
+                                  gboolean is_foreign)
 {
     PyObject *py_obj = NULL;
 
@@ -431,6 +430,23 @@ pygi_arg_struct_to_py_marshal (GIArgument *arg,
     return py_obj;
 }
 
+PyObject *
+pygi_arg_struct_to_py_marshal (GIArgument *arg,
+                               GIInterfaceInfo *interface_info,
+                               GType g_type,
+                               PyObject *py_type,
+                               GITransfer transfer,
+                               gboolean is_allocated,
+                               gboolean is_foreign)
+{
+    PyObject *ret = pygi_arg_struct_to_py_marshaller (arg, interface_info, g_type, py_type, transfer, 
is_allocated, is_foreign);
+
+    if (ret && PyObject_IsInstance (ret, (PyObject *) &PyGIBoxed_Type) && transfer == GI_TRANSFER_NOTHING)
+        _pygi_boxed_copy_in_place ((PyGIBoxed *) ret);
+
+    return ret;
+};
+
 static PyObject *
 arg_struct_to_py_marshal_adapter (PyGIInvokeState   *state,
                                   PyGICallableCache *callable_cache,
@@ -441,13 +457,13 @@ arg_struct_to_py_marshal_adapter (PyGIInvokeState   *state,
     PyGIInterfaceCache *iface_cache = (PyGIInterfaceCache *)arg_cache;
     PyObject *ret;
 
-    ret = pygi_arg_struct_to_py_marshal (arg,
-                                         iface_cache->interface_info,
-                                         iface_cache->g_type,
-                                         iface_cache->py_type,
-                                         arg_cache->transfer,
-                                         arg_cache->is_caller_allocates,
-                                         iface_cache->is_foreign);
+    ret = pygi_arg_struct_to_py_marshaller (arg,
+                                            iface_cache->interface_info,
+                                            iface_cache->g_type,
+                                            iface_cache->py_type,
+                                            arg_cache->transfer,
+                                            arg_cache->is_caller_allocates,
+                                            iface_cache->is_foreign);
 
     *cleanup_data = ret;
 


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