[glib] GVariant variable arguments, tests, cleanups



commit 75f761bcaa66c82d132c9e3d8cdfcb8ee0971eb6
Author: Ryan Lortie <desrt desrt ca>
Date:   Mon Mar 8 10:30:59 2010 -0500

    GVariant variable arguments, tests, cleanups
    
    Merge GVariant variable arguments support and put it under tests.
    
    Also, remove the hack of the test case directly '#include'ing .c files
    from glib/.  Instead, create a non-installed gvariant-internal.h that
    the tests can include and make the symbols in it visible on the symbol
    table of the shared library.  These symbols (as they are present in no
    installed header files) are not part of the API of GLib.
    
    Increase test coverage in a few other areas.

 docs/reference/glib/glib-docs.sgml       |    1 +
 docs/reference/glib/glib-sections.txt    |   11 +
 docs/reference/glib/gvariant-varargs.xml |  987 +++++++++++++++++++++
 glib/glib.symbols                        |   48 +-
 glib/gvariant-internal.h                 |   49 +
 glib/gvariant-serialiser.c               |    4 +
 glib/gvariant-serialiser.h               |    9 -
 glib/gvariant.c                          | 1397 ++++++++++++++++++++++++++----
 glib/gvariant.h                          |   18 +
 glib/gvarianttypeinfo.c                  |   11 +-
 glib/gvarianttypeinfo.h                  |   10 +-
 glib/tests/gvariant.c                    |  773 ++++++++++++++++-
 12 files changed, 3110 insertions(+), 208 deletions(-)
---
diff --git a/docs/reference/glib/glib-docs.sgml b/docs/reference/glib/glib-docs.sgml
index 47c9a9a..0ab911b 100644
--- a/docs/reference/glib/glib-docs.sgml
+++ b/docs/reference/glib/glib-docs.sgml
@@ -121,6 +121,7 @@ synchronize their operation.
       <xi:include href="xml/allocators.xml" />
       <xi:include href="xml/gvarianttype.xml"/>
       <xi:include href="xml/gvariant.xml"/>
+      <xi:include href="gvariant-varargs.xml"/>
   </chapter>
 
   <chapter id="tools">
diff --git a/docs/reference/glib/glib-sections.txt b/docs/reference/glib/glib-sections.txt
index 015a649..5ae7413 100644
--- a/docs/reference/glib/glib-sections.txt
+++ b/docs/reference/glib/glib-sections.txt
@@ -2799,6 +2799,12 @@ g_variant_classify
 GVariantClass
 
 <SUBSECTION>
+g_variant_get
+g_variant_get_va
+g_variant_new
+g_variant_new_va
+
+<SUBSECTION>
 g_variant_new_boolean
 g_variant_new_byte
 g_variant_new_int16
@@ -2844,6 +2850,7 @@ g_variant_new_dict_entry
 g_variant_get_maybe
 g_variant_n_children
 g_variant_get_child_value
+g_variant_get_child
 g_variant_get_fixed_array
 
 <SUBSECTION>
@@ -2878,9 +2885,13 @@ g_variant_builder_new
 g_variant_builder_init
 g_variant_builder_clear
 g_variant_builder_add_value
+g_variant_builder_add
 g_variant_builder_end
 g_variant_builder_open
 g_variant_builder_close
+
+<SUBSECTION Private>
+g_variant_type_checked_
 </SECTION>
 
 
