Commit 56ac6bd9 authored by Simon Feltman's avatar Simon Feltman

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
parent 204f5a18
......@@ -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;
}
......
......@@ -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;
}
}
......@@ -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;
}
......@@ -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
......
......@@ -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;
}
......
......@@ -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;
}
}
......@@ -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;
}
}
......@@ -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;
}
}
......@@ -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;
}
}
......@@ -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);
}
......
......@@ -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;
}
......
......@@ -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;
}
}
......@@ -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;
}
}
......@@ -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;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment