[pygobject/invoke-rewrite] [gi] marshal out flags and enum



commit 9f101baaa63a75acf62f955cfc4b311ff0dd5464
Author: John (J5) Palmieri <johnp redhat com>
Date:   Fri Jan 21 09:23:54 2011 -0500

    [gi] marshal out flags and enum

 gi/pygi-argument.c |   14 +++++++++-----
 gi/pygi-cache.c    |   24 ++++++++++++------------
 2 files changed, 21 insertions(+), 17 deletions(-)
---
diff --git a/gi/pygi-argument.c b/gi/pygi-argument.c
index ccbe8b0..d2be489 100644
--- a/gi/pygi-argument.c
+++ b/gi/pygi-argument.c
@@ -3532,7 +3532,7 @@ _pygi_marshal_out_gerror (PyGIInvokeState   *state,
     PyObject *py_obj = NULL;
 
     PyErr_Format(PyExc_NotImplementedError,
-                 "Marshalling for this type is not implemented yet");
+                 "Marshalling for gerror out is not implemented");
     return py_obj;
 }
 
@@ -3556,9 +3556,13 @@ _pygi_marshal_out_interface_enum (PyGIInvokeState   *state,
                                   GIArgument        *arg)
 {
     PyObject *py_obj = NULL;
+    PyGIInterfaceCache *iface_cache = (PyGIInterfaceCache *)arg_cache;
 
-    PyErr_Format(PyExc_NotImplementedError,
-                 "Marshalling for this type is not implemented yet");
+    if (iface_cache->g_type == G_TYPE_NONE) {
+        py_obj = PyObject_CallFunction (iface_cache->py_type, "l", arg->v_long);
+    } else {
+        py_obj = pyg_enum_from_gtype(iface_cache->g_type, arg->v_long);
+    }
     return py_obj;
 }
 
@@ -3569,9 +3573,9 @@ _pygi_marshal_out_interface_flags (PyGIInvokeState   *state,
                                    GIArgument        *arg)
 {
     PyObject *py_obj = NULL;
+    PyGIInterfaceCache *iface_cache = (PyGIInterfaceCache *)arg_cache;
+    py_obj = pyg_flags_from_gtype(iface_cache->g_type, arg->v_long);
 
-    PyErr_Format(PyExc_NotImplementedError,
-                 "Marshalling for this type is not implemented yet");
     return py_obj;
 }
 
diff --git a/gi/pygi-cache.c b/gi/pygi-cache.c
index c6ba290..70e6daa 100644
--- a/gi/pygi-cache.c
+++ b/gi/pygi-cache.c
@@ -854,12 +854,11 @@ _arg_cache_new_for_out_interface_callback(void)
 }
 
 static inline PyGIArgCache *
-_arg_cache_new_for_out_interface_enum(void)
+_arg_cache_new_for_out_interface_enum(GIInterfaceInfo *iface_info,
+                                      GITransfer transfer)
 {
-    PyGIArgCache *arg_cache = NULL;
-    /*arg_cache->in_marshaller = _pygi_marshal_in_enum;*/
-    PyErr_Format(PyExc_NotImplementedError,
-                 "Caching for Out Interface ENum is not fully implemented yet");
+    PyGIArgCache *arg_cache = (PyGIArgCache *)_interface_cache_new_from_interface_info(iface_info);
+    arg_cache->out_marshaller = _pygi_marshal_out_interface_enum;
     return arg_cache;
 }
 
@@ -873,12 +872,11 @@ _arg_cache_new_for_out_interface_union(GIInterfaceInfo *iface_info,
 }
 
 static inline PyGIArgCache *
-_arg_cache_new_for_out_interface_flags(void)
+_arg_cache_new_for_out_interface_flags(GIInterfaceInfo *iface_info,
+                                       GITransfer transfer)
 {
-    PyGIArgCache *arg_cache = NULL;
-    /*arg_cache->in_marshaller = _pygi_marshal_in_flags;*/
-    PyErr_Format(PyExc_NotImplementedError,
-                 "Caching for Out Interface Flags is not fully implemented yet");
+    PyGIArgCache *arg_cache = (PyGIArgCache *)_interface_cache_new_from_interface_info(iface_info);
+    arg_cache->out_marshaller = _pygi_marshal_out_interface_flags;
     return arg_cache;
 }
 
@@ -913,10 +911,12 @@ _arg_cache_out_new_from_interface_info (GIInterfaceInfo *iface_info,
             arg_cache = _arg_cache_new_for_out_interface_callback();
             break;
         case GI_INFO_TYPE_ENUM:
-            arg_cache = _arg_cache_new_for_out_interface_enum();
+            arg_cache = _arg_cache_new_for_out_interface_enum(iface_info,
+                                                              transfer);
             break;
         case GI_INFO_TYPE_FLAGS:
-            arg_cache = _arg_cache_new_for_out_interface_flags();
+            arg_cache = _arg_cache_new_for_out_interface_flags(iface_info,
+                                                               transfer);
             break;
         default:
             g_assert_not_reached();



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