Merge branch '896-variant-type-docs' into 'master'

Documentation and typing improvements for GVariant bytes

Closes #896

See merge request GNOME/glib!117
This commit is contained in:
Emmanuele Bassi 2018-06-19 14:15:37 +00:00
commit df28cfe0b5
4 changed files with 12 additions and 9 deletions

View File

@ -563,7 +563,10 @@
<title>Bytestrings</title>
<para>
The bytestring syntax is a piece of syntactic sugar meant to complement the bytestring APIs in GVariant. It
constructs arrays of non-nul bytes (type '<literal>ay</literal>') with a nul terminator at the end.
constructs arrays of non-nul bytes (type '<literal>ay</literal>') with a nul terminator at the end. These are
normal C strings with no particular encoding enforced, so the bytes may not be valid UTF-8.
Bytestrings are a special case of byte arrays; byte arrays (also type '<literal>ay</literal>'), in the general
case, can contain nul at any position, and need not end with nul.
</para>
<para>
Bytestrings are specified with either <literal>b""</literal> or <literal>b''</literal>. As with strings,

View File

@ -984,7 +984,7 @@ data = g_variant_new_parsed ("(%o, {'brightness': {'value': <%i>, 'max': <%i>}})
<para>
The '<literal>^</literal>' character currently supports conversion to and from bytestrings or to and from arrays
of strings or bytestrings. It has a number of forms.
of strings or bytestrings. It does not support byte arrays. It has a number of forms.
</para>
<para>

View File

@ -403,11 +403,11 @@ g_variant_get_boolean (GVariant *value)
* It is an error to call this function with a @value of any type
* other than %G_VARIANT_TYPE_BYTE.
*
* Returns: a #guchar
* Returns: a #guint8
*
* Since: 2.24
**/
NUMERIC_TYPE (BYTE, byte, guchar)
NUMERIC_TYPE (BYTE, byte, guint8)
/**
* g_variant_new_int16:
@ -1105,7 +1105,7 @@ g_variant_lookup_value (GVariant *dictionary,
* the appropriate type:
* - %G_VARIANT_TYPE_INT16 (etc.): #gint16 (etc.)
* - %G_VARIANT_TYPE_BOOLEAN: #guchar (not #gboolean!)
* - %G_VARIANT_TYPE_BYTE: #guchar
* - %G_VARIANT_TYPE_BYTE: #guint8
* - %G_VARIANT_TYPE_HANDLE: #guint32
* - %G_VARIANT_TYPE_DOUBLE: #gdouble
*
@ -5042,7 +5042,7 @@ g_variant_valist_get_leaf (const gchar **str,
return;
case 'y':
*(guchar *) ptr = g_variant_get_byte (value);
*(guint8 *) ptr = g_variant_get_byte (value);
return;
case 'n':
@ -5083,7 +5083,7 @@ g_variant_valist_get_leaf (const gchar **str,
switch (*(*str)++)
{
case 'y':
*(guchar *) ptr = 0;
*(guint8 *) ptr = 0;
return;
case 'n':

View File

@ -80,7 +80,7 @@ GVariantClass g_variant_classify (GVarian
GLIB_AVAILABLE_IN_ALL
GVariant * g_variant_new_boolean (gboolean value);
GLIB_AVAILABLE_IN_ALL
GVariant * g_variant_new_byte (guchar value);
GVariant * g_variant_new_byte (guint8 value);
GLIB_AVAILABLE_IN_ALL
GVariant * g_variant_new_int16 (gint16 value);
GLIB_AVAILABLE_IN_ALL
@ -133,7 +133,7 @@ GVariant * g_variant_new_fixed_array (const G
GLIB_AVAILABLE_IN_ALL
gboolean g_variant_get_boolean (GVariant *value);
GLIB_AVAILABLE_IN_ALL
guchar g_variant_get_byte (GVariant *value);
guint8 g_variant_get_byte (GVariant *value);
GLIB_AVAILABLE_IN_ALL
gint16 g_variant_get_int16 (GVariant *value);
GLIB_AVAILABLE_IN_ALL