tuple_info = (TupleInfo *) info;
for (i = 0; i < tuple_info->n_members; i++)
- g_variant_type_info_unref (tuple_info->members[i].type);
+ g_variant_type_info_unref (tuple_info->members[i].type_info);
g_slice_free1 (sizeof (GVariantMemberInfo) * tuple_info->n_members,
tuple_info->members);
item_type = g_variant_type_first (type);
while (item_type)
{
- (*members)[i++].type = g_variant_type_info_get (item_type);
+ GVariantMemberInfo *member = &(*members)[i++];
+
+ member->type_info = g_variant_type_info_get (item_type);
item_type = g_variant_type_next (item_type);
+
+ if (item_type == NULL)
+ member->ending_type = G_VARIANT_MEMBER_ENDING_LAST;
+ else if (member->type_info->fixed_size)
+ member->ending_type = G_VARIANT_MEMBER_ENDING_FIXED;
+ else
+ member->ending_type = G_VARIANT_MEMBER_ENDING_OFFSET;
}
g_assert (i == *n_members);
if (&info->members[info->n_members] == item)
return FALSE;
- *d = item->type->alignment;
- *e = item->type->fixed_size;
+ *d = item->type_info->alignment;
+ *e = item->type_info->fixed_size;
return TRUE;
}
/* can find the max of a list of "one less than" powers of two
* by 'or'ing them
*/
- base->alignment |= m->type->alignment;
+ base->alignment |= m->type_info->alignment;
m--; /* take 'm' back to the last item */
* offsets are stored and the last item is fixed-sized too (since
* an offset is never stored for the last item).
*/
- if (m->i == -1 && m->type->fixed_size)
+ if (m->i == -1 && m->type_info->fixed_size)
/* in that case, the fixed size can be found by finding the
* start of the last item (in the usual way) and adding its
* fixed size.
* easier) so we round up to that here.
*/
base->fixed_size =
- tuple_align (((m->a & m->b) | m->c) + m->type->fixed_size,
+ tuple_align (((m->a & m->b) | m->c) + m->type_info->fixed_size,
base->alignment);
else
/* else, the tuple is not fixed size */
*
* For details about how 'a', 'b' and 'c' are calculated, see the
* comments at the point of the implementation in gvariantypeinfo.c.
+ *
+ * The end address of the item is then determined in one of three ways,
+ * according to the 'end_type' field.
+ *
+ * - FIXED: For fixed sized items, the end address is equal to the
+ * start address plus the fixed size.
+ *
+ * - LAST: For the last variable sized item in the tuple, the end
+ * address is equal to the end address of the tuple, minus the size
+ * of the offset array.
+ *
+ * - OFFSET: For other variable sized items, the next index past 'i'
+ * (ie: 'i + 1') must be consulted to find the end of this item.
*/
typedef struct
{
- GVariantTypeInfo *type;
+ GVariantTypeInfo *type_info;
gsize i, a;
gint8 b, c;
+
+ guint8 ending_type;
} GVariantMemberInfo;
+#define G_VARIANT_MEMBER_ENDING_FIXED 0
+#define G_VARIANT_MEMBER_ENDING_LAST 1
+#define G_VARIANT_MEMBER_ENDING_OFFSET 2
+
/* query */
G_GNUC_INTERNAL
const gchar * g_variant_type_info_get_type_string (GVariantTypeInfo *typeinfo);
sep = ", ";
minfo = g_variant_type_info_member_info (info, i);
- subtype = describe_info (minfo->type);
+ subtype = describe_info (minfo->type_info);
g_string_append (string, subtype);
g_free (subtype);
}
g_assert_cmpint (g_variant_type_info_n_members (info), ==, 2);
keyinfo = g_variant_type_info_member_info (info, 0);
valueinfo = g_variant_type_info_member_info (info, 1);
- key = describe_info (keyinfo->type);
- value = describe_info (valueinfo->type);
+ key = describe_info (keyinfo->type_info);
+ value = describe_info (valueinfo->type_info);
result = g_strjoin ("", "e of [", key, ", ", value, "]", NULL);
g_free (key);
g_free (value);