[glib/wjt/gdbus-codegen-add-autocleanup-for-FooObject: 1/2] gdbus-codegen: test generating autocleanups



commit 5b78c3fdff817ee8204a0addcc4bd3879e46adfa
Author: Will Thompson <will willthompson co uk>
Date:   Fri Oct 26 13:49:54 2018 +0100

    gdbus-codegen: test generating autocleanups
    
    This is the most degenerate possible test but it does exercise this code
    path.
    
    (Tweaked by Philip Withnall <withnall endlessm com> to also add the flag
    to the autotools build.)

 gio/tests/Makefile.am          |  1 +
 gio/tests/gdbus-test-codegen.c | 41 +++++++++++++++++++++++++++++++++++++++++
 gio/tests/meson.build          |  1 +
 3 files changed, 43 insertions(+)
---
diff --git a/gio/tests/Makefile.am b/gio/tests/Makefile.am
index 2df156e6b..b8a414954 100644
--- a/gio/tests/Makefile.am
+++ b/gio/tests/Makefile.am
@@ -502,6 +502,7 @@ gdbus-test-codegen-generated.h: test-codegen.xml Makefile $(top_builddir)/gio/gd
                --interface-prefix org.project. \
                --generate-c-code gdbus-test-codegen-generated \
                --c-generate-object-manager \
+               --c-generate-autocleanup all \
                --c-namespace Foo_iGen \
                --generate-docbook gdbus-test-codegen-generated-doc \
                --annotate "org.project.Bar" Key1 Value1 \
diff --git a/gio/tests/gdbus-test-codegen.c b/gio/tests/gdbus-test-codegen.c
index 1c4e83c4c..a51cf1846 100644
--- a/gio/tests/gdbus-test-codegen.c
+++ b/gio/tests/gdbus-test-codegen.c
@@ -2385,6 +2385,46 @@ test_property_naming (void)
 
 /* ---------------------------------------------------------------------------------------------------- */
 
+/* autocleanups
+ *
+ * - check that g_autoptr() works for all generated types, if supported by the
+ *   current compiler
+ */
+
+static void
+test_autocleanups (void)
+{
+#ifdef g_autoptr
+  g_autoptr(FooiGenBar) bar = NULL;
+  g_autoptr(FooiGenBarProxy) bar_proxy = NULL;
+  g_autoptr(FooiGenBarSkeleton) bar_skeleton = NULL;
+  g_autoptr(FooiGenObjectProxy) object_proxy = NULL;
+  g_autoptr(FooiGenObjectSkeleton) object_skeleton = NULL;
+  g_autoptr(FooiGenObjectManagerClient) object_manager_client = NULL;
+
+  (void) bar;
+  (void) bar_proxy;
+  (void) bar_skeleton;
+  (void) object_proxy;
+  (void) object_skeleton;
+  (void) object_manager_client;
+#elif GLIB_CHECK_VERSION(2, 38, 0)
+  /* This file is compiled twice, once without GLib version guards and once
+   * with
+   *
+   *   -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_36
+   *   -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_36
+   *
+   * g_test_skip() was added in 2.38.
+   */
+  g_test_skip ("g_autoptr() not supported on this compiler");
+#else
+  /* Let's just say it passed. */
+#endif
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
 int
 main (int   argc,
       char *argv[])
@@ -2395,6 +2435,7 @@ main (int   argc,
   g_test_add_func ("/gdbus/codegen/interface_stability", test_interface_stability);
   g_test_add_func ("/gdbus/codegen/object-manager", test_object_manager);
   g_test_add_func ("/gdbus/codegen/property-naming", test_property_naming);
+  g_test_add_func ("/gdbus/codegen/autocleanups", test_autocleanups);
 
   return session_bus_run ();
 }
diff --git a/gio/tests/meson.build b/gio/tests/meson.build
index 65ddcdad8..757516b46 100644
--- a/gio/tests/meson.build
+++ b/gio/tests/meson.build
@@ -182,6 +182,7 @@ if host_machine.system() != 'windows'
                    '--output-directory', '@OUTDIR@',
                    '--generate-c-code', 'gdbus-test-codegen-generated',
                    '--c-generate-object-manager',
+                   '--c-generate-autocleanup', 'all',
                    '--c-namespace', 'Foo_iGen',
                    '--generate-docbook', 'gdbus-test-codegen-generated-doc',
                    '--annotate', 'org.project.Bar', 'Key1', 'Value1',


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