2 * Copyright © 2008 Ryan Lortie
3 * Copyright © 2010 Codethink Limited
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
20 * Author: Ryan Lortie <desrt@desrt.ca>
25 #include "gvarianttypeinfo.h"
27 #include <glib/gtestutils.h>
28 #include <glib/gthread.h>
29 #include <glib/ghash.h>
36 * This structure contains the necessary information to facilitate the
37 * serialisation and fast deserialisation of a given type of GVariant
38 * value. A GVariant instance holds a pointer to one of these
39 * structures to provide for efficient operation.
41 * The GVariantTypeInfo structures for all of the base types, plus the
42 * "variant" type are stored in a read-only static array.
44 * For container types, a hash table and reference counting is used to
45 * ensure that only one of these structures exists for any given type.
46 * In general, a container GVariantTypeInfo will exist for a given type
47 * only if one or more GVariant instances of that type exist or if
48 * another GVariantTypeInfo has that type as a subtype. For example, if
49 * a process contains a single GVariant instance with type "(asv)", then
50 * container GVariantTypeInfo structures will exist for "(asv)" and
51 * for "as" (note that "s" and "v" always exist in the static array).
53 * The trickiest part of GVariantTypeInfo (and in fact, the major reason
54 * for its existance) is the storage of somewhat magical constants that
55 * allow for O(1) lookups of items in tuples. This is described below.
57 * 'container_class' is set to 'a' or 'r' if the GVariantTypeInfo is
58 * contained inside of an ArrayInfo or TupleInfo, respectively. This
59 * allows the storage of the necessary additional information.
61 * 'fixed_size' is set to the fixed size of the type, if applicable, or
62 * 0 otherwise (since no type has a fixed size of 0).
64 * 'alignment' is set to one less than the alignment requirement for
65 * this type. This makes many operations much more convenient.
67 struct _GVariantTypeInfo
71 guchar container_class;
74 /* Container types are reference counted. They also need to have their
75 * type string stored explicitly since it is not merely a single letter.
79 GVariantTypeInfo info;
85 /* For 'array' and 'maybe' types, we store some extra information on the
86 * end of the GVariantTypeInfo struct -- the element type (ie: "s" for
87 * "as"). The container GVariantTypeInfo structure holds a reference to
88 * the element typeinfo.
92 ContainerInfo container;
94 GVariantTypeInfo *element;
97 /* For 'tuple' and 'dict entry' types, we store extra information for
98 * each member -- its type and how to find it inside the serialised data
99 * in O(1) time using 4 variables -- 'i', 'a', 'b', and 'c'. See the
100 * comment on GVariantMemberInfo in gvarianttypeinfo.h.
104 ContainerInfo container;
106 GVariantMemberInfo *members;
111 /* Hard-code the base types in a constant array */
112 static const GVariantTypeInfo g_variant_type_info_basic_table[24] = {
113 #define fixed_aligned(x) x, x - 1
114 #define unaligned 0, 0
115 #define aligned(x) 0, x - 1
116 /* 'b' */ { fixed_aligned(1) }, /* boolean */
118 /* 'd' */ { fixed_aligned(8) }, /* double */
121 /* 'g' */ { unaligned }, /* signature string */
122 /* 'h' */ { fixed_aligned(4) }, /* file handle (int32) */
123 /* 'i' */ { fixed_aligned(4) }, /* int32 */
128 /* 'n' */ { fixed_aligned(2) }, /* int16 */
129 /* 'o' */ { unaligned }, /* object path string */
131 /* 'q' */ { fixed_aligned(2) }, /* uint16 */
133 /* 's' */ { unaligned }, /* string */
134 /* 't' */ { fixed_aligned(8) }, /* uint64 */
135 /* 'u' */ { fixed_aligned(4) }, /* uint32 */
136 /* 'v' */ { aligned(8) }, /* variant */
138 /* 'x' */ { fixed_aligned(8) }, /* int64 */
139 /* 'y' */ { fixed_aligned(1) }, /* byte */
145 /* We need to have type strings to return for the base types. We store
146 * those in another array. Since all base type strings are single
147 * characters this is easy. By not storing pointers to strings into the
148 * GVariantTypeInfo itself, we save a bunch of relocations.
150 static const char g_variant_type_info_basic_chars[24][2] = {
151 "b", " ", "d", " ", " ", "g", "h", "i", " ", " ", " ", " ",
152 "n", "o", " ", "q", " ", "s", "t", "u", "v", " ", "x", "y"
155 /* sanity checks to make debugging easier */
157 g_variant_type_info_check (const GVariantTypeInfo *info,
158 char container_class)
160 g_assert (!container_class || info->container_class == container_class);
162 /* alignment can only be one of these */
163 g_assert (info->alignment == 0 || info->alignment == 1 ||
164 info->alignment == 3 || info->alignment == 7);
166 if (info->container_class)
168 ContainerInfo *container = (ContainerInfo *) info;
170 /* extra checks for containers */
171 g_assert_cmpint (container->ref_count, >, 0);
172 g_assert (container->type_string != NULL);
178 /* if not a container, then ensure that it is a valid member of
179 * the basic types table
181 index = info - g_variant_type_info_basic_table;
183 g_assert (G_N_ELEMENTS (g_variant_type_info_basic_table) == 24);
184 g_assert (G_N_ELEMENTS (g_variant_type_info_basic_chars) == 24);
185 g_assert (0 <= index && index < 24);
186 g_assert (g_variant_type_info_basic_chars[index][0] != ' ');
191 * g_variant_type_info_get_type_string:
192 * @info: a #GVariantTypeInfo
194 * Gets the type string for @info. The string is nul-terminated.
197 g_variant_type_info_get_type_string (GVariantTypeInfo *info)
199 g_variant_type_info_check (info, 0);
201 if (info->container_class)
203 ContainerInfo *container = (ContainerInfo *) info;
205 /* containers have their type string stored inside them */
206 return container->type_string;
212 /* look up the type string in the base type array. the call to
213 * g_variant_type_info_check() above already ensured validity.
215 index = info - g_variant_type_info_basic_table;
217 return g_variant_type_info_basic_chars[index];
222 * g_variant_type_info_query:
223 * @info: a #GVariantTypeInfo
224 * @alignment: the location to store the alignment, or %NULL
225 * @fixed_size: the location to store the fixed size, or %NULL
227 * Queries @info to determine the alignment requirements and fixed size
228 * (if any) of the type.
230 * @fixed_size, if non-%NULL is set to the fixed size of the type, or 0
231 * to indicate that the type is a variable-sized type. No type has a
234 * @alignment, if non-%NULL, is set to one less than the required
235 * alignment of the type. For example, for a 32bit integer, @alignment
236 * would be set to 3. This allows you to round an integer up to the
237 * proper alignment by performing the following efficient calculation:
239 * offset += ((-offset) & alignment);
242 g_variant_type_info_query (GVariantTypeInfo *info,
246 g_variant_type_info_check (info, 0);
249 *alignment = info->alignment;
252 *fixed_size = info->fixed_size;
256 #define ARRAY_INFO_CLASS 'a'
258 ARRAY_INFO (GVariantTypeInfo *info)
260 g_variant_type_info_check (info, ARRAY_INFO_CLASS);
262 return (ArrayInfo *) info;
266 array_info_free (GVariantTypeInfo *info)
268 ArrayInfo *array_info;
270 g_assert (info->container_class == ARRAY_INFO_CLASS);
271 array_info = (ArrayInfo *) info;
273 g_variant_type_info_unref (array_info->element);
274 g_slice_free (ArrayInfo, array_info);
277 static ContainerInfo *
278 array_info_new (const GVariantType *type)
282 info = g_slice_new (ArrayInfo);
283 info->container.info.container_class = ARRAY_INFO_CLASS;
285 info->element = g_variant_type_info_get (g_variant_type_element (type));
286 info->container.info.alignment = info->element->alignment;
287 info->container.info.fixed_size = 0;
289 return (ContainerInfo *) info;
293 * g_variant_type_info_element:
294 * @info: a #GVariantTypeInfo for an array or maybe type
296 * Returns the element type for the array or maybe type. A reference is
297 * not added, so the caller must add their own.
300 g_variant_type_info_element (GVariantTypeInfo *info)
302 return ARRAY_INFO (info)->element;
306 * g_variant_type_query_element:
307 * @info: a #GVariantTypeInfo for an array or maybe type
308 * @alignment: the location to store the alignment, or %NULL
309 * @fixed_size: the location to store the fixed size, or %NULL
311 * Returns the alignment requires and fixed size (if any) for the
312 * element type of the array. This call is a convenience wrapper around
313 * g_variant_type_info_element() and g_variant_type_info_query().
316 g_variant_type_info_query_element (GVariantTypeInfo *info,
320 g_variant_type_info_query (ARRAY_INFO (info)->element,
321 alignment, fixed_size);
325 #define TUPLE_INFO_CLASS 'r'
327 TUPLE_INFO (GVariantTypeInfo *info)
329 g_variant_type_info_check (info, TUPLE_INFO_CLASS);
331 return (TupleInfo *) info;
335 tuple_info_free (GVariantTypeInfo *info)
337 TupleInfo *tuple_info;
340 g_assert (info->container_class == TUPLE_INFO_CLASS);
341 tuple_info = (TupleInfo *) info;
343 for (i = 0; i < tuple_info->n_members; i++)
344 g_variant_type_info_unref (tuple_info->members[i].type_info);
346 g_slice_free1 (sizeof (GVariantMemberInfo) * tuple_info->n_members,
347 tuple_info->members);
348 g_slice_free (TupleInfo, tuple_info);
352 tuple_allocate_members (const GVariantType *type,
353 GVariantMemberInfo **members,
356 const GVariantType *item_type;
359 *n_members = g_variant_type_n_items (type);
360 *members = g_slice_alloc (sizeof (GVariantMemberInfo) * *n_members);
362 item_type = g_variant_type_first (type);
365 GVariantMemberInfo *member = &(*members)[i++];
367 member->type_info = g_variant_type_info_get (item_type);
368 item_type = g_variant_type_next (item_type);
370 if (member->type_info->fixed_size)
371 member->ending_type = G_VARIANT_MEMBER_ENDING_FIXED;
372 else if (item_type == NULL)
373 member->ending_type = G_VARIANT_MEMBER_ENDING_LAST;
375 member->ending_type = G_VARIANT_MEMBER_ENDING_OFFSET;
378 g_assert (i == *n_members);
381 /* this is g_variant_type_info_query for a given member of the tuple.
382 * before the access is done, it is ensured that the item is within
383 * range and %FALSE is returned if not.
386 tuple_get_item (TupleInfo *info,
387 GVariantMemberInfo *item,
391 if (&info->members[info->n_members] == item)
394 *d = item->type_info->alignment;
395 *e = item->type_info->fixed_size;
399 /* Read the documentation for #GVariantMemberInfo in gvarianttype.h
400 * before attempting to understand this.
402 * This function adds one set of "magic constant" values (for one item
403 * in the tuple) to the table.
405 * The algorithm in tuple_generate_table() calculates values of 'a', 'b'
406 * and 'c' for each item, such that the procedure for finding the item
407 * is to start at the end of the previous variable-sized item, add 'a',
408 * then round up to the nearest multiple of 'b', then then add 'c'.
409 * Note that 'b' is stored in the usual "one less than" form. ie:
411 * start = ROUND_UP(prev_end + a, (b + 1)) + c;
413 * We tweak these values a little to allow for a slightly easier
414 * computation and more compact storage.
417 tuple_table_append (GVariantMemberInfo **items,
423 GVariantMemberInfo *item = (*items)++;
425 /* We can shift multiples of the alignment size from 'c' into 'a'.
426 * As long as we're shifting whole multiples, it won't affect the
427 * result. This means that we can take the "aligned" portion off of
428 * 'c' and add it into 'a'.
430 * Imagine (for sake of clarity) that ROUND_10 rounds up to the
431 * nearest 10. It is clear that:
433 * ROUND_10(a) + c == ROUND_10(a + 10*(c / 10)) + (c % 10)
435 * ie: remove the 10s portion of 'c' and add it onto 'a'.
437 * To put some numbers on it, imagine we start with a = 34 and c = 27:
439 * ROUND_10(34) + 27 = 40 + 27 = 67
441 * but also, we can split 27 up into 20 and 7 and do this:
443 * ROUND_10(34 + 20) + 7 = ROUND_10(54) + 7 = 60 + 7 = 67
445 * without affecting the result. We do that here.
447 * This reduction in the size of 'c' means that we can store it in a
448 * gchar instead of a gsize. Due to how the structure is packed, this
449 * ends up saving us 'two pointer sizes' per item in each tuple when
450 * allocating using GSlice.
452 a += ~b & c; /* take the "aligned" part of 'c' and add to 'a' */
453 c &= b; /* chop 'c' to contain only the unaligned part */
456 /* Finally, we made one last adjustment. Recall:
458 * start = ROUND_UP(prev_end + a, (b + 1)) + c;
460 * Forgetting the '+ c' for the moment:
462 * ROUND_UP(prev_end + a, (b + 1));
464 * we can do a "round up" operation by adding 1 less than the amount
465 * to round up to, then rounding down. ie:
467 * #define ROUND_UP(x, y) ROUND_DOWN(x + (y-1), y)
469 * Of course, for rounding down to a power of two, we can just mask
470 * out the appropriate number of low order bits:
472 * #define ROUND_DOWN(x, y) (x & ~(y - 1))
476 * #define ROUND_UP(x, y) (x + (y - 1) & ~(y - 1))
478 * but recall that our alignment value 'b' is already "one less".
479 * This means that to round 'prev_end + a' up to 'b' we can just do:
481 * ((prev_end + a) + b) & ~b
483 * Associativity, and putting the 'c' back on:
485 * (prev_end + (a + b)) & ~b + c
487 * Now, since (a + b) is constant, we can just add 'b' to 'a' now and
488 * store that as the number to add to prev_end. Then we use ~b as the
489 * number to take a bitwise 'and' with. Finally, 'c' is added on.
491 * Note, however, that all the low order bits of the 'aligned' value
492 * are masked out and that all of the high order bits of 'c' have been
493 * "moved" to 'a' (in the previous step). This means that there are
494 * no overlapping bits in the addition -- so we can do a bitwise 'or'
497 * This means that we can now compute the start address of a given
498 * item in the tuple using the algorithm given in the documentation
499 * for #GVariantMemberInfo:
501 * item_start = ((prev_end + a) & b) | c;
511 tuple_align (gsize offset,
514 return offset + ((-offset) & alignment);
517 /* This function is the heart of the algorithm for calculating 'i', 'a',
518 * 'b' and 'c' for each item in the tuple.
520 * Imagine we want to find the start of the "i" in the type "(su(qx)ni)".
521 * That's a string followed by a uint32, then a tuple containing a
522 * uint16 and a int64, then an int16, then our "i". In order to get to
525 * Start at the end of the string, align to 4 (for the uint32), add 4.
526 * Align to 8, add 16 (for the tuple). Align to 2, add 2 (for the
527 * int16). Then we're there. It turns out that, given 3 simple rules,
528 * we can flatten this iteration into one addition, one alignment, then
531 * The loop below plays through each item in the tuple, querying its
532 * alignment and fixed_size into 'd' and 'e', respectively. At all
533 * times the variables 'a', 'b', and 'c' are maintained such that in
534 * order to get to the current point, you add 'a', align to 'b' then add
535 * 'c'. 'b' is kept in "one less than" form. For each item, the proper
536 * alignment is applied to find the values of 'a', 'b' and 'c' to get to
537 * the start of that item. Those values are recorded into the table.
538 * The fixed size of the item (if applicable) is then added on.
540 * These 3 rules are how 'a', 'b' and 'c' are modified for alignment and
541 * addition of fixed size. They have been proven correct but are
542 * presented here, without proof:
544 * 1) in order to "align to 'd'" where 'd' is less than or equal to the
545 * largest level of alignment seen so far ('b'), you align 'c' to
547 * 2) in order to "align to 'd'" where 'd' is greater than the largest
548 * level of alignment seen so far, you add 'c' aligned to 'b' to the
549 * value of 'a', set 'b' to 'd' (ie: increase the 'largest alignment
550 * seen') and reset 'c' to 0.
551 * 3) in order to "add 'e'", just add 'e' to 'c'.
554 tuple_generate_table (TupleInfo *info)
556 GVariantMemberInfo *items = info->members;
557 gsize i = -1, a = 0, b = 0, c = 0, d, e;
559 /* iterate over each item in the tuple.
560 * 'd' will be the alignment of the item (in one-less form)
561 * 'e' will be the fixed size (or 0 for variable-size items)
563 while (tuple_get_item (info, items, &d, &e))
567 c = tuple_align (c, d); /* rule 1 */
569 a += tuple_align (c, b), b = d, c = 0; /* rule 2 */
571 /* the start of the item is at this point (ie: right after we
572 * have aligned for it). store this information in the table.
574 tuple_table_append (&items, i, a, b, c);
576 /* "move past" the item by adding in its size. */
580 * we'll have an offset stored to mark the end of this item, so
581 * just bump the offset index to give us a new starting point
582 * and reset all the counters.
592 tuple_set_base_info (TupleInfo *info)
594 GVariantTypeInfo *base = &info->container.info;
596 if (info->n_members > 0)
598 GVariantMemberInfo *m;
600 /* the alignment requirement of the tuple is the alignment
601 * requirement of its largest item.
604 for (m = info->members; m < &info->members[info->n_members]; m++)
605 /* can find the max of a list of "one less than" powers of two
608 base->alignment |= m->type_info->alignment;
610 m--; /* take 'm' back to the last item */
612 /* the structure only has a fixed size if no variable-size
613 * offsets are stored and the last item is fixed-sized too (since
614 * an offset is never stored for the last item).
616 if (m->i == -1 && m->type_info->fixed_size)
617 /* in that case, the fixed size can be found by finding the
618 * start of the last item (in the usual way) and adding its
621 * if a tuple has a fixed size then it is always a multiple of
622 * the alignment requirement (to make packing into arrays
623 * easier) so we round up to that here.
626 tuple_align (((m->a & m->b) | m->c) + m->type_info->fixed_size,
629 /* else, the tuple is not fixed size */
630 base->fixed_size = 0;
634 /* the empty tuple: '()'.
636 * has a size of 1 and an no alignment requirement.
638 * It has a size of 1 (not 0) for two practical reasons:
640 * 1) So we can determine how many of them are in an array
641 * without dividing by zero or without other tricks.
643 * 2) Even if we had some trick to know the number of items in
644 * the array (as GVariant did at one time) this would open a
645 * potential denial of service attack: an attacker could send
646 * you an extremely small array (in terms of number of bytes)
647 * containing trillions of zero-sized items. If you iterated
648 * over this array you would effectively infinite-loop your
649 * program. By forcing a size of at least one, we bound the
650 * amount of computation done in response to a message to a
651 * reasonable function of the size of that message.
654 base->fixed_size = 1;
658 static ContainerInfo *
659 tuple_info_new (const GVariantType *type)
663 info = g_slice_new (TupleInfo);
664 info->container.info.container_class = TUPLE_INFO_CLASS;
666 tuple_allocate_members (type, &info->members, &info->n_members);
667 tuple_generate_table (info);
668 tuple_set_base_info (info);
670 return (ContainerInfo *) info;
674 * g_variant_type_info_n_members:
675 * @info: a #GVariantTypeInfo for a tuple or dictionary entry type
677 * Returns the number of members in a tuple or dictionary entry type.
678 * For a dictionary entry this will always be 2.
681 g_variant_type_info_n_members (GVariantTypeInfo *info)
683 return TUPLE_INFO (info)->n_members;
687 * g_variant_type_info_member_info:
688 * @info: a #GVariantTypeInfo for a tuple or dictionary entry type
689 * @index: the member to fetch information for
691 * Returns the #GVariantMemberInfo for a given member. See
692 * documentation for that structure for why you would want this
695 * @index must refer to a valid child (ie: strictly less than
696 * g_variant_type_info_n_members() returns).
698 const GVariantMemberInfo *
699 g_variant_type_info_member_info (GVariantTypeInfo *info,
702 TupleInfo *tuple_info = TUPLE_INFO (info);
704 if (index < tuple_info->n_members)
705 return &tuple_info->members[index];
710 /* == new/ref/unref == */
711 static GStaticRecMutex g_variant_type_info_lock = G_STATIC_REC_MUTEX_INIT;
712 static GHashTable *g_variant_type_info_table;
715 * g_variant_type_info_get:
716 * @type: a #GVariantType
718 * Returns a reference to a #GVariantTypeInfo for @type.
720 * If an info structure already exists for this type, a new reference is
721 * returned. If not, the required calculations are performed and a new
722 * info structure is returned.
724 * It is appropriate to call g_variant_type_info_unref() on the return
728 g_variant_type_info_get (const GVariantType *type)
732 type_char = g_variant_type_peek_string (type)[0];
734 if (type_char == G_VARIANT_TYPE_INFO_CHAR_MAYBE ||
735 type_char == G_VARIANT_TYPE_INFO_CHAR_ARRAY ||
736 type_char == G_VARIANT_TYPE_INFO_CHAR_TUPLE ||
737 type_char == G_VARIANT_TYPE_INFO_CHAR_DICT_ENTRY)
739 GVariantTypeInfo *info;
742 type_string = g_variant_type_dup_string (type);
744 g_static_rec_mutex_lock (&g_variant_type_info_lock);
746 if (g_variant_type_info_table == NULL)
747 g_variant_type_info_table = g_hash_table_new (g_str_hash,
749 info = g_hash_table_lookup (g_variant_type_info_table, type_string);
753 ContainerInfo *container;
755 if (type_char == G_VARIANT_TYPE_INFO_CHAR_MAYBE ||
756 type_char == G_VARIANT_TYPE_INFO_CHAR_ARRAY)
758 container = array_info_new (type);
760 else /* tuple or dict entry */
762 container = tuple_info_new (type);
765 info = (GVariantTypeInfo *) container;
766 container->type_string = type_string;
767 container->ref_count = 1;
769 g_hash_table_insert (g_variant_type_info_table, type_string, info);
773 g_variant_type_info_ref (info);
775 g_static_rec_mutex_unlock (&g_variant_type_info_lock);
776 g_variant_type_info_check (info, 0);
777 g_free (type_string);
783 const GVariantTypeInfo *info;
786 index = type_char - 'b';
787 g_assert (G_N_ELEMENTS (g_variant_type_info_basic_table) == 24);
788 g_assert_cmpint (0, <=, index);
789 g_assert_cmpint (index, <, 24);
791 info = g_variant_type_info_basic_table + index;
792 g_variant_type_info_check (info, 0);
794 return (GVariantTypeInfo *) info;
799 * g_variant_type_info_ref:
800 * @info: a #GVariantTypeInfo
802 * Adds a reference to @info.
805 g_variant_type_info_ref (GVariantTypeInfo *info)
807 g_variant_type_info_check (info, 0);
809 if (info->container_class)
811 ContainerInfo *container = (ContainerInfo *) info;
813 g_assert_cmpint (container->ref_count, >, 0);
814 g_atomic_int_inc (&container->ref_count);
821 * g_variant_type_info_unref:
822 * @info: a #GVariantTypeInfo
824 * Releases a reference held on @info. This may result in @info being
828 g_variant_type_info_unref (GVariantTypeInfo *info)
830 g_variant_type_info_check (info, 0);
832 if (info->container_class)
834 ContainerInfo *container = (ContainerInfo *) info;
836 g_static_rec_mutex_lock (&g_variant_type_info_lock);
837 if (g_atomic_int_dec_and_test (&container->ref_count))
839 g_hash_table_remove (g_variant_type_info_table,
840 container->type_string);
841 if (g_hash_table_size (g_variant_type_info_table) == 0)
843 g_hash_table_unref (g_variant_type_info_table);
844 g_variant_type_info_table = NULL;
846 g_static_rec_mutex_unlock (&g_variant_type_info_lock);
848 g_free (container->type_string);
850 if (info->container_class == ARRAY_INFO_CLASS)
851 array_info_free (info);
853 else if (info->container_class == TUPLE_INFO_CLASS)
854 tuple_info_free (info);
857 g_assert_not_reached ();
860 g_static_rec_mutex_unlock (&g_variant_type_info_lock);
864 /* used from the test cases */
865 #define assert_no_type_infos() \
866 g_assert (g_variant_type_info_table == NULL)