[pygobject] cache refactoring: Use consistent prefix for arg cache functions



commit 56ac6bd9ed99d6bb2cb8641581a594105036be68
Author: Simon Feltman <sfeltman src gnome org>
Date:   Mon Feb 3 06:24:18 2014 -0800

    cache refactoring: Use consistent prefix for arg cache functions
    
    Use "pygi_arg_cache" as the prefix for arg cache memory related functions.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=709700

 gi/pygi-array.c          |    6 ++--
 gi/pygi-basictype.c      |    4 +-
 gi/pygi-cache.c          |   74 +++++++++++++++++++++++-----------------------
 gi/pygi-cache.h          |   58 ++++++++++++++++++++----------------
 gi/pygi-ccallback.c      |    2 +-
 gi/pygi-closure.c        |    6 ++--
 gi/pygi-enum-marshal.c   |    4 +-
 gi/pygi-error.c          |    4 +-
 gi/pygi-hashtable.c      |   30 +++++++++---------
 gi/pygi-info.c           |    2 +-
 gi/pygi-invoke.c         |    2 +-
 gi/pygi-list.c           |    2 +-
 gi/pygi-object.c         |    2 +-
 gi/pygi-struct-marshal.c |    2 +-
 14 files changed, 102 insertions(+), 96 deletions(-)
---
diff --git a/gi/pygi-array.c b/gi/pygi-array.c
index 22eea53..937c6b3 100644
--- a/gi/pygi-array.c
+++ b/gi/pygi-array.c
@@ -754,7 +754,7 @@ static void
 _array_cache_free_func (PyGIArgGArray *cache)
 {
     if (cache != NULL) {
-        _pygi_arg_cache_free (((PyGISequenceCache *)cache)->item_cache);
+        pygi_arg_cache_free (((PyGISequenceCache *)cache)->item_cache);
         g_slice_free (PyGIArgGArray, cache);
     }
 }
