From d34c9bc6f335b22260df25d849cb3f26d3998349 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 13 Oct 2010 12:22:41 +0100 Subject: [PATCH] g_variant_get_fixed_array: document which types are appropriate Bug: https://bugzilla.gnome.org/show_bug.cgi?id=632049 Signed-off-by: Simon McVittie Reviewed-by: Ryan Lortie --- glib/gvariant.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/glib/gvariant.c b/glib/gvariant.c index d4469adbb..9c92811b7 100644 --- a/glib/gvariant.c +++ b/glib/gvariant.c @@ -94,7 +94,7 @@ * information cache, buffer management memory and memory for the * #GVariant structure itself. * - * + * * Serialised Data Memory * * This is the memory that is used for storing GVariant data in @@ -1055,10 +1055,33 @@ g_variant_lookup_value (GVariant *dictionary, * items. * * @value must be an array with fixed-sized elements. Numeric types are - * fixed-size as are tuples containing only other fixed-sized types. + * fixed-size, as are tuples containing only other fixed-sized types. * - * @element_size must be the size of a single element in the array. For - * example, if calling this function for an array of 32 bit integers, + * @element_size must be the size of a single element in the array, + * as given by the section on + * Serialised Data + * Memory. + * + * In particular, arrays of these fixed-sized types can be interpreted + * as an array of the given C type, with @element_size set to + * sizeof the appropriate type: + * + * + * + * element type C type + * + * %G_VARIANT_TYPE_INT16 (etc.) + * #gint16 (etc.) + * %G_VARIANT_TYPE_BOOLEAN + * #guchar (not #gboolean!) + * %G_VARIANT_TYPE_BYTE #guchar + * %G_VARIANT_TYPE_HANDLE #guint32 + * %G_VARIANT_TYPE_DOUBLE #gdouble + * + * + * + * + * For example, if calling this function for an array of 32 bit integers, * you might say sizeof (gint32). This value isn't used * except for the purpose of a double-check that the form of the * seralised data matches the caller's expectation.