summaryrefslogtreecommitdiffstats
path: root/gi
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu@sugarlabs.org>2009-11-25 10:33:56 +0100
committerTomeu Vizoso <tomeu@sugarlabs.org>2009-12-22 17:58:52 +0100
commit24fa1224ff00b9da177e0bfaa1e14e1b899e4976 (patch)
tree9d987e0adf0932ddf538aaff17cb33fc5d239762 /gi
parente955b931b07113c7432f7a85f882f69f12d263ad (diff)
downloadpygi-24fa1224ff00b9da177e0bfaa1e14e1b899e4976.tar.gz
pygi-24fa1224ff00b9da177e0bfaa1e14e1b899e4976.tar.xz
pygi-24fa1224ff00b9da177e0bfaa1e14e1b899e4976.zip
The array field 'length' starts to count from the C arg list, so need to decrement when it's a method
https://bugzilla.gnome.org/show_bug.cgi?id=602640
Diffstat (limited to 'gi')
-rw-r--r--gi/pygi-argument.c11
-rw-r--r--gi/pygi-argument.h3
-rw-r--r--gi/pygi-info.c14
3 files changed, 24 insertions, 4 deletions
diff --git a/gi/pygi-argument.c b/gi/pygi-argument.c
index 7740d0c..b7edcdf 100644
--- a/gi/pygi-argument.c
+++ b/gi/pygi-argument.c
@@ -597,7 +597,8 @@ check_number_release:
GArray *
_pygi_argument_to_array (GArgument *arg,
GArgument *args[],
- GITypeInfo *type_info)
+ GITypeInfo *type_info,
+ gboolean is_method)
{
GITypeInfo *item_type_info;
gboolean is_zero_terminated;
@@ -622,11 +623,19 @@ _pygi_argument_to_array (GArgument *arg,
length_arg_pos = g_type_info_get_array_length(type_info);
g_assert(length_arg_pos >= 0);
+ if (is_method) {
+ length_arg_pos--;
+ }
+
+ g_assert (length_arg_pos >= 0);
+
/* FIXME: Take into account the type of the argument. */
length = args[length_arg_pos]->v_int;
}
}
+ g_assert (length >= 0);
+
g_array = g_array_new(is_zero_terminated, FALSE, item_size);
g_array->data = arg->v_pointer;
diff --git a/gi/pygi-argument.h b/gi/pygi-argument.h
index 59458fc..eef61a2 100644
--- a/gi/pygi-argument.h
+++ b/gi/pygi-argument.h
@@ -42,7 +42,8 @@ gint _pygi_g_registered_type_info_check_object (GIRegisteredTypeInfo *info,
GArray* _pygi_argument_to_array (GArgument *arg,
GArgument *args[],
- GITypeInfo *type_info);
+ GITypeInfo *type_info,
+ gboolean is_method);
GArgument _pygi_argument_from_object (PyObject *object,
GITypeInfo *type_info,
diff --git a/gi/pygi-info.c b/gi/pygi-info.c
index 11751a9..6e2b938 100644
--- a/gi/pygi-info.c
+++ b/gi/pygi-info.c
@@ -584,6 +584,10 @@ _wrap_g_function_info_invoke (PyGIBaseInfo *self,
gint length_arg_pos;
length_arg_pos = g_type_info_get_array_length(arg_type_infos[i]);
+
+ if (is_method)
+ length_arg_pos--; // length_arg_pos refers to C args
+
if (length_arg_pos < 0) {
break;
}
@@ -615,6 +619,10 @@ _wrap_g_function_info_invoke (PyGIBaseInfo *self,
if (return_type_tag == GI_TYPE_TAG_ARRAY) {
gint length_arg_pos;
length_arg_pos = g_type_info_get_array_length(return_type_info);
+
+ if (is_method)
+ length_arg_pos--; // length_arg_pos refers to C args
+
if (length_arg_pos >= 0) {
g_assert(length_arg_pos < n_args);
args_is_auxiliary[length_arg_pos] = TRUE;
@@ -894,6 +902,8 @@ _wrap_g_function_info_invoke (PyGIBaseInfo *self,
array = args[i]->v_pointer;
length_arg_pos = g_type_info_get_array_length(arg_type_infos[i]);
+ if (is_method)
+ length_arg_pos--; // length_arg_pos refers to C args
if (length_arg_pos >= 0) {
/* Set the auxiliary argument holding the length. */
args[length_arg_pos]->v_size = array->len;
@@ -1031,7 +1041,7 @@ _wrap_g_function_info_invoke (PyGIBaseInfo *self,
if (return_type_tag == GI_TYPE_TAG_ARRAY) {
/* Create a #GArray. */
- return_arg.v_pointer = _pygi_argument_to_array(&return_arg, args, return_type_info);
+ return_arg.v_pointer = _pygi_argument_to_array(&return_arg, args, return_type_info, is_method);
}
transfer = g_callable_info_get_caller_owns((GICallableInfo *)self->info);
@@ -1100,7 +1110,7 @@ _wrap_g_function_info_invoke (PyGIBaseInfo *self,
if (type_tag == GI_TYPE_TAG_ARRAY
&& (direction != GI_DIRECTION_IN || transfer == GI_TRANSFER_NOTHING)) {
/* Create a #GArray. */
- args[i]->v_pointer = _pygi_argument_to_array(args[i], args, arg_type_infos[i]);
+ args[i]->v_pointer = _pygi_argument_to_array(args[i], args, arg_type_infos[i], is_method);
}
if (direction == GI_DIRECTION_INOUT || direction == GI_DIRECTION_OUT) {