summaryrefslogtreecommitdiff
path: root/gi/pygi-info.c
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2017-07-12 08:42:21 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2017-07-12 08:42:25 +0900
commit70d11d3c9704b35313f8b4dfbb3bc1c1c4afd87d (patch)
tree11933300cf1858b15462f508825db2d7607af1c8 /gi/pygi-info.c
parent7db802a3275790915ed33b470f58786a362551c6 (diff)
downloadpygobject2-70d11d3c9704b35313f8b4dfbb3bc1c1c4afd87d.tar.gz
pygobject2-70d11d3c9704b35313f8b4dfbb3bc1c1c4afd87d.tar.bz2
pygobject2-70d11d3c9704b35313f8b4dfbb3bc1c1c4afd87d.zip
Imported Upstream version 3.13.90
Change-Id: I048554219111ec0298380f936df392f24036bfd3 Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'gi/pygi-info.c')
-rw-r--r--gi/pygi-info.c59
1 files changed, 57 insertions, 2 deletions
diff --git a/gi/pygi-info.c b/gi/pygi-info.c
index c07d113..4df3359 100644
--- a/gi/pygi-info.c
+++ b/gi/pygi-info.c
@@ -1761,6 +1761,57 @@ static PyMethodDef _PyGIValueInfo_methods[] = {
/* GIFieldInfo */
PYGLIB_DEFINE_TYPE ("gi.FieldInfo", PyGIFieldInfo_Type, PyGIBaseInfo);
+static gssize
+_struct_field_array_length_marshal (gsize length_index,
+ void *container_ptr,
+ void *struct_data_ptr)
+{
+ gssize array_len = -1;
+ GIFieldInfo *array_len_field = NULL;
+ GIArgument arg = {0};
+ GIBaseInfo *container_info = (GIBaseInfo *)container_ptr;
+
+ switch (g_base_info_get_type (container_info)) {
+ case GI_INFO_TYPE_UNION:
+ array_len_field = g_union_info_get_field ((GIUnionInfo *)container_info, length_index);
+ break;
+ case GI_INFO_TYPE_STRUCT:
+ array_len_field = g_struct_info_get_field ((GIStructInfo *)container_info, length_index);
+ break;
+ case GI_INFO_TYPE_OBJECT:
+ array_len_field = g_object_info_get_field ((GIObjectInfo *)container_info, length_index);
+ break;
+ default:
+ /* Other types don't have fields. */
+ g_assert_not_reached();
+ }
+
+ if (array_len_field == NULL) {
+ return -1;
+ }
+
+ if (g_field_info_get_field (array_len_field, struct_data_ptr, &arg)) {
+ GITypeInfo *array_len_type_info;
+
+ array_len_type_info = g_field_info_get_type (array_len_field);
+ if (array_len_type_info == NULL) {
+ goto out;
+ }
+
+ if (!pygi_argument_to_gssize (&arg,
+ g_type_info_get_tag (array_len_type_info),
+ &array_len)) {
+ array_len = -1;
+ }
+
+ g_base_info_unref (array_len_type_info);
+ }
+
+out:
+ g_base_info_unref (array_len_field);
+ return array_len;
+}
+
static PyObject *
_wrap_g_field_info_get_value (PyGIBaseInfo *self,
PyObject *args)
@@ -1850,8 +1901,12 @@ _wrap_g_field_info_get_value (PyGIBaseInfo *self,
}
if (g_type_info_get_tag (field_type_info) == GI_TYPE_TAG_ARRAY) {
- value.v_pointer = _pygi_argument_to_array (&value, NULL, NULL, NULL,
- field_type_info, &free_array);
+ value.v_pointer = _pygi_argument_to_array (&value,
+ _struct_field_array_length_marshal,
+ container_info,
+ pointer,
+ field_type_info,
+ &free_array);
}
argument_to_object: