mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-13 15:56:23 +01:00
Add g_variant_is_floating
This commit is contained in:
parent
7bb00fd0e8
commit
052ef2614a
@ -2808,6 +2808,7 @@ GVariant
|
||||
g_variant_unref
|
||||
g_variant_ref
|
||||
g_variant_ref_sink
|
||||
g_variant_is_floating
|
||||
g_variant_get_type
|
||||
g_variant_get_type_string
|
||||
g_variant_is_of_type
|
||||
|
@ -1710,6 +1710,7 @@ g_variant_type_checked_
|
||||
g_variant_unref
|
||||
g_variant_ref
|
||||
g_variant_ref_sink
|
||||
g_variant_is_floating
|
||||
g_variant_n_children
|
||||
g_variant_get_child_value
|
||||
g_variant_get_size
|
||||
|
@ -674,6 +674,30 @@ g_variant_ref_sink (GVariant *value)
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* g_variant_is_floating:
|
||||
* @value: a #GVariant
|
||||
* @returns: whether @value is floating
|
||||
*
|
||||
* Checks whether @value has a floating reference count.
|
||||
*
|
||||
* This function should only ever be used to assert that a given variant
|
||||
* is or is not floating, or for debug purposes. To acquire a reference
|
||||
* to a variant that might be floating, always use g_variant_ref_sink().
|
||||
*
|
||||
* See g_variant_ref_sink() for more information about floating reference
|
||||
* counts.
|
||||
*
|
||||
* Since: 2.26
|
||||
**/
|
||||
gboolean
|
||||
g_variant_is_floating (GVariant *value)
|
||||
{
|
||||
g_return_val_if_fail (value != NULL, FALSE);
|
||||
|
||||
return (value->state & STATE_FLOATING) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* g_variant_get_size:
|
||||
* @value: a #GVariant instance
|
||||
|
@ -55,6 +55,7 @@ typedef enum
|
||||
void g_variant_unref (GVariant *value);
|
||||
GVariant * g_variant_ref (GVariant *value);
|
||||
GVariant * g_variant_ref_sink (GVariant *value);
|
||||
gboolean g_variant_is_floating (GVariant *value);
|
||||
|
||||
const GVariantType * g_variant_get_type (GVariant *value);
|
||||
const gchar * g_variant_get_type_string (GVariant *value);
|
||||
|
@ -3800,6 +3800,18 @@ test_parse_positional (void)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
test_floating (void)
|
||||
{
|
||||
GVariant *value;
|
||||
|
||||
value = g_variant_new_int32 (42);
|
||||
g_assert (g_variant_is_floating (value));
|
||||
g_variant_ref_sink (value);
|
||||
g_assert (!g_variant_is_floating (value));
|
||||
g_variant_unref (value);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
@ -3838,6 +3850,7 @@ main (int argc, char **argv)
|
||||
g_test_add_func ("/gvariant/parser", test_parses);
|
||||
g_test_add_func ("/gvariant/parse-failures", test_parse_failures);
|
||||
g_test_add_func ("/gvariant/parse-positional", test_parse_positional);
|
||||
g_test_add_func ("/gvariant/floating", test_floating);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user