diff --git a/docs/reference/glib/gvariant-varargs.xml b/docs/reference/glib/gvariant-varargs.xml
new file mode 100644
index 0000000..7b0acfa
--- /dev/null
+++ b/docs/reference/glib/gvariant-varargs.xml
@@ -0,0 +1,987 @@
+<?xml version='1.0' encoding='utf-8'?>
+
+<refentry id='gvariant-format-strings'>
+ <refmeta>
+  <refentrytitle>GVariant Format Strings</refentrytitle>
+ </refmeta>
+
+ <refsect1>
+  <title>Variable Argument Conversions</title>
+
+  <para>
+   This page attempts to document how to perform variable argument conversions with GVariant.
+  </para>
+  <para>
+   Conversions occur according to format strings.  A format string is a two-way mapping between a single
+   <link linkend='GVariant'>GVariant</link> value and one or more C values.
+  </para>
+  <para>
+   A conversion from C values into a <link linkend='GVariant'>GVariant</link> value is made using the
+   <link linkend='g-variant-new'><function>g_variant_new()</function></link> function.  A conversion from a
+   <link linkend='GVariant'>GVariant</link> into C values is made using the
+   <link linkend='g-variant-get'><function>g_variant_get()</function></link> function.
+  </para>
+ </refsect1>
+
+ <refsect1>
+  <title>Syntax</title>
+
+  <para>
+   This section exhaustively describes all possibilities for GVariant format strings.  There are no valid forms of
+   format strings other than those described here.  Please note that the format string syntax is likely to expand in the
+   future.
+  </para>
+  <para>
+   Valid format strings have one of the following forms:
+  </para>
+  <itemizedlist>
+   <listitem>
+    <para>any type string</para>
+   </listitem>
+   <listitem>
+    <para>
+     a type string prefixed with a '<literal>@</literal>'
+    </para>
+   </listitem>
+   <listitem>
+    <para>
+     a type string of a concrete, fixed-sized type, prefixed with a '<literal>&amp;</literal>'
+    </para>
+   </listitem>
+   <listitem>
+    <para>
+     a type string of a concrete, fixed-sized type, prefixed with a '<literal>&amp;a</literal>'
+    </para>
+   </listitem>
+   <listitem>
+    <para>
+     '<literal>&amp;s</literal>' '<literal>&amp;o</literal>', '<literal>&amp;g</literal>', '<literal>^as</literal>',
+     '<literal>^ao</literal>', '<literal>^ag</literal>', '<literal>^a&amp;s</literal>', '<literal>^a&amp;o</literal>' or
+     '<literal>^a&amp;g</literal>'
+    </para>
+   </listitem>
+   <listitem>
+    <para>
+     any conversion string, prefixed with an '<literal>m</literal>'
+    </para>
+   </listitem>
+   <listitem>
+    <para>
+     a sequence of zero or more format strings strings, concatenated and enclosed in parentheses
+    </para>
+   </listitem>
+   <listitem>
+    <para>
+     an opening brace, followed by two format strings, followed by a closing brace (subject to the constraint that the
+     first format string correspond to a type valid for use as the key type of a dictionary)
+    </para>
+   </listitem>
+  </itemizedlist>
+ </refsect1>
+ <refsect1>
+  <title>Symbols</title>
+
+   <para>
+    The following table describes the rough meaning of symbols that may appear inside a GVariant format string.  Each
+    symbol is described in detail in its own section, including usage examples.
+  </para>
+
+  <informaltable>
+   <tgroup cols='2'>
+    <colspec colname='col_0'/>
+    <colspec colname='col_1'/>
+    <tbody>
+
+     <row rowsep='1'>
+      <entry colsep='1' rowsep='1'>
+       <para>
+        <emphasis role='strong'>Symbol</emphasis>
+       </para>
+      </entry>
+      <entry colsep='1' rowsep='1'>
+       <para>
+         <emphasis role='strong'>Meaning</emphasis>
+       </para>
+      </entry>
+     </row>
+
+     <row rowsep='1'>
+      <entry colsep='1' rowsep='1'>
+       <para>
+        <emphasis role='strong'>
+         <literal>b</literal>, <literal>y</literal>, <literal>n</literal>, <literal>q</literal>, <literal>i</literal>,
+         <literal>u</literal>, <literal>x</literal>, <literal>t</literal>, <literal>h</literal>, <literal>d</literal>
+        </emphasis>
+       </para>
+      </entry>
+      <entry colsep='1' rowsep='1'>
+       <para>
+        Used for building or deconstructing boolean, byte and numeric types.  See
+        <link linkend='gvariant-format-strings-numeric-types'>Numeric Types</link> below.
+       </para>
+      </entry>
+     </row>
+
+     <row rowsep='1'>
+      <entry colsep='1' rowsep='1'>
+       <para>
+        <emphasis role='strong'>
+         <literal>s</literal>, <literal>o</literal>, <literal>g</literal>
+        </emphasis>
+       </para>
+      </entry>
+      <entry colsep='1' rowsep='1'>
+       <para>
+        Used for building or deconstructing string types.  See
+        <link linkend='gvariant-format-strings-strings'>Strings</link> below.
+       </para>
+      </entry>
+     </row>
+
+     <row rowsep='1'>
+      <entry colsep='1' rowsep='1'>
+       <para>
+        <emphasis role='strong'><literal>v</literal></emphasis>
+       </para>
+      </entry>
+      <entry colsep='1' rowsep='1'>
+       <para>
+        Used for building or deconstructing variant types.  See
+        <link linkend='gvariant-format-strings-variant'>Variants</link> below.
+       </para>
+      </entry>
+     </row>
+
+     <row rowsep='1'>
+      <entry colsep='1' rowsep='1'>
+       <para>
+        <emphasis role='strong'>
+         <literal>a</literal>
+        </emphasis>
+       </para>
+      </entry>
+      <entry colsep='1' rowsep='1'>
+       <para>
+        Used for building or deconstructing arrays.  See
+        <link linkend='gvariant-format-strings-arrays'>Arrays</link> below.
+       </para>
+      </entry>
+     </row>
+
+     <row rowsep='1'>
+      <entry colsep='1' rowsep='1'>
+       <para>
+        <emphasis role='strong'>
+         <literal>m</literal>
+        </emphasis>
+       </para>
+      </entry>
+      <entry colsep='1' rowsep='1'>
+       <para>
+         Used for building or deconstructing maybe types.  See
+         <link linkend='gvariant-format-strings-maybe-types'>Maybe Types</link> below.
+       </para>
+      </entry>
+     </row>
+
+     <row rowsep='1'>
+      <entry colsep='1' rowsep='1'>
+       <para>
+        <emphasis role='strong'>
+         <literal>()</literal>
+        </emphasis>
+       </para>
+      </entry>
+      <entry colsep='1' rowsep='1'>
+       <para>
+         Used for building or deconstructing tuples.  See
+         <link linkend='gvariant-format-strings-tuples'>Tuples</link> below.
+       </para>
+      </entry>
+     </row>
+
+     <row rowsep='1'>
+      <entry colsep='1' rowsep='1'>
+       <para>
+        <emphasis role='strong'>
+         <literal>{}</literal>
+        </emphasis>
+       </para>
+      </entry>
+      <entry colsep='1' rowsep='1'>
+       <para>
+        Used for building or deconstructing dictionary entries. See
+        <link linkend='gvariant-format-strings-dictionaries'>Dictionaries</link> below.
+       </para>
+      </entry>
+     </row>
+
+     <row rowsep='1'>
+      <entry colsep='1' rowsep='1'>
+       <para>
+        <emphasis role='strong'>
+         <literal>@</literal>
+        </emphasis>
+       </para>
+      </entry>
+      <entry colsep='1' rowsep='1'>
+       <para>
+        Used as a prefix on a GVariant type string (not format string).  Denotes that a pointer to a
+        <link linkend='GVariant'>GVariant</link> should be used in place of the normal C type or types.  For
+        <link linkend='g-variant-new'><function>g_variant_new()</function></link> this means that you must pass a
+        non-<link linkend='NULL--CAPS'><literal>NULL</literal></link> <code>(<link linkend='GVariant'>GVariant</link>
+        *)</code>.  For <link linkend='g-variant-get'><function>g_variant_get()</function></link> this means that you
+        must pass a pointer to a <code>(<link linkend='GVariant'>GVariant</link> *)</code> for the value to be returned
+        by reference or <link linkend='NULL--CAPS'><literal>NULL</literal></link> to ignore the value.  See
+        <link linkend='gvariant-format-strings-gvariant'><code>GVariant *</code></link> below.
+       </para>
+      </entry>
+     </row>
+
+     <row rowsep='1'>
+      <entry colsep='1' rowsep='1'>
+       <para>
+        <emphasis role='strong'>
+         <literal>*</literal>, <literal>?</literal>, <literal>r</literal>
+        </emphasis>
+       </para>
+      </entry>
+      <entry colsep='1' rowsep='1'>
+       <para>
+        Exactly equivalent to <literal>@*</literal>, <literal>@?</literal> and <literal>@r</literal>.  Provided only for
+        completeness so that all GVariant type strings can be used also as format strings.  See <link
+        linkend='gvariant-format-strings-gvariant'><code>GVariant *</code></link> below.
+       </para>
+      </entry>
+     </row>
+
+     <row rowsep='1'>
+      <entry colsep='1' rowsep='1'>
+       <para>
+        <emphasis role='strong'><literal>&amp;</literal></emphasis>
+       </para>
+      </entry>
+      <entry colsep='1' rowsep='1'>
+       <para>
+        Used as a prefix on a GVariant type string (not format string).  Denotes that a C pointer to serialised data
+        should be used in place of the normal C type.  See
+        <link linkend='gvariant-format-strings-pointers'>Pointers</link> below.
+       </para>
+      </entry>
+     </row>
+
+     <row rowsep='1'>
+      <entry colsep='1' rowsep='1'>
+       <para>
+        <emphasis role='strong'><literal>^</literal></emphasis>
+       </para>
+      </entry>
+      <entry colsep='1' rowsep='1'>
+       <para>
+        Used as a prefix on some specific types of format strings.  See
+        <link linkend='gvariant-format-strings-convenience'>Convenience Conversions</link> below.
+       </para>
+      </entry>
+     </row>
+    </tbody>
+   </tgroup>
+  </informaltable>
+
+
+  <refsect2 id='gvariant-format-strings-numeric-types'>
+   <title>Numeric Types</title>
+   <para>
+    <emphasis role='strong'>
+     Characters: <literal>b</literal>, <literal>y</literal>, <literal>n</literal>, <literal>q</literal>,
+     <literal>i</literal>, <literal>u</literal>, <literal>x</literal>, <literal>t</literal>, <literal>h</literal>,
+     <literal>d</literal>
+    </emphasis>
+   </para>
+
+   <para>
+    Variable argument conversions from numeric types work in the most obvious way possible.  Upon encountering one of
+    these characters, <link linkend='g-variant-new'><function>g_variant_new()</function></link> takes the equivalent C
+    type as an argument.  <link linkend='g-variant-get'><function>g_variant_get()</function></link> takes a pointer to
+    the equivalent C type (or <link linkend='NULL--CAPS'><literal>NULL</literal></link> to ignore the value).
+   </para>
+
+   <para>
+    The equivalent C types are as follows:
+   </para>
+
+   <informaltable>
+    <tgroup cols='2'>
+     <colspec colname='col_0'/><colspec colname='col_1'/>
+     <tbody>
+      <row rowsep='1'>
+       <entry colsep='1' rowsep='1'>
+        <para>
+          <emphasis role='strong'>Character</emphasis>
+        </para>
+       </entry>
+       <entry colsep='1' rowsep='1'>
+        <para>
+          <emphasis role='strong'>Equivalent C type</emphasis>
+        </para>
+       </entry>
+      </row>
+      <row rowsep='1'>
+       <entry colsep='1' rowsep='1'>
+        <para>
+         <emphasis role='strong'>
+          <literal>b</literal>
+         </emphasis>
+        </para>
+       </entry>
+       <entry colsep='1' rowsep='1'>
+        <para>
+         <link linkend='gboolean'><type>gboolean</type></link>
+        </para>
+       </entry>
+      </row>
+      <row rowsep='1'>
+       <entry colsep='1' rowsep='1'>
+        <para>
+         <emphasis role='strong'>
+          <literal>y</literal>
+         </emphasis>
+        </para>
+       </entry>
+       <entry colsep='1' rowsep='1'>
+        <para>
+         <link linkend='guchar'><type>guchar</type></link>
+        </para>
+       </entry>
+      </row>
+      <row rowsep='1'>
+       <entry colsep='1' rowsep='1'>
+        <para>
+         <emphasis role='strong'>
+          <literal>n</literal>
+         </emphasis>
+        </para>
+       </entry>
+       <entry colsep='1' rowsep='1'>
+        <para>
+         <link linkend='gint16'><type>gint16</type></link>
+        </para>
+       </entry>
+      </row>
+      <row rowsep='1'>
+       <entry colsep='1' rowsep='1'>
+        <para>
+         <emphasis role='strong'>
+          <literal>q</literal>
+         </emphasis>
+        </para>
+       </entry>
+       <entry colsep='1' rowsep='1'>
+        <para>
+         <link linkend='guint16'><type>guint16</type></link>
+        </para>
+       </entry>
+      </row>
+      <row rowsep='1'>
+       <entry colsep='1' rowsep='1'>
+        <para>
+         <emphasis role='strong'>
+          <literal>i</literal>
+         </emphasis>
+        </para>
+       </entry>
+       <entry colsep='1' rowsep='1'>
+        <para>
+         <link linkend='gint32'><type>gint32</type></link>
+        </para>
+       </entry>
+      </row>
+      <row rowsep='1'>
+       <entry colsep='1' rowsep='1'>
+        <para>
+         <emphasis role='strong'>
+          <literal>u</literal>
+         </emphasis>
+        </para>
+       </entry>
+       <entry colsep='1' rowsep='1'>
+        <para>
+         <link linkend='guint32'><type>guint32</type></link>
+        </para>
+       </entry>
+      </row>
+      <row rowsep='1'>
+       <entry colsep='1' rowsep='1'>
+        <para>
+         <emphasis role='strong'>
+          <literal>x</literal>
+         </emphasis>
+        </para>
+       </entry>
+       <entry colsep='1' rowsep='1'>
+        <para>
+         <link linkend='gint64'><type>gint64</type></link>
+        </para>
+       </entry>
+      </row>
+      <row rowsep='1'>
+       <entry colsep='1' rowsep='1'>
+        <para>
+         <emphasis role='strong'>
+          <literal>t</literal>
+         </emphasis>
+        </para>
+       </entry>
+       <entry colsep='1' rowsep='1'>
+        <para>
+         <link linkend='guint64'><type>guint64</type></link>
+        </para>
+       </entry>
+      </row>
+      <row rowsep='1'>
+       <entry colsep='1' rowsep='1'>
+        <para>
+         <emphasis role='strong'>
+          <literal>h</literal>
+         </emphasis>
+        </para>
+       </entry>
+       <entry colsep='1' rowsep='1'>
+        <para>
+         <link linkend='gint32'><type>gint32</type></link>
+        </para>
+       </entry>
+      </row>
+      <row rowsep='1'>
+       <entry colsep='1' rowsep='1'>
+        <para>
+         <emphasis role='strong'>
+          <literal>d</literal>
+         </emphasis>
+        </para>
+       </entry>
+       <entry colsep='1' rowsep='1'>
+        <para>
+         <link linkend='gdouble'><type>gdouble</type></link>
+        </para>
+       </entry>
+      </row>
+     </tbody>
+    </tgroup>
+   </informaltable>
+
+   <para>
+    Note that in C, small integer types in variable argument lists are promoted up to <link
+    linkend='gint'><type>int</type></link> or <link linkend='guint'><type>unsigned int</type></link> as appropriate, and
+    read back accordingly.  <link linkend='gint'><type>int</type></link> is 32 bits on every platform on which GLib is
+    currently suported.  This means that you can use C expressions of type <link linkend='gint'><type>int</type></link>
+    with <link linkend='g-variant-new'><function>g_variant_new()</function></link> and format characters
+    '<literal>b</literal>', '<literal>y</literal>', '<literal>n</literal>', '<literal>q</literal>',
+    '<literal>i</literal>', '<literal>u</literal>' and '<literal>h</literal>'.  Specifically, you can use integer
+    literals with these characters.
+   </para>
+
+   <para>
+    When using the '<literal>x</literal>' and '<literal>t</literal>' characters, you must ensure that the value that you
+    provide is 64 bit.  This means that you should use a cast or make use of the
+    <link linkend='G-GINT64-CONSTANT--CAPS'><literal>G_GINT64_CONSTANT</literal></link> or
+    <link linkend='G-GUINT64-CONSTANT--CAPS'><literal>G_GUINT64_CONSTANT</literal></link> macros.
+   </para>
+
+   <para>
+    No type promotion occurs when using <link linkend='g-variant-get'><function>g_variant_get()</function></link> since
+    it operates with pointers.  The pointers must always point to a memory region of exactly the correct size.
+   </para>
+
+   <refsect3>
+    <title>Examples</title>
+    <informalexample><programlisting>
+<![CDATA[GVariant *value1, *value2, *value3, *value4;
+
+value1 = g_variant_new ("y", 200);
+value2 = g_variant_new ("b", TRUE);
+value3 = g_variant_new ("d", 37.5):
+value4 = g_variant_new ("x", G_GINT64_CONSTANT (998877665544332211));
+
+{
+  gdouble floating;
+  gboolean truth;
+  gint64 bignum;
+
+
+  g_variant_get (value1, "y", NULL);      /* ignore the value. */
+  g_variant_get (value2, "b", &truth);
+  g_variant_get (value3, "d", &floating);
+  g_variant_get (value4, "x", &bignum);
+}]]></programlisting></informalexample>
+   </refsect3>
+  </refsect2>
+
+  <refsect2 id='gvariant-format-strings-strings'>
+   <title>Strings</title>
+   <para>
+    <emphasis role='strong'>
+     Characters: <literal>s</literal>, <literal>o</literal>, <literal>g</literal>
+    </emphasis>
+   </para>
+
+   <para>
+    String conversions occur to and from standard nul-terminated C strings.  Upon encountering an
+    '<literal>s</literal>', '<literal>o</literal>' or '<literal>g</literal>' in a format string,
+    <link linkend='g-variant-new'><function>g_variant_new()</function></link> takes a <code>(const
+    <link linkend='gchar'>gchar</link> *)</code> and makes a copy of it.
+    <link linkend='NULL--CAPS'><literal>NULL</literal></link> is not a valid string.  If the '<literal>o</literal>' or
+    '<literal>g</literal>' characters are used, care must be taken to ensure that the passed string is a valid DBus
+    object path or DBus type signature, respectively.
+   </para>
+   <para>
+    Upon encounting '<literal>s</literal>', '<literal>o</literal>' or '<literal>g</literal>', <link
+    linkend='g-variant-get'><function>g_variant_get()</function></link> takes a pointer to a
+    <code>(<link linkend='gchar'>gchar</link> *)</code> (ie: <code>(<link linkend='gchar'>gchar</link> **)</code>) and
+    sets it to a newly-allocated copy of the string.  It is appropriate to free this copy using
+    <link linkend='g-free'><function>g_free()</function></link>.
+    <link linkend='NULL--CAPS'><literal>NULL</literal></link> may also be passed to indicate that the value of the
+    string should be ignored (in which case no copy is made).
+   </para>
+
+   <refsect3>
+    <title>Examples</title>
+    <informalexample><programlisting>
+<![CDATA[GVariant *value1, *value2, *value3;
+
+value1 = g_variant_new ("s", "hello world!");
+value2 = g_variant_new ("o", "/must/be/a/valid/path");
+value3 = g_variant_new ("g", "iias");
+
+#if 0
+  g_variant_new ("s", NULL);      /* not valid: NULL is not a string. */
+#endif
+
+{
+  gchar *result;
+
+  g_variant_get (value1, "s", &result);
+  g_print ("It was '%s'\n", result);
+  g_free (result);
+}]]></programlisting></informalexample>
+   </refsect3>
+  </refsect2>
+
+  <refsect2 id='gvariant-format-strings-variants'>
+   <title>Variants</title>
+   <para>
+    <emphasis role='strong'>
+     Characters: <literal>v</literal>
+    </emphasis>
+   </para>
+
+   <para>
+    Upon encountering a '<literal>v</literal>',
+    <link linkend='g-variant-new'><function>g_variant_new()</function></link> takes a <code>(<link
+    linkend='GVariant'>GVariant</link> *)</code>.  The value of the
+    <link linkend='GVariant'><type>GVariant</type></link> is used as the contents of the variant value.
+   </para>
+   <para>
+    Upon encountering a '<literal>v</literal>', <link
+    linkend='g-variant-get'><function>g_variant_get()</function></link> takes a pointer to a
+    <code>(<link linkend='GVariant'>GVariant</link> *)</code> (ie: <code>(<link linkend='GVariant'>GVariant</link> **)
+    </code>).  It is set to a new reference to a <link linkend='GVariant'><type>GVariant</type></link> instance
+    containing the contents of the variant value.  It is appropriate to free this reference using
+    <link linkend='g-variant-unref'><function>g_variant_unref()</function></link>.
+    <link linkend='NULL--CAPS'><literal>NULL</literal></link> may also be passed to indicate that the value should be
+    ignored (in which case no new reference is created).
+   </para>
+
+   <refsect3>
+    <title>Examples</title>
+    <informalexample><programlisting>
+<![CDATA[GVariant *x, *y;
+
+/* the following two lines are equivalent: */
+x = g_variant_new ("v", y);
+x = g_variant_new_variant (y);
+
+/* as are these: */
+g_variant_get (x, "v", &y);
+y = g_variant_get_variant (x);]]></programlisting></informalexample>
+   </refsect3>
+  </refsect2>
+
+
+  <refsect2 id='gvariant-format-strings-arrays'>
+   <title>Arrays</title>
+   <para>
+    <emphasis role='strong'>
+     Characters: <literal>a</literal>
+    </emphasis>
+   </para>
+
+   <para>
+    Upon encountering an '<literal>a</literal>' character followed by a type string,
+    <link linkend='g-variant-new'><function>g_variant_new()</function></link> will take a
+    <code>(<link linkend='GVariantBuilder'>GVariantBuilder</link> *)</code> that has been created as an array builder
+    for an array of the type given in the type string.  The builder will have
+    <link linkend='g-variant-builder-end'><function>g_variant_builder_end()</function></link> called on it and the
+    result will be used as the value.  As a special exception, if the given type string is a definite type, then
+    <link linkend='NULL--CAPS'><literal>NULL</literal></link> may be given to mean an empty array of that type.
+   </para>
+
+   <para>
+    Upon encountering an '<literal>a</literal>' character followed by a type string,
+    <link linkend='g-variant-get'><function>g_variant_get()</function></link> will take a pointer to a
+    <code>(<link linkend='GVariantIter'>GVariantIter</link> *)</code> (ie:
+    <code>(<link linkend='GVariantIter'>GVariantIter</link> **)</code>).
+    A new heap-allocated iterator is created and returned, initialised for iterating over the elements of the array.
+    This iterator should be freed when you are done with it, using
+    <link linkend='g-variant-iter-unref'><function>g_variant_iter_unref()</function></link>.
+    <link linkend='NULL--CAPS'><literal>NULL</literal></link> may also be given to indicate that the value of the array
+    should be ignored.
+   </para>
+
+   <refsect3>
+    <title>Examples</title>
+    <informalexample><programlisting>
+<![CDATA[GVariantBuilder *builder;
+GVariant *value;
+
+builder = g_variant_builder_new (G_VARIANT_TYPE_CLASS_ARRAY, NULL);
+g_variant_builder_add (builder, "s", "when");
+g_variant_builder_add (builder, "s", "in");
+g_variant_builder_add (builder, "s", "the");
+g_variant_builder_add (builder, "s", "course");
+value = g_variant_new ("as", builder);
+
+{
+  GVariantIter *iter;
+  gchar *str;
+
+  g_variant_get (value, "as", &iter);
+  while (g_variant_iter_loop (iter, "s", &str))
+    g_print ("%s\n");
+  g_variant_iter_unref (iter);
+}]]></programlisting></informalexample>
+   </refsect3>
+  </refsect2>
+
+  <refsect2 id='gvariant-format-strings-maybe-types'>
+   <title>Maybe Types</title>
+   <para>
+    <emphasis role='strong'>
+     Characters: <literal>m</literal>
+    </emphasis>
+   </para>
+   <para>
+    Maybe types are handled in two separate ways depending on the format string that follows the
+    '<literal>m</literal>'.  The method that is used currently depends entirely on the character immediately following the
+    '<literal>m</literal>'.
+   </para>
+
+   <para>
+    The first way is used with format strings starting with '<literal>s</literal>', '<literal>o</literal>',
+    '<literal>g</literal>', '<literal>v</literal>', '<literal>@</literal>', '<literal>*</literal>',
+    '<literal>?</literal>', '<literal>r</literal>', '<literal>&amp;</literal>', or '<literal>^</literal>'.  In all of
+    these cases, for non-maybe types, <link linkend='g-variant-new'><function>g_variant_new()</function></link> takes
+    a pointer to a non-<link linkend='NULL--CAPS'><literal>NULL</literal></link> value and
+    <link linkend='g-variant-get'><function>g_variant_get()</function></link> returns (by reference) a
+    non-<link linkend='NULL--CAPS'><literal>NULL</literal></link> pointer.  When any of these format strings are
+    prefixed with an '<literal>m</literal>', the type of arguments that are collected does not change in any way, but
+    <link linkend='NULL--CAPS'><literal>NULL</literal></link> becomes a permissable value, to indicate the Nothing case.
+   </para>
+   <para>
+    The second way is used with all other format strings.  For
+    <link linkend='g-variant-new'><function>g_variant_new()</function></link> an additional
+    <link linkend='gboolean'><type>gboolean</type></link> argument is collected and for
+    <link linkend='g-variant-get'><function>g_variant_get()</function></link> an additional
+    <code>(<link linkend='gboolean'>gboolean</link> *)</code>.  Following this argument, the arguments that are normally
+    collected for the equivalent non-maybe type will be collected.
+   </para>
+   <para>
+    If <link linkend='FALSE--CAPS'><literal>FALSE</literal></link> is given to
+    <link linkend='g-variant-new'><function>g_variant_new()</function></link> then the Nothing value is constructed and
+    the collected arguments are ignored.  Otherwise (if <link linkend='TRUE--CAPS'><literal>TRUE</literal></link> was
+    given), the arguments are used in the normal way to create the Just value.
+   </para>
+   <para>
+    If <link linkend='NULL--CAPS'><literal>NULL</literal></link> is given to
+    <link linkend='g-variant-get'><function>g_variant_get()</function></link> then the value is ignored.  If a
+    non-<link linkend='NULL--CAPS'><literal>NULL</literal></link> pointer is given then it is used to return by reference
+    whether the value was Just.  In the case that the value was Just, the
+    <link linkend='gboolean'><type>gboolean</type></link> will be set to
+    <link linkend='TRUE--CAPS'><literal>TRUE</literal></link> and the value will be stored in the arguments in the usual
+    way.  In the case that the value was Nothing, the <link linkend='gboolean'><type>gboolean</type></link> will be set to
+    <link linkend='FALSE--CAPS'><literal>FALSE</literal></link> and the arguments will be collected in the normal way
+    but have their values set to binary zero.
+   </para>
+
+   <refsect3>
+    <title>Examples</title>
+    <informalexample><programlisting>
+<![CDATA[GVariant *value1, *value2, *value3, *value4, *value5, *value6;
+value1 = g_variant_new ("ms", "Hello world");
+value2 = g_variant_new ("ms", NULL);
+value3 = g_variant_new ("(m(ii)s)", TRUE, 123, 456, "Done");
+value4 = g_variant_new ("(m(ii)s)", FALSE, -1, -1, "Done");          /* both '-1' are ignored. */
+value5 = g_variant_new ("(m@(ii)s)", NULL, "Done");
+
+{
+  GVariant *contents;
+  const gchar *cstr;
+  gboolean just;
+  gint32 x, y;
+  gchar *str;
+
+  g_variant_get (value1, "ms", &str);
+  if (str != NULL)
+    g_print ("str: %s\n", str);
+  else
+    g_print ("it was null\n");
+  g_free (str);
+
+
+  g_variant_get (value2, "m&s", &cstr);
+  if (cstr != NULL)
+    g_print ("str: %s\n", cstr);
+  else
+    g_print ("it was null\n");
+  /* don't free 'cstr' */
+
+
+  /* NULL passed for the gboolean *, but two 'gint32 *' still collected */
+  g_variant_get (value3, "(m(ii)s)", NULL, NULL, NULL, &str);
+  g_print ("string is %s\n", str);
+  g_free (str);
+
+  /* note: &s used, so g_free() not needed */
+  g_variant_get (value4, "(m(ii)&s)", &just, &x, &y, &cstr);
+  if (just)
+    g_print ("it was (%d, %d)\n", x, y);
+  else
+    g_print ("it was null\n");
+  g_print ("string is %s\n", cstr);
+  /* don't free 'cstr' */
+
+
+  g_variant_get (value5, "(m*s)", &contents, NULL); /* ignore the string. */
+  if (contents != NULL)
+    {
+      g_variant_get (contents, "(ii)", &x, &y);
+      g_print ("it was (%d, %d)\n", x, y);
+      g_variant_unref (contents);
+    }
+  else
+    g_print ("it was null\n");
+}]]></programlisting></informalexample>
+   </refsect3>
+  </refsect2>
+
+  <refsect2 id='gvariant-format-strings-tuples'>
+   <title>Tuples</title>
+   <para>
+    <emphasis role='strong'>
+     Characters: <code>()</code>
+    </emphasis>
+   </para>
+
+   <para>
+    Tuples are handled by handling each item in the tuple, in sequence.  Each item is handled in the usual way.
+   </para>
+
+   <refsect3>
+    <title>Examples</title>
+    <informalexample><programlisting>
+<![CDATA[GVariant *value1, *value2;
+
+value1 = g_variant_new ("(s(ii))", "Hello", 55, 77);
+value2 = g_variant_new ("()");
+
+{
+  gchar *string;
+  gint x, y;
+
+  g_variant_get (value1, "(s(ii))", &string, &x, &y);
+  g_print ("%s, %d, %d\n", string, x, y);
+  g_free (string);
+
+  g_variant_get (value2, "()");   /* do nothing... */
+}]]></programlisting></informalexample>
+   </refsect3>
+  </refsect2>
+
+  <refsect2 id='gvariant-format-strings-dictionaries'>
+   <title>Dictionaries</title>
+   <para>
+    <emphasis role='strong'>
+     Characters: <code>{}</code>
+    </emphasis>
+   </para>
+
+   <para>
+    Dictionary entries are handled by handling first the key, then the value.  Each is handled in the usual way.
+   </para>
+
+   <refsect3>
+    <title>Examples</title>
+    <informalexample><programlisting>
+<![CDATA[GVariantBuilder *b;
+GVariant *dict;
+
+b = g_variant_builder_new (G_VARIANT_TYPE_CLASS_ARRAY, G_VARIANT_TYPE ("a{sv}"));
+g_variant_builder_add (b, "{sv}", "name", g_variant_new_string ("foo"));
+g_variant_builder_add (b, "{sv}", "timeout", g_variant_new_int32 (10));
+dict = g_variant_builder_end (b);]]></programlisting></informalexample>
+   </refsect3>
+  </refsect2>
+
+  <refsect2 id='gvariant-format-strings-gvariant'>
+   <title>GVariant *</title>
+   <para>
+    <emphasis role='strong'>
+     Characters: <literal>@</literal>, <literal>*</literal>, <literal>?</literal>, <literal>r</literal>
+    </emphasis>
+
+   </para>
+   <para>
+    Upon encountering a '<literal>@</literal>' in front of a type string,
+    <link linkend='g-variant-new'><function>g_variant_new()</function></link> takes a
+    non-<link linkend='NULL--CAPS'><literal>NULL</literal></link> pointer to a
+    <link linkend='GVariant'><type>GVariant</type></link> and uses its value directly instead of collecting arguments to
+    create the value.  The provided <link linkend='GVariant'><type>GVariant</type></link> must have a type that matches the
+    type string following the '<literal>@</literal>'.  '<literal>*</literal>' is
+    the same as '<literal>@*</literal>' (ie: take a <link linkend='GVariant'><type>GVariant</type></link> of any type).
+    '<literal>?</literal>' is the same as '<literal>@?</literal>' (ie: take a
+    <link linkend='GVariant'><type>GVariant</type></link> of any basic type).  '<literal>r</literal>' is the same as
+    '<literal>@r</literal>' (ie: take a <link linkend='GVariant'><type>GVariant</type></link> of any tuple type).
+   </para>
+   <para>
+    Upon encountering a '<literal>@</literal>' in front of a type string,
+    <link linkend='g-variant-get'><function>g_variant_get()</function></link>
+    takes a pointer to a <code>(<link linkend='GVariant'>GVariant</link> *)</code> (ie: a
+    <code>(<link linkend='GVariant'>GVariant</link> **)</code>) and sets it to a new reference to a
+    <link linkend='GVariant'><type>GVariant</type></link> containing the value (instead of deconstructing the value into
+    C types in the usual way).  <link linkend='NULL--CAPS'><literal>NULL</literal></link> can be given to ignore the
+    value.  '<literal>*</literal>', '<literal>?</literal>' and '<literal>r</literal>' are handled in a way analogous to
+    what is stated above.
+   </para>
+   <para>
+    You can always use '<literal>*</literal>' as an alternative to '<literal>?</literal>', '<literal>r</literal>' or any
+    use of '<literal>@</literal>'.  Using the other characters where possible is recommended, however, due to the
+    improvements in type safety and code self-documentation.
+   </para>
+
+   <refsect3>
+    <title>Examples</title>
+    <informalexample><programlisting>
+<![CDATA[GVariant *value1, *value2;
+
+value1 = g_variant_new ("(i ii)", 44, g_variant_new_int32 (55), 66);
+
+/* note: consumes floating reference count on 'value1' */
+value2 = g_variant_new ("(@(iii)*)", value1, g_variant_new_string ("foo"));
+
+{
+  const gchar *string;
+  GVariant *tmp;
+  gsize length;
+  gint x, y, z;
+
+  g_variant_get (value2, "((iii)*)", &x, &y, &z, &tmp);
+  string = g_variant_get_string (tmp, &length);
+  g_print ("it is %d %d %d %s (length=%d)\n", x, y, z, string, (int) length);
+  g_variant_unref (tmp);
+
+  /* quick way to skip all the values in a tuple */
+  g_variant_get (value2, "(rs)", NULL, &string); /* or "(@(iii)s)" */
+  g_print ("i only got the string: %s\n", string);
+  g_free (string);
+}]]></programlisting></informalexample>
+   </refsect3>
+  </refsect2>
+
+  <refsect2 id='gvariant-format-strings-pointers'>
+   <title>Pointers</title>
+   <para>
+    <emphasis role='strong'>
+     Characters: <code>&amp;</code>
+    </emphasis>
+   </para>
+
+   <para>
+    The '<code>&amp;</code>' character is used to indicate that serialised data should be directly exchanged via a
+    pointer.
+   </para>
+   <para>
+    Currently there is only one use for this character -- to avoid making a copy of a string when using
+    <link linkend='g-variant-get'><function>g_variant_get()</function></link>.
+   </para>
+   <para>
+    The three cases are as follows:
+   </para>
+   <para>
+    Currently, the only use for this character is when it is applied to a string (ie: '<literal>&amp;s</literal>',
+    '<literal>&amp;o</literal>' or '<code>&amp;g</code>').  For
+    <link linkend='g-variant-new'><function>g_variant_new()</function></link> this has absolutely no effect.  The string
+    is collected and duplicated normally.  For <link linkend='g-variant-get'><function>g_variant_get()</function></link>
+    it means that instead of creating a newly allocated copy of the string, a pointer to the serialised data is
+    returned.  This pointer should not be freed.  Validity checks are performed to ensure that the string data will
+    always be properly nul-terminated.
+   </para>
+
+   <refsect3>
+    <title>Examples</title>
+    <informalexample><programlisting>
+<![CDATA[{
+  const gchar *str;
+  GVariant *value;
+
+  value = g_variant_new ("&s", "hello world");
+  str = g_variant_get ("&s", &str);
+  g_print ("string is: %s\n", str);
+  /* no need to free str */
+}]]></programlisting></informalexample>
+   </refsect3>
+  </refsect2>
+
+  <refsect2 id='gvariant-format-strings-convenience'>
+   <title>Convenience Conversions</title>
+   <para>
+    <emphasis role='strong'>
+     Characters: <literal>^</literal>
+    </emphasis>
+   </para>
+
+   <para>
+    The '<literal>^</literal>' character currently only has one purpose: to convert to and from
+    <link linkend='G-TYPE-STRV'><literal>G_TYPE_STRV</literal></link> type arrays of strings.  It is always used with
+    arrays of strings (or other string types).  It has two forms.
+   </para>
+   <itemizedlist>
+    <listitem>
+     <para>
+      '<literal>^as</literal>' (or <literal>o</literal> or <literal>g</literal>)
+     </para>
+    </listitem>
+    <listitem>
+     <para>
+      '<literal>^a&amp;s</literal>' (or <literal>o</literal> or <literal>g</literal>)
+     </para>
+    </listitem>
+   </itemizedlist>
+   <para>
+    When used with <link linkend='g-variant-new'><function>g_variant_new()</function></link> both forms are equivalent.
+    A <code>(const <link linkend='gchar'>gchar</link> * const *)</code> is collected.  This must be a pointer to the
+    array of <link linkend='NULL--CAPS'><literal>NULL</literal></link>-terminated pointers to strings.  This array is
+    converted to a <link linkend='GVariant'><type>GVariant</type></link> instance.  Copies are made, so the original
+    array may be freed immediately.
+   </para>
+   <para>
+    When used with <link linkend='g-variant-get'><function>g_variant_get()</function></link> the two forms have
+    different meaning.  Both return a freshly allocated
+    <link linkend='NULL--CAPS'><literal>NULL</literal></link>-terminated array of pointers to strings.  In the case of
+    '<literal>^as</literal>', the strings are owned by the caller -- it is appropriate to free the array with
+    <link linkend='g-strfreev'><function>g_strfreev()</function></link>.  In the case of '<literal>^a&amp;s</literal>',
+    a shallow copy is made; the strings themselves are embedded in the serialised data and owned by the original
+    <link linkend='GVariant'><type>GVariant</type></link> instance -- it is only appropriate to free the outer array
+    with <link linkend='g-free'><function>g_free()</function></link>.
+   </para>
+  </refsect2>
+ </refsect1>
+</refentry>
diff --git a/glib/glib.symbols b/glib/glib.symbols
index bc5d514..9d0c2a1 100644
--- a/glib/glib.symbols
+++ b/glib/glib.symbols
@@ -1767,8 +1767,6 @@ g_variant_iter_free
 g_variant_iter_init
 g_variant_iter_n_children
 g_variant_iter_new