@@ -787,7 +787,7 @@ pygi_arg_garray_len_arg_setup (PyGIArgCache *arg_cache,
         child_cache = _pygi_callable_cache_get_arg (callable_cache,
                                                     seq_cache->len_arg_index);
         if (child_cache == NULL) {
-            child_cache = _arg_cache_alloc ();
+            child_cache = pygi_arg_cache_alloc ();
         } else {
             /* If the "length" arg cache already exists (the length comes before
              * the array in the argument list), remove it from the to_py_args list
@@ -901,7 +901,7 @@ pygi_arg_garray_new_from_info (GITypeInfo *type_info,
                                 arg_info,
                                 transfer,
                                 direction)) {
-        _pygi_arg_cache_free ( (PyGIArgCache *)array_cache);
+        pygi_arg_cache_free ( (PyGIArgCache *)array_cache);
         return NULL;
     }
 
diff --git a/gi/pygi-basictype.c b/gi/pygi-basictype.c
index 740463f..6fbe929 100644
--- a/gi/pygi-basictype.c
+++ b/gi/pygi-basictype.c
@@ -806,7 +806,7 @@ pygi_arg_basic_type_new_from_info (GITypeInfo   *type_info,
                                    PyGIDirection direction)
 {
     gboolean res = FALSE;
-    PyGIArgCache *arg_cache = _arg_cache_alloc ();
+    PyGIArgCache *arg_cache = pygi_arg_cache_alloc ();
     if (arg_cache == NULL)
         return NULL;
 
@@ -818,7 +818,7 @@ pygi_arg_basic_type_new_from_info (GITypeInfo   *type_info,
     if (res) {
         return arg_cache;
     } else {
-        _pygi_arg_cache_free (arg_cache);
+        pygi_arg_cache_free (arg_cache);
         return NULL;
     }
 }
diff --git a/gi/pygi-cache.c b/gi/pygi-cache.c
index 012ebcb..04f6118 100644
--- a/gi/pygi-cache.c
+++ b/gi/pygi-cache.c
@@ -94,7 +94,7 @@ pygi_arg_base_setup (PyGIArgCache *arg_cache,
 }
 
 void
-_pygi_arg_cache_free (PyGIArgCache *cache)
+pygi_arg_cache_free (PyGIArgCache *cache)
 {
     if (cache == NULL)
         return;
@@ -108,7 +108,7 @@ _pygi_arg_cache_free (PyGIArgCache *cache)
 }
 
 void
-_pygi_callable_cache_free (PyGICallableCache *cache)
+pygi_callable_cache_free (PyGICallableCache *cache)
 {
     if (cache == NULL)
         return;
@@ -119,7 +119,7 @@ _pygi_callable_cache_free (PyGICallableCache *cache)
     g_ptr_array_unref (cache->args_cache);
 
     if (cache->return_cache != NULL)
-        _pygi_arg_cache_free (cache->return_cache);
+        pygi_arg_cache_free (cache->return_cache);
 
     g_slice_free (PyGICallableCache, cache);
 }
@@ -188,7 +188,7 @@ pygi_arg_interface_new_from_info (GITypeInfo         *type_info,
                                    transfer,
                                    direction,
                                    iface_info)) {
-        _pygi_arg_cache_free ((PyGIArgCache *)ic);
+        pygi_arg_cache_free ((PyGIArgCache *)ic);
         return NULL;
     }
 
@@ -201,7 +201,7 @@ static void
 _sequence_cache_free_func (PyGISequenceCache *cache)
 {
     if (cache != NULL) {
-        _pygi_arg_cache_free (cache->item_cache);
+        pygi_arg_cache_free (cache->item_cache);
         g_slice_free (PyGISequenceCache, cache);
     }
 }
@@ -229,12 +229,12 @@ pygi_arg_sequence_setup (PyGISequenceCache  *sc,
     item_transfer =
         transfer == GI_TRANSFER_CONTAINER ? GI_TRANSFER_NOTHING : transfer;
 
-    sc->item_cache = _arg_cache_new (item_type_info,
-                                     NULL,
-                                     item_transfer,
-                                     direction,
-                                     0, 0,
-                                     NULL);
+    sc->item_cache = pygi_arg_cache_new (item_type_info,
+                                         NULL,
+                                         item_transfer,
+                                         direction,
+                                         0, 0,
+                                         NULL);
 
     g_base_info_unref ( (GIBaseInfo *)item_type_info);
 
@@ -246,7 +246,7 @@ pygi_arg_sequence_setup (PyGISequenceCache  *sc,
 }
 
 PyGIArgCache *
-_arg_cache_alloc (void)
+pygi_arg_cache_alloc (void)
 {
     return g_slice_new0 (PyGIArgCache);
 }
@@ -306,13 +306,13 @@ _arg_cache_new_for_interface (GIInterfaceInfo   *iface_info,
 }
 
 PyGIArgCache *
-_arg_cache_new (GITypeInfo *type_info,
-                GIArgInfo *arg_info,     /* may be null */
-                GITransfer transfer,
-                PyGIDirection direction,
-                gssize c_arg_index,
-                gssize py_arg_index,
-                PyGICallableCache *callable_cache)
+pygi_arg_cache_new (GITypeInfo *type_info,
+                    GIArgInfo *arg_info,     /* may be null */
+                    GITransfer transfer,
+                    PyGIDirection direction,
+                    gssize c_arg_index,
+                    gssize py_arg_index,
+                    PyGICallableCache *callable_cache)
 {
     PyGIArgCache *arg_cache = NULL;
     GITypeTag type_tag;
@@ -449,13 +449,13 @@ _args_cache_generate (GICallableInfo *callable_info,
     return_transfer =
         g_callable_info_get_caller_owns (callable_info);
     return_cache =
-        _arg_cache_new (return_info,
-                        NULL,
-                        return_transfer,
-                        return_direction,
-                        -1,
-                        -1,
-                        callable_cache);
+        pygi_arg_cache_new (return_info,
+                            NULL,
+                            return_transfer,
+                            return_direction,
+                            -1,
+                            -1,
+                            callable_cache);
     if (return_cache == NULL)
         return FALSE;
 
@@ -507,7 +507,7 @@ _args_cache_generate (GICallableInfo *callable_info,
 
         if (g_arg_info_get_closure (arg_info) == i) {
 
-            arg_cache = _arg_cache_alloc ();
+            arg_cache = pygi_arg_cache_alloc ();
             _pygi_callable_cache_set_arg (callable_cache, arg_index, arg_cache);
 
             direction = PYGI_DIRECTION_FROM_PYTHON;
@@ -558,13 +558,13 @@ _args_cache_generate (GICallableInfo *callable_info,
                 }
 
                 arg_cache =
-                    _arg_cache_new (type_info,
-                                    arg_info,
-                                    transfer,
-                                    direction,
-                                    arg_index,
-                                    py_arg_index,
-                                    callable_cache);
+                    pygi_arg_cache_new (type_info,
+                                        arg_info,
+                                        transfer,
+                                        direction,
+                                        arg_index,
+                                        py_arg_index,
+                                        callable_cache);
 
                 if (arg_cache == NULL) {
                     g_base_info_unref( (GIBaseInfo *)type_info);
@@ -650,7 +650,7 @@ _args_cache_generate (GICallableInfo *callable_info,
 }
 
 PyGICallableCache *
-_pygi_callable_cache_new (GICallableInfo *callable_info, gboolean is_ccallback)
+pygi_callable_cache_new (GICallableInfo *callable_info, gboolean is_ccallback)
 {
     gint n_args;
     PyGICallableCache *cache;
@@ -705,7 +705,7 @@ _pygi_callable_cache_new (GICallableInfo *callable_info, gboolean is_ccallback)
         n_args++;
 
     if (n_args >= 0) {
-        cache->args_cache = g_ptr_array_new_full (n_args, (GDestroyNotify) _pygi_arg_cache_free);
+        cache->args_cache = g_ptr_array_new_full (n_args, (GDestroyNotify) pygi_arg_cache_free);
         g_ptr_array_set_size (cache->args_cache, n_args);
     }
 
@@ -714,6 +714,6 @@ _pygi_callable_cache_new (GICallableInfo *callable_info, gboolean is_ccallback)
 
     return cache;
 err:
-    _pygi_callable_cache_free (cache);
+    pygi_callable_cache_free (cache);
     return NULL;
 }
diff --git a/gi/pygi-cache.h b/gi/pygi-cache.h
index 28046f1..5521605 100644
--- a/gi/pygi-cache.h
+++ b/gi/pygi-cache.h
@@ -194,11 +194,11 @@ struct _PyGICallableCache
 };
 
 gboolean
-pygi_arg_base_setup (PyGIArgCache *arg_cache,
-                     GITypeInfo   *type_info,
-                     GIArgInfo    *arg_info,  /* may be NULL for return arguments */
-                     GITransfer    transfer,
-                     PyGIDirection direction);
+pygi_arg_base_setup      (PyGIArgCache *arg_cache,
+                          GITypeInfo   *type_info,
+                          GIArgInfo    *arg_info,  /* may be NULL for return arguments */
+                          GITransfer    transfer,
+                          PyGIDirection direction);
 
 gboolean
 pygi_arg_interface_setup (PyGIInterfaceCache *iface_cache,
@@ -209,11 +209,11 @@ pygi_arg_interface_setup (PyGIInterfaceCache *iface_cache,
                           GIInterfaceInfo    *iface_info);
 
 gboolean
-pygi_arg_sequence_setup (PyGISequenceCache  *sc,
-                         GITypeInfo         *type_info,
-                         GIArgInfo          *arg_info,    /* may be NULL for return arguments */
-                         GITransfer          transfer,
-                         PyGIDirection       direction);
+pygi_arg_sequence_setup  (PyGISequenceCache  *sc,
+                          GITypeInfo         *type_info,
+                          GIArgInfo          *arg_info,    /* may be NULL for return arguments */
+                          GITransfer          transfer,
+                          PyGIDirection       direction);
 
 PyGIArgCache *
 pygi_arg_interface_new_from_info (GITypeInfo         *type_info,
@@ -222,22 +222,28 @@ pygi_arg_interface_new_from_info (GITypeInfo         *type_info,
                                   PyGIDirection       direction,
                                   GIInterfaceInfo    *iface_info);
 
-PyGIArgCache * _arg_cache_alloc (void);
-PyGIArgCache * _arg_cache_new (GITypeInfo *type_info,
-                               GIArgInfo *arg_info,
-                               GITransfer transfer,
-                               PyGIDirection direction,
-                               /* will be removed */
-                               gssize c_arg_index,
-                               gssize py_arg_index,
-                               PyGICallableCache *callable_cache);
-
-void _pygi_arg_cache_free       (PyGIArgCache *cache);
-void _pygi_arg_cache_clear      (PyGIArgCache *cache);
-void _pygi_callable_cache_free  (PyGICallableCache *cache);
-
-PyGICallableCache *_pygi_callable_cache_new (GICallableInfo *callable_info,
-                                             gboolean is_ccallback);
+PyGIArgCache *
+pygi_arg_cache_alloc     (void);
+
+PyGIArgCache *
+pygi_arg_cache_new       (GITypeInfo *type_info,
+                          GIArgInfo *arg_info,
+                          GITransfer transfer,
+                          PyGIDirection direction,
+                          /* will be removed */
+                          gssize c_arg_index,
+                          gssize py_arg_index,
+                          PyGICallableCache *callable_cache);
+
+void
+pygi_arg_cache_free      (PyGIArgCache *cache);
+
+void
+pygi_callable_cache_free (PyGICallableCache *cache);
+
+PyGICallableCache *
+pygi_callable_cache_new  (GICallableInfo *callable_info,
+                          gboolean is_ccallback);
 
 #define _pygi_callable_cache_args_len(cache) ((cache)->args_cache)->len
 
diff --git a/gi/pygi-ccallback.c b/gi/pygi-ccallback.c
index 7a35e60..01e109b 100644
--- a/gi/pygi-ccallback.c
+++ b/gi/pygi-ccallback.c
@@ -34,7 +34,7 @@ _ccallback_call(PyGICCallback *self, PyObject *args, PyObject *kwargs)
     PyObject *result;
 
     if (self->cache == NULL) {
-        self->cache = _pygi_callable_cache_new (self->info, TRUE);
+        self->cache = pygi_callable_cache_new (self->info, TRUE);
         if (self->cache == NULL)
             return NULL;
     }
diff --git a/gi/pygi-closure.c b/gi/pygi-closure.c
index 3dd73da..a30363f 100644
--- a/gi/pygi-closure.c
+++ b/gi/pygi-closure.c
@@ -882,7 +882,7 @@ _arg_cache_from_py_interface_callback_setup (PyGIArgCache *arg_cache,
 {
     PyGICallbackCache *callback_cache = (PyGICallbackCache *)arg_cache;
     if (callback_cache->user_data_index >= 0) {
-        PyGIArgCache *user_data_arg_cache = _arg_cache_alloc ();
+        PyGIArgCache *user_data_arg_cache = pygi_arg_cache_alloc ();
         user_data_arg_cache->meta_type = PYGI_META_ARG_TYPE_CHILD_WITH_PYARG;
         user_data_arg_cache->direction = PYGI_DIRECTION_FROM_PYTHON;
         user_data_arg_cache->has_default = TRUE; /* always allow user data with a NULL default. */
@@ -891,7 +891,7 @@ _arg_cache_from_py_interface_callback_setup (PyGIArgCache *arg_cache,
     }
 
     if (callback_cache->destroy_notify_index >= 0) {
-        PyGIArgCache *destroy_arg_cache = _arg_cache_alloc ();
+        PyGIArgCache *destroy_arg_cache = pygi_arg_cache_alloc ();
         destroy_arg_cache->meta_type = PYGI_META_ARG_TYPE_CHILD;
         destroy_arg_cache->direction = PYGI_DIRECTION_FROM_PYTHON;
         _pygi_callable_cache_set_arg (callable_cache, callback_cache->destroy_notify_index,
@@ -973,7 +973,7 @@ pygi_arg_callback_new_from_info  (GITypeInfo        *type_info,
     if (res) {
         return (PyGIArgCache *)callback_cache;
     } else {
-        _pygi_arg_cache_free ((PyGIArgCache *)callback_cache);
+        pygi_arg_cache_free ((PyGIArgCache *)callback_cache);
         return NULL;
     }
 }
diff --git a/gi/pygi-enum-marshal.c b/gi/pygi-enum-marshal.c
index 0a8e7e4..dec5924 100644
--- a/gi/pygi-enum-marshal.c
+++ b/gi/pygi-enum-marshal.c
@@ -354,7 +354,7 @@ pygi_arg_enum_new_from_info (GITypeInfo      *type_info,
     if (res) {
         return cache;
     } else {
-        _pygi_arg_cache_free (cache);
+        pygi_arg_cache_free (cache);
         return NULL;
     }
 }
@@ -402,7 +402,7 @@ pygi_arg_flags_new_from_info (GITypeInfo      *type_info,
     if (res) {
         return cache;
     } else {
-        _pygi_arg_cache_free (cache);
+        pygi_arg_cache_free (cache);
         return NULL;
     }
 }
diff --git a/gi/pygi-error.c b/gi/pygi-error.c
index 33bf928..349bb7e 100644
--- a/gi/pygi-error.c
+++ b/gi/pygi-error.c
@@ -91,7 +91,7 @@ pygi_arg_gerror_new_from_info (GITypeInfo   *type_info,
     gboolean res = FALSE;
     PyGIArgCache *arg_cache = NULL;
 
-    arg_cache = _arg_cache_alloc ();
+    arg_cache = pygi_arg_cache_alloc ();
     if (arg_cache == NULL)
         return NULL;
 
@@ -103,7 +103,7 @@ pygi_arg_gerror_new_from_info (GITypeInfo   *type_info,
     if (res) {
         return arg_cache;
     } else {
-        _pygi_arg_cache_free (arg_cache);
+        pygi_arg_cache_free (arg_cache);
         return NULL;
     }
 }
diff --git a/gi/pygi-hashtable.c b/gi/pygi-hashtable.c
index f8864f0..f7d5e74 100644
--- a/gi/pygi-hashtable.c
+++ b/gi/pygi-hashtable.c
@@ -34,8 +34,8 @@ static void
 _hash_cache_free_func (PyGIHashCache *cache)
 {
     if (cache != NULL) {
-        _pygi_arg_cache_free (cache->key_cache);
-        _pygi_arg_cache_free (cache->value_cache);
+        pygi_arg_cache_free (cache->key_cache);
+        pygi_arg_cache_free (cache->value_cache);
         g_slice_free (PyGIHashCache, cache);
     }
 }
@@ -350,23 +350,23 @@ pygi_arg_hash_table_setup_from_info (PyGIHashCache *hc,
     item_transfer =
         transfer == GI_TRANSFER_CONTAINER ? GI_TRANSFER_NOTHING : transfer;
 
-    hc->key_cache = _arg_cache_new (key_type_info,
-                                    NULL,
-                                    item_transfer,
-                                    direction,
-                                    0, 0,
-                                    NULL);
+    hc->key_cache = pygi_arg_cache_new (key_type_info,
+                                        NULL,
+                                        item_transfer,
+                                        direction,
+                                        0, 0,
+                                        NULL);
 
     if (hc->key_cache == NULL) {
         return FALSE;
     }
 
-    hc->value_cache = _arg_cache_new (value_type_info,
-                                      NULL,
-                                      item_transfer,
-                                      direction,
-                                      0, 0,
-                                      NULL);
+    hc->value_cache = pygi_arg_cache_new (value_type_info,
+                                          NULL,
+                                          item_transfer,
+                                          direction,
+                                          0, 0,
+                                          NULL);
 
     if (hc->value_cache == NULL) {
         return FALSE;
@@ -407,7 +407,7 @@ pygi_arg_hash_table_new_from_info (GITypeInfo   *type_info,
     if (res) {
         return (PyGIArgCache *)hc;
     } else {
-        _pygi_arg_cache_free ((PyGIArgCache *)hc);
+        pygi_arg_cache_free ((PyGIArgCache *)hc);
         return NULL;
     }
 }
diff --git a/gi/pygi-info.c b/gi/pygi-info.c
index d0d2158..ffc9d4f 100644
--- a/gi/pygi-info.c
+++ b/gi/pygi-info.c
@@ -177,7 +177,7 @@ _base_info_dealloc (PyGIBaseInfo *self)
 
     g_base_info_unref (self->info);
 
-    _pygi_callable_cache_free(self->cache);
+    pygi_callable_cache_free(self->cache);
 
     Py_TYPE( (PyObject *) self)->tp_free ( (PyObject *) self);
 }
diff --git a/gi/pygi-invoke.c b/gi/pygi-invoke.c
index 151c9e5..1d89912 100644
--- a/gi/pygi-invoke.c
+++ b/gi/pygi-invoke.c
@@ -720,7 +720,7 @@ _wrap_g_callable_info_invoke (PyGIBaseInfo *self, PyObject *py_args,
                               PyObject *kwargs)
 {
     if (self->cache == NULL) {
-        self->cache = _pygi_callable_cache_new (self->info, FALSE);
+        self->cache = pygi_callable_cache_new (self->info, FALSE);
         if (self->cache == NULL)
             return NULL;
     }
diff --git a/gi/pygi-list.c b/gi/pygi-list.c
index 5244b1a..af2afd8 100644
--- a/gi/pygi-list.c
+++ b/gi/pygi-list.c
@@ -460,7 +460,7 @@ pygi_arg_glist_new_from_info (GITypeInfo   *type_info,
     if (res) {
         return arg_cache;
     } else {
-        _pygi_arg_cache_free (arg_cache);
+        pygi_arg_cache_free (arg_cache);
         return NULL;
     }
 }
diff --git a/gi/pygi-object.c b/gi/pygi-object.c
index 9abfc6b..2aefee1 100644
--- a/gi/pygi-object.c
+++ b/gi/pygi-object.c
@@ -267,7 +267,7 @@ pygi_arg_gobject_new_from_info (GITypeInfo      *type_info,
     if (res) {
         return cache;
     } else {
-        _pygi_arg_cache_free (cache);
+        pygi_arg_cache_free (cache);
         return NULL;
     }
 }
diff --git a/gi/pygi-struct-marshal.c b/gi/pygi-struct-marshal.c
index 52573d6..338f2be 100644
--- a/gi/pygi-struct-marshal.c
+++ b/gi/pygi-struct-marshal.c
@@ -511,7 +511,7 @@ pygi_arg_struct_new_from_info (GITypeInfo      *type_info,
     if (res) {
         return cache;
     } else {
-        _pygi_arg_cache_free (cache);
+        pygi_arg_cache_free (cache);
         return NULL;
     }
 }


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