GNOME Bugzilla – Bug 748806
GVariant: Better introduction to the concepts and its uses
Last modified: 2016-04-13 11:09:56 UTC
Created attachment 302764 [details] [review]
gvariant.c: Elaborate on GVariant concept and its use
From a newcomer-to-glib's point of view, the current documentation on GVariant could be more elaborate on what GVariant is and how it can be possibly be used.
Attached patch is a proposal which adds some text briefly explaining the concept of GVariance and its uses.
Attachment 302764 [details] pushed as 985ae37 - gvariant.c: Elaborate on GVariant concept and its use
+ * When declaring a new GVariant, you parse the data you want to store in it
+ * along with a string representing the type of data you wish to parse to it.
+ * If you, for example, want to make a GVariant holding a string:
+ * |[<!-- language="C" -->
+ * g_variant_new('u','40');
+ * ]|
+ * The string 'u' tells GVariant that the data parsed to it (40) is an integer.
This seems completely wrong, and the code would create, if the compiler accepts it, a variant that holds the uint32 value of the multichar constant '40', probably 13360.
Created attachment 325781 [details] [review]
docs: Clean up the GVariant introduction
Fix the example, as well as the consistency in the terms.
Review of attachment 325781 [details] [review]:
Attachment 325781 [details] pushed as a772c28 - docs: Clean up the GVariant introduction
The compiler should not accept this code [g_variant_new('u', 40)], because 'u' is not a string.