-g_variant_iter_next
-g_variant_iter_loop
 g_variant_iter_next_value
 
 g_variant_builder_add_value
@@ -1780,6 +1778,52 @@ g_variant_builder_end
 g_variant_builder_new
 g_variant_builder_unref
 g_variant_builder_ref
+
+g_variant_new_va
+g_variant_get_va
+g_variant_new
+g_variant_get
+
+g_variant_builder_add
+g_variant_get_child
+g_variant_iter_next
+g_variant_iter_loop
+#endif
+#endif
+
+#if IN_HEADER(__G_VARIANT_TYPE_INFO_H__)
+#if IN_FILE(__G_VARIANT_TYPE_INFO_C__)
+g_variant_type_info_get_type_string
+g_variant_type_info_query
+g_variant_type_info_element
+g_variant_type_info_query_element
+g_variant_type_info_n_members
+g_variant_type_info_member_info
+g_variant_type_info_get
+g_variant_type_info_ref
+g_variant_type_info_unref
+g_variant_type_info_assert_no_infos
+#endif
+#endif
+
+#if IN_HEADER(__G_VARIANT_SERIALISER_H__)
+#if IN_FILE(__G_VARIANT_SERIALISER_C__)
+g_variant_serialised_byteswap
+g_variant_serialised_get_child
+g_variant_serialised_is_normal
+g_variant_serialised_n_children
+g_variant_serialiser_is_object_path
+g_variant_serialiser_is_signature
+g_variant_serialiser_is_string
+g_variant_serialiser_needed_size
+g_variant_serialiser_serialise
+#endif
+#endif
+
+#if IN_HEADER(__G_VARIANT_INTERNAL_H__)
+#if IN_FILE(__G_VARIANT_C__)
+g_variant_format_string_scan_type
+g_variant_format_string_scan
 #endif
 #endif
 
diff --git a/glib/gvariant-internal.h b/glib/gvariant-internal.h
new file mode 100644
index 0000000..66a080a
--- /dev/null
+++ b/glib/gvariant-internal.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright © 2007, 2008 Ryan Lortie
+ * Copyright © 2009, 2010 Codethink Limited
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Ryan Lortie <desrt desrt ca>
+ */
+
+
+/* The purpose of this header is to allow certain internal symbols of
+ * GVariant to be put under test cases.
+ */
+
+#ifndef __G_VARIANT_INTERNAL_H__
+#define __G_VARIANT_INTERNAL_H__
+
+#ifndef GLIB_COMPILATION
+#define GLIB_COMPILATION
+#endif
+
+#include <glib/gvarianttype.h>
+#include <glib/gtypes.h>
+
+#include "gvariant-serialiser.h"
+#include "gvarianttypeinfo.h"
+
+gboolean                        g_variant_format_string_scan            (const gchar          *string,
+                                                                         const gchar          *limit,
+                                                                         const gchar         **endptr);
+
+GVariantType *                  g_variant_format_string_scan_type       (const gchar          *string,
+                                                                         const gchar          *limit,
+                                                                         const gchar         **endptr);
+
+#endif /* __G_VARIANT_INTERNAL_H__ */
diff --git a/glib/gvariant-serialiser.c b/glib/gvariant-serialiser.c
index b10e618..a4c7fa6 100644
--- a/glib/gvariant-serialiser.c
+++ b/glib/gvariant-serialiser.c
@@ -1654,4 +1654,8 @@ g_variant_serialiser_is_signature (gconstpointer data,
   return TRUE;
 }
 
+/* Epilogue {{{1 */
+#define __G_VARIANT_SERIALISER_C__
+#include "galiasdef.c"
+
 /* vim:set foldmethod=marker: */
diff --git a/glib/gvariant-serialiser.h b/glib/gvariant-serialiser.h
index d6a89b5..f26b118 100644
--- a/glib/gvariant-serialiser.h
+++ b/glib/gvariant-serialiser.h
@@ -33,9 +33,7 @@ typedef struct
 } GVariantSerialised;
 
 /* deserialisation */
-G_GNUC_INTERNAL
 gsize                           g_variant_serialised_n_children         (GVariantSerialised        container);
-G_GNUC_INTERNAL
 GVariantSerialised              g_variant_serialised_get_child          (GVariantSerialised        container,
                                                                          gsize                     index);
 
