From 18eb38fa1573dba8ded4cdc7a26d27103e08ba20 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 1 Apr 2025 08:46:22 +0100 Subject: [PATCH] gvarianttype: Improve docs on type validation Spotted by skrcprst. Signed-off-by: Philip Withnall --- glib/gvarianttype.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/glib/gvarianttype.c b/glib/gvarianttype.c index d92b966f7..41d5503e2 100644 --- a/glib/gvarianttype.c +++ b/glib/gvarianttype.c @@ -36,6 +36,19 @@ * * A type in the [type@GLib.Variant] type system. * + * [type@GLib.Variant] types are represented as strings, but have a strict + * syntax described below. All [type@GLib.VariantType]s passed to GLib must be + * valid, and they are typically expected to be static (i.e. not provided by + * user input) as they determine how binary [type@GLib.Variant] data is + * interpreted. + * + * To convert a static string to a [type@GLib.VariantType] in C, use the + * [func@GLib.VARIANT_TYPE] casting macro. When GLib is compiled with checks + * enabled, it will validate the type. To check if an arbitrary string is a + * valid [type@GLib.VariantType], use [func@GLib.VariantType.string_is_valid]. + * + * ## GVariant Type System + * * This section introduces the [type@GLib.Variant] type system. It is based, in * large part, on the D-Bus type system, with two major changes and * some minor lifting of restrictions. The