[Telepathy-commits] [telepathy-glib/master] Add a test for glib-gtypes-generator.py
Simon McVittie
simon.mcvittie at collabora.co.uk
Fri Jan 30 09:21:30 PST 2009
---
.gitignore | 2 +
tests/tools/Makefile.am | 10 ++-
tests/tools/expected-gtypes-body.h | 100 ++++++++++++++++
tests/tools/expected-gtypes.h | 175 +++++++++++++++++++++++++++++
tests/tools/glib-gtypes-generator.xml | 42 +++++++
tests/tools/test-glib-gtypes-generator.sh | 14 +++
6 files changed, 341 insertions(+), 2 deletions(-)
create mode 100644 tests/tools/expected-gtypes-body.h
create mode 100644 tests/tools/expected-gtypes.h
create mode 100644 tests/tools/glib-gtypes-generator.xml
create mode 100644 tests/tools/test-glib-gtypes-generator.sh
diff --git a/.gitignore b/.gitignore
index d7f8bfd..38b3f9d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -97,4 +97,6 @@ tests/test-heap
tests/test-internal-debug
tests/test-intset
tests/test-util
+tests/tools/actual.h
+tests/tools/actual-body.h
tools/telepathy-glib-env
diff --git a/tests/tools/Makefile.am b/tests/tools/Makefile.am
index cb0acd7..735fc80 100644
--- a/tests/tools/Makefile.am
+++ b/tests/tools/Makefile.am
@@ -1,9 +1,13 @@
dist_noinst_SCRIPTS = \
- test-gobject-foo.sh
+ test-gobject-foo.sh \
+ test-glib-gtypes-generator.sh
EXTRA_DIST = \
expected-gobject-foo.h \
- expected-ginterface-foo.h
+ expected-gtypes.h \
+ expected-gtypes-body.h \
+ expected-ginterface-foo.h \
+ glib-gtypes-generator.xml
TESTS = $(dist_noinst_SCRIPTS)
@@ -12,3 +16,5 @@ TESTS_ENVIRONMENT = \
srcdir=$(srcdir) \
top_srcdir=$(top_srcdir) \
sh
+
+CLEANFILES = actual.h actual-body.h
diff --git a/tests/tools/expected-gtypes-body.h b/tests/tools/expected-gtypes-body.h
new file mode 100644
index 0000000..ab1d7e9
--- /dev/null
+++ b/tests/tools/expected-gtypes-body.h
@@ -0,0 +1,100 @@
+/* Auto-generated, do not edit.
+ *
+ * This file may be distributed under the same terms
+ * as the specification from which it was generated.
+ */
+
+GType
+the_prefix_type_dbus_hash_ss (void)
+{
+ static GType t = 0;
+
+ if (G_UNLIKELY (t == 0))
+ t = dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING);
+ return t;
+}
+
+GType
+the_prefix_type_dbus_hash_sa_7bsv_7d (void)
+{
+ static GType t = 0;
+
+ if (G_UNLIKELY (t == 0))
+ t = dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE)));
+ return t;
+}
+
+GType
+the_prefix_type_dbus_hash_sv (void)
+{
+ static GType t = 0;
+
+ if (G_UNLIKELY (t == 0))
+ t = dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE);
+ return t;
+}
+
+GType
+the_prefix_type_dbus_hash_saa_7bsv_7d (void)
+{
+ static GType t = 0;
+
+ if (G_UNLIKELY (t == 0))
+ t = dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, (dbus_g_type_get_collection ("GPtrArray", (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE)))));
+ return t;
+}
+
+GType
+the_prefix_type_dbus_struct_isu (void)
+{
+ static GType t = 0;
+
+ if (G_UNLIKELY (t == 0))
+ t = dbus_g_type_get_struct ("GValueArray",
+ G_TYPE_INT,
+ G_TYPE_STRING,
+ G_TYPE_UINT,
+ G_TYPE_INVALID);
+ return t;
+}
+
+GType
+the_prefix_type_dbus_array_isu (void)
+{
+ static GType t = 0;
+
+ if (G_UNLIKELY (t == 0))
+ t = dbus_g_type_get_collection ("GPtrArray", the_prefix_type_dbus_struct_isu ());
+ return t;
+}
+
+GType
+the_prefix_type_dbus_array_of_a_7bsa_7bsv_7d_7d (void)
+{
+ static GType t = 0;
+
+ if (G_UNLIKELY (t == 0))
+ t = dbus_g_type_get_collection ("GPtrArray", the_prefix_type_dbus_hash_sa_7bsv_7d ());
+ return t;
+}
+
+GType
+the_prefix_type_dbus_array_of_a_7bsv_7d (void)
+{
+ static GType t = 0;
+
+ if (G_UNLIKELY (t == 0))
+ t = dbus_g_type_get_collection ("GPtrArray", the_prefix_type_dbus_hash_sv ());
+ return t;
+}
+
+GType
+the_prefix_type_dbus_array_of_a_7bsaa_7bsv_7d_7d (void)
+{
+ static GType t = 0;
+
+ if (G_UNLIKELY (t == 0))
+ t = dbus_g_type_get_collection ("GPtrArray", the_prefix_type_dbus_hash_saa_7bsv_7d ());
+ return t;
+}
+
diff --git a/tests/tools/expected-gtypes.h b/tests/tools/expected-gtypes.h
new file mode 100644
index 0000000..d499392
--- /dev/null
+++ b/tests/tools/expected-gtypes.h
@@ -0,0 +1,175 @@
+/* Auto-generated, do not edit.
+ *
+ * This file may be distributed under the same terms
+ * as the specification from which it was generated.
+ */
+
+/**
+ * THE_PREFIX_HASH_TYPE_STRING_VARIANT_MAP:
+ *
+ * (Undocumented)
+ *
+ * This macro expands to a call to a function
+ * that returns the #GType of a #GHashTable
+ * appropriate for representing a D-Bus
+ * dictionary of signature
+ * <literal>a{sv}</literal>.
+ *
+ * Keys (D-Bus type <literal>s</literal>,
+ * named <literal>Key</literal>):
+ * (Undocumented)
+ *
+ * Values (D-Bus type <literal>v</literal>,
+ * named <literal>Value</literal>):
+ * (Undocumented)
+ *
+ */
+#define THE_PREFIX_HASH_TYPE_STRING_VARIANT_MAP (the_prefix_type_dbus_hash_sv ())
+
+/**
+ * THE_PREFIX_ARRAY_TYPE_STRING_VARIANT_MAP_LIST:
+
+ * Expands to a call to a function
+ * that returns the #GType of a #GPtrArray
+ * of #THE_PREFIX_HASH_TYPE_STRING_VARIANT_MAP.
+ */
+#define THE_PREFIX_ARRAY_TYPE_STRING_VARIANT_MAP_LIST (the_prefix_type_dbus_array_of_a_7bsv_7d ())
+
+/**
+ * THE_PREFIX_HASH_TYPE_STRING_STRING_MAP:
+ *
+ * (Undocumented)
+ *
+ * This macro expands to a call to a function
+ * that returns the #GType of a #GHashTable
+ * appropriate for representing a D-Bus
+ * dictionary of signature
+ * <literal>a{ss}</literal>.
+ *
+ * Keys (D-Bus type <literal>s</literal>,
+ * named <literal>Key</literal>):
+ * (Undocumented)
+ *
+ * Values (D-Bus type <literal>s</literal>,
+ * named <literal>Value</literal>):
+ * (Undocumented)
+ *
+ */
+#define THE_PREFIX_HASH_TYPE_STRING_STRING_MAP (the_prefix_type_dbus_hash_ss ())
+
+/**
+ * THE_PREFIX_HASH_TYPE_STRING_VARIANT_MAP_MAP:
+ *
+ * (Undocumented)
+ *
+ * This macro expands to a call to a function
+ * that returns the #GType of a #GHashTable
+ * appropriate for representing a D-Bus
+ * dictionary of signature
+ * <literal>a{sa{sv}}</literal>.
+ *
+ * Keys (D-Bus type <literal>s</literal>,
+ * named <literal>Key</literal>):
+ * (Undocumented)
+ *
+ * Values (D-Bus type <literal>a{sv}</literal>,
+ * type <literal>String_Variant_Map</literal>,
+ * named <literal>Value</literal>):
+ * (Undocumented)
+ *
+ */
+#define THE_PREFIX_HASH_TYPE_STRING_VARIANT_MAP_MAP (the_prefix_type_dbus_hash_sa_7bsv_7d ())
+
+/**
+ * THE_PREFIX_ARRAY_TYPE_STRING_VARIANT_MAP_MAP_LIST:
+
+ * Expands to a call to a function
+ * that returns the #GType of a #GPtrArray
+ * of #THE_PREFIX_HASH_TYPE_STRING_VARIANT_MAP_MAP.
+ */
+#define THE_PREFIX_ARRAY_TYPE_STRING_VARIANT_MAP_MAP_LIST (the_prefix_type_dbus_array_of_a_7bsa_7bsv_7d_7d ())
+
+/**
+ * THE_PREFIX_HASH_TYPE_STRING_VARIANT_MAP_LIST_MAP:
+ *
+ * (Undocumented)
+ *
+ * This macro expands to a call to a function
+ * that returns the #GType of a #GHashTable
+ * appropriate for representing a D-Bus
+ * dictionary of signature
+ * <literal>a{saa{sv}}</literal>.
+ *
+ * Keys (D-Bus type <literal>s</literal>,
+ * named <literal>Key</literal>):
+ * (Undocumented)
+ *
+ * Values (D-Bus type <literal>aa{sv}</literal>,
+ * type <literal>String_Variant_Map[]</literal>,
+ * named <literal>Value</literal>):
+ * (Undocumented)
+ *
+ */
+#define THE_PREFIX_HASH_TYPE_STRING_VARIANT_MAP_LIST_MAP (the_prefix_type_dbus_hash_saa_7bsv_7d ())
+
+/**
+ * THE_PREFIX_ARRAY_TYPE_STRING_VARIANT_MAP_LIST_MAP_LIST:
+
+ * Expands to a call to a function
+ * that returns the #GType of a #GPtrArray
+ * of #THE_PREFIX_HASH_TYPE_STRING_VARIANT_MAP_LIST_MAP.
+ */
+#define THE_PREFIX_ARRAY_TYPE_STRING_VARIANT_MAP_LIST_MAP_LIST (the_prefix_type_dbus_array_of_a_7bsaa_7bsv_7d_7d ())
+
+GType the_prefix_type_dbus_hash_ss (void);
+
+GType the_prefix_type_dbus_hash_sa_7bsv_7d (void);
+
+GType the_prefix_type_dbus_hash_sv (void);
+
+GType the_prefix_type_dbus_hash_saa_7bsv_7d (void);
+
+/**
+ * THE_PREFIX_STRUCT_TYPE_STRUCT:
+
+ * (Undocumented)
+ *
+ * This macro expands to a call to a function
+ * that returns the #GType of a #GValueArray
+ * appropriate for representing a D-Bus struct
+ * with signature <literal>(isu)</literal>.
+ *
+ * Member 0 (D-Bus type <literal>i</literal>,
+ * named <literal>Int</literal>):
+ * (Undocumented)
+ *
+ * Member 1 (D-Bus type <literal>s</literal>,
+ * named <literal>String</literal>):
+ * (Undocumented)
+ *
+ * Member 2 (D-Bus type <literal>u</literal>,
+ * named <literal>UInt</literal>):
+ * (Undocumented)
+ *
+ */
+#define THE_PREFIX_STRUCT_TYPE_STRUCT (the_prefix_type_dbus_struct_isu ())
+
+/**
+ * THE_PREFIX_ARRAY_TYPE_STRUCT_LIST:
+
+ * Expands to a call to a function
+ * that returns the #GType of a #GPtrArray
+ * of #THE_PREFIX_STRUCT_TYPE_STRUCT.
+ */
+#define THE_PREFIX_ARRAY_TYPE_STRUCT_LIST (the_prefix_type_dbus_array_isu ())
+
+GType the_prefix_type_dbus_struct_isu (void);
+
+GType the_prefix_type_dbus_array_isu (void);
+
+GType the_prefix_type_dbus_array_of_a_7bsa_7bsv_7d_7d (void);
+
+GType the_prefix_type_dbus_array_of_a_7bsv_7d (void);
+
+GType the_prefix_type_dbus_array_of_a_7bsaa_7bsv_7d_7d (void);
+
diff --git a/tests/tools/glib-gtypes-generator.xml b/tests/tools/glib-gtypes-generator.xml
new file mode 100644
index 0000000..3f14a9c
--- /dev/null
+++ b/tests/tools/glib-gtypes-generator.xml
@@ -0,0 +1,42 @@
+<tp:spec
+ xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
+
+ <tp:mapping name="String_Variant_Map" array-name="String_Variant_Map_List">
+ <tp:member type="s" name="Key"/>
+ <tp:member type="v" name="Value"/>
+ </tp:mapping>
+
+ <tp:mapping name="String_String_Map">
+ <tp:member type="s" name="Key"/>
+ <tp:member type="s" name="Value"/>
+ </tp:mapping>
+
+ <tp:mapping name="String_Variant_Map_Map" array-name="String_Variant_Map_Map_List">
+ <tp:member type="s" name="Key"/>
+ <tp:member type="a{sv}" name="Value" tp:type="String_Variant_Map"/>
+ </tp:mapping>
+
+ <tp:mapping name="String_Variant_Map_List_Map" array-name="String_Variant_Map_List_Map_List">
+ <tp:member type="s" name="Key"/>
+ <tp:member type="aa{sv}" name="Value" tp:type="String_Variant_Map[]"/>
+ </tp:mapping>
+
+ <tp:struct name="Struct" array-name="Struct_List">
+ <tp:member type="i" name="Int"/>
+ <tp:member type="s" name="String"/>
+ <tp:member type="u" name="UInt"/>
+ </tp:struct>
+
+ <tp:simple-type name="Word" type="s" array-name="Word_List">
+ </tp:simple-type>
+
+ <tp:simple-type name="Sixty_Four" type="x" array-name="Sixty_Four_List">
+ </tp:simple-type>
+
+ <tp:simple-type name="Thirty_Two" type="u" array-name="Thirty_Two_List">
+ </tp:simple-type>
+
+ <tp:simple-type name="Byte" type="y" array-name="Byte_Array">
+ </tp:simple-type>
+
+</tp:spec>
diff --git a/tests/tools/test-glib-gtypes-generator.sh b/tests/tools/test-glib-gtypes-generator.sh
new file mode 100644
index 0000000..95f302d
--- /dev/null
+++ b/tests/tools/test-glib-gtypes-generator.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+set -e
+
+${PYTHON} ${top_srcdir}/tools/glib-gtypes-generator.py \
+ ${top_srcdir}/tests/tools/glib-gtypes-generator.xml \
+ actual The_Prefix
+
+e=0
+# We assume POSIX diff, until someone complains
+diff -b -c ${srcdir}/expected-gtypes.h actual.h || e=$?
+diff -b -c ${srcdir}/expected-gtypes-body.h actual-body.h || e=$?
+
+exit $e
--
1.5.6.5
More information about the telepathy-commits
mailing list