@@ -43,32 +41,25 @@ GVariantSerialised              g_variant_serialised_get_child          (GVarian
 typedef void                  (*GVariantSerialisedFiller)               (GVariantSerialised       *serialised,
                                                                          gpointer                  data);
 
-G_GNUC_INTERNAL
 gsize                           g_variant_serialiser_needed_size        (GVariantTypeInfo         *info,
                                                                          GVariantSerialisedFiller  gsv_filler,
                                                                          const gpointer           *children,
                                                                          gsize                     n_children);
 
-G_GNUC_INTERNAL
 void                            g_variant_serialiser_serialise          (GVariantSerialised        container,
                                                                          GVariantSerialisedFiller  gsv_filler,
                                                                          const gpointer           *children,
                                                                          gsize                     n_children);
 
 /* misc */
-G_GNUC_INTERNAL
 gboolean                        g_variant_serialised_is_normal          (GVariantSerialised        value);
-G_GNUC_INTERNAL
 void                            g_variant_serialised_byteswap           (GVariantSerialised        value);
 
 /* validation of strings */
-G_GNUC_INTERNAL
 gboolean                        g_variant_serialiser_is_string          (gconstpointer             data,
                                                                          gsize                     size);
-G_GNUC_INTERNAL
 gboolean                        g_variant_serialiser_is_object_path     (gconstpointer             data,
                                                                          gsize                     size);
-G_GNUC_INTERNAL
 gboolean                        g_variant_serialiser_is_signature       (gconstpointer             data,
                                                                          gsize                     size);
 
diff --git a/glib/gvariant.c b/glib/gvariant.c
index 4f2b560..adc9030 100644
--- a/glib/gvariant.c
+++ b/glib/gvariant.c
@@ -25,6 +25,7 @@
 #include "config.h"
 
 #include <glib/gvariant-serialiser.h>
+#include "gvariant-internal.h"
 #include <glib/gvariant-core.h>
 #include <glib/gtestutils.h>
 #include <glib/gstrfuncs.h>
@@ -2133,167 +2134,6 @@ g_variant_iter_next_value (GVariantIter *iter)
   return NULL;
 }
 
