[pygobject/invoke-rewrite] [gi-invoke-ng] marshal instances seperately since they differ slightly from other args



commit 507b5051c83f70ceae79e0fa693c86e5cbb9f442
Author: John (J5) Palmieri <johnp redhat com>
Date:   Mon Mar 28 18:30:31 2011 -0400

    [gi-invoke-ng] marshal instances seperately since they differ slightly from other args

 gi/pygi-cache.c   |    2 +-
 gi/pygi-marshal.c |   38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 1 deletions(-)
---
diff --git a/gi/pygi-cache.c b/gi/pygi-cache.c
index 4bb2f4d..bda4617 100644
--- a/gi/pygi-cache.c
+++ b/gi/pygi-cache.c
@@ -1262,7 +1262,7 @@ _args_cache_generate (GICallableInfo *callable_info,
                                                 arg_index,
                                                 0);
 
-
+        instance_cache->in_marshaller = _pygi_marshal_in_interface_instance;
         g_base_info_unref ( (GIBaseInfo *)interface_info);
 
         if (instance_cache == NULL)
diff --git a/gi/pygi-marshal.c b/gi/pygi-marshal.c
index 1bb8666..702c5ab 100644
--- a/gi/pygi-marshal.c
+++ b/gi/pygi-marshal.c
@@ -1306,6 +1306,44 @@ _pygi_marshal_in_interface_union (PyGIInvokeState   *state,
     return FALSE;
 }
 
+gboolean _pygi_marshal_in_interface_instance (PyGIInvokeState   *state,
+                                              PyGICallableCache *callable_cache,
+                                              PyGIArgCache      *arg_cache,
+                                              PyObject          *py_arg,
+                                              GIArgument        *arg)
+{
+    GIInfoType info_type;
+    PyGIInterfaceCache *iface_cache = (PyGIInterfaceCache *)arg_cache;
+
+    /* FIXME: add instance checks */
+
+    info_type = g_base_info_get_type (iface_cache->interface_info);
+    switch (info_type) {
+        case GI_INFO_TYPE_UNION:
+        case GI_INFO_TYPE_STRUCT:
+        {
+            GType type = iface_cache->g_type;
+            if (g_type_is_a (type, G_TYPE_BOXED)) {
+                arg->v_pointer = pyg_boxed_get (py_arg, void);
+            } else if (g_type_is_a (type, G_TYPE_POINTER) || type == G_TYPE_NONE) {
+                arg->v_pointer = pyg_pointer_get (py_arg, void);
+            } else {
+                 PyErr_Format (PyExc_TypeError, "unable to convert an instance of '%s'", g_type_name (type));
+                 return FALSE;
+            }
+
+            break;
+        }
+        case GI_INFO_TYPE_OBJECT:
+        case GI_INFO_TYPE_INTERFACE:
+            arg->v_pointer = pygobject_get (py_arg);
+            break;
+        default:
+            /* Other types don't have methods. */
+            g_assert_not_reached();
+   }
+}
+
 PyObject *
 _pygi_marshal_out_void (PyGIInvokeState   *state,
                         PyGICallableCache *callable_cache,



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