mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-23 01:18:53 +02:00
gvariant: Document the need to cast varargs when constructing GVariants
Slightly expand on the documentation about casting varargs when constructing GVariants, and link to it from all the functions where it’s a necessary consideration. Add an example of passing flags to a ‘t’ type variable (guint64). Assuming the flags enum does not have many members, the flag variable will be 32 bits wide, and needs an explicit cast to be passed into g_variant_new() as a 64-bit value. https://bugzilla.gnome.org/show_bug.cgi?id=712837
This commit is contained in:
@@ -2428,6 +2428,10 @@ g_variant_parse (const GVariantType *type,
|
||||
* #GVariant pointer will be returned unmodified, without adding any
|
||||
* additional references.
|
||||
*
|
||||
* Note that the arguments in @app must be of the correct width for their types
|
||||
* specified in @format when collected into the #va_list. See
|
||||
* the <link linkend='gvariant-varargs'>GVariant varargs documentation</link>.
|
||||
*
|
||||
* In order to behave correctly in all cases it is necessary for the
|
||||
* calling function to g_variant_ref_sink() the return result before
|
||||
* returning control to the user that originally provided the pointer.
|
||||
@@ -2481,6 +2485,10 @@ g_variant_new_parsed_va (const gchar *format,
|
||||
* that case, the same arguments are collected from the argument list as
|
||||
* g_variant_new() would have collected.
|
||||
*
|
||||
* Note that the arguments must be of the correct width for their types
|
||||
* specified in @format. This can be achieved by casting them. See
|
||||
* the <link linkend='gvariant-varargs'>GVariant varargs documentation</link>.
|
||||
*
|
||||
* Consider this simple example:
|
||||
* |[<!-- language="C" -->
|
||||
* g_variant_new_parsed ("[('one', 1), ('two', %i), (%s, 3)]", 2, "three");
|
||||
@@ -2530,6 +2538,10 @@ g_variant_new_parsed (const gchar *format,
|
||||
* calling g_variant_new_parsed() followed by
|
||||
* g_variant_builder_add_value().
|
||||
*
|
||||
* Note that the arguments must be of the correct width for their types
|
||||
* specified in @format_string. This can be achieved by casting them. See
|
||||
* the <link linkend='gvariant-varargs'>GVariant varargs documentation</link>.
|
||||
*
|
||||
* This function might be used as follows:
|
||||
*
|
||||
* |[<!-- language="C" -->
|
||||
|
Reference in New Issue
Block a user