-/**
- * g_variant_iter_loop:
- * @iter: a #GVariantIter
- * @format_string: a GVariant format string
- * @...: the arguments to unpack the value into
- * @returns: %TRUE if a value was unpacked, or %FALSE if there as no
- *           value
- *
- * Gets the next item in the container and unpacks it into the variable
- * argument list according to @format_string, returning %TRUE.
- *
- * If no more items remain then %FALSE is returned.
- *
- * On the first call to this function, the pointers appearing on the
- * variable argument list are assumed to point at uninitialised memory.
- * On the second and later calls, it is assumed that the same pointers
- * will be given and that they will point to the memory as set by the
- * previous call to this function.  This allows the previous values to
- * be freed, as appropriate.
- *
- * This function is intended to be used with a while loop as
- * demonstrated in the following example.  This function can only be
- * used when iterating over an array.  It is only valid to call this
- * function with a string constant for the format string and the same
- * string constant must be used each time.  Mixing calls to this
- * function and g_variant_iter_next() or g_variant_iter_next_value() on
- * the same iterator is not recommended.
- *
- * <example>
- *  <title>Memory management with g_variant_iter_loop()</title>
- *  <programlisting>
- *   /<!-- -->* Iterates a dictionary of type 'a{sv}' *<!-- -->/
- *   void
- *   iterate_dictionary (GVariant *dictionary)
- *   {
- *     GVariantIter iter;
- *     GVariant *value;
- *     gchar *key;
- *
- *     g_variant_iter_init (&iter, dictionary);
- *     while (g_variant_iter_loop (&iter, "{sv}", &key, &value))
- *       {
- *         g_print ("Item '%s' has type '%s'\n", key,
- *                  g_variant_get_type_string (value));
- *
- *         /<!-- -->* no need to free 'key' and 'value' here *<!-- -->/
- *       }
- *   }
- *  </programlisting>
- * </example>
- *
- * If you want a slightly less magical alternative that requires more
- * typing, see g_variant_iter_next().
- *
- * Since: 2.24
- **/
-gboolean
-g_variant_iter_loop (GVariantIter *iter,
-                     const gchar  *format_string,
-                     ...)
-{
-  gboolean first_time = GVSI(iter)->loop_format == NULL;
-  GVariant *value;
-
-  g_return_val_if_fail (first_time ||
-                        format_string == GVSI(iter)->loop_format,
-                        FALSE);
-
-  if (first_time)
-    {
-      TYPE_CHECK (GVSI(iter)->value, G_VARIANT_TYPE_ARRAY, FALSE);
-      GVSI(iter)->loop_format = format_string;
-    }
-
-  value = g_variant_iter_next_value (iter);
-
-  if (value != NULL)
-    {
-      va_list ap;
-
-      va_start (ap, format_string);
-      /* varargs get stuff */
-      va_end (ap);
-
-      g_variant_unref (value);
-    }
-
-  return value != NULL;
-}
-
-/**
- * g_variant_iter_next:
- * @iter: a #GVariantIter
- * @format_string: a GVariant format string
- * @...: the arguments to unpack the value into
- * @returns: %TRUE if a value was unpacked, or %FALSE if there as no
- *           value
- *
- * Gets the next item in the container and unpacks it into the variable
- * argument list according to @format_string, returning %TRUE.
- *
- * If no more items remain then %FALSE is returned.
- *
- * All of the pointers given on the variable arguments list of this
- * function are assumed to point at uninitialised memory.  It is the
- * responsibility of the caller to free all of the values returned by
- * the unpacking process.
- *
- * <example>
- *  <title>Memory management with g_variant_iter_next()</title>
- *  <programlisting>
- *   /<!-- -->* Iterates a dictionary of type 'a{sv}' *<!-- -->/
- *   void
- *   iterate_dictionary (GVariant *dictionary)
- *   {
- *     GVariantIter iter;
- *     GVariant *value;
- *     gchar *key;
- *
- *     g_variant_iter_init (&iter, dictionary);
- *     while (g_variant_iter_next (&iter, "{sv}", &key, &value))
- *       {
- *         g_print ("Item '%s' has type '%s'\n", key,
- *                  g_variant_get_type_string (value));
- *
- *         /<!-- -->* must free data for ourselves *<!-- -->/
- *         g_variant_unref (value);
- *         g_free (key);
- *       }
- *   }
- *  </programlisting>
- * </example>
- *
- * For a solution that is likely to be more convenient to C programmers,
- * see g_variant_iter_loop().
- *
- * Since: 2.24
- **/
-gboolean
-g_variant_iter_next (GVariantIter *iter,
-                     const gchar  *format_string,
-                     ...)
-{
-  GVariant *value;
-
-  value = g_variant_iter_next_value (iter);
-
-  if (value != NULL)
-    {
-      va_list ap;
-
-      va_start (ap, format_string);
-      /* varargs get stuff */
-      va_end (ap);
-
-      g_variant_unref (value);
-    }
-
-  return value != NULL;
-}
-
 /* GVariantBuilder {{{1 */
 /**
  * GVariantBuilder:
@@ -2837,6 +2677,1241 @@ g_variant_builder_end (GVariantBuilder *builder)
   return value;
 }
 
+/* Format strings {{{1 */
+/*< private >
+ * g_variant_format_string_scan:
+ * @string: a string that may be prefixed with a format string
+ * @limit: a pointer to the end of @string, or %NULL
+ * @endptr: location to store the end pointer, or %NULL
+ * @returns: %TRUE if there was a valid format string
+ *
+ * Checks the string pointed to by @string for starting with a properly
+ * formed #GVariant varargs format string.  If no valid format string is
+ * found then %FALSE is returned.
+ *
+ * If @string does start with a valid format string then %TRUE is
+ * returned.  If @endptr is non-%NULL then it is updated to point to the
+ * first character after the format string.
+ *
+ * If @limit is non-%NULL then @limit (and any charater after it) will
+ * not be accessed and the effect is otherwise equivalent to if the
+ * character at @limit were nul.
+ *
+ * See the section on <link linkend='gvariant-format-strings'>GVariant
+ * Format Strings</link>.
+ *
+ * Since: 2.24
+ */
+gboolean
+g_variant_format_string_scan (const gchar  *string,
+                              const gchar  *limit,
+                              const gchar **endptr)
+{
+#define next_char() (string == limit ? '\0' : *string++)
+#define peek_char() (string == limit ? '\0' : *string)
+  char c;
+
+  switch (next_char())
+    {
+    case 'b': case 'y': case 'n': case 'q': case 'i': case 'u':
+    case 'x': case 't': case 'h': case 'd': case 's': case 'o':
+    case 'g': case 'v': case '*': case '?': case 'r':
+      break;
+
+    case 'm':
+      return g_variant_format_string_scan (string, limit, endptr);
+
+    case 'a':
+    case '@':
+      return g_variant_type_string_scan (string, limit, endptr);
+
+    case '(':
+      while (peek_char() != ')')
+        if (!g_variant_format_string_scan (string, limit, &string))
+          return FALSE;
+
+      next_char(); /* consume ')' */
+      break;
+
+    case '{':
+      c = next_char();
+
+      if (c == '@')
+        c = next_char ();
+
+      /* ISO/IEC 9899:1999 (C99) §7.21.5.2:
+       *    The terminating null character is considered to be
+       *    part of the string.
+       */
+      if (c != '\0' && strchr ("bynqiuxthdsog?", c) == NULL)
+        return FALSE;
+
+      if (!g_variant_format_string_scan (string, limit, &string))
+        return FALSE;
+
+      if (next_char() != '}')
+        return FALSE;
+
+      break;
+
+    case '^': /* '^as' or '^a&s' only */
+      if (next_char() != 'a')
+        return FALSE;
+
+      if (peek_char() == '&')
+        next_char ();
+
+      c = next_char ();
+
+      if (c != 's' && c != 'o' && c != 'g')
+        return FALSE;
+
+      break;
+
+    case '&':
+      c = next_char();
+
+      if (c != 's' && c != 'o' && c != 'g')
+        return FALSE;
+
+      break;
+
+    default:
+      return FALSE;
+    }
+
+  if (endptr != NULL)
+    *endptr = string;
+
+#undef next_char
+#undef peek_char
+
+  return TRUE;
+}
+
+/*< private >
+ * g_variant_format_string_scan_type:
+ * @string: a string that may be prefixed with a format string
+ * @limit: a pointer to the end of @string
+ * @endptr: location to store the end pointer, or %NULL
+ * @returns: a #GVariantType if there was a valid format string
+ *
+ * If @string starts with a valid format string then this function will
+ * return the type that the format string corresponds to.  Otherwise
+ * this function returns %NULL.
+ *
+ * Use g_variant_type_free() to free the return value when you no longer
+ * need it.
+ *
+ * This function is otherwise exactly like
+ * g_variant_format_string_scan().
+ *
+ * Since: 2.24
+ */
+GVariantType *
+g_variant_format_string_scan_type (const gchar  *string,
+                                   const gchar  *limit,
+                                   const gchar **endptr)
+{
+  const gchar *my_end;
+  gchar *dest;
+  gchar *new;
+
+  if (endptr == NULL)
+    endptr = &my_end;
+
+  if (!g_variant_format_string_scan (string, limit, endptr))
+    return NULL;
+
+  dest = new = g_malloc (*endptr - string + 1);
+  while (string != *endptr)
+    {
+      if (*string != '@' && *string != '&' && *string != '^')
+        *dest++ = *string;
+      string++;
+    }
+  *dest = '\0';
+
+  return (GVariantType *) G_VARIANT_TYPE (new);
+}
+
+static gboolean
+valid_format_string (const gchar *format_string,
+                     gboolean     single,
+                     GVariant    *value)
+{
+  const gchar *endptr;
+  GVariantType *type;
+
+  type = g_variant_format_string_scan_type (format_string, NULL, &endptr);
+
+  if G_UNLIKELY (type == NULL || (single && *endptr != '\0'))
+    {
+      if (single)
+        g_critical ("`%s' is not a valid GVariant format string",
+                    format_string);
+      else
+        g_critical ("`%s' does not have a valid GVariant format "
+                    "string as a prefix", format_string);
+
+      if (type != NULL)
+        g_variant_type_free (type);
+
+      return FALSE;
+    }
+
+  if G_UNLIKELY (value && !g_variant_is_of_type (value, type))
+    {
+      gchar *fragment;
+      gchar *typestr;
+
+      fragment = g_strndup (format_string, endptr - format_string);
+      typestr = g_variant_type_dup_string (type);
+
+      g_critical ("the GVariant format string `%s' has a type of "
+                  "`%s' but the given value has a type of `%s'",
+                  fragment, typestr, g_variant_get_type_string (value));
+
+      g_variant_type_free (type);
+
+      return FALSE;
+    }
+
+  g_variant_type_free (type);
+
+  return TRUE;
+}
+
+/* Variable Arguments {{{1 */
+/* We consider 2 main classes of format strings:
+ *
+ *   - recursive format strings
+ *      these are ones that result in recursion and the collection of
+ *      possibly more than one argument.  Maybe types, tuples,
+ *      dictionary entries.
+ *
+ *   - leaf format string
+ *      these result in the collection of a single argument.
+ *
+ * Leaf format strings are further subdivided into two categories:
+ *
+ *   - single non-null pointer ("nnp")
+ *      these either collect or return a single non-null pointer.
+ *
+ *   - other
+ *      these collect or return something else (bool, number, etc).
+ *
+ * Based on the above, the varargs handling code is split into 4 main parts:
+ *
+ *   - nnp handling code
+ *   - leaf handling code (which may invoke nnp code)
+ *   - generic handling code (may be recursive, may invoke leaf code)
+ *   - user-facing API (which invokes the generic code)
+ *
+ * Each section implements some of the following functions:
+ *
+ *   - skip:
+ *      collect the arguments for the format string as if
+ *      g_variant_new() had been called, but do nothing with them.  used
+ *      for skipping over arguments when constructing a Nothing maybe
+ *      type.
+ *
+ *   - new:
+ *      create a GVariant *
+ *
+ *   - get:
+ *      unpack a GVariant *
+ *
+ *   - free (nnp only):
+ *      free a previously allocated item
+ */
+
+static gboolean
+g_variant_format_string_is_leaf (const gchar *str)
+{
+  return str[0] != 'm' && str[0] != '(' && str[0] != '{';
+}
+
+static gboolean
+g_variant_format_string_is_nnp (const gchar *str)
+{
+  return str[0] == 'a' || str[0] == 's' || str[0] == 'o' || str[0] == 'g' ||
+         str[0] == '^' || str[0] == '@' || str[0] == '*' || str[0] == '?' ||
+         str[0] == 'r' || str[0] == 'v' || str[0] == '&';
+}
+
+/* Single non-null pointer ("nnp") {{{2 */
+static void
+g_variant_valist_free_nnp (const gchar *str,
+                           gpointer     ptr)
+{
+  switch (*str)
+    {
+    case 'a':
+      g_variant_iter_free (ptr);
+      break;
+
+    case '^':
+      if (str[2] != '&')        /* '^as' */
+        g_strfreev (ptr);
+      else                      /* '^a&s' */
+        g_free (ptr);
+      break;
+
+    case 's':
+    case 'o':
+    case 'g':
+      g_free (ptr);
+      break;
+
+    case '@':
+    case '*':
+    case '?':
+    case 'v':
+      g_variant_unref (ptr);
+      break;
+
+    case '&':
+      break;
+
+    default:
+      g_assert_not_reached ();
+    }
+}
+
+static GVariant *
+g_variant_valist_new_nnp (const gchar **str,
+                          gpointer      ptr)
+{
+  if (**str == '&')
+    (*str)++;
+
+  switch (*(*str)++)
+    {
+    case 'a':
+      {
+        const GVariantType *type;
+        GVariant *value;
+
+        value = g_variant_builder_end (ptr);
+        type = g_variant_get_type (value);
+
+        if G_UNLIKELY (!g_variant_type_is_array (type))
+          g_error ("g_variant_new: expected array GVariantBuilder but "
+                   "the built value has type `%s'",
+                   g_variant_get_type_string (value));
+
+        type = g_variant_type_element (type);
+
+        if G_UNLIKELY (!g_variant_type_is_subtype_of (type, (GVariantType *) *str))
+          g_error ("g_variant_new: expected GVariantBuilder array element "
+                   "type `%s' but the built value has element type `%s'",
+                   g_variant_type_dup_string ((GVariantType *) *str),
+                   g_variant_get_type_string (value) + 1);
+
+        g_variant_type_string_scan (*str, NULL, str);
+
+        return value;
+      }
+
+    case 's':
+      return g_variant_new_string (ptr);
+
+    case 'o':
+      return g_variant_new_object_path (ptr);
+
+    case 'g':
+      return g_variant_new_signature (ptr);
+
+    case '^':
+      {
+        const GVariantType *type;
+        GVariantType *array_type;
+        GVariant **children;
+        gchar **strv = ptr;
+        GVariant *value;
+        guint length, i;
+
+        if ((*str)[1] == '&')    /* '^a&s' */
+          (*str) += 2;
+        else                     /* '^as' */
+          (*str)++;
+
+        type = (GVariantType *) (*str)++;
+        array_type = g_variant_type_new_array (type);
+        length = g_strv_length (strv);
+        children = g_new (GVariant *, length);
+        for (i = 0; i < length; i++)
+          children[i] = g_variant_ref_sink (
+            g_variant_new_from_trusted (type, strv[i], strlen (strv[i]) + 1));
+
+        value = g_variant_new_from_children (array_type, children,
+                                             length, TRUE);
+        g_variant_type_free (array_type);
+
+        return value;
+      }
+
+    case '@':
+      if G_UNLIKELY (!g_variant_is_of_type (ptr, (GVariantType *) *str))
+        g_error ("g_variant_new: expected GVariant of type `%s' but "
+                 "received value has type `%s'",
+                 g_variant_type_dup_string ((GVariantType *) *str),
+                 g_variant_get_type_string (ptr));
+
+      g_variant_type_string_scan (*str, NULL, str);
+
+      return ptr;
+
+    case '*':
+      return ptr;
+
+    case '?':
+      if G_UNLIKELY (!g_variant_type_is_basic (g_variant_get_type (ptr)))
+        g_error ("g_variant_new: format string `?' expects basic-typed "
+                 "GVariant, but received value has type `%s'",
+                 g_variant_get_type_string (ptr));
+
+      return ptr;
+
+    case 'r':
+      if G_UNLIKELY (!g_variant_type_is_tuple (g_variant_get_type (ptr)))
+        g_error ("g_variant_new: format string `r` expects tuple-typed "
+                 "GVariant, but received value has type `%s'",
+                 g_variant_get_type_string (ptr));
+
+      return ptr;
+
+    case 'v':
+      return g_variant_new_variant (ptr);
+
+    default:
+      g_assert_not_reached ();
+    }
+}
+
+static gpointer
+g_variant_valist_get_nnp (const gchar **str,
+                          GVariant     *value)
+{
+  switch (*(*str)++)
+    {
+    case 'a':
+      g_variant_type_string_scan (*str, NULL, str);
+      return g_variant_iter_new (value);
+
+    case '&':
+      (*str)++;
+      return (gchar *) g_variant_get_string (value, NULL);
+
+    case 's':
+    case 'o':
+    case 'g':
+      return g_variant_dup_string (value, NULL);
+
+    case '^':
+      if ((*str)[1] == '&')    /* '^a&s' */
+        {
+          (*str) += 3;
+          return g_variant_get_strv (value, NULL);
+        }
+      else                    /* '^as' */
+        {
+          (*str) += 2;
+          return g_variant_dup_strv (value, NULL);
+        }
+
+    case '@':
+      g_variant_type_string_scan (*str, NULL, str);
+      /* fall through */
+
+    case '*':
+    case '?':
+    case 'r':
+      return g_variant_ref (value);
+
+    case 'v':
+      return g_variant_get_variant (value);
+
+    default:
+      g_assert_not_reached ();
+    }
+}
+
+/* Leaves {{{2 */
+static void
+g_variant_valist_skip_leaf (const gchar **str,
+                            va_list      *app)
+{
+  if (g_variant_format_string_is_nnp (*str))
+    {
+      g_variant_format_string_scan (*str, NULL, str);
+      va_arg (*app, gpointer);
+      return;
+    }
+
+  switch (*(*str)++)
+    {
+    case 'b':
+    case 'y':
+    case 'n':
+    case 'q':
+    case 'i':
+    case 'u':
+    case 'h':
+      va_arg (*app, int);
+      return;
+
+    case 'x':
+    case 't':
+      va_arg (*app, guint64);
+      return;
+
+    case 'd':
+      va_arg (*app, gdouble);
+      return;
+
+    default:
+      g_assert_not_reached ();
+    }
+}
+
+static GVariant *
+g_variant_valist_new_leaf (const gchar **str,
+                           va_list      *app)
+{
+  if (g_variant_format_string_is_nnp (*str))
+    return g_variant_valist_new_nnp (str, va_arg (*app, gpointer));
+
+  switch (*(*str)++)
+    {
+    case 'b':
+      return g_variant_new_boolean (va_arg (*app, gboolean));
+
+    case 'y':
+      return g_variant_new_byte (va_arg (*app, guint));
+
+    case 'n':
+      return g_variant_new_int16 (va_arg (*app, gint));
+
+    case 'q':
+      return g_variant_new_uint16 (va_arg (*app, guint));
+
+    case 'i':
+      return g_variant_new_int32 (va_arg (*app, gint));
+
+    case 'u':
+      return g_variant_new_uint32 (va_arg (*app, guint));
+
+    case 'x':
+      return g_variant_new_int64 (va_arg (*app, gint64));
+
+    case 't':
+      return g_variant_new_uint64 (va_arg (*app, guint64));
+
+    case 'h':
+      return g_variant_new_handle (va_arg (*app, gint));
+
+    case 'd':
+      return g_variant_new_double (va_arg (*app, gdouble));
+
+    default:
+      g_assert_not_reached ();
+    }
+}
+
+static void
+g_variant_valist_get_leaf (const gchar **str,
+                           GVariant     *value,
+                           gboolean      free,
+                           va_list      *app)
+{
+  gpointer ptr = va_arg (*app, gpointer);
+
+  if (ptr == NULL)
+    {
+      g_variant_format_string_scan (*str, NULL, str);
+      return;
+    }
+
+  if (g_variant_format_string_is_nnp (*str))
+    {
+      gpointer *nnp = (gpointer *) ptr;
+
+      if (free && *nnp != NULL)
+        g_variant_valist_free_nnp (*str, *nnp);
+
+      *nnp = NULL;
+
+      if (value != NULL)
+        *nnp = g_variant_valist_get_nnp (str, value);
+      else
+        g_variant_format_string_scan (*str, NULL, str);
+
+      return;
+    }
+
+  if (value != NULL)
+    {
+      switch (*(*str)++)
+        {
+        case 'b':
+          *(gboolean *) ptr = g_variant_get_boolean (value);
+          return;
+
+        case 'y':
+          *(guchar *) ptr = g_variant_get_byte (value);
+          return;
+
+        case 'n':
+          *(gint16 *) ptr = g_variant_get_int16 (value);
+          return;
+
+        case 'q':
+          *(guint16 *) ptr = g_variant_get_uint16 (value);
+          return;
+
+        case 'i':
+          *(gint32 *) ptr = g_variant_get_int32 (value);
+          return;
+
+        case 'u':
+          *(guint32 *) ptr = g_variant_get_uint32 (value);
+          return;
+
+        case 'x':
+          *(gint64 *) ptr = g_variant_get_int64 (value);
+          return;
+
+        case 't':
+          *(guint64 *) ptr = g_variant_get_uint64 (value);
+          return;
+
+        case 'h':
+          *(gint32 *) ptr = g_variant_get_handle (value);
+          return;
+
+        case 'd':
+          *(gdouble *) ptr = g_variant_get_double (value);
+          return;
+        }
+    }
+  else
+    {
+      switch (*(*str)++)
+        {
+        case 'y':
+          *(guchar *) ptr = 0;
+          return;
+
+        case 'n':
+        case 'q':
+          *(guint16 *) ptr = 0;
+          return;
+
+        case 'i':
+        case 'u':
+        case 'h':
+        case 'b':
+          g_assert (sizeof (gboolean) == sizeof (guint32));
+          *(guint32 *) ptr = 0;
+          return;
+
+        case 'x':
+        case 't':
+        case 'd':
+          g_assert (sizeof (gdouble) == sizeof (guint64));
+          *(guint64 *) ptr = 0;
+          return;
+        }
+    }
+
+  g_assert_not_reached ();
+}
+
+/* Generic (recursive) {{{2 */
+static void
+g_variant_valist_skip (const gchar **str,
+                       va_list      *app)
+{
+  if (g_variant_format_string_is_leaf (*str))
+    g_variant_valist_skip_leaf (str, app);
+
+  else if (**str == 'm') /* maybe */
+    {
+      (*str)++;
+
+      if (!g_variant_format_string_is_nnp (*str))
+        va_arg (*app, gboolean);
+
+      g_variant_valist_skip (str, app);
+    }
+  else /* tuple, dictionary entry */
+    {
+      g_assert (**str == '(' || **str == '{');
+      (*str)++;
+      while (**str != ')' && **str != '}')
+        g_variant_valist_skip (str, app);
+      (*str)++;
+    }
+}
+
+static GVariant *
+g_variant_valist_new (const gchar **str,
+                      va_list      *app)
+{
+  if (g_variant_format_string_is_leaf (*str))
+    return g_variant_valist_new_leaf (str, app);
+
+  if (**str == 'm') /* maybe */
+    {
+      GVariantType *type = NULL;
+      GVariant *value = NULL;
+
+      (*str)++;
+
+      if (g_variant_format_string_is_nnp (*str))
+        {
+          gpointer nnp = va_arg (*app, gpointer);
+
+          if (nnp != NULL)
+            value = g_variant_valist_new_nnp (str, nnp);
+          else
+            type = g_variant_format_string_scan_type (*str, NULL, str);
+        }
+      else
+        {
+          gboolean just = va_arg (*app, gboolean);
+
+          if (just)
+            value = g_variant_valist_new (str, app);
+          else
+            {
+              type = g_variant_format_string_scan_type (*str, NULL, NULL);
+              g_variant_valist_skip (str, app);
+            }
+        }
+
+      value = g_variant_new_maybe (type, value);
+
+      if (type != NULL)
+        g_variant_type_free (type);
+
+      return value;
+    }
+  else /* tuple, dictionary entry */
+    {
+      GVariantBuilder b;
+
+      if (**str == '(')
+        g_variant_builder_init (&b, G_VARIANT_TYPE_TUPLE);
+      else
+        {
+          g_assert (**str == '{');
+          g_variant_builder_init (&b, G_VARIANT_TYPE_DICT_ENTRY);
+        }
+
+      (*str)++; /* '(' */
+      while (**str != ')' && **str != '}')
+        g_variant_builder_add_value (&b, g_variant_valist_new (str, app));
+      (*str)++; /* ')' */
+
+      return g_variant_builder_end (&b);
+    }
+}
+
+static void
+g_variant_valist_get (const gchar **str,
+                      GVariant     *value,
+                      gboolean      free,
+                      va_list      *app)
+{
+  if (g_variant_format_string_is_leaf (*str))
+    g_variant_valist_get_leaf (str, value, free, app);
+
+  else if (**str == 'm')
+    {
+      (*str)++;
+
+      if (value != NULL)
+        value = g_variant_get_maybe (value);
+
+      if (!g_variant_format_string_is_nnp (*str))
+        {
+          gboolean *ptr = va_arg (*app, gboolean *);
+
+          if (ptr != NULL)
+            *ptr = value != NULL;
+        }
+
+      g_variant_valist_get (str, value, free, app);
+
+      if (value != NULL)
+        g_variant_unref (value);
+    }
+
+  else /* tuple, dictionary entry */
+    {
+      GVariantIter iter;
+
+      g_assert (**str == '(' || **str == '{');
+      g_variant_iter_init (&iter, value);
+
+      (*str)++;
+      while (**str != ')' && **str != '}')
+        {
+          value = g_variant_iter_next_value (&iter);
+          g_variant_valist_get (str, value, free, app);
+          g_variant_unref (value);
+        }
+      (*str)++;
+    }
+}
+
+/* User-facing API {{{2 */
+/**
+ * g_variant_new:
+ * @format_string: a #GVariant format string
+ * @...: arguments, as per @format_string
+ * @returns: a new floating #GVariant instance
+ *
+ * Creates a new #GVariant instance.
+ *
+ * Think of this function as an analogue to g_strdup_printf().
+ *
+ * The type of the created instance and the arguments that are
+ * expected by this function are determined by @format_string.  See the
+ * section on <link linkend='gvariant-format-strings'>GVariant Format
+ * Strings</link>.  Please note that the syntax of the format string is
+ * very likely to be extended in the future.
+ *
+ * The first character of the format string must not be '*' '?' '@' or
+ * 'r'; in essence, a new #GVariant must always be constructed by this
+ * function (and not merely passed through it unmodified).
+ *
+ * Since: 2.24
+ **/
+GVariant *
+g_variant_new (const gchar *format_string,
+               ...)
+{
+  GVariant *value;
+  va_list ap;
+
+  g_return_val_if_fail (valid_format_string (format_string, TRUE, NULL) &&
+                        format_string[0] != '?' && format_string[0] != '@' &&
+                        format_string[0] != '*' && format_string[0] != 'r',
+                        NULL);
+
+  va_start (ap, format_string);
+  value = g_variant_new_va (format_string, NULL, &ap);
+  va_end (ap);
+
+  return value;
+}
+
+/**
+ * g_variant_new_va:
+ * @format_string: a string that is prefixed with a format string
+ * @endptr: location to store the end pointer, or %NULL
+ * @app: a pointer to a #va_list
+ * @returns: a new, usually floating, #GVariant
+ *
+ * This function is intended to be used by libraries based on
+ * #GVariant that want to provide g_variant_new()-like functionality
+ * to their users.
+ *
+ * The API is more general than g_variant_new() to allow a wider range
+ * of possible uses.
+ *
+ * @format_string must still point to a valid format string, but it only
+ * needs to be nul-terminated if @endptr is %NULL.  If @endptr is
+ * non-%NULL then it is updated to point to the first character past the
+ * end of the format string.
+ *
+ * @app is a pointer to a #va_list.  The arguments, according to
+ * @format_string, are collected from this #va_list and the list is left
+ * pointing to the argument following the last.
+ *
+ * These two generalisations allow mixing of multiple calls to
+ * g_variant_new_va() and g_variant_get_va() within a single actual
+ * varargs call by the user.
+ *
+ * The return value will be floating if it was a newly created GVariant
+ * instance (for example, if the format string was "(ii)").  In the case
+ * that the format_string was '*', '?', 'r', or a format starting with
+ * '@' then the collected #GVariant pointer will be returned unmodified,
+ * without adding any additional references.
+ *
+ * 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.
+ * At this point, the caller will have their own full reference to the
+ * result.  This can also be done by adding the result to a container,
+ * or by passing it to another g_variant_new() call.
+ *
+ * Since: 2.24
+ **/
+GVariant *
+g_variant_new_va (const gchar  *format_string,
+                  const gchar **endptr,
+                  va_list      *app)
+{
+  GVariant *value;
+
+  g_return_val_if_fail (valid_format_string (format_string, !endptr, NULL),
+                        NULL);
+  g_return_val_if_fail (app != NULL, NULL);
+
+  value = g_variant_valist_new (&format_string, app);
+
+  if (endptr != NULL)
+    *endptr = format_string;
+
+  return value;
+}
+
+/**
+ * g_variant_get:
+ * @value: a #GVariant instance
+ * @format_string: a #GVariant format string
+ * @...: arguments, as per @format_string
+ *
+ * Deconstructs a #GVariant instance.
+ *
+ * Think of this function as an analogue to scanf().
+ *
+ * The arguments that are expected by this function are entirely
+ * determined by @format_string.  @format_string also restricts the
+ * permissible types of @value.  It is an error to give a value with
+ * an incompatible type.  See the section on <link
+ * linkend='gvariant-format-strings'>GVariant Format Strings</link>.
+ * Please note that the syntax of the format string is very likely to be
+ * extended in the future.
+ *
+ * Since: 2.24
+ **/
+void
+g_variant_get (GVariant    *value,
+               const gchar *format_string,
+               ...)
+{
+  va_list ap;
+
+  g_return_if_fail (valid_format_string (format_string, TRUE, value));
+
+  /* if any direct-pointer-access formats are in use, flatten first */
+  if (strchr (format_string, '&'))
+    g_variant_get_data (value);
+
+  va_start (ap, format_string);
+  g_variant_get_va (value, format_string, NULL, &ap);
+  va_end (ap);
+}
+
+/**
+ * g_variant_get_va:
+ * @value: a #GVariant
+ * @format_string: a string that is prefixed with a format string
+ * @endptr: location to store the end pointer, or %NULL
+ * @app: a pointer to a #va_list
+ *
+ * This function is intended to be used by libraries based on #GVariant
+ * that want to provide g_variant_get()-like functionality to their
+ * users.
+ *
+ * The API is more general than g_variant_get() to allow a wider range
+ * of possible uses.
+ *
+ * @format_string must still point to a valid format string, but it only
+ * need to be nul-terminated if @endptr is %NULL.  If @endptr is
+ * non-%NULL then it is updated to point to the first character past the
+ * end of the format string.
+ *
+ * @app is a pointer to a #va_list.  The arguments, according to
+ * @format_string, are collected from this #va_list and the list is left
+ * pointing to the argument following the last.
+ *
+ * These two generalisations allow mixing of multiple calls to
+ * g_variant_new_va() and g_variant_get_va() within a single actual
+ * varargs call by the user.
+ *
+ * Since: 2.24
+ **/
+void
+g_variant_get_va (GVariant     *value,
+                  const gchar  *format_string,
+                  const gchar **endptr,
+                  va_list      *app)
+{
+  g_return_if_fail (valid_format_string (format_string, !endptr, value));
+  g_return_if_fail (value != NULL);
+  g_return_if_fail (app != NULL);
+
+  /* if any direct-pointer-access formats are in use, flatten first */
+  if (strchr (format_string, '&'))
+    g_variant_get_data (value);
+
+  g_variant_valist_get (&format_string, value, FALSE, app);
+
+  if (endptr != NULL)
+    *endptr = format_string;
+}
+
+/* Varargs-enabled Utility Functions {{{1 */
+
+/**
+ * g_variant_builder_add:
+ * @builder: a #GVariantBuilder
+ * @format_string: a #GVariant varargs format string
+ * @...: arguments, as per @format_string
+ *
+ * Adds to a #GVariantBuilder.
+ *
+ * This call is a convenience wrapper that is exactly equivalent to
+ * calling g_variant_new() followed by g_variant_builder_add_value().
+ *
+ * This function might be used as follows:
+ *
+ * <programlisting>
+ * GVariant *
+ * make_pointless_dictionary (void)
+ * {
+ *   GVariantBuilder *builder;
+ *   int i;
+ *
+ *   builder = g_variant_builder_new (G_VARIANT_TYPE_CLASS_ARRAY,
+ *                                    NULL);
+ *   for (i = 0; i < 16; i++)
+ *     {
+ *       gchar buf[3];
+ *
+ *       sprintf (buf, "%d", i);
+ *       g_variant_builder_add (builder, "{is}", i, buf);
+ *     }
+ *
+ *   return g_variant_builder_end (builder);
+ * }
+ * </programlisting>
+ *
+ * Since: 2.24
+ **/
+void
+g_variant_builder_add (GVariantBuilder *builder,
+                       const gchar     *format_string,
+                       ...)
+{
+  GVariant *variant;
+  va_list ap;
+
+  va_start (ap, format_string);
+  variant = g_variant_new_va (format_string, NULL, &ap);
+  va_end (ap);
+
+  g_variant_builder_add_value (builder, variant);
+}
+
+/**
+ * g_variant_get_child:
+ * @value: a container #GVariant
+ * @index_: the index of the child to deconstruct
+ * @format_string: a #GVariant format string
+ * @...: arguments, as per @format_string
+ *
+ * Reads a child item out of a container #GVariant instance and
+ * deconstructs it according to @format_string.  This call is
+ * essentially a combination of g_variant_get_child_value() and
+ * g_variant_get().
+ *
+ * Since: 2.24
+ **/
+void
+g_variant_get_child (GVariant    *value,
+                     gsize        index_,
+                     const gchar *format_string,
+                     ...)
+{
+  GVariant *child;
+  va_list ap;
+
+  child = g_variant_get_child_value (value, index_);
+  g_return_if_fail (valid_format_string (format_string, TRUE, child));
+
+  va_start (ap, format_string);
+  g_variant_get_va (child, format_string, NULL, &ap);
+  va_end (ap);
+
+  g_variant_unref (child);
+}
+
+/**
+ * g_variant_iter_next:
+ * @iter: a #GVariantIter
+ * @format_string: a GVariant format string
+ * @...: the arguments to unpack the value into
+ * @returns: %TRUE if a value was unpacked, or %FALSE if there as no
+ *           value
+ *
+ * Gets the next item in the container and unpacks it into the variable
+ * argument list according to @format_string, returning %TRUE.
+ *
+ * If no more items remain then %FALSE is returned.
+ *
+ * All of the pointers given on the variable arguments list of this
+ * function are assumed to point at uninitialised memory.  It is the
+ * responsibility of the caller to free all of the values returned by
+ * the unpacking process.
+ *
+ * <example>
+ *  <title>Memory management with g_variant_iter_next()</title>
+ *  <programlisting>
+ *   /<!-- -->* Iterates a dictionary of type 'a{sv}' *<!-- -->/
+ *   void
+ *   iterate_dictionary (GVariant *dictionary)
+ *   {
+ *     GVariantIter iter;
+ *     GVariant *value;
+ *     gchar *key;
+ *
+ *     g_variant_iter_init (&iter, dictionary);
+ *     while (g_variant_iter_next (&iter, "{sv}", &key, &value))
+ *       {
+ *         g_print ("Item '%s' has type '%s'\n", key,
+ *                  g_variant_get_type_string (value));
+ *
+ *         /<!-- -->* must free data for ourselves *<!-- -->/
+ *         g_variant_unref (value);
+ *         g_free (key);
+ *       }
+ *   }
+ *  </programlisting>
+ * </example>
+ *
+ * For a solution that is likely to be more convenient to C programmers
+ * when dealing with loops, see g_variant_iter_loop().
+ *
+ * Since: 2.24
+ **/
+gboolean
+g_variant_iter_next (GVariantIter *iter,
+                     const gchar  *format_string,
+                     ...)
+{
+  GVariant *value;
+
+  value = g_variant_iter_next_value (iter);
+
+  g_return_val_if_fail (valid_format_string (format_string, TRUE, value),
+                        FALSE);
+
+  if (value != NULL)
+    {
+      va_list ap;
+
+      va_start (ap, format_string);
+      g_variant_valist_get (&format_string, value, FALSE, &ap);
+      va_end (ap);
+
+      g_variant_unref (value);
+    }
+
+  return value != NULL;
+}
+
+/**
+ * g_variant_iter_loop:
+ * @iter: a #GVariantIter
+ * @format_string: a GVariant format string
+ * @...: the arguments to unpack the value into
+ * @returns: %TRUE if a value was unpacked, or %FALSE if there as no
+ *           value
+ *
+ * Gets the next item in the container and unpacks it into the variable
+ * argument list according to @format_string, returning %TRUE.
+ *
+ * If no more items remain then %FALSE is returned.
+ *
+ * On the first call to this function, the pointers appearing on the
+ * variable argument list are assumed to point at uninitialised memory.
+ * On the second and later calls, it is assumed that the same pointers
+ * will be given and that they will point to the memory as set by the
+ * previous call to this function.  This allows the previous values to
+ * be freed, as appropriate.
+ *
+ * This function is intended to be used with a while loop as
+ * demonstrated in the following example.  This function can only be
+ * used when iterating over an array.  It is only valid to call this
+ * function with a string constant for the format string and the same
+ * string constant must be used each time.  Mixing calls to this
+ * function and g_variant_iter_next() or g_variant_iter_next_value() on
+ * the same iterator is not recommended.
+ *
+ * <example>
+ *  <title>Memory management with g_variant_iter_loop()</title>
+ *  <programlisting>
+ *   /<!-- -->* Iterates a dictionary of type 'a{sv}' *<!-- -->/
+ *   void
+ *   iterate_dictionary (GVariant *dictionary)
+ *   {
+ *     GVariantIter iter;
+ *     GVariant *value;
+ *     gchar *key;
+ *
+ *     g_variant_iter_init (&iter, dictionary);
+ *     while (g_variant_iter_loop (&iter, "{sv}", &key, &value))
+ *       {
+ *         g_print ("Item '%s' has type '%s'\n", key,
+ *                  g_variant_get_type_string (value));
+ *
+ *         /<!-- -->* no need to free 'key' and 'value' here *<!-- -->/
+ *       }
+ *   }
+ *  </programlisting>
+ * </example>
+ *
+ * If you want a slightly less magical alternative that requires more
+ * typing, see g_variant_iter_next().
+ *
+ * Since: 2.24
+ **/
+gboolean
+g_variant_iter_loop (GVariantIter *iter,
+                     const gchar  *format_string,
+                     ...)
+{
+  gboolean first_time = GVSI(iter)->loop_format == NULL;
+  GVariant *value;
+  va_list ap;
+
+  g_return_val_if_fail (first_time ||
+                        format_string == GVSI(iter)->loop_format,
+                        FALSE);
+
+  if (first_time)
+    {
+      TYPE_CHECK (GVSI(iter)->value, G_VARIANT_TYPE_ARRAY, FALSE);
+      GVSI(iter)->loop_format = format_string;
+
+      if (strchr (format_string, '&'))
+        g_variant_get_data (GVSI(iter)->value);
+    }
+
+  value = g_variant_iter_next_value (iter);
+
+  g_return_val_if_fail (!first_time ||
+                        valid_format_string (format_string, TRUE, value),
+                        FALSE);
+
+  va_start (ap, format_string);
+  g_variant_valist_get (&format_string, value, !first_time, &ap);
+  va_end (ap);
+
+  if (value != NULL)
+    g_variant_unref (value);
+
+  return value != NULL;
+}
+
 /* Epilogue {{{1 */
 #define __G_VARIANT_C__
 #include "galiasdef.c"
