Commit b626c46b authored by John (J5) Palmieri's avatar John (J5) Palmieri
Browse files

[gi-invoke-ng] add list cleanup routines

parent 2e542c32
......@@ -575,7 +575,7 @@ _arg_cache_in_glist_setup (PyGIArgCache *arg_cache,
GITransfer transfer)
{
arg_cache->in_marshaller = _pygi_marshal_in_glist;
/* arg_cache->cleanup = */
arg_cache->in_cleanup = _pygi_marshal_cleanup_in_glist;
}
static inline void
......@@ -583,7 +583,7 @@ _arg_cache_out_glist_setup (PyGIArgCache *arg_cache,
GITransfer transfer)
{
arg_cache->out_marshaller = _pygi_marshal_out_glist;
/* arg_cache->cleanup = */
arg_cache->in_cleanup = _pygi_marshal_cleanup_out_glist;
}
static inline void
......@@ -591,7 +591,7 @@ _arg_cache_in_gslist_setup (PyGIArgCache *arg_cache,
GITransfer transfer)
{
arg_cache->in_marshaller = _pygi_marshal_in_gslist;
/* arg_cache->cleanup = */
arg_cache->in_cleanup = _pygi_marshal_cleanup_in_glist;
}
static inline void
......@@ -599,7 +599,7 @@ _arg_cache_out_gslist_setup (PyGIArgCache *arg_cache,
GITransfer transfer)
{
arg_cache->out_marshaller = _pygi_marshal_out_gslist;
/* arg_cache->cleanup = */
arg_cache->out_cleanup = _pygi_marshal_cleanup_out_glist;
}
static inline void
......
......@@ -336,3 +336,87 @@ _pygi_marshal_cleanup_out_array (PyGIInvokeState *state,
g_array_free (array_, TRUE);
}
}
void
_pygi_marshal_cleanup_in_glist (PyGIInvokeState *state,
PyGIArgCache *arg_cache,
gpointer data,
gboolean was_processed)
{
if (was_processed) {
GSList *list_;
PyGISequenceCache *sequence_cache = (PyGISequenceCache *)arg_cache;
list_ = (GSList *)data;
/* clean up items first */
if (sequence_cache->item_cache->in_cleanup != NULL) {
PyGIMarshalCleanupFunc cleanup_func =
sequence_cache->item_cache->in_cleanup;
GSList *node = list_;
while (node != NULL) {
cleanup_func (state,
sequence_cache->item_cache,
node->data,
TRUE);
node = node->next;
}
}
if (state->failed ||
arg_cache->transfer == GI_TRANSFER_NOTHING ||
arg_cache->transfer == GI_TRANSFER_CONTAINER) {
switch (arg_cache->type_tag) {
case GI_TYPE_TAG_GLIST:
g_list_free ( (GList *)list_);
break;
case GI_TYPE_TAG_GSLIST:
g_slist_free (list_);
break;
default:
g_assert_not_reached();
}
}
}
}
void
_pygi_marshal_cleanup_out_glist (PyGIInvokeState *state,
PyGIArgCache *arg_cache,
gpointer data,
gboolean was_processed)
{
PyGISequenceCache *sequence_cache = (PyGISequenceCache *)arg_cache;
if (arg_cache->transfer == GI_TRANSFER_EVERYTHING ||
arg_cache->transfer == GI_TRANSFER_CONTAINER) {
GSList *list_ = (GSList *)data;
if (sequence_cache->item_cache->out_cleanup != NULL) {
PyGIMarshalCleanupFunc cleanup_func =
sequence_cache->item_cache->out_cleanup;
GSList *node = list_;
while (node != NULL) {
cleanup_func (state,
sequence_cache->item_cache,
node->data,
was_processed);
node = node->next;
}
}
if (arg_cache->transfer == GI_TRANSFER_EVERYTHING) {
switch (arg_cache->type_tag) {
case GI_TYPE_TAG_GLIST:
g_list_free ( (GList *)list_);
break;
case GI_TYPE_TAG_GSLIST:
g_slist_free (list_);
break;
default:
g_assert_not_reached();
}
}
}
}
......@@ -76,6 +76,14 @@ void _pygi_marshal_cleanup_out_array (PyGIInvokeState *state,
PyGIArgCache *arg_cache,
gpointer data,
gboolean was_processed);
void _pygi_marshal_cleanup_in_glist (PyGIInvokeState *state,
PyGIArgCache *arg_cache,
gpointer data,
gboolean was_processed);
void _pygi_marshal_cleanup_out_glist (PyGIInvokeState *state,
PyGIArgCache *arg_cache,
gpointer data,
gboolean was_processed);
G_END_DECLS
......
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