summaryrefslogtreecommitdiff
path: root/gi/pygi-marshal-to-py.c
diff options
context:
space:
mode:
authorSimon Feltman <sfeltman@src.gnome.org>2013-10-11 21:30:45 -0700
committerSimon Feltman <sfeltman@src.gnome.org>2014-02-02 16:02:57 -0800
commitc48ddacf4479d2cf80beb9c614cdce2a61599b3b (patch)
tree708a19ea7febbd9a2cf9a23d34a1d22df96939f0 /gi/pygi-marshal-to-py.c
parentc1a2a86a7b51f4dc5a5da9f8808552c38acadf9d (diff)
downloadpygobject-c48ddacf4479d2cf80beb9c614cdce2a61599b3b.tar.gz
cache refactoring: Break sequence cache up for array vs list
Add new arg cache type specialized for arrays. This cleans up the basic sequence cache type which does not need length and size related info. Remove fixed length checks from GList and GSList from_py marshaling because these will always be -1. https://bugzilla.gnome.org/show_bug.cgi?id=709700
Diffstat (limited to 'gi/pygi-marshal-to-py.c')
-rw-r--r--gi/pygi-marshal-to-py.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/gi/pygi-marshal-to-py.c b/gi/pygi-marshal-to-py.c
index 292f9628..e3d5475d 100644
--- a/gi/pygi-marshal-to-py.c
+++ b/gi/pygi-marshal-to-py.c
@@ -121,18 +121,19 @@ _pygi_marshal_to_py_array (PyGIInvokeState *state,
GArray *array_;
PyObject *py_obj = NULL;
PyGISequenceCache *seq_cache = (PyGISequenceCache *)arg_cache;
+ PyGIArgGArray *array_cache = (PyGIArgGArray *)arg_cache;
gsize processed_items = 0;
/* GArrays make it easier to iterate over arrays
* with different element sizes but requires that
* we allocate a GArray if the argument was a C array
*/
- if (seq_cache->array_type == GI_ARRAY_TYPE_C) {
+ if (array_cache->array_type == GI_ARRAY_TYPE_C) {
gsize len;
- if (seq_cache->fixed_size >= 0) {
+ if (array_cache->fixed_size >= 0) {
g_assert(arg->v_pointer != NULL);
- len = seq_cache->fixed_size;
- } else if (seq_cache->is_zero_terminated) {
+ len = array_cache->fixed_size;
+ } else if (array_cache->is_zero_terminated) {
if (arg->v_pointer == NULL) {
len = 0;
} else if (seq_cache->item_cache->type_tag == GI_TYPE_TAG_UINT8) {
@@ -141,9 +142,9 @@ _pygi_marshal_to_py_array (PyGIInvokeState *state,
len = g_strv_length ((gchar **)arg->v_pointer);
}
} else {
- GIArgument *len_arg = state->args[seq_cache->len_arg_index];
+ GIArgument *len_arg = state->args[array_cache->len_arg_index];
PyGIArgCache *arg_cache = _pygi_callable_cache_get_arg (callable_cache,
- seq_cache->len_arg_index);
+ array_cache->len_arg_index);
if (!gi_argument_to_gsize (len_arg, &len, arg_cache->type_tag)) {
return NULL;
@@ -152,7 +153,7 @@ _pygi_marshal_to_py_array (PyGIInvokeState *state,
array_ = g_array_new (FALSE,
FALSE,
- seq_cache->item_size);
+ array_cache->item_size);
if (array_ == NULL) {
PyErr_NoMemory ();
@@ -204,7 +205,7 @@ _pygi_marshal_to_py_array (PyGIInvokeState *state,
* and move on, letting the per-item marshaler deal with the
* various transfer modes and ref counts (e.g. g_variant_ref_sink).
*/
- if (seq_cache->array_type == GI_ARRAY_TYPE_PTR_ARRAY) {
+ if (array_cache->array_type == GI_ARRAY_TYPE_PTR_ARRAY) {
item_arg.v_pointer = g_ptr_array_index ( ( GPtrArray *)array_, i);
} else if (item_arg_cache->is_pointer) {
@@ -243,7 +244,7 @@ _pygi_marshal_to_py_array (PyGIInvokeState *state,
if (py_item == NULL) {
Py_CLEAR (py_obj);
- if (seq_cache->array_type == GI_ARRAY_TYPE_C)
+ if (array_cache->array_type == GI_ARRAY_TYPE_C)
g_array_unref (array_);
goto err;
@@ -254,13 +255,13 @@ _pygi_marshal_to_py_array (PyGIInvokeState *state,
}
}
- if (seq_cache->array_type == GI_ARRAY_TYPE_C)
+ if (array_cache->array_type == GI_ARRAY_TYPE_C)
g_array_free (array_, FALSE);
return py_obj;
err:
- if (seq_cache->array_type == GI_ARRAY_TYPE_C) {
+ if (array_cache->array_type == GI_ARRAY_TYPE_C) {
g_array_free (array_, arg_cache->transfer == GI_TRANSFER_EVERYTHING);
} else {
/* clean up unprocessed items */