diff --git a/glib/gvariant.h b/glib/gvariant.h
index d8ea126..a073b2b 100644
--- a/glib/gvariant.h
+++ b/glib/gvariant.h
@@ -114,6 +114,10 @@ GVariant *                      g_variant_new_dict_entry                (GVarian
 
 GVariant *                      g_variant_get_maybe                     (GVariant             *value);
 gsize                           g_variant_n_children                    (GVariant             *value);
+void                            g_variant_get_child                     (GVariant             *value,
+                                                                         gsize                 index_,
+                                                                         const gchar          *format_string,
+                                                                         ...);
 GVariant *                      g_variant_get_child_value               (GVariant             *value,
                                                                          gsize                 index_);
 gconstpointer                   g_variant_get_fixed_array               (GVariant             *value,
@@ -178,6 +182,20 @@ void                            g_variant_builder_add                   (GVarian
                                                                          const gchar          *format_string,
                                                                          ...);
 
+GVariant *                      g_variant_new                           (const gchar          *format_string,
+                                                                         ...);
+void                            g_variant_get                           (GVariant             *value,
+                                                                         const gchar          *format_string,
+                                                                         ...);
+GVariant *                      g_variant_new_va                        (const gchar          *format_string,
+                                                                         const gchar         **endptr,
+                                                                         va_list              *app);
+void                            g_variant_get_va                        (GVariant             *value,
+                                                                         const gchar          *format_string,
+                                                                         const gchar         **endptr,
+                                                                         va_list              *app);
+
+
 G_END_DECLS
 
 #endif /* __G_VARIANT_H__ */
diff --git a/glib/gvarianttypeinfo.c b/glib/gvarianttypeinfo.c
index 00fafe9..f85db7e 100644
--- a/glib/gvarianttypeinfo.c
+++ b/glib/gvarianttypeinfo.c
@@ -861,6 +861,11 @@ g_variant_type_info_unref (GVariantTypeInfo *info)
     }
 }
 
-/* used from the test cases */
-#define assert_no_type_infos() \
-  g_assert (g_variant_type_info_table == NULL)
+void
+g_variant_type_info_assert_no_infos (void)
+{
+  g_assert (g_variant_type_info_table == NULL);
+}
+
+#define __G_VARIANT_TYPE_INFO_C__
+#include "galiasdef.c"
diff --git a/glib/gvarianttypeinfo.h b/glib/gvarianttypeinfo.h
index 25a645b..7c7b544 100644
--- a/glib/gvarianttypeinfo.h
+++ b/glib/gvarianttypeinfo.h
@@ -125,35 +125,27 @@ typedef struct
 #define G_VARIANT_MEMBER_ENDING_OFFSET  2
 
 /* query */
-G_GNUC_INTERNAL
 const gchar *                   g_variant_type_info_get_type_string     (GVariantTypeInfo   *typeinfo);
 
-G_GNUC_INTERNAL
 void                            g_variant_type_info_query               (GVariantTypeInfo   *typeinfo,
                                                                          guint              *alignment,
                                                                          gsize              *size);
 
 /* array */
-G_GNUC_INTERNAL
 GVariantTypeInfo *              g_variant_type_info_element             (GVariantTypeInfo   *typeinfo);
-G_GNUC_INTERNAL
 void                            g_variant_type_info_query_element       (GVariantTypeInfo   *typeinfo,
                                                                          guint              *alignment,
                                                                          gsize              *size);
 
 /* structure */
-G_GNUC_INTERNAL
 gsize                           g_variant_type_info_n_members           (GVariantTypeInfo   *typeinfo);
-G_GNUC_INTERNAL
 const GVariantMemberInfo *      g_variant_type_info_member_info         (GVariantTypeInfo   *typeinfo,
                                                                          gsize               index);
 
 /* new/ref/unref */
-G_GNUC_INTERNAL
 GVariantTypeInfo *              g_variant_type_info_get                 (const GVariantType *type);
-G_GNUC_INTERNAL
 GVariantTypeInfo *              g_variant_type_info_ref                 (GVariantTypeInfo   *typeinfo);
-G_GNUC_INTERNAL
 void                            g_variant_type_info_unref               (GVariantTypeInfo   *typeinfo);
+void                            g_variant_type_info_assert_no_infos     (void);
 
 #endif /* __G_VARIANT_TYPE_INFO_H__ */
