[gjs: 1/2] arg: Fix the marshalling of GPtrArrays by ensuring that their elements are considered as pointers in
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 1/2] arg: Fix the marshalling of GPtrArrays by ensuring that their elements are considered as pointers in
- Date: Thu, 20 Jun 2019 01:44:03 +0000 (UTC)
commit 3a5e42dbe750ed27534d60de1f78cdefa2ce20b1
Author: Stephane Seng <seng stephane gmail com>
Date: Mon Jun 10 15:10:05 2019 +0200
arg: Fix the marshalling of GPtrArrays by ensuring that their elements are considered as pointers instead
of structures
When marshalling GPtrArrays of GI_INFO_TYPE_STRUCT such as NMIPAddress,
GPtrArrays are considered as arrays of structures instead of arrays of
pointers, with both `info_type == GI_INFO_TYPE_STRUCT` and
`!g_type_info_is_pointer(param_info)` being `true`.
One way of fixing this issue is to consider the array type in
`gjs_array_from_carray_internal()` so that we can avoid treating array elements
as structures instead of pointers when the array is a `GPtrArray`.
Unfortunately it does not look like tests can easily be added to cover this
fix, without having to add new functions in
https://gitlab.gnome.org/GNOME/gobject-introspection/blob/1.60.1/tests/gimarshallingtests.c.
Closes #9.
gi/arg.cpp | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/gi/arg.cpp b/gi/arg.cpp
index 21f1de33..d8e61946 100644
--- a/gi/arg.cpp
+++ b/gi/arg.cpp
@@ -2237,6 +2237,7 @@ GJS_JSAPI_RETURN_CONVENTION
static bool
gjs_array_from_carray_internal (JSContext *context,
JS::MutableHandleValue value_p,
+ GIArrayType array_type,
GITypeInfo *param_info,
guint length,
gpointer array)
@@ -2325,7 +2326,8 @@ gjs_array_from_carray_internal (JSContext *context,
GIBaseInfo *interface_info = g_type_info_get_interface (param_info);
GIInfoType info_type = g_base_info_get_type (interface_info);
- if ((info_type == GI_INFO_TYPE_STRUCT ||
+ if (array_type != GI_ARRAY_TYPE_PTR_ARRAY &&
+ (info_type == GI_INFO_TYPE_STRUCT ||
info_type == GI_INFO_TYPE_UNION) &&
!g_type_info_is_pointer(param_info)) {
size_t struct_size;
@@ -2394,7 +2396,9 @@ gjs_array_from_fixed_size_array (JSContext *context,
param_info = g_type_info_get_param_type(type_info, 0);
- res = gjs_array_from_carray_internal(context, value_p, param_info, length, array);
+ res = gjs_array_from_carray_internal(context, value_p,
+ g_type_info_get_array_type(type_info),
+ param_info, length, array);
g_base_info_unref((GIBaseInfo*)param_info);
@@ -2413,7 +2417,9 @@ gjs_value_from_explicit_array(JSContext *context,
param_info = g_type_info_get_param_type(type_info, 0);
- res = gjs_array_from_carray_internal(context, value_p, param_info, length, arg->v_pointer);
+ res = gjs_array_from_carray_internal(context, value_p,
+ g_type_info_get_array_type(type_info),
+ param_info, length, arg->v_pointer);
g_base_info_unref((GIBaseInfo*)param_info);
@@ -2456,7 +2462,8 @@ gjs_array_from_boxed_array (JSContext *context,
g_assert_not_reached();
}
- return gjs_array_from_carray_internal(context, value_p, param_info, length, data);
+ return gjs_array_from_carray_internal(context, value_p, array_type,
+ param_info, length, data);
}
GJS_JSAPI_RETURN_CONVENTION
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]