[pygobject] cache refactoring: Move arg cache field assignments into _arg_cache_new



commit 03f531ffb1adde0c48e98f92bd92f79416654fbe
Author: Simon Feltman <sfeltman src gnome org>
Date:   Fri Aug 2 22:27:10 2013 -0700

    cache refactoring: Move arg cache field assignments into _arg_cache_new
    
    https://bugzilla.gnome.org/show_bug.cgi?id=640812

 gi/pygi-cache.c |   23 +++++++++++------------
 1 files changed, 11 insertions(+), 12 deletions(-)
---
diff --git a/gi/pygi-cache.c b/gi/pygi-cache.c
index e60471c..f8573fc 100644
--- a/gi/pygi-cache.c
+++ b/gi/pygi-cache.c
@@ -695,7 +695,7 @@ _arg_cache_new_for_interface (GIInterfaceInfo *iface_info,
 PyGIArgCache *
 _arg_cache_new (GITypeInfo *type_info,
                 PyGICallableCache *callable_cache,
-                GIArgInfo *arg_info,
+                GIArgInfo *arg_info,     /* may be null */
                 GITransfer transfer,
                 PyGIDirection direction,
                 gssize c_arg_index,
@@ -893,6 +893,16 @@ _arg_cache_new (GITypeInfo *type_info,
         arg_cache->is_pointer = g_type_info_is_pointer (type_info);
         g_base_info_ref ( (GIBaseInfo *) type_info);
         arg_cache->type_info = type_info;
+
+        if (arg_info != NULL) {
+            arg_cache->arg_name = g_base_info_get_name ((GIBaseInfo *) arg_info);
+            arg_cache->allow_none = g_arg_info_may_be_null (arg_info);
+
+            if (type_tag == GI_TYPE_TAG_INTERFACE || type_tag == GI_TYPE_TAG_ARRAY)
+                arg_cache->is_caller_allocates = g_arg_info_is_caller_allocates (arg_info);
+            else
+                arg_cache->is_caller_allocates = FALSE;
+        }
     }
 
     return arg_cache;
@@ -1068,18 +1078,10 @@ _args_cache_generate (GICallableInfo *callable_info,
                 arg_cache->type_tag = g_type_info_get_tag (type_info);
 
             } else {
-                GITypeTag type_tag;
                 GITransfer transfer;
                 gssize py_arg_index = -1;
-                gboolean is_caller_allocates = FALSE;
-
-                type_tag = g_type_info_get_tag (type_info);
                 transfer = g_arg_info_get_ownership_transfer (arg_info);
 
-                if (type_tag == GI_TYPE_TAG_INTERFACE || type_tag == GI_TYPE_TAG_ARRAY)
-                    is_caller_allocates = g_arg_info_is_caller_allocates (arg_info);
-
-
                 if (direction & PYGI_DIRECTION_FROM_PYTHON) {
                     py_arg_index = callable_cache->n_py_args;
                     callable_cache->n_from_py_args++;
@@ -1101,9 +1103,6 @@ _args_cache_generate (GICallableInfo *callable_info,
                     return FALSE;
                 }
 
-                arg_cache->arg_name = g_base_info_get_name ((GIBaseInfo *) arg_info);
-                arg_cache->allow_none = g_arg_info_may_be_null(arg_info);
-                arg_cache->is_caller_allocates = is_caller_allocates;
 
                 if (direction & PYGI_DIRECTION_TO_PYTHON) {
                     callable_cache->n_to_py_args++;


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