diff --git a/glib/tests/gvariant.c b/glib/tests/gvariant.c
index ea01500..ec28e76 100644
--- a/glib/tests/gvariant.c
+++ b/glib/tests/gvariant.c
@@ -11,7 +11,9 @@
  * Author: Ryan Lortie <desrt desrt ca>
  */
 
+#include <glib/gvariant-internal.h>
 #include <string.h>
+#include <stdlib.h>
 #include <glib.h>
 
 #define BASIC "bynqiuxthdsog?"
@@ -645,13 +647,6 @@ test_gvarianttype (void)
     }
 }
 
-#undef  G_GNUC_INTERNAL
-#define G_GNUC_INTERNAL static
-
-#define DISABLE_VISIBILITY
-#define GLIB_COMPILATION
-#include <glib/gvarianttypeinfo.c>
-
 #define ALIGNED(x, y)   (((x + (y - 1)) / y) * y)
 
 /* do our own calculation of the fixed_size and alignment of a type
@@ -1027,11 +1022,9 @@ test_gvarianttypeinfo (void)
       g_free (desc);
     }
 
-  assert_no_type_infos ();
+  g_variant_type_info_assert_no_infos ();
 }
 
-#include <glib/gvariant-serialiser.c>
-
 #define MAX_FIXED_MULTIPLIER    256
 #define MAX_INSTANCE_SIZE       1024
 #define MAX_ARRAY_CHILDREN      128
@@ -1384,7 +1377,7 @@ test_maybes (void)
   for (i = 0; i < 1000; i++)
     test_maybe ();
 
-  assert_no_type_infos ();
+  g_variant_type_info_assert_no_infos ();
 }
 
 static void
@@ -1523,7 +1516,7 @@ test_arrays (void)
   for (i = 0; i < 100; i++)
     test_array ();
 
-  assert_no_type_infos ();
+  g_variant_type_info_assert_no_infos ();
 }
 
 static void
@@ -1683,7 +1676,7 @@ test_tuples (void)
   for (i = 0; i < 100; i++)
     test_tuple ();
 
-  assert_no_type_infos ();
+  g_variant_type_info_assert_no_infos ();
 }
 
 static void
@@ -1756,7 +1749,7 @@ test_variants (void)
   for (i = 0; i < 100; i++)
     test_variant ();
 
-  assert_no_type_infos ();
+  g_variant_type_info_assert_no_infos ();
 }
 
 static void
@@ -2184,7 +2177,7 @@ test_byteswaps (void)
   for (i = 0; i < 200; i++)
     test_byteswap ();
 
-  assert_no_type_infos ();
+  g_variant_type_info_assert_no_infos ();
 }
 
 static void
@@ -2254,7 +2247,7 @@ test_fuzzes (gpointer data)
   for (i = 0; i < 200; i++)
     test_fuzz (&fuzziness);
 
-  assert_no_type_infos ();
+  g_variant_type_info_assert_no_infos ();
 }
 
 static GVariant *
@@ -2470,11 +2463,8 @@ tree_instance_check_gvariant (TreeInstance *tree,
         child = g_variant_get_variant (value);
         str1 = g_variant_get_type_string (child);
         str2 = g_variant_type_info_get_type_string (tree->children[0]->info);
-
-        /* can't pointer-compare str1 and str2 since one comes from the
-         * real GVariantTypeInfo and one comes from our private copy...
-         */
-        equal = strcmp (str1, str2) == 0 &&
+        /* GVariant only keeps one copy of type strings around */
+        equal = str1 == str2 &&
                 tree_instance_check_gvariant (tree->children[0], child);
 
         g_variant_unref (child);
