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

[gi] fix sequence caching to support out

parent 9f101baa
...@@ -33,6 +33,14 @@ PyGIArgCache * _arg_cache_in_new_from_type_info (GITypeInfo *type_info, ...@@ -33,6 +33,14 @@ PyGIArgCache * _arg_cache_in_new_from_type_info (GITypeInfo *type_info,
GIDirection direction, GIDirection direction,
gint c_arg_index, gint c_arg_index,
gint py_arg_index); gint py_arg_index);
PyGIArgCache * _arg_cache_out_new_from_type_info (GITypeInfo *type_info,
PyGIFunctionCache *function_cache,
GITypeTag type_tag,
GITransfer transfer,
GIDirection direction,
gboolean is_caller_allocates,
gint c_arg_index);
/* cleanup */ /* cleanup */
void void
_pygi_arg_cache_free(PyGIArgCache *cache) _pygi_arg_cache_free(PyGIArgCache *cache)
...@@ -156,11 +164,14 @@ _interface_cache_new_from_interface_info(GIInterfaceInfo *iface_info) ...@@ -156,11 +164,14 @@ _interface_cache_new_from_interface_info(GIInterfaceInfo *iface_info)
static inline PyGISequenceCache * static inline PyGISequenceCache *
_sequence_cache_new_from_type_info(GITypeInfo *type_info, _sequence_cache_new_from_type_info(GITypeInfo *type_info,
GIDirection direction,
GITransfer transfer,
gint aux_offset) gint aux_offset)
{ {
PyGISequenceCache *sc; PyGISequenceCache *sc;
GITypeInfo *item_type_info; GITypeInfo *item_type_info;
GITypeTag item_type_tag; GITypeTag item_type_tag;
GITransfer item_transfer;
sc = g_slice_new0(PyGISequenceCache); sc = g_slice_new0(PyGISequenceCache);
((PyGIArgCache *)sc)->destroy_notify = (GDestroyNotify)_sequence_cache_free_func; ((PyGIArgCache *)sc)->destroy_notify = (GDestroyNotify)_sequence_cache_free_func;
...@@ -176,14 +187,30 @@ _sequence_cache_new_from_type_info(GITypeInfo *type_info, ...@@ -176,14 +187,30 @@ _sequence_cache_new_from_type_info(GITypeInfo *type_info,
item_type_info = g_type_info_get_param_type (type_info, 0); item_type_info = g_type_info_get_param_type (type_info, 0);
item_type_tag = g_type_info_get_tag (item_type_info); item_type_tag = g_type_info_get_tag (item_type_info);
/* FIXME: support out also */ item_transfer = GI_TRANSFER_NOTHING;
sc->item_cache = _arg_cache_in_new_from_type_info(item_type_info, if (transfer == GI_TRANSFER_EVERYTHING ||
NULL, transfer == GI_TRANSFER_CONTAINER)
NULL, item_transfer = GI_TRANSFER_EVERYTHING;
item_type_tag,
GI_TRANSFER_EVERYTHING, /* FIXME: in/out */
GI_DIRECTION_IN,
0, 0); if (direction == GI_DIRECTION_IN)
sc->item_cache = _arg_cache_in_new_from_type_info(item_type_info,
NULL,
NULL,
item_type_tag,
item_transfer,
direction,
0, 0);
else
sc->item_cache = _arg_cache_out_new_from_type_info(item_type_info,
NULL,
item_type_tag,
item_transfer,
direction,
FALSE,
0);
if (sc->item_cache == NULL) { if (sc->item_cache == NULL) {
_pygi_arg_cache_free((PyGIArgCache *)sc); _pygi_arg_cache_free((PyGIArgCache *)sc);
...@@ -410,7 +437,9 @@ _arg_cache_new_for_in_array(PyGIFunctionCache *function_cache, ...@@ -410,7 +437,9 @@ _arg_cache_new_for_in_array(PyGIFunctionCache *function_cache,
GITypeInfo *type_info, GITypeInfo *type_info,
GITransfer transfer) GITransfer transfer)
{ {
PyGISequenceCache *seq_cache = _sequence_cache_new_from_type_info(type_info, PyGISequenceCache *seq_cache = _sequence_cache_new_from_type_info(type_info,
GI_DIRECTION_IN,
transfer,
(function_cache->is_method ? 1: 0)); (function_cache->is_method ? 1: 0));
PyGIArgCache *arg_cache = (PyGIArgCache *)seq_cache; PyGIArgCache *arg_cache = (PyGIArgCache *)seq_cache;
...@@ -440,7 +469,10 @@ _arg_cache_new_for_in_glist(GITypeInfo *type_info, ...@@ -440,7 +469,10 @@ _arg_cache_new_for_in_glist(GITypeInfo *type_info,
GITransfer transfer) GITransfer transfer)
{ {
PyGIArgCache *arg_cache = PyGIArgCache *arg_cache =
(PyGIArgCache *)_sequence_cache_new_from_type_info(type_info, 0); (PyGIArgCache *)_sequence_cache_new_from_type_info(type_info,
GI_DIRECTION_IN,
transfer,
0);
arg_cache->in_marshaller = _pygi_marshal_in_glist; arg_cache->in_marshaller = _pygi_marshal_in_glist;
/* arg_cache->cleanup = */ /* arg_cache->cleanup = */
...@@ -449,10 +481,13 @@ _arg_cache_new_for_in_glist(GITypeInfo *type_info, ...@@ -449,10 +481,13 @@ _arg_cache_new_for_in_glist(GITypeInfo *type_info,
static inline PyGIArgCache * static inline PyGIArgCache *
_arg_cache_new_for_in_gslist(GITypeInfo *type_info, _arg_cache_new_for_in_gslist(GITypeInfo *type_info,
GITransfer transfer) GITransfer transfer)
{ {
PyGIArgCache *arg_cache = PyGIArgCache *arg_cache =
(PyGIArgCache *)_sequence_cache_new_from_type_info(type_info, 0); (PyGIArgCache *)_sequence_cache_new_from_type_info(type_info,
GI_DIRECTION_IN,
transfer,
0);
arg_cache->in_marshaller = _pygi_marshal_in_gslist; arg_cache->in_marshaller = _pygi_marshal_in_gslist;
/* arg_cache->cleanup = */ /* arg_cache->cleanup = */
...@@ -483,9 +518,9 @@ _arg_cache_new_for_in_interface_union(GIInterfaceInfo *iface_info, ...@@ -483,9 +518,9 @@ _arg_cache_new_for_in_interface_union(GIInterfaceInfo *iface_info,
PyGIInterfaceCache *iface_cache = _interface_cache_new_from_interface_info(iface_info); PyGIInterfaceCache *iface_cache = _interface_cache_new_from_interface_info(iface_info);
PyGIArgCache *arg_cache = (PyGIArgCache *)iface_cache; PyGIArgCache *arg_cache = (PyGIArgCache *)iface_cache;
arg_cache->in_marshaller = _pygi_marshal_in_interface_struct; arg_cache->in_marshaller = _pygi_marshal_in_interface_struct;
return arg_cache;
} }
static void static void
_g_slice_free_gvalue_func(GValue *value) { _g_slice_free_gvalue_func(GValue *value) {
g_slice_free(GValue, value); g_slice_free(GValue, value);
...@@ -761,23 +796,47 @@ _arg_cache_new_for_out_filename(GITransfer transfer) ...@@ -761,23 +796,47 @@ _arg_cache_new_for_out_filename(GITransfer transfer)
} }
static inline PyGIArgCache * static inline PyGIArgCache *
_arg_cache_new_for_out_array(GITypeInfo *type_info, _arg_cache_new_for_out_array(PyGIFunctionCache *function_cache,
GITransfer transfer) GITypeInfo *type_info,
{ GITransfer transfer)
PyGIArgCache *arg_cache = {
(PyGIArgCache *)_sequence_cache_new_from_type_info(type_info, 0); PyGISequenceCache *seq_cache =
_sequence_cache_new_from_type_info(type_info,
GI_DIRECTION_OUT,
transfer,
function_cache->is_method ? 1: 0);
PyGIArgCache *arg_cache = (PyGIArgCache *)seq_cache;
arg_cache->out_marshaller = _pygi_marshal_out_array; arg_cache->out_marshaller = _pygi_marshal_out_array;
seq_cache->array_type = g_type_info_get_array_type(type_info);
if (seq_cache->len_arg_index >= 0) {
PyGIArgCache *aux_cache = _arg_cache_new();
aux_cache->aux_type = PYGI_AUX_TYPE_IGNORE;
if (function_cache->args_cache[seq_cache->len_arg_index] != NULL) {
PyGIArgCache *invalid_cache = function_cache->args_cache[seq_cache->len_arg_index];
arg_cache->c_arg_index = invalid_cache->c_arg_index;
_pygi_arg_cache_free(invalid_cache);
}
function_cache->args_cache[seq_cache->len_arg_index] = aux_cache;
}
/* arg_cache->cleanup = _pygi_cleanup_array; */ /* arg_cache->cleanup = _pygi_cleanup_array; */
return arg_cache; return arg_cache;
} }
static inline PyGIArgCache * static inline PyGIArgCache *
_arg_cache_new_for_out_glist(GITypeInfo *type_info, _arg_cache_new_for_out_glist(GITypeInfo *type_info,
GITransfer transfer) GITransfer transfer)
{ {
PyGIArgCache *arg_cache = PyGIArgCache *arg_cache =
(PyGIArgCache *)_sequence_cache_new_from_type_info(type_info, 0); (PyGIArgCache *)_sequence_cache_new_from_type_info(type_info,
GI_DIRECTION_OUT,
transfer,
0);
arg_cache->out_marshaller = _pygi_marshal_out_glist; arg_cache->out_marshaller = _pygi_marshal_out_glist;
/* arg_cache->cleanup = */ /* arg_cache->cleanup = */
...@@ -786,10 +845,13 @@ _arg_cache_new_for_out_glist(GITypeInfo *type_info, ...@@ -786,10 +845,13 @@ _arg_cache_new_for_out_glist(GITypeInfo *type_info,
static inline PyGIArgCache * static inline PyGIArgCache *
_arg_cache_new_for_out_gslist(GITypeInfo *type_info, _arg_cache_new_for_out_gslist(GITypeInfo *type_info,
GITransfer transfer) GITransfer transfer)
{ {
PyGIArgCache *arg_cache = PyGIArgCache *arg_cache =
(PyGIArgCache *)_sequence_cache_new_from_type_info(type_info, 0); (PyGIArgCache *)_sequence_cache_new_from_type_info(type_info,
GI_DIRECTION_OUT,
transfer,
0);
arg_cache->out_marshaller = _pygi_marshal_out_gslist; arg_cache->out_marshaller = _pygi_marshal_out_gslist;
/* arg_cache->cleanup = */ /* arg_cache->cleanup = */
...@@ -996,8 +1058,9 @@ _arg_cache_out_new_from_type_info (GITypeInfo *type_info, ...@@ -996,8 +1058,9 @@ _arg_cache_out_new_from_type_info (GITypeInfo *type_info,
arg_cache = _arg_cache_new_for_out_filename(transfer); arg_cache = _arg_cache_new_for_out_filename(transfer);
break; break;
case GI_TYPE_TAG_ARRAY: case GI_TYPE_TAG_ARRAY:
arg_cache = _arg_cache_new_for_out_array(type_info, arg_cache = _arg_cache_new_for_out_array(function_cache,
transfer); type_info,
transfer);
break; break;
case GI_TYPE_TAG_INTERFACE: case GI_TYPE_TAG_INTERFACE:
{ {
......
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