[pygobject/invoke-rewrite] [gi] handle allow_none for all args



commit 9baf3240fbac103823ad0feaaf1c82e46d276722
Author: John (J5) Palmieri <johnp redhat com>
Date:   Wed Jan 12 16:24:17 2011 -0500

    [gi] handle allow_none for all args

 gi/pygi-cache.c  |    3 ++-
 gi/pygi-cache.h  |    1 +
 gi/pygi-invoke.c |    7 +++++++
 3 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/gi/pygi-cache.c b/gi/pygi-cache.c
index 7622e72..3ad0995 100644
--- a/gi/pygi-cache.c
+++ b/gi/pygi-cache.c
@@ -1000,7 +1000,8 @@ _args_cache_generate(GIFunctionInfo *function_info,
 
                 if (arg_cache == NULL)
                     goto arg_err;
-
+                 
+                arg_cache->allow_none = g_arg_info_may_be_null (arg_info);
                 function_cache->in_args =
                     g_slist_append(function_cache->in_args, arg_cache);
                 break;
diff --git a/gi/pygi-cache.h b/gi/pygi-cache.h
index 9e9a29f..7ecbc97 100644
--- a/gi/pygi-cache.h
+++ b/gi/pygi-cache.h
@@ -48,6 +48,7 @@ struct _PyGIArgCache
     gboolean is_aux;
     gboolean is_pointer;
     gboolean is_caller_allocates;
+    gboolean allow_none;
 
     GIDirection direction;
     GITransfer transfer;
diff --git a/gi/pygi-invoke.c b/gi/pygi-invoke.c
index 1be824c..81636c4 100644
--- a/gi/pygi-invoke.c
+++ b/gi/pygi-invoke.c
@@ -986,6 +986,13 @@ _invoke_marshal_in_args(PyGIInvokeState *state, PyGIFunctionCache *cache)
 
         c_arg = state->args[i];
         if (arg_cache->in_marshaller != NULL) {
+            if (!arg_cache->allow_none && py_arg == Py_None) {
+                PyErr_Format(PyExc_TypeError,
+                             "Argument %i does not allow None as a value",
+                             i);
+
+                return FALSE;
+            }
             gboolean success = arg_cache->in_marshaller(state,
                                                         cache,
                                                         arg_cache,



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