@@ -2530,7 +2520,8 @@ tree_instance_check_gvariant (TreeInstance *tree,
 
 static void
 tree_instance_build_gvariant (TreeInstance    *tree,
-                              GVariantBuilder *builder)
+                              GVariantBuilder *builder,
+                              gboolean         guess_ok)
 {
   const GVariantType *type;
 
@@ -2540,10 +2531,28 @@ tree_instance_build_gvariant (TreeInstance    *tree,
     {
       gsize i;
 
+      /* force GVariantBuilder to guess the type half the time */
+      if (guess_ok && randomly (0.5))
+        {
+          if (g_variant_type_is_array (type) && tree->n_children)
+            type = G_VARIANT_TYPE_ARRAY;
+
+          if (g_variant_type_is_maybe (type) && tree->n_children)
+            type = G_VARIANT_TYPE_MAYBE;
+
+          if (g_variant_type_is_tuple (type))
+            type = G_VARIANT_TYPE_TUPLE;
+
+          if (g_variant_type_is_dict_entry (type))
+            type = G_VARIANT_TYPE_DICT_ENTRY;
+        }
+      else
+        guess_ok = FALSE;
+
       g_variant_builder_open (builder, type);
 
       for (i = 0; i < tree->n_children; i++)
-        tree_instance_build_gvariant (tree->children[i], builder);
+        tree_instance_build_gvariant (tree->children[i], builder, guess_ok);
 
       g_variant_builder_close (builder);
     }
@@ -2626,7 +2635,7 @@ test_container (void)
       gchar *s3;
 
       g_variant_builder_init (&builder, G_VARIANT_TYPE_VARIANT);
-      tree_instance_build_gvariant (tree, &builder);
+      tree_instance_build_gvariant (tree, &builder, TRUE);
       built = g_variant_builder_end (&builder);
       g_variant_ref_sink (built);
       g_variant_get_data (built);
@@ -2659,6 +2668,716 @@ test_containers (void)
     {
       test_container ();
     }
+
+  g_variant_type_info_assert_no_infos ();
+}
+
+static void
+test_format_strings (void)
+{
+  GVariantType *type;
+  const gchar *end;
+
+  g_assert (g_variant_format_string_scan ("i", NULL, &end) && *end == '\0');
+  g_assert (g_variant_format_string_scan ("@i", NULL, &end) && *end == '\0');
+  g_assert (g_variant_format_string_scan ("@ii", NULL, &end) && *end == 'i');
+  g_assert (g_variant_format_string_scan ("^a&s", NULL, &end) && *end == '\0');
+  g_assert (g_variant_format_string_scan ("(^as)", NULL, &end) &&
+            *end == '\0');
+  g_assert (!g_variant_format_string_scan ("(^s)", NULL, &end));
+  g_assert (!g_variant_format_string_scan ("(^a)", NULL, &end));
+  g_assert (!g_variant_format_string_scan ("(z)", NULL, &end));
+  g_assert (!g_variant_format_string_scan ("az", NULL, &end));
+  g_assert (!g_variant_format_string_scan ("{**}", NULL, &end));
+  g_assert (!g_variant_format_string_scan ("{ **}", NULL, &end));
+  g_assert (g_variant_format_string_scan ("{ y*}", NULL, &end) &&
+            *end == '\0');
+  g_assert (g_variant_format_string_scan ("{yv}", NULL, &end) &&
+            *end == '\0');
+  g_assert (!g_variant_format_string_scan ("{vv}", NULL, &end));
+  g_assert (!g_variant_format_string_scan ("{y}", NULL, &end));
+  g_assert (!g_variant_format_string_scan ("{yyy}", NULL, &end));
+  g_assert (!g_variant_format_string_scan ("{ya}", NULL, &end));
+  g_assert (g_variant_format_string_scan ("&s", NULL, &end) && *end == '\0');
+  g_assert (!g_variant_format_string_scan ("&as", NULL, &end));
+  g_assert (!g_variant_format_string_scan ("@z", NULL, &end));
+  g_assert (!g_variant_format_string_scan ("az", NULL, &end));
+  g_assert (!g_variant_format_string_scan ("a&s", NULL, &end));
+
+  type = g_variant_format_string_scan_type ("mm(@xy^a&s*? ?)", NULL, &end);
+  g_assert (type && *end == '\0');
+  g_assert (g_variant_type_equal (type, G_VARIANT_TYPE ("mm(xyas*?\?)")));
+  g_variant_type_free (type);
+
+  type = g_variant_format_string_scan_type ("mm(@xy^a&*? ?)", NULL, NULL);
+  g_assert (type == NULL);
+}
+
+static void
+exit_on_abort (int signal)
+{
+  exit (signal);
+}
+
+static gboolean
+do_failed_test (const gchar *pattern)
+{
+  if (g_test_trap_fork (1000000, G_TEST_TRAP_SILENCE_STDERR))
+    {
+      signal (SIGABRT, exit_on_abort);
+      return TRUE;
+    }
+
+  g_test_trap_assert_failed ();
+  g_test_trap_assert_stderr (pattern);
+
+  return FALSE;
+}
+
+static void
+test_invalid_varargs (void)
+{
+  if (do_failed_test ("*not a valid GVariant format string*"))
+    {
+      g_variant_new ("z");
+      abort ();
+    }
+
+  if (do_failed_test ("*valid GVariant format string as a prefix*"))
+    {
+      const gchar *end;
+
+      g_variant_new_va ("z", &end, NULL);
+      abort ();
+    }
+
+  if (do_failed_test ("*type of `q' but * has a type of `y'*"))
+    {
+      g_variant_get (g_variant_new ("y", 'a'), "q");
+      abort ();
+    }
+}
+
+static void
+check_and_free (GVariant    *value,
+                const gchar *str)
+{
+  gchar *valstr = g_variant_print (value, FALSE);
+  g_assert_cmpstr (str, ==, valstr);
+  g_variant_unref (value);
+  g_free (valstr);
+}
+
+static void
+test_varargs (void)
+{
+  {
+    GVariantBuilder array;
+
+    g_variant_builder_init (&array, G_VARIANT_TYPE_ARRAY);
+    g_variant_builder_add (&array, "{sv}", "size",
+                           g_variant_new ("(ii)", 800, 600));
+    g_variant_builder_add (&array, "{sv}", "title",
+                           g_variant_new_string ("Test case"));
+    g_variant_builder_add_value (&array,
+      g_variant_new_dict_entry (g_variant_new_string ("temperature"),
+                                g_variant_new_variant (
+                                  g_variant_new_double (37.5))));
+    check_and_free (g_variant_new ("(ma{sv}m(a{sv})ma{sv}ii)",
+                                   NULL, FALSE, NULL, &array, 7777, 8888),
+                    "(Nothing, Nothing, {'size': <(800, 600)>, "
+                                        "'title': <'Test case'>, "
+                                        "'temperature': <37.5>}, "
+                     "7777, 8888)");
+
+    check_and_free (g_variant_new ("(imimimmimmimmi)",
+                                   123,
+                                   FALSE, 321,
+                                   TRUE, 123,
+                                   FALSE, TRUE, 321,
+                                   TRUE, FALSE, 321,
+                                   TRUE, TRUE, 123),
+                    "(123, Nothing, 123, Nothing, Just Nothing, 123)");
+
+    check_and_free (g_variant_new ("(ybnixd)",
+                                   'a', 1, 22, 33, (guint64) 44, 5.5),
+                    "(0x61, true, 22, 33, 44, 5.5)");
+
+    check_and_free (g_variant_new ("(@y?*rv)",
+                                   g_variant_new ("y", 'a'),
+                                   g_variant_new ("y", 'b'),
+                                   g_variant_new ("y", 'c'),
+                                   g_variant_new ("(y)", 'd'),
+                                   g_variant_new ("y", 'e')),
+                    "(0x61, 0x62, 0x63, (0x64,), <byte 0x65>)");
+  }
+
+  {
+    GVariantBuilder array;
+    GVariantIter iter;
+    GVariant *value;
+    gchar *number;
+    gboolean just;
+    gint i, val;
+
+    g_variant_builder_init (&array, G_VARIANT_TYPE_ARRAY);
+    for (i = 0; i < 100; i++)
+      {
+        number = g_strdup_printf ("%d", i);
+        g_variant_builder_add (&array, "s", number);
+        g_free (number);
+      }
+
+    value = g_variant_builder_end (&array);
+    g_variant_iter_init (&iter, value);
+
+    i = 0;
+    while (g_variant_iter_loop (&iter, "s", &number))
+      {
+        gchar *check = g_strdup_printf ("%d", i++);
+        g_assert_cmpstr (number, ==, check);
+        g_free (check);
+      }
+    g_assert (number == NULL);
+    g_assert (i == 100);
+
+    g_variant_unref (value);
+
+    g_variant_builder_init (&array, G_VARIANT_TYPE_ARRAY);
+    for (i = 0; i < 100; i++)
+      g_variant_builder_add (&array, "mi", i % 2 == 0, i);
+    value = g_variant_builder_end (&array);
+
+    i = 0;
+    g_variant_iter_init (&iter, value);
+    while (g_variant_iter_loop (&iter, "mi", NULL, &val))
+      g_assert (val == i++ || val == 0);
+    g_assert (i == 100);
+
+    i = 0;
+    g_variant_iter_init (&iter, value);
+    while (g_variant_iter_loop (&iter, "mi", &just, &val))
+      {
+        gint this = i++;
+
+        if (this % 2 == 0)
+          {
+            g_assert (just);
+            g_assert (val == this);
+          }
+        else
+          {
+            g_assert (!just);
+            g_assert (val == 0);
+          }
+      }
+    g_assert (i == 100);
+
+    g_variant_unref (value);
+  }
+
+  {
+    const gchar *strvector[] = {"/hello", "/world", NULL};
+    const gchar *test_strs[] = {"/foo", "/bar", "/baz" };
+    GVariantBuilder builder;
+    GVariantIter *array;
+    GVariantIter tuple;
+    const gchar **strv;
+    gchar **my_strv;
+    GVariant *value;
+    gchar *str;
+    gint i;
+
+    g_variant_builder_init (&builder, G_VARIANT_TYPE ("ao"));
+    g_variant_builder_add (&builder, "o", "/foo");
+    g_variant_builder_add (&builder, "o", "/bar");
+    g_variant_builder_add (&builder, "o", "/baz");
+    value = g_variant_new("(ao^ao^a&o)", &builder, strvector, strvector);
+    g_variant_iter_init (&tuple, value);
+    g_variant_iter_next (&tuple, "ao", &array);
+
+    i = 0;
+    while (g_variant_iter_loop (array, "o", &str))
+      g_assert_cmpstr (str, ==, test_strs[i++]);
+    g_assert (i == 3);
+
+    g_variant_iter_free (array);
+
+    /* start over */
+    g_variant_iter_init (&tuple, value);
+    g_variant_iter_next (&tuple, "ao", &array);
+
+    i = 0;
+    while (g_variant_iter_loop (array, "&o", &str))
+      g_assert_cmpstr (str, ==, test_strs[i++]);
+    g_assert (i == 3);
+
+    g_variant_iter_free (array);
+
+    g_variant_iter_next (&tuple, "^a&o", &strv);
+    g_variant_iter_next (&tuple, "^ao", &my_strv);
+
+    g_assert_cmpstr (strv[0], ==, "/hello");
+    g_assert_cmpstr (strv[1], ==, "/world");
+    g_assert (strv[2] == NULL);
+    g_assert_cmpstr (my_strv[0], ==, "/hello");
+    g_assert_cmpstr (my_strv[1], ==, "/world");
+    g_assert (my_strv[2] == NULL);
+
+    g_variant_unref (value);
+    g_strfreev (my_strv);
+    g_free (strv);
+  }
+
+  {
+    const gchar *strvector[] = { "i", "ii", "iii", "iv", "v", "vi", NULL };
+    GVariantBuilder builder;
+    GVariantIter iter;
+    GVariantIter *i2;
+    GVariantIter *i3;
+    GVariant *value;
+    GVariant *sub;
+    gchar **strv;
+    gint i;
+
+    g_variant_builder_init (&builder, G_VARIANT_TYPE ("aag"));
+    g_variant_builder_open (&builder, G_VARIANT_TYPE ("ag"));
+    for (i = 0; i < 6; i++)
+      if (i & 1)
+        g_variant_builder_add (&builder, "g", strvector[i]);
+      else
+        g_variant_builder_add (&builder, "&g", strvector[i]);
+    g_variant_builder_close (&builder);
+    g_variant_builder_add (&builder, "^ag", strvector);
+    g_variant_builder_add (&builder, "^ag", strvector);
+    value = g_variant_new ("aag", &builder);
+
+    g_variant_iter_init (&iter, value);
+    while (g_variant_iter_loop (&iter, "^ag", &strv))
+      for (i = 0; i < 6; i++)
+        g_assert_cmpstr (strv[i], ==, strvector[i]);
+
+    g_variant_iter_init (&iter, value);
+    while (g_variant_iter_loop (&iter, "^a&g", &strv))
+      for (i = 0; i < 6; i++)
+        g_assert_cmpstr (strv[i], ==, strvector[i]);
+
+    g_variant_iter_init (&iter, value);
+    while (g_variant_iter_loop (&iter, "ag", &i2))
+      {
+        gchar *str;
+
+        i = 0;
+        while (g_variant_iter_loop (i2, "g", &str))
+          g_assert_cmpstr (str, ==, strvector[i++]);
+        g_assert (i == 6);
+      }
+
+    g_variant_iter_init (&iter, value);
+    i3 = g_variant_iter_copy (&iter);
+    while (g_variant_iter_loop (&iter, "@ag", &sub))
+      {
+        gchar *str = g_variant_print (sub, TRUE);
+        g_assert_cmpstr (str, ==,
+                         "[signature 'i', 'ii', 'iii', 'iv', 'v', 'vi']");
+        g_free (str);
+      }
+
+  if (do_failed_test ("*NULL has already been returned*"))
+    {
+      g_variant_iter_next_value (&iter);
+      abort ();
+    }
+
+
+    while (g_variant_iter_loop (i3, "*", &sub))
+      {
+        gchar *str = g_variant_print (sub, TRUE);
+        g_assert_cmpstr (str, ==,
+                         "[signature 'i', 'ii', 'iii', 'iv', 'v', 'vi']");
+        g_free (str);
+      }
+
+    g_variant_iter_free (i3);
+
+    for (i = 0; i < g_variant_n_children (value); i++)
+      {
+        gint j;
+
+        g_variant_get_child (value, i, "*", &sub);
+
+        for (j = 0; j < g_variant_n_children (sub); j++)
+          {
+            const gchar *str = NULL;
+            GVariant *cval;
+
+            g_variant_get_child (sub, j, "&g", &str);
+            g_assert_cmpstr (str, ==, strvector[j]);
+
+            cval = g_variant_get_child_value (sub, j);
+            g_variant_get (cval, "&g", &str);
+            g_assert_cmpstr (str, ==, strvector[j]);
+            g_variant_unref (cval);
+          }
+
+        g_variant_unref (sub);
+      }
+
+    g_variant_unref (value);
+  }
+
+  {
+    gboolean justs[10];
+    GVariant *value;
+
+    GVariant *vval;
+    guchar byteval;
+    gboolean bval;
+    gint16 i16val;
+    guint16 u16val;
+    gint32 i32val;
+    guint32 u32val;
+    gint64 i64val;
+    guint64 u64val;
+    gdouble dval;
+    gint32 hval;
+
+    /* test all 'Nothing' */
+    value = g_variant_new ("(mymbmnmqmimumxmtmhmdmv)",
+                           FALSE, 'a',
+                           FALSE, TRUE,
+                           FALSE, (gint16) 123,
+                           FALSE, (guint16) 123,
+                           FALSE, (gint32) 123,
+                           FALSE, (guint32) 123,
+                           FALSE, (gint64) 123,
+                           FALSE, (guint64) 123,
+                           FALSE, (gint32) -1,
+                           FALSE, (gdouble) 37.5,
+                           NULL);
+
+    /* both NULL */
+    g_variant_get (value, "(mymbmnmqmimumxmtmhmdmv)",
+                   NULL, NULL,
+                   NULL, NULL,
+                   NULL, NULL,
+                   NULL, NULL,
+                   NULL, NULL,
+                   NULL, NULL,
+                   NULL, NULL,
+                   NULL, NULL,
+                   NULL, NULL,
+                   NULL, NULL,
+                   NULL);
+
+    /* NULL values */
+    memset (justs, 1, sizeof justs);
+    g_variant_get (value, "(mymbmnmqmimumxmtmhmdmv)",
+                   &justs[0], NULL,
+                   &justs[1], NULL,
+                   &justs[2], NULL,
+                   &justs[3], NULL,
+                   &justs[4], NULL,
+                   &justs[5], NULL,
+                   &justs[6], NULL,
+                   &justs[7], NULL,
+                   &justs[8], NULL,
+                   &justs[9], NULL,
+                   NULL);
+    g_assert (!(justs[0] || justs[1] || justs[2] || justs[3] || justs[4] ||
+                justs[5] || justs[6] || justs[7] || justs[8] || justs[9]));
+
+    /* both non-NULL */
+    memset (justs, 1, sizeof justs);
+    byteval = i16val = u16val = i32val = u32val = i64val = u64val = hval = 88;
+    vval = (void *) 1;
+    bval = TRUE;
+    dval = 88.88;
+    g_variant_get (value, "(mymbmnmqmimumxmtmhmdmv)",
+                   &justs[0], &byteval,
+                   &justs[1], &bval,
+                   &justs[2], &i16val,
+                   &justs[3], &u16val,
+                   &justs[4], &i32val,
+                   &justs[5], &u32val,
+                   &justs[6], &i64val,
+                   &justs[7], &u64val,
+                   &justs[8], &hval,
+                   &justs[9], &dval,
+                   &vval);
+    g_assert (!(justs[0] || justs[1] || justs[2] || justs[3] || justs[4] ||
+                justs[5] || justs[6] || justs[7] || justs[8] || justs[9]));
+    g_assert (byteval == '\0' && bval == FALSE);
+    g_assert (i16val == 0 && u16val == 0 && i32val == 0 &&
+              u32val == 0 && i64val == 0 && u64val == 0 &&
+              hval == 0 && dval == 0.0);
+    g_assert (vval == NULL);
+
+    /* NULL justs */
+    byteval = i16val = u16val = i32val = u32val = i64val = u64val = hval = 88;
+    vval = (void *) 1;
+    bval = TRUE;
+    dval = 88.88;
+    g_variant_get (value, "(mymbmnmqmimumxmtmhmdmv)",
+                   NULL, &byteval,
+                   NULL, &bval,
+                   NULL, &i16val,
+                   NULL, &u16val,
+                   NULL, &i32val,
+                   NULL, &u32val,
+                   NULL, &i64val,
+                   NULL, &u64val,
+                   NULL, &hval,
+                   NULL, &dval,
+                   &vval);
+    g_assert (byteval == '\0' && bval == FALSE);
+    g_assert (i16val == 0 && u16val == 0 && i32val == 0 &&
+              u32val == 0 && i64val == 0 && u64val == 0 &&
+              hval == 0 && dval == 0.0);
+    g_assert (vval == NULL);
+
+    g_variant_unref (value);
+
+
+    /* test all 'Just' */
+    value = g_variant_new ("(mymbmnmqmimumxmtmhmdmv)",
+                           TRUE, 'a',
+                           TRUE, TRUE,
+                           TRUE, (gint16) 123,
+                           TRUE, (guint16) 123,
+                           TRUE, (gint32) 123,
+                           TRUE, (guint32) 123,
+                           TRUE, (gint64) 123,
+                           TRUE, (guint64) 123,
+                           TRUE, (gint32) -1,
+                           TRUE, (gdouble) 37.5,
+                           g_variant_new ("()"));
+
+    /* both NULL */
+    g_variant_get (value, "(mymbmnmqmimumxmtmhmdmv)",
+                   NULL, NULL,
+                   NULL, NULL,
+                   NULL, NULL,
+                   NULL, NULL,
+                   NULL, NULL,
+                   NULL, NULL,
+                   NULL, NULL,
+                   NULL, NULL,
+                   NULL, NULL,
+                   NULL, NULL,
+                   NULL);
+
+    /* NULL values */
+    memset (justs, 0, sizeof justs);
+    g_variant_get (value, "(mymbmnmqmimumxmtmhmdmv)",
+                   &justs[0], NULL,
+                   &justs[1], NULL,
+                   &justs[2], NULL,
+                   &justs[3], NULL,
+                   &justs[4], NULL,
+                   &justs[5], NULL,
+                   &justs[6], NULL,
+                   &justs[7], NULL,
+                   &justs[8], NULL,
+                   &justs[9], NULL,
+                   NULL);
+    g_assert (justs[0] && justs[1] && justs[2] && justs[3] && justs[4] &&
+              justs[5] && justs[6] && justs[7] && justs[8] && justs[9]);
+
+    /* both non-NULL */
+    memset (justs, 0, sizeof justs);
+    byteval = i16val = u16val = i32val = u32val = i64val = u64val = hval = 88;
+    vval = (void *) 1;
+    bval = FALSE;
+    dval = 88.88;
+    g_variant_get (value, "(mymbmnmqmimumxmtmhmdmv)",
+                   &justs[0], &byteval,
+                   &justs[1], &bval,
+                   &justs[2], &i16val,
+                   &justs[3], &u16val,
+                   &justs[4], &i32val,
+                   &justs[5], &u32val,
+                   &justs[6], &i64val,
+                   &justs[7], &u64val,
+                   &justs[8], &hval,
+                   &justs[9], &dval,
+                   &vval);
+    g_assert (justs[0] && justs[1] && justs[2] && justs[3] && justs[4] &&
+              justs[5] && justs[6] && justs[7] && justs[8] && justs[9]);
+    g_assert (byteval == 'a' && bval == TRUE);
+    g_assert (i16val == 123 && u16val == 123 && i32val == 123 &&
+              u32val == 123 && i64val == 123 && u64val == 123 &&
+              hval == -1 && dval == 37.5);
+    g_assert (g_variant_is_of_type (vval, G_VARIANT_TYPE_UNIT));
+    g_variant_unref (vval);
+
+    /* NULL justs */
+    byteval = i16val = u16val = i32val = u32val = i64val = u64val = hval = 88;
+    vval = (void *) 1;
+    bval = TRUE;
+    dval = 88.88;
+    g_variant_get (value, "(mymbmnmqmimumxmtmhmdmv)",
+                   NULL, &byteval,
+                   NULL, &bval,
+                   NULL, &i16val,
+                   NULL, &u16val,
+                   NULL, &i32val,
+                   NULL, &u32val,
+                   NULL, &i64val,
+                   NULL, &u64val,
+                   NULL, &hval,
+                   NULL, &dval,
+                   &vval);
+    g_assert (byteval == 'a' && bval == TRUE);
+    g_assert (i16val == 123 && u16val == 123 && i32val == 123 &&
+              u32val == 123 && i64val == 123 && u64val == 123 &&
+              hval == -1 && dval == 37.5);
+    g_assert (g_variant_is_of_type (vval, G_VARIANT_TYPE_UNIT));
+    g_variant_unref (vval);
+
+    g_variant_unref (value);
+  }
+
+  g_variant_type_info_assert_no_infos ();
+}
+
+static void
+hash_get (GVariant    *value,
+          const gchar *format,
+          ...)
+{
+  const gchar *endptr = NULL;
+  gboolean hash;
+  va_list ap;
+
+  hash = g_str_has_suffix (format, "#");
+
+  va_start (ap, format);
+  g_variant_get_va (value, format, hash ? &endptr : NULL, &ap);
+  va_end (ap);
+
+  if (hash)
+    g_assert (*endptr == '#');
+}
+
+static GVariant *
+hash_new (const gchar *format,
+          ...)
+{
+  const gchar *endptr = NULL;
+  GVariant *value;
+  gboolean hash;
+  va_list ap;
+
+  hash = g_str_has_suffix (format, "#");
+
+  va_start (ap, format);
+  value = g_variant_new_va (format, hash ? &endptr : NULL, &ap);
+  va_end (ap);
+
+  if (hash)
+    g_assert (*endptr == '#');
+
+  return value;
+}
+
+static void
+test_valist (void)
+{
+  GVariant *value;
+  gint32 x;
+
+  x = 0;
+  value = hash_new ("i", 234);
+  hash_get (value, "i", &x);
+  g_assert (x == 234);
+  g_variant_unref (value);
+
+  x = 0;
+  value = hash_new ("i#", 234);
+  hash_get (value, "i#", &x);
+  g_assert (x == 234);
+  g_variant_unref (value);
+
+  g_variant_type_info_assert_no_infos ();
+}
+
+static void
+test_builder_memory (void)
+{
+  GVariantBuilder *hb;
+  GVariantBuilder sb;
+
+  hb = g_variant_builder_new  (G_VARIANT_TYPE_ARRAY);
+  g_variant_builder_open (hb, G_VARIANT_TYPE_ARRAY);
+  g_variant_builder_open (hb, G_VARIANT_TYPE_ARRAY);
+  g_variant_builder_open (hb, G_VARIANT_TYPE_ARRAY);
+  g_variant_builder_add (hb, "s", "some value");
+  g_variant_builder_ref (hb);
+  g_variant_builder_unref (hb);
+  g_variant_builder_unref (hb);
+
+  hb = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
+  g_variant_builder_unref (hb);
+
+  hb = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
+  g_variant_builder_clear (hb);
+  g_variant_builder_unref (hb);
+
+  g_variant_builder_init (&sb, G_VARIANT_TYPE_ARRAY);
+  g_variant_builder_open (&sb, G_VARIANT_TYPE_ARRAY);
+  g_variant_builder_open (&sb, G_VARIANT_TYPE_ARRAY);
+  g_variant_builder_add (&sb, "s", "some value");
+  g_variant_builder_clear (&sb);
+
+  g_variant_type_info_assert_no_infos ();
+}
+
+static void
+test_hashing (void)
+{
+  const gint n_items = 4096;
+  GVariant *items[n_items];
+  GHashTable *table;
+  gint i;
+
+  table = g_hash_table_new_full (g_variant_hash, g_variant_equal,
+                                 (GDestroyNotify ) g_variant_unref,
+                                 NULL);
+
+  for (i = 0; i < n_items; i++)
+    {
+      TreeInstance *tree;
+      gint j;
+
+ again:
+      tree = tree_instance_new (NULL, 0);
+      items[i] = tree_instance_get_gvariant (tree);
+      tree_instance_free (tree);
+
+      for (j = 0; j < i; j++)
+        if (g_variant_equal (items[i], items[j]))
+          {
+            g_variant_unref (items[i]);
+            goto again;
+          }
+
+      g_hash_table_insert (table,
+                           g_variant_ref_sink (items[i]),
+                           GINT_TO_POINTER (i));
+    }
+
+  for (i = 0; i < n_items; i++)
+    {
+      gpointer result;
+
+      result = g_hash_table_lookup (table, items[i]);
+      g_assert_cmpint (GPOINTER_TO_INT (result), ==, i);
+    }
+
+  g_hash_table_unref (table);
+
+  g_variant_type_info_assert_no_infos ();
 }
 
 int
@@ -2688,6 +3407,12 @@ main (int argc, char **argv)
     }
 
   g_test_add_func ("/gvariant/containers", test_containers);
+  g_test_add_func ("/gvariant/format-strings", test_format_strings);
+  g_test_add_func ("/gvariant/invalid-varargs", test_invalid_varargs);
+  g_test_add_func ("/gvariant/varargs", test_varargs);
+  g_test_add_func ("/gvariant/valist", test_valist);
+  g_test_add_func ("/gvariant/builder-memory", test_builder_memory);
+  g_test_add_func ("/gvariant/hashing", test_hashing);
 
   return g_test_run ();
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]