[glib/wip/gcleanup] gcleanup: A bit of cleanup and reorg



commit d2bd2707642250ab4baaba84562bbbe5c4c88415
Author: Stef Walter <stefw gnome org>
Date:   Sat Nov 9 20:12:53 2013 +0100

    gcleanup: A bit of cleanup and reorg
    
     * s/G_CLEANUP_MODULE/G_CLEANUP_SCOPE/
     * Change args for g_type_cleanup_push()
     * Explicit about what G_CLEANUP_DEFINE is defining

 gio/Makefile.am                            |    2 +-
 gio/gio.c                                  |    2 +-
 gio/tests/Makefile.am                      |    2 +-
 gio/tests/converter-stream.c               |    2 ++
 gio/tests/dbus-appinfo.c                   |    2 ++
 gio/tests/filter-streams.c                 |    4 ++--
 gio/tests/gapplication-example-cmdline2.c  |    2 ++
 gio/tests/gapplication-example-dbushooks.c |    2 ++
 gio/tests/gapplication.c                   |    2 ++
 gio/tests/gdbus-bz627724.c                 |    1 +
 gio/tests/gdbus-close-pending.c            |    2 ++
 gio/tests/gdbus-connection-flush.c         |    2 ++
 gio/tests/gdbus-daemon.c                   |    2 ++
 gio/tests/gdbus-example-export.c           |    2 ++
 gio/tests/gdbus-example-proxy-subclass.c   |    2 ++
 gio/tests/gdbus-non-socket.c               |    2 ++
 gio/tests/gdbus-peer-object-manager.c      |    2 ++
 gio/tests/gdbus-test-codegen.c             |    4 ++++
 gio/tests/gmenumodel.c                     |    2 ++
 gio/tests/gsettings.c                      |    2 ++
 gio/tests/io-stream.c                      |    2 ++
 gio/tests/proxy-test.c                     |    2 ++
 gio/tests/sleepy-stream.c                  |    2 ++
 gio/tests/socket-client.c                  |    2 ++
 gio/tests/tls-certificate.c                |    2 ++
 gio/tests/tls-interaction.c                |    3 +++
 glib/Makefile.am                           |    2 +-
 glib/gcleanup.c                            |    2 +-
 glib/gcleanup.h                            |   16 ++++++++--------
 glib/gthread.h                             |    7 ++++++-
 glib/tests/private.c                       |    4 ++--
 gmodule/Makefile.am                        |    2 +-
 gmodule/gmodule.c                          |    2 +-
 gobject/Makefile.am                        |    2 +-
 gobject/gbinding.c                         |    2 +-
 gobject/gboxed.c                           |    4 ++--
 gobject/genums.c                           |    4 ++--
 gobject/gobject.c                          |    4 ++--
 gobject/gparam.c                           |    2 +-
 gobject/gparamspecs.c                      |    2 +-
 gobject/gsourceclosure.c                   |    2 +-
 gobject/gtype.c                            |    8 ++++----
 gobject/gtype.h                            |   24 ++++++++++++++++--------
 gobject/gtypemodule.c                      |    2 +-
 gobject/gtypemodule.h                      |    2 +-
 gobject/gtypeplugin.c                      |    2 +-
 gobject/gvaluetypes.c                      |   28 ++++++++++++++--------------
 gobject/tests/Makefile.am                  |    2 +-
 gobject/tests/binding.c                    |    2 +-
 gobject/tests/boxed.c                      |    2 +-
 gobject/tests/dynamictests.c               |    4 ++--
 gobject/tests/enums.c                      |    6 +++---
 gobject/tests/object.c                     |    2 +-
 gobject/tests/param.c                      |    3 +--
 gobject/tests/private.c                    |    2 +-
 gobject/tests/properties.c                 |    2 +-
 gobject/tests/reference.c                  |    2 +-
 gobject/tests/signals.c                    |   10 +++++-----
 gobject/tests/testcommon.h                 |    6 +++---
 gobject/tests/threadtests.c                |    2 +-
 gobject/tests/type.c                       |    4 ++--
 tests/gobject/Makefile.am                  |    2 +-
 tests/gobject/accumulator.c                |    2 +-
 tests/gobject/deftype.c                    |    2 ++
 tests/gobject/override.c                   |    2 +-
 tests/gobject/performance.c                |    3 +++
 tests/gobject/references.c                 |    2 ++
 tests/gobject/signals.c                    |    2 +-
 tests/gobject/singleton.c                  |    3 +++
 tests/gobject/testcommon.h                 |    4 ++--
 tests/gobject/testmodule.c                 |    2 +-
 71 files changed, 160 insertions(+), 92 deletions(-)
---
diff --git a/gio/Makefile.am b/gio/Makefile.am
index 77801fd..edf90a8 100644
--- a/gio/Makefile.am
+++ b/gio/Makefile.am
@@ -23,7 +23,7 @@ uninstall-ms-lib:
 
 AM_CPPFLAGS = \
        -DG_LOG_DOMAIN=\"GLib-GIO\"                     \
-       -DG_CLEANUP_MODULE=gio                          \
+       -DG_CLEANUP_SCOPE=gio                           \
        $(gmodule_INCLUDES)                             \
        $(GLIB_DEBUG_FLAGS)                             \
        -DGIO_COMPILATION                               \
diff --git a/gio/gio.c b/gio/gio.c
index fbab6bb..c30b4b0 100644
--- a/gio/gio.c
+++ b/gio/gio.c
@@ -25,4 +25,4 @@
 #include <glib/glib.h>
 
 /* The cleanup list for libgio */
-G_CLEANUP_DEFINE
+G_CLEANUP_DEFINE (gio);
diff --git a/gio/tests/Makefile.am b/gio/tests/Makefile.am
index 758ac17..a0635ed 100644
--- a/gio/tests/Makefile.am
+++ b/gio/tests/Makefile.am
@@ -11,7 +11,7 @@ LDADD = \
        $(top_builddir)/gmodule/libgmodule-2.0.la       \
        $(top_builddir)/gio/libgio-2.0.la
 AM_CPPFLAGS = $(gio_INCLUDES) $(GLIB_DEBUG_FLAGS) -I$(top_builddir)/gio -I$(top_srcdir)/gio
-DEFS = -DG_LOG_DOMAIN=\"GLib-GIO\" -DTEST_SERVICES=\""$(abs_top_builddir)/gio/tests/services"\"
+DEFS = -DG_LOG_DOMAIN=\"GLib-GIO\" -DTEST_SERVICES=\""$(abs_top_builddir)/gio/tests/services"\" 
-DG_CLEANUP_SCOPE=test
 AM_CFLAGS = $(GLIB_WARN_CFLAGS)
 
 # -----------------------------------------------------------------------------
diff --git a/gio/tests/converter-stream.c b/gio/tests/converter-stream.c
index 2da0513..9a6e31a 100644
--- a/gio/tests/converter-stream.c
+++ b/gio/tests/converter-stream.c
@@ -1163,6 +1163,8 @@ test_truncation (gconstpointer data)
   g_free (data0);
 }
 
+G_CLEANUP_DEFINE (test);
+
 int
 main (int   argc,
       char *argv[])
diff --git a/gio/tests/dbus-appinfo.c b/gio/tests/dbus-appinfo.c
index 7698429..b47133c 100644
--- a/gio/tests/dbus-appinfo.c
+++ b/gio/tests/dbus-appinfo.c
@@ -275,6 +275,8 @@ test_dbus_appinfo (void)
   g_object_unref (app);
 }
 
+G_CLEANUP_DEFINE (test);
+
 int
 main (int argc, char **argv)
 {
diff --git a/gio/tests/filter-streams.c b/gio/tests/filter-streams.c
index 18a3964..d5ace6e 100644
--- a/gio/tests/filter-streams.c
+++ b/gio/tests/filter-streams.c
@@ -10,7 +10,7 @@
  *
  * Author: Ryan Lortie <desrt desrt ca>
  */
-#define G_CLEANUP_MODULE test
+#define G_CLEANUP_SCOPE test
 
 #include <string.h>
 #include <glib/glib.h>
@@ -378,7 +378,7 @@ test_output_async (void)
   g_main_loop_unref (loop);
 }
 
-G_CLEANUP_DEFINE
+G_CLEANUP_DEFINE (test);
 
 int
 main (int argc, char **argv)
diff --git a/gio/tests/gapplication-example-cmdline2.c b/gio/tests/gapplication-example-cmdline2.c
index dc25e95..7bef5de 100644
--- a/gio/tests/gapplication-example-cmdline2.c
+++ b/gio/tests/gapplication-example-cmdline2.c
@@ -88,6 +88,8 @@ test_application_new (const gchar       *application_id,
                        NULL);
 }
 
+G_CLEANUP_DEFINE (test);
+
 int
 main (int argc, char **argv)
 {
diff --git a/gio/tests/gapplication-example-dbushooks.c b/gio/tests/gapplication-example-dbushooks.c
index e93cf08..e0085bd 100644
--- a/gio/tests/gapplication-example-dbushooks.c
+++ b/gio/tests/gapplication-example-dbushooks.c
@@ -79,6 +79,8 @@ test_application_new (const gchar       *application_id,
                        NULL);
 }
 
+G_CLEANUP_DEFINE (test);
+
 int
 main (int argc, char **argv)
 {
diff --git a/gio/tests/gapplication.c b/gio/tests/gapplication.c
index c9610c0..dcb09ef 100644
--- a/gio/tests/gapplication.c
+++ b/gio/tests/gapplication.c
@@ -512,6 +512,8 @@ test_local_command_line (void)
   g_free (binpath);
 }
 
+G_CLEANUP_DEFINE (test);
+
 int
 main (int argc, char **argv)
 {
diff --git a/gio/tests/gdbus-bz627724.c b/gio/tests/gdbus-bz627724.c
index d3d8cac..b943148 100644
--- a/gio/tests/gdbus-bz627724.c
+++ b/gio/tests/gdbus-bz627724.c
@@ -75,6 +75,7 @@ test_bz627724 (void)
   session_bus_down ();
 }
 
+G_CLEANUP_DEFINE (test);
 
 int
 main (int   argc,
diff --git a/gio/tests/gdbus-close-pending.c b/gio/tests/gdbus-close-pending.c
index a707e08..ac0bb54 100644
--- a/gio/tests/gdbus-close-pending.c
+++ b/gio/tests/gdbus-close-pending.c
@@ -380,6 +380,8 @@ test_many_times (Fixture       *f,
     test_once (f, context);
 }
 
+G_CLEANUP_DEFINE (test);
+
 int
 main (int   argc,
       char *argv[])
diff --git a/gio/tests/gdbus-connection-flush.c b/gio/tests/gdbus-connection-flush.c
index b331e4b..26a8a64 100644
--- a/gio/tests/gdbus-connection-flush.c
+++ b/gio/tests/gdbus-connection-flush.c
@@ -364,6 +364,8 @@ teardown (Fixture       *f,
 
 /* ---------------------------------------------------------------------------------------------------- */
 
+G_CLEANUP_DEFINE (test);
+
 int
 main (int   argc,
       char *argv[])
diff --git a/gio/tests/gdbus-daemon.c b/gio/tests/gdbus-daemon.c
index a332699..1b8f742 100644
--- a/gio/tests/gdbus-daemon.c
+++ b/gio/tests/gdbus-daemon.c
@@ -3,6 +3,8 @@
 #include "gdbusdaemon.h"
 #include <glib/gi18n.h>
 
+G_CLEANUP_DEFINE (test);
+
 int
 main (int argc, char *argv[])
 {
diff --git a/gio/tests/gdbus-example-export.c b/gio/tests/gdbus-example-export.c
index 341ce60..38de95b 100644
--- a/gio/tests/gdbus-example-export.c
+++ b/gio/tests/gdbus-example-export.c
@@ -296,6 +296,8 @@ on_name_lost (GDBusConnection *connection,
   exit (1);
 }
 
+G_CLEANUP_DEFINE (test);
+
 int
 main (int argc, char *argv[])
 {
diff --git a/gio/tests/gdbus-example-proxy-subclass.c b/gio/tests/gdbus-example-proxy-subclass.c
index fb1a528..de75479 100644
--- a/gio/tests/gdbus-example-proxy-subclass.c
+++ b/gio/tests/gdbus-example-proxy-subclass.c
@@ -351,6 +351,8 @@ accounts_user_frobnicate_finish (AccountsUser        *user,
 
 /* ---------------------------------------------------------------------------------------------------- */
 
+G_CLEANUP_DEFINE (test);
+
 gint
 main (gint argc, gchar *argv[])
 {
diff --git a/gio/tests/gdbus-non-socket.c b/gio/tests/gdbus-non-socket.c
index b28d9bd..b571e8a 100644
--- a/gio/tests/gdbus-non-socket.c
+++ b/gio/tests/gdbus-non-socket.c
@@ -288,6 +288,8 @@ test_non_socket (void)
 
 /* ---------------------------------------------------------------------------------------------------- */
 
+G_CLEANUP_DEFINE (test);
+
 int
 main (int   argc,
       char *argv[])
diff --git a/gio/tests/gdbus-peer-object-manager.c b/gio/tests/gdbus-peer-object-manager.c
index 7a19c71..15e031d 100644
--- a/gio/tests/gdbus-peer-object-manager.c
+++ b/gio/tests/gdbus-peer-object-manager.c
@@ -353,6 +353,8 @@ test_object_manager (Test *test,
   g_object_unref (client);
 }
 
+G_CLEANUP_DEFINE (test);
+
 int
 main (int   argc,
       char *argv[])
diff --git a/gio/tests/gdbus-test-codegen.c b/gio/tests/gdbus-test-codegen.c
index d4d9c36..97ab12c 100644
--- a/gio/tests/gdbus-test-codegen.c
+++ b/gio/tests/gdbus-test-codegen.c
@@ -2348,6 +2348,10 @@ test_property_naming (void)
 
 /* ---------------------------------------------------------------------------------------------------- */
 
+#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_40
+G_CLEANUP_DEFINE (test);
+#endif
+
 int
 main (int   argc,
       char *argv[])
diff --git a/gio/tests/gmenumodel.c b/gio/tests/gmenumodel.c
index 75c70cd..a1d5a44 100644
--- a/gio/tests/gmenumodel.c
+++ b/gio/tests/gmenumodel.c
@@ -1153,6 +1153,8 @@ test_menuitem (void)
   g_object_unref (submenu);
 }
 
+G_CLEANUP_DEFINE (test);
+
 /* Epilogue {{{1 */
 int
 main (int argc, char **argv)
diff --git a/gio/tests/gsettings.c b/gio/tests/gsettings.c
index ab54ad4..20eb6dc 100644
--- a/gio/tests/gsettings.c
+++ b/gio/tests/gsettings.c
@@ -2383,6 +2383,8 @@ test_extended_schema (void)
   g_object_unref (settings);
 }
 
+G_CLEANUP_DEFINE (test);
+
 int
 main (int argc, char *argv[])
 {
diff --git a/gio/tests/io-stream.c b/gio/tests/io-stream.c
index 59b1c26..bdd84a4 100644
--- a/gio/tests/io-stream.c
+++ b/gio/tests/io-stream.c
@@ -173,6 +173,8 @@ test_copy_chunks (void)
   g_main_loop_unref (data.main_loop);
 }
 
+G_CLEANUP_DEFINE (test);
+
 int
 main (int   argc,
       char *argv[])
diff --git a/gio/tests/proxy-test.c b/gio/tests/proxy-test.c
index ad2fcdf..e111f5a 100644
--- a/gio/tests/proxy-test.c
+++ b/gio/tests/proxy-test.c
@@ -1316,6 +1316,8 @@ test_proxy_enumerator_ports (void)
   teardown_test (NULL, NULL);
 }
 
+G_CLEANUP_DEFINE (test);
+
 int
 main (int   argc,
       char *argv[])
diff --git a/gio/tests/sleepy-stream.c b/gio/tests/sleepy-stream.c
index 4d3ca1d..4e02927 100644
--- a/gio/tests/sleepy-stream.c
+++ b/gio/tests/sleepy-stream.c
@@ -279,6 +279,8 @@ asynch (void)
   g_object_unref (data);
 }
 
+G_CLEANUP_DEFINE (test);
+
 int
 main (int argc, char **argv)
 {
diff --git a/gio/tests/socket-client.c b/gio/tests/socket-client.c
index 62dda89..2535b15 100644
--- a/gio/tests/socket-client.c
+++ b/gio/tests/socket-client.c
@@ -245,6 +245,8 @@ make_connection (const char       *argument,
   return TRUE;
 }
 
+G_CLEANUP_DEFINE (test);
+
 int
 main (int argc,
       char *argv[])
diff --git a/gio/tests/tls-certificate.c b/gio/tests/tls-certificate.c
index 07303ca..36885e0 100644
--- a/gio/tests/tls-certificate.c
+++ b/gio/tests/tls-certificate.c
@@ -265,6 +265,8 @@ list_from_file (const Reference *ref)
   g_assert_cmpint (g_list_length (list), ==, 0);
 }
 
+G_CLEANUP_DEFINE (test);
+
 int
 main (int   argc,
       char *argv[])
diff --git a/gio/tests/tls-interaction.c b/gio/tests/tls-interaction.c
index ce2aa88..38bb80a 100644
--- a/gio/tests/tls-interaction.c
+++ b/gio/tests/tls-interaction.c
@@ -1006,6 +1006,9 @@ test_with_all_request_certificate (const gchar *name,
   test_with_async_request_certificate (name, setup, func, teardown);
   test_with_sync_request_certificate (name, setup, func, teardown);
 }
+
+G_CLEANUP_DEFINE (test);
+
 int
 main (int   argc,
       char *argv[])
diff --git a/glib/Makefile.am b/glib/Makefile.am
index 05360d8..3104916 100644
--- a/glib/Makefile.am
+++ b/glib/Makefile.am
@@ -38,7 +38,7 @@ AM_CPPFLAGS =                                 \
        $(glib_INCLUDES)                \
        $(pcre_inc)                     \
        -DG_LOG_DOMAIN=\"GLib\"         \
-       -DG_CLEANUP_MODULE=glib         \
+       -DG_CLEANUP_SCOPE=glib          \
        $(GLIB_DEBUG_FLAGS)             \
        -DGLIB_COMPILATION              \
        -DPCRE_STATIC
diff --git a/glib/gcleanup.c b/glib/gcleanup.c
index 27081c4..240ad86 100644
--- a/glib/gcleanup.c
+++ b/glib/gcleanup.c
@@ -40,7 +40,7 @@
 #include <stdio.h>
 
 /* As good a place as any to put this... */
-G_CLEANUP_DEFINE
+G_CLEANUP_DEFINE (glib);
 
 typedef struct _GCleanupNode GCleanupNode;
 struct _GCleanupNode
diff --git a/glib/gcleanup.h b/glib/gcleanup.h
index 8337be1..f0e9df6 100644
--- a/glib/gcleanup.h
+++ b/glib/gcleanup.h
@@ -61,17 +61,17 @@ void                    g_cleanup_list_remove                           (GCleanu
 GLIB_AVAILABLE_IN_2_40
 void                    g_cleanup_list_clear                            (GCleanupList *list);
 
-#if defined(G_HAS_CONSTRUCTORS) && !defined(G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA) && defined(G_CLEANUP_MODULE)
+#if defined(G_HAS_CONSTRUCTORS) && !defined(G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA) && defined(G_CLEANUP_SCOPE)
 
-extern GCleanupList G_PASTE(G_CLEANUP_MODULE, _cleanup_list);
+extern GCleanupList G_PASTE(G_CLEANUP_SCOPE, _cleanup_list);
 
 #define G_CLEANUP_LOCAL                                                         \
-  (&G_PASTE (G_CLEANUP_MODULE, _cleanup_list))
-#define G_CLEANUP_DEFINE \
-  GCleanupList G_PASTE(G_CLEANUP_MODULE, _cleanup_list) =                       \
+  (&G_PASTE (G_CLEANUP_SCOPE, _cleanup_list))
+#define G_CLEANUP_DEFINE(scope)                                                 \
+  GCleanupList G_PASTE(scope, _cleanup_list) =                                  \
     { 0, { 0, }, };                                                             \
-  G_DEFINE_DESTRUCTOR (G_PASTE (G_CLEANUP_MODULE, _cleanup_perform))            \
-  static void G_PASTE (G_CLEANUP_MODULE, _cleanup_perform) (void) {             \
+  G_DEFINE_DESTRUCTOR (G_PASTE (scope, _cleanup_perform))                       \
+  static void G_PASTE (scope, _cleanup_perform) (void) {                        \
     g_cleanup_list_clear (G_CLEANUP_LOCAL);                                     \
   }
 #define G_CLEANUP(data, func) \
@@ -102,7 +102,7 @@ extern GCleanupList G_PASTE(G_CLEANUP_MODULE, _cleanup_list);
 #else
 
 #define G_CLEANUP_LOCAL    NULL
-#define G_CLEANUP_DEFINE
+#define G_CLEANUP_DEFINE(scope)
 #define G_CLEANUP(data, func) \
   G_STMT_START {                                                        \
     if (0) (func) (data);                                               \
diff --git a/glib/gthread.h b/glib/gthread.h
index 53548d3..fb4c49b 100644
--- a/glib/gthread.h
+++ b/glib/gthread.h
@@ -85,13 +85,18 @@ struct _GRecMutex
   guint i[2];
 };
 
+#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_40
 #define G_PRIVATE_INIT(notify) { NULL, (notify), G_CLEANUP_LOCAL, { NULL } }
+#else
+#define G_PRIVATE_INIT(notify) { NULL, (notify), NULL, { NULL } }
+#endif
+
 struct _GPrivate
 {
   /*< private >*/
   gpointer       p;
   GDestroyNotify notify;
-  GCleanupList  *cleanup;
+  gpointer       cleanup;
   gpointer future[1];
 };
 
diff --git a/glib/tests/private.c b/glib/tests/private.c
index 803d2dd..d416eac 100644
--- a/glib/tests/private.c
+++ b/glib/tests/private.c
@@ -22,7 +22,7 @@
 
 /* We are testing some deprecated APIs here */
 #define GLIB_DISABLE_DEPRECATION_WARNINGS
-#define G_CLEANUP_MODULE tests
+#define G_CLEANUP_SCOPE test
 
 #include <glib.h>
 
@@ -371,7 +371,7 @@ test_static_private5 (void)
     g_thread_join (thread[i]);
 }
 
-G_CLEANUP_DEFINE
+G_CLEANUP_DEFINE (test);
 
 int
 main (int argc, char *argv[])
diff --git a/gmodule/Makefile.am b/gmodule/Makefile.am
index 9727aa9..090ffd6 100644
--- a/gmodule/Makefile.am
+++ b/gmodule/Makefile.am
@@ -4,7 +4,7 @@ include $(top_srcdir)/glib.mk
 AM_CPPFLAGS =                          \
        $(glib_INCLUDES)                \
        -DG_LOG_DOMAIN=\"GModule\"      \
-       -DG_CLEANUP_MODULE=gmodule      \
+       -DG_CLEANUP_SCOPE=gmodule       \
        @GLIB_DEBUG_FLAGS@              \
        -DG_DISABLE_DEPRECATED
 
diff --git a/gmodule/gmodule.c b/gmodule/gmodule.c
index 13cf4c7..8d3e7ee 100644
--- a/gmodule/gmodule.c
+++ b/gmodule/gmodule.c
@@ -48,7 +48,7 @@
 #include "gmoduleconf.h"
 #include "gstdio.h"
 
-G_CLEANUP_DEFINE
+G_CLEANUP_DEFINE (gmodule);
 
 /**
  * SECTION:modules
diff --git a/gobject/Makefile.am b/gobject/Makefile.am
index d9bece1..46e99fb 100644
--- a/gobject/Makefile.am
+++ b/gobject/Makefile.am
@@ -8,7 +8,7 @@ SUBDIRS = . tests
 
 AM_CPPFLAGS =                                  \
        -DG_LOG_DOMAIN=\"GLib-GObject\"         \
-       -DG_CLEANUP_MODULE=gobject              \
+       -DG_CLEANUP_SCOPE=gobject               \
        $(glib_INCLUDES)                        \
        $(GLIB_DEBUG_FLAGS)                     \
        -DGOBJECT_COMPILATION
diff --git a/gobject/gbinding.c b/gobject/gbinding.c
index 4a7ccea..6f8ac34 100644
--- a/gobject/gbinding.c
+++ b/gobject/gbinding.c
@@ -135,7 +135,7 @@ g_binding_flags_get_type (void)
       };
       GType g_define_type_id =
         g_flags_register_static (g_intern_static_string ("GBindingFlags"), values);
-      g_type_cleanup_push (G_CLEANUP_LOCAL, g_define_type_id);
+      g_type_cleanup_push (g_define_type_id, G_CLEANUP_LOCAL);
       g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
     }
 
diff --git a/gobject/gboxed.c b/gobject/gboxed.c
index e31a71e..05c6a1e 100644
--- a/gobject/gboxed.c
+++ b/gobject/gboxed.c
@@ -108,7 +108,7 @@ _g_boxed_type_init (void)
    */
   type = g_type_register_fundamental (G_TYPE_BOXED, g_intern_static_string ("GBoxed"), &info, &finfo,
                                      G_TYPE_FLAG_ABSTRACT | G_TYPE_FLAG_VALUE_ABSTRACT);
-  g_type_cleanup_push (G_CLEANUP_LOCAL, type);
+  g_type_cleanup_push (type, G_CLEANUP_LOCAL);
   g_assert (type == G_TYPE_BOXED);
 }
 
@@ -178,7 +178,7 @@ g_strv_get_type (void)
         g_boxed_type_register_static (g_intern_static_string ("GStrv"),
                                       (GBoxedCopyFunc) g_strdupv,
                                       (GBoxedFreeFunc) g_strfreev);
-      g_type_cleanup_push (G_CLEANUP_LOCAL, g_define_type_id);
+      g_type_cleanup_push (g_define_type_id, G_CLEANUP_LOCAL);
       g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
     }
 
diff --git a/gobject/genums.c b/gobject/genums.c
index a3e2814..357f8e2 100644
--- a/gobject/genums.c
+++ b/gobject/genums.c
@@ -113,7 +113,7 @@ _g_enum_types_init (void)
   info.class_size = sizeof (GEnumClass);
   type = g_type_register_fundamental (G_TYPE_ENUM, g_intern_static_string ("GEnum"), &info, &finfo,
                                      G_TYPE_FLAG_ABSTRACT | G_TYPE_FLAG_VALUE_ABSTRACT);
-  g_type_cleanup_push (G_CLEANUP_LOCAL, type);
+  g_type_cleanup_push (type, G_CLEANUP_LOCAL);
   g_assert (type == G_TYPE_ENUM);
   
   /* G_TYPE_FLAGS
@@ -121,7 +121,7 @@ _g_enum_types_init (void)
   info.class_size = sizeof (GFlagsClass);
   type = g_type_register_fundamental (G_TYPE_FLAGS, g_intern_static_string ("GFlags"), &info, &finfo,
                                      G_TYPE_FLAG_ABSTRACT | G_TYPE_FLAG_VALUE_ABSTRACT);
-  g_type_cleanup_push (G_CLEANUP_LOCAL, type);
+  g_type_cleanup_push (type, G_CLEANUP_LOCAL);
   g_assert (type == G_TYPE_FLAGS);
 }
 
diff --git a/gobject/gobject.c b/gobject/gobject.c
index fb03838..c51fb51 100644
--- a/gobject/gobject.c
+++ b/gobject/gobject.c
@@ -100,7 +100,7 @@
  * ]|
  */
 
-G_CLEANUP_DEFINE
+G_CLEANUP_DEFINE (gobject);
 
 /* --- macros --- */
 #define PARAM_SPEC_PARAM_ID(pspec)             ((pspec)->param_id)
@@ -393,7 +393,7 @@ _g_object_type_init (void)
    */
   info.value_table = &value_table;
   type = g_type_register_fundamental (G_TYPE_OBJECT, g_intern_static_string ("GObject"), &info, &finfo, 0);
-  g_type_cleanup_push (G_CLEANUP_LOCAL, type);
+  g_type_cleanup_push (type, G_CLEANUP_LOCAL);
   g_assert (type == G_TYPE_OBJECT);
   g_value_register_transform_func (G_TYPE_OBJECT, G_TYPE_OBJECT, g_value_object_transform_value);
   
diff --git a/gobject/gparam.c b/gobject/gparam.c
index a8a1500..066d6b1 100644
--- a/gobject/gparam.c
+++ b/gobject/gparam.c
@@ -137,7 +137,7 @@ _g_param_type_init (void)
    */
   type = g_type_register_fundamental (G_TYPE_PARAM, g_intern_static_string ("GParam"), &param_spec_info, 
&finfo, G_TYPE_FLAG_ABSTRACT);
   g_assert (type == G_TYPE_PARAM);
-  g_type_cleanup_push (G_CLEANUP_LOCAL, type);
+  g_type_cleanup_push (type, G_CLEANUP_LOCAL);
   g_param_private_offset = g_type_add_instance_private (type, sizeof (GParamSpecPrivate));
   g_value_register_transform_func (G_TYPE_PARAM, G_TYPE_PARAM, value_param_transform_value);
 }
diff --git a/gobject/gparamspecs.c b/gobject/gparamspecs.c
index c50af69..ce84cad 100644
--- a/gobject/gparamspecs.c
+++ b/gobject/gparamspecs.c
@@ -1593,7 +1593,7 @@ _g_param_spec_types_init (void)
   g_assert (spec_types == spec_types_bound);
 
   for (i = 0; i < G_N_ELEMENTS (types); i++)
-    g_type_cleanup_push (G_CLEANUP_LOCAL, g_param_spec_types[i]);
+    g_type_cleanup_push (g_param_spec_types[i], G_CLEANUP_LOCAL);
 }
 
 /* --- GParamSpec initialization --- */
diff --git a/gobject/gsourceclosure.c b/gobject/gsourceclosure.c
index f86465a..e1a7056 100644
--- a/gobject/gsourceclosure.c
+++ b/gobject/gsourceclosure.c
@@ -47,7 +47,7 @@ g_io_condition_get_type (void)
        { 0, NULL, NULL }
       };
       etype = g_flags_register_static ("GIOCondition", values);
-      g_type_cleanup_push (G_CLEANUP_LOCAL, etype);
+      g_type_cleanup_push (etype, G_CLEANUP_LOCAL);
     }
   return etype;
 }
diff --git a/gobject/gtype.c b/gobject/gtype.c
index 653e4be..e0648e8 100644
--- a/gobject/gtype.c
+++ b/gobject/gtype.c
@@ -4380,7 +4380,7 @@ gobject_init_ctor (void)
    */
   node = type_node_fundamental_new_W (G_TYPE_NONE, g_intern_static_string ("void"), 0);
   type = NODE_TYPE (node);
-  g_type_cleanup_push (G_CLEANUP_LOCAL, type);
+  g_type_cleanup_push (type, G_CLEANUP_LOCAL);
   g_assert (type == G_TYPE_NONE);
   
   /* interface fundamental type G_TYPE_INTERFACE (!classed)
@@ -4389,7 +4389,7 @@ gobject_init_ctor (void)
   node = type_node_fundamental_new_W (G_TYPE_INTERFACE, g_intern_static_string ("GInterface"), 
G_TYPE_FLAG_DERIVABLE);
   type = NODE_TYPE (node);
   type_data_make_W (node, &info, NULL);
-  g_type_cleanup_push (G_CLEANUP_LOCAL, type);
+  g_type_cleanup_push (type, G_CLEANUP_LOCAL);
   g_assert (type == G_TYPE_INTERFACE);
   
   G_WRITE_UNLOCK (&type_rw_lock);
@@ -5061,8 +5061,8 @@ type_cleanup (void)
 }
 
 void
-g_type_cleanup_push (GCleanupList *cleanup,
-                     GType type)
+g_type_cleanup_push (GType type,
+                     GCleanupList *cleanup)
 {
   gint phase;
 
diff --git a/gobject/gtype.h b/gobject/gtype.h
index b5c5cd8..74acf9f 100644
--- a/gobject/gtype.h
+++ b/gobject/gtype.h
@@ -733,8 +733,8 @@ GLIB_AVAILABLE_IN_ALL
 void                 g_type_query                   (GType            type,
                                                      GTypeQuery      *query);
 GLIB_AVAILABLE_IN_2_40
-void                  g_type_cleanup_push            (GCleanupList    *cleanup,
-                                                      GType            type);
+void                  g_type_cleanup_push            (GType            type,
+                                                      GCleanupList    *cleanup);
 
 /* --- type registration --- */
 /**
@@ -1454,7 +1454,7 @@ guint     g_type_get_type_registration_serial (void);
  *                                        sizeof (GtkGadget),
  *                                        (GInstanceInitFunc) gtk_gadget_init,
  *                                        0);
- *       g_type_cleanup_push (G_CLEANUP_LOCAL, g_define_type_id); \
+ *       g_type_cleanup_push (g_define_type_id, G_CLEANUP_LOCAL); \
  *       {
  *         const GInterfaceInfo g_implement_interface_info = {
  *           (GInterfaceInitFunc) gtk_gadget_gizmo_init
@@ -1673,6 +1673,14 @@ static void     type_name##_class_intern_init (gpointer klass) \
 }
 #endif /* GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 */
 
+/* Cleanup the type in the module within which it was defined */
+#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_40
+#define _G_DEFINE_TYPE_CLEANUP()  g_type_cleanup_push (g_define_type_id, G_CLEANUP_LOCAL)
+#else
+#define _G_DEFINE_TYPE_CLEANUP()
+#endif
+
+
 #define _G_DEFINE_TYPE_EXTENDED_BEGIN(TypeName, type_name, TYPE_PARENT, flags) \
 \
 static void     type_name##_init              (TypeName        *self); \
@@ -1702,7 +1710,7 @@ type_name##_get_type (void) \
                                        sizeof (TypeName), \
                                        (GInstanceInitFunc) type_name##_init, \
                                        (GTypeFlags) flags); \
-      g_type_cleanup_push (G_CLEANUP_LOCAL, g_define_type_id); \
+      _G_DEFINE_TYPE_CLEANUP (); \
       { /* custom code follows */
 #define _G_DEFINE_TYPE_EXTENDED_END()  \
         /* following custom code */    \
@@ -1730,7 +1738,7 @@ type_name##_get_type (void) \
                                        0, \
                                        (GInstanceInitFunc)NULL, \
                                        (GTypeFlags) 0); \
-      g_type_cleanup_push (G_CLEANUP_LOCAL, g_define_type_id); \
+      _G_DEFINE_TYPE_CLEANUP (); \
       if (TYPE_PREREQ) \
         g_type_interface_add_prerequisite (g_define_type_id, TYPE_PREREQ); \
       { /* custom code follows */
@@ -1801,7 +1809,7 @@ type_name##_get_type (void) \
         ) = g_boxed_type_register_static; \
       GType g_define_type_id = \
         _g_register_boxed (g_intern_static_string (#TypeName), copy_func, free_func); \
-      g_type_cleanup_push (G_CLEANUP_LOCAL, g_define_type_id); \
+      _G_DEFINE_TYPE_CLEANUP (); \
       { /* custom code follows */
 #else
 #define _G_DEFINE_BOXED_TYPE_BEGIN(TypeName, type_name, copy_func, free_func) \
@@ -1815,7 +1823,7 @@ type_name##_get_type (void) \
         g_boxed_type_register_static (g_intern_static_string (#TypeName), \
                                       (GBoxedCopyFunc) copy_func, \
                                       (GBoxedFreeFunc) free_func); \
-      g_type_cleanup_push (G_CLEANUP_LOCAL, g_define_type_id); \
+      _G_DEFINE_TYPE_CLEANUP (); \
       { /* custom code follows */
 #endif /* __GNUC__ */
 
@@ -1855,7 +1863,7 @@ type_name##_get_type (void) \
     { \
       GType g_define_type_id = \
         g_pointer_type_register_static (g_intern_static_string (#TypeName)); \
-      g_type_cleanup_push (G_CLEANUP_LOCAL, g_define_type_id); \
+      _G_DEFINE_TYPE_CLEANUP (); \
       { /* custom code follows */
 
 /* --- protected (for fundamental type implementations) --- */
diff --git a/gobject/gtypemodule.c b/gobject/gtypemodule.c
index 8101afa..f8c433c 100644
--- a/gobject/gtypemodule.c
+++ b/gobject/gtypemodule.c
@@ -172,7 +172,7 @@ g_type_module_get_type (void)
 
       type_module_type = g_type_register_static (G_TYPE_OBJECT, g_intern_static_string ("GTypeModule"), 
&type_module_info, G_TYPE_FLAG_ABSTRACT);
       g_type_add_interface_static (type_module_type, G_TYPE_TYPE_PLUGIN, &iface_info);
-      g_type_cleanup_push (G_CLEANUP_LOCAL, type_module_type);
+      g_type_cleanup_push (type_module_type, G_CLEANUP_LOCAL);
     }
   
   return type_module_type;
diff --git a/gobject/gtypemodule.h b/gobject/gtypemodule.h
index 451700f..043a8fe 100644
--- a/gobject/gtypemodule.h
+++ b/gobject/gtypemodule.h
@@ -219,7 +219,7 @@ type_name##_register_type (GTypeModule *type_module) \
                                                     (GTypeFlags) flags); \
   g_define_type_id = type_name##_type_id; \
   if (!previous) \
-    g_type_cleanup_push (G_CLEANUP_LOCAL, g_define_type_id); \
+    g_type_cleanup_push (g_define_type_id, G_CLEANUP_LOCAL); \
   { CODE ; } \
 }
 
diff --git a/gobject/gtypeplugin.c b/gobject/gtypeplugin.c
index bc49f9b..89e304e 100644
--- a/gobject/gtypeplugin.c
+++ b/gobject/gtypeplugin.c
@@ -102,7 +102,7 @@ g_type_plugin_get_type (void)
       };
       
       type_plugin_type = g_type_register_static (G_TYPE_INTERFACE, g_intern_static_string ("GTypePlugin"), 
&type_plugin_info, 0);
-      g_type_cleanup_push (G_CLEANUP_LOCAL, type_plugin_type);
+      g_type_cleanup_push (type_plugin_type, G_CLEANUP_LOCAL);
     }
   
   return type_plugin_type;
diff --git a/gobject/gvaluetypes.c b/gobject/gvaluetypes.c
index a802e0e..ba5d942 100644
--- a/gobject/gvaluetypes.c
+++ b/gobject/gvaluetypes.c
@@ -455,10 +455,10 @@ _g_value_types_init (void)
     info.value_table = &value_table;
     type = g_type_register_fundamental (G_TYPE_CHAR, g_intern_static_string ("gchar"), &info, &finfo, 0);
     g_assert (type == G_TYPE_CHAR);
-    g_type_cleanup_push (G_CLEANUP_LOCAL, type);
+    g_type_cleanup_push (type, G_CLEANUP_LOCAL);
     type = g_type_register_fundamental (G_TYPE_UCHAR, g_intern_static_string ("guchar"), &info, &finfo, 0);
     g_assert (type == G_TYPE_UCHAR);
-    g_type_cleanup_push (G_CLEANUP_LOCAL, type);
+    g_type_cleanup_push (type, G_CLEANUP_LOCAL);
   }
 
   /* G_TYPE_BOOLEAN
@@ -477,7 +477,7 @@ _g_value_types_init (void)
     info.value_table = &value_table;
     type = g_type_register_fundamental (G_TYPE_BOOLEAN, g_intern_static_string ("gboolean"), &info, &finfo, 
0);
     g_assert (type == G_TYPE_BOOLEAN);
-    g_type_cleanup_push (G_CLEANUP_LOCAL, type);
+    g_type_cleanup_push (type, G_CLEANUP_LOCAL);
   }
   
   /* G_TYPE_INT / G_TYPE_UINT
@@ -496,10 +496,10 @@ _g_value_types_init (void)
     info.value_table = &value_table;
     type = g_type_register_fundamental (G_TYPE_INT, g_intern_static_string ("gint"), &info, &finfo, 0);
     g_assert (type == G_TYPE_INT);
-    g_type_cleanup_push (G_CLEANUP_LOCAL, type);
+    g_type_cleanup_push (type, G_CLEANUP_LOCAL);
     type = g_type_register_fundamental (G_TYPE_UINT, g_intern_static_string ("guint"), &info, &finfo, 0);
     g_assert (type == G_TYPE_UINT);
-    g_type_cleanup_push (G_CLEANUP_LOCAL, type);
+    g_type_cleanup_push (type, G_CLEANUP_LOCAL);
   }
 
   /* G_TYPE_LONG / G_TYPE_ULONG
@@ -518,10 +518,10 @@ _g_value_types_init (void)
     info.value_table = &value_table;
     type = g_type_register_fundamental (G_TYPE_LONG, g_intern_static_string ("glong"), &info, &finfo, 0);
     g_assert (type == G_TYPE_LONG);
-    g_type_cleanup_push (G_CLEANUP_LOCAL, type);
+    g_type_cleanup_push (type, G_CLEANUP_LOCAL);
     type = g_type_register_fundamental (G_TYPE_ULONG, g_intern_static_string ("gulong"), &info, &finfo, 0);
     g_assert (type == G_TYPE_ULONG);
-    g_type_cleanup_push (G_CLEANUP_LOCAL, type);
+    g_type_cleanup_push (type, G_CLEANUP_LOCAL);
   }
   
   /* G_TYPE_INT64 / G_TYPE_UINT64
@@ -540,10 +540,10 @@ _g_value_types_init (void)
     info.value_table = &value_table;
     type = g_type_register_fundamental (G_TYPE_INT64, g_intern_static_string ("gint64"), &info, &finfo, 0);
     g_assert (type == G_TYPE_INT64);
-    g_type_cleanup_push (G_CLEANUP_LOCAL, type);
+    g_type_cleanup_push (type, G_CLEANUP_LOCAL);
     type = g_type_register_fundamental (G_TYPE_UINT64, g_intern_static_string ("guint64"), &info, &finfo, 0);
     g_assert (type == G_TYPE_UINT64);
-    g_type_cleanup_push (G_CLEANUP_LOCAL, type);
+    g_type_cleanup_push (type, G_CLEANUP_LOCAL);
   }
   
   /* G_TYPE_FLOAT
@@ -562,7 +562,7 @@ _g_value_types_init (void)
     info.value_table = &value_table;
     type = g_type_register_fundamental (G_TYPE_FLOAT, g_intern_static_string ("gfloat"), &info, &finfo, 0);
     g_assert (type == G_TYPE_FLOAT);
-    g_type_cleanup_push (G_CLEANUP_LOCAL, type);
+    g_type_cleanup_push (type, G_CLEANUP_LOCAL);
   }
   
   /* G_TYPE_DOUBLE
@@ -581,7 +581,7 @@ _g_value_types_init (void)
     info.value_table = &value_table;
     type = g_type_register_fundamental (G_TYPE_DOUBLE, g_intern_static_string ("gdouble"), &info, &finfo, 0);
     g_assert (type == G_TYPE_DOUBLE);
-    g_type_cleanup_push (G_CLEANUP_LOCAL, type);
+    g_type_cleanup_push (type, G_CLEANUP_LOCAL);
   }
 
   /* G_TYPE_STRING
@@ -600,7 +600,7 @@ _g_value_types_init (void)
     info.value_table = &value_table;
     type = g_type_register_fundamental (G_TYPE_STRING, g_intern_static_string ("gchararray"), &info, &finfo, 
0);
     g_assert (type == G_TYPE_STRING);
-    g_type_cleanup_push (G_CLEANUP_LOCAL, type);
+    g_type_cleanup_push (type, G_CLEANUP_LOCAL);
   }
 
   /* G_TYPE_POINTER
@@ -619,7 +619,7 @@ _g_value_types_init (void)
     info.value_table = &value_table;
     type = g_type_register_fundamental (G_TYPE_POINTER, g_intern_static_string ("gpointer"), &info, &finfo, 
0);
     g_assert (type == G_TYPE_POINTER);
-    g_type_cleanup_push (G_CLEANUP_LOCAL, type);
+    g_type_cleanup_push (type, G_CLEANUP_LOCAL);
   }
 
   /* G_TYPE_VARIANT
@@ -638,7 +638,7 @@ _g_value_types_init (void)
     info.value_table = &value_table;
     type = g_type_register_fundamental (G_TYPE_VARIANT, g_intern_static_string ("GVariant"), &info, &finfo, 
0);
     g_assert (type == G_TYPE_VARIANT);
-    g_type_cleanup_push (G_CLEANUP_LOCAL, type);
+    g_type_cleanup_push (type, G_CLEANUP_LOCAL);
   }
 }
 
diff --git a/gobject/tests/Makefile.am b/gobject/tests/Makefile.am
index 0176112..7102b29 100644
--- a/gobject/tests/Makefile.am
+++ b/gobject/tests/Makefile.am
@@ -2,7 +2,7 @@ include $(top_srcdir)/glib-tap.mk
 
 LDADD = ../libgobject-2.0.la $(top_builddir)/glib/libglib-2.0.la
 AM_CPPFLAGS = -g $(gobject_INCLUDES) $(GLIB_DEBUG_FLAGS)
-DEFS = -DG_LOG_DOMAIN=\"GLib-GObject\" -DG_CLEANUP_MODULE=tests
+DEFS = -DG_LOG_DOMAIN=\"GLib-GObject\" -DG_CLEANUP_SCOPE=test
 AM_CFLAGS = $(GLIB_WARN_CFLAGS)
 
 # -----------------------------------------------------------------------------
diff --git a/gobject/tests/binding.c b/gobject/tests/binding.c
index f7ce064..4daa565 100644
--- a/gobject/tests/binding.c
+++ b/gobject/tests/binding.c
@@ -612,7 +612,7 @@ binding_unbind (void)
   g_object_unref (target);
 }
 
-G_CLEANUP_DEFINE
+G_CLEANUP_DEFINE (test);
 
 int
 main (int argc, char *argv[])
diff --git a/gobject/tests/boxed.c b/gobject/tests/boxed.c
index 8d11662..d9f4962 100644
--- a/gobject/tests/boxed.c
+++ b/gobject/tests/boxed.c
@@ -615,7 +615,7 @@ test_boxed_checksum (void)
   g_value_unset (&value);
 }
 
-G_CLEANUP_DEFINE
+G_CLEANUP_DEFINE (test);
 
 int
 main (int argc, char *argv[])
diff --git a/gobject/tests/dynamictests.c b/gobject/tests/dynamictests.c
index be51dd0..4892642 100644
--- a/gobject/tests/dynamictests.c
+++ b/gobject/tests/dynamictests.c
@@ -96,7 +96,7 @@ static GType test_module_get_type (void)
        (GInstanceInitFunc)NULL
       };
     object_type = g_type_register_static (G_TYPE_TYPE_MODULE, "TestModule", &object_info, 0);
-    g_type_cleanup_push (G_CLEANUP_LOCAL, object_type);
+    g_type_cleanup_push (object_type, G_CLEANUP_LOCAL);
   }
   return object_type;
 }
@@ -365,7 +365,7 @@ test_dynamic_interface_properties (void)
   g_object_unref (module);
 }
 
-G_CLEANUP_DEFINE
+G_CLEANUP_DEFINE (test);
 
 int
 main (int   argc,
diff --git a/gobject/tests/enums.c b/gobject/tests/enums.c
index 7e52a95..e9b062d 100644
--- a/gobject/tests/enums.c
+++ b/gobject/tests/enums.c
@@ -17,7 +17,7 @@ test_enum_basic (void)
   GValue value = G_VALUE_INIT;
 
   type = g_enum_register_static ("MyEnum", my_enum_values);
-  g_type_cleanup_push (G_CLEANUP_LOCAL, type);
+  g_type_cleanup_push (type, G_CLEANUP_LOCAL);
 
   g_value_init (&value, type);
   g_assert (G_VALUE_HOLDS_ENUM (&value));
@@ -81,7 +81,7 @@ test_flags_basic (void)
   GValue value = G_VALUE_INIT;
 
   type = g_flags_register_static ("MyFlags", my_flag_values);
-  g_type_cleanup_push (G_CLEANUP_LOCAL, type);
+  g_type_cleanup_push (type, G_CLEANUP_LOCAL);
 
   g_value_init (&value, type);
   g_assert (G_VALUE_HOLDS_FLAGS (&value));
@@ -118,7 +118,7 @@ test_flags_basic (void)
   g_type_class_unref (class);
 }
 
-G_CLEANUP_DEFINE
+G_CLEANUP_DEFINE (test);
 
 int
 main (int argc, char *argv[])
diff --git a/gobject/tests/object.c b/gobject/tests/object.c
index 3aa73fe..92e2743 100644
--- a/gobject/tests/object.c
+++ b/gobject/tests/object.c
@@ -137,7 +137,7 @@ test_object_constructor_infanticide (void)
 
 /* --------------------------------- */
 
-G_CLEANUP_DEFINE
+G_CLEANUP_DEFINE (test);
 
 int
 main (int argc, char *argv[])
diff --git a/gobject/tests/param.c b/gobject/tests/param.c
index 6cdbdb9..32fd297 100644
--- a/gobject/tests/param.c
+++ b/gobject/tests/param.c
@@ -1,4 +1,3 @@
-#define G_CLEANUP_MODULE tests
 #define GLIB_DISABLE_DEPRECATION_WARNINGS
 #include <glib-object.h>
 #include <stdlib.h>
@@ -828,7 +827,7 @@ test_param_default (void)
 }
 
 /* For cleaning up types defined in these tests */
-G_CLEANUP_DEFINE
+G_CLEANUP_DEFINE (test);
 
 int
 main (int argc, char *argv[])
diff --git a/gobject/tests/private.c b/gobject/tests/private.c
index 7b15b0b..a06fdc0 100644
--- a/gobject/tests/private.c
+++ b/gobject/tests/private.c
@@ -232,7 +232,7 @@ private_mixed_derived_instance (void)
   g_object_unref (mixed);
 }
 
-G_CLEANUP_DEFINE
+G_CLEANUP_DEFINE (test);
 
 int
 main (int argc,
diff --git a/gobject/tests/properties.c b/gobject/tests/properties.c
index 9021004..e5ae9a2 100644
--- a/gobject/tests/properties.c
+++ b/gobject/tests/properties.c
@@ -260,7 +260,7 @@ properties_construct (void)
   g_object_unref (obj);
 }
 
-G_CLEANUP_DEFINE
+G_CLEANUP_DEFINE (test);
 
 int
 main (int argc, char *argv[])
diff --git a/gobject/tests/reference.c b/gobject/tests/reference.c
index 23d5d8e..836d350 100644
--- a/gobject/tests/reference.c
+++ b/gobject/tests/reference.c
@@ -593,7 +593,7 @@ test_object_qdata2 (void)
   unref_value (v3);
 }
 
-G_CLEANUP_DEFINE
+G_CLEANUP_DEFINE (test);
 
 int
 main (int argc, char **argv)
diff --git a/gobject/tests/signals.c b/gobject/tests/signals.c
index 198331d..2e31442 100644
--- a/gobject/tests/signals.c
+++ b/gobject/tests/signals.c
@@ -32,7 +32,7 @@ test_enum_get_type (void)
       };
       GType g_define_type_id =
         g_enum_register_static (g_intern_static_string ("TestEnum"), values);
-      g_type_cleanup_push (G_CLEANUP_LOCAL, g_define_type_id);
+      g_type_cleanup_push (g_define_type_id, G_CLEANUP_LOCAL);
       g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
     }
 
@@ -53,7 +53,7 @@ test_unsigned_enum_get_type (void)
       };
       GType g_define_type_id =
         g_enum_register_static (g_intern_static_string ("TestUnsignedEnum"), values);
-      g_type_cleanup_push (G_CLEANUP_LOCAL, g_define_type_id);
+      g_type_cleanup_push (g_define_type_id, G_CLEANUP_LOCAL);
       g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
     }
 
@@ -111,9 +111,9 @@ test_class_init (TestClass *klass)
   guint s;
 
   enum_type = g_enum_register_static ("MyEnum", my_enum_values);
-  g_type_cleanup_push (G_CLEANUP_LOCAL, enum_type);
+  g_type_cleanup_push (enum_type, G_CLEANUP_LOCAL);
   flags_type = g_flags_register_static ("MyFlag", my_flag_values);
-  g_type_cleanup_push (G_CLEANUP_LOCAL, flags_type);
+  g_type_cleanup_push (flags_type, G_CLEANUP_LOCAL);
 
   klass->all_types = all_types_handler;
 
@@ -1050,7 +1050,7 @@ test_stop_emission (void)
 
 /* --- */
 
-G_CLEANUP_DEFINE
+G_CLEANUP_DEFINE (test);
 
 int
 main (int argc,
diff --git a/gobject/tests/testcommon.h b/gobject/tests/testcommon.h
index 0be819a..d23bf5d 100644
--- a/gobject/tests/testcommon.h
+++ b/gobject/tests/testcommon.h
@@ -48,7 +48,7 @@ prefix ## _get_type (void)                                    \
       object_type = g_type_register_static (parent_type,       \
                                            # name,             \
                                            &object_info, 0);   \
-      g_type_cleanup_push (G_CLEANUP_LOCAL, object_type);       \
+      g_type_cleanup_push (object_type, G_CLEANUP_LOCAL);       \
       interface_decl                                           \
     }                                                          \
                                                                \
@@ -80,7 +80,7 @@ prefix ## _get_type (void)                                    \
       iface_type = g_type_register_static (G_TYPE_INTERFACE,   \
                                            # name,             \
                                            &iface_info, 0);    \
-      g_type_cleanup_push (G_CLEANUP_LOCAL, iface_type);         \
+      g_type_cleanup_push (iface_type, G_CLEANUP_LOCAL);        \
     }                                                          \
   return iface_type;                                           \
 }
@@ -98,7 +98,7 @@ prefix ## _get_type (void)                                    \
   INTERFACE_FULL(object_type, init_func, iface_type)
 
 /* Get this into each test */
-G_CLEANUP_DEFINE
+G_CLEANUP_DEFINE (test);
 
 G_END_DECLS
 
diff --git a/gobject/tests/threadtests.c b/gobject/tests/threadtests.c
index 95d437b..1e462e1 100644
--- a/gobject/tests/threadtests.c
+++ b/gobject/tests/threadtests.c
@@ -336,7 +336,7 @@ test_threaded_weak_ref (void)
              get_wins, unref_wins);
 }
 
-G_CLEANUP_DEFINE
+G_CLEANUP_DEFINE (test);
 
 int
 main (int   argc,
diff --git a/gobject/tests/type.c b/gobject/tests/type.c
index fec69e5..d90463c 100644
--- a/gobject/tests/type.c
+++ b/gobject/tests/type.c
@@ -8,7 +8,7 @@ test_registration_serial (void)
 
   serial1 = g_type_get_type_registration_serial ();
   type = g_pointer_type_register_static ("my+pointer");
-  g_type_cleanup_push (G_CLEANUP_LOCAL, type);
+  g_type_cleanup_push (type, G_CLEANUP_LOCAL);
   serial2 = g_type_get_type_registration_serial ();
   g_assert (serial1 != serial2);
   serial3 = g_type_get_type_registration_serial ();
@@ -140,7 +140,7 @@ test_next_base (void)
   g_assert (type == G_TYPE_INITIALLY_UNOWNED);
 }
 
-G_CLEANUP_DEFINE
+G_CLEANUP_DEFINE (test);
 
 int
 main (int argc, char *argv[])
diff --git a/tests/gobject/Makefile.am b/tests/gobject/Makefile.am
index 1cfce4b..75d7d23 100644
--- a/tests/gobject/Makefile.am
+++ b/tests/gobject/Makefile.am
@@ -2,7 +2,7 @@ include $(top_srcdir)/glib.mk
 
 LDADD = $(top_builddir)/glib/libglib-2.0.la $(top_builddir)/gobject/libgobject-2.0.la
 AM_CPPFLAGS = $(gmodule_INCLUDES) $(GLIB_DEBUG_FLAGS)
-DEFS = -DGLIB_DISABLE_DEPRECATION_WARNINGS -DG_LOG_DOMAIN=\"GLib\" -DG_CLEANUP_MODULE=test
+DEFS = -DGLIB_DISABLE_DEPRECATION_WARNINGS -DG_LOG_DOMAIN=\"GLib\" -DG_CLEANUP_SCOPE=test
 AM_CFLAGS = -g
 
 # So far, only two gtester-ified cases
diff --git a/tests/gobject/accumulator.c b/tests/gobject/accumulator.c
index 0f1b1d2..21da28f 100644
--- a/tests/gobject/accumulator.c
+++ b/tests/gobject/accumulator.c
@@ -249,7 +249,7 @@ static DEFINE_TYPE(TestObject, test_object,
                   test_object_class_init, NULL, NULL,
                   G_TYPE_OBJECT)
 
-G_CLEANUP_DEFINE
+G_CLEANUP_DEFINE (test);
 
 int
 main (int   argc,
diff --git a/tests/gobject/deftype.c b/tests/gobject/deftype.c
index 232feff..f792511 100644
--- a/tests/gobject/deftype.c
+++ b/tests/gobject/deftype.c
@@ -54,6 +54,8 @@ static void     type_name_class_init        (TypeNameClass *klass)
 {
 }
 
+G_CLEANUP_DEFINE (test);
+
 int
 main (void)
 {
diff --git a/tests/gobject/override.c b/tests/gobject/override.c
index 340c473..497225b 100644
--- a/tests/gobject/override.c
+++ b/tests/gobject/override.c
@@ -397,7 +397,7 @@ test (GType        type,
   g_object_unref (self);
 }
 
-G_CLEANUP_DEFINE
+G_CLEANUP_DEFINE (test);
 
 int
 main (int argc, char **argv)
diff --git a/tests/gobject/performance.c b/tests/gobject/performance.c
index fdc51da..d73e016 100644
--- a/tests/gobject/performance.c
+++ b/tests/gobject/performance.c
@@ -917,6 +917,9 @@ find_test (const char *name)
     }
   return NULL;
 }
+
+G_CLEANUP_DEFINE (test);
+
 int
 main (int   argc,
       char *argv[])
diff --git a/tests/gobject/references.c b/tests/gobject/references.c
index cfedfa9..4a73218 100644
--- a/tests/gobject/references.c
+++ b/tests/gobject/references.c
@@ -160,6 +160,8 @@ toggle_ref3 (gpointer data,
     toggle_ref3_strengthened = TRUE;
 }
 
+G_CLEANUP_DEFINE (test);
+
 int
 main (int   argc,
       char *argv[])
diff --git a/tests/gobject/signals.c b/tests/gobject/signals.c
index 9dc4d56..ed30c07 100644
--- a/tests/gobject/signals.c
+++ b/tests/gobject/signals.c
@@ -108,7 +108,7 @@ static DEFINE_TYPE(TestObject, test_object,
                    test_object_class_init, NULL, NULL,
                    G_TYPE_OBJECT)
 
-G_CLEANUP_DEFINE
+G_CLEANUP_DEFINE (test);
 
 int
 main (int   argc,
diff --git a/tests/gobject/singleton.c b/tests/gobject/singleton.c
index abf1a0b..27a226a 100644
--- a/tests/gobject/singleton.c
+++ b/tests/gobject/singleton.c
@@ -67,6 +67,9 @@ my_singleton_class_init (MySingletonClass *klass)
 }
 
 /* --- test program --- */
+
+G_CLEANUP_DEFINE (test);
+
 int
 main (int   argc,
       char *argv[])
diff --git a/tests/gobject/testcommon.h b/tests/gobject/testcommon.h
index aa645fc..467b0fc 100644
--- a/tests/gobject/testcommon.h
+++ b/tests/gobject/testcommon.h
@@ -48,7 +48,7 @@ prefix ## _get_type (void)                                    \
       object_type = g_type_register_static (parent_type,       \
                                            # name,             \
                                            &object_info, 0);   \
-      g_type_cleanup_push (G_CLEANUP_LOCAL, object_type);       \
+      g_type_cleanup_push (object_type, G_CLEANUP_LOCAL);       \
       interface_decl                                           \
     }                                                          \
                                                                \
@@ -80,7 +80,7 @@ prefix ## _get_type (void)                                    \
       iface_type = g_type_register_static (G_TYPE_INTERFACE,   \
                                            # name,             \
                                            &iface_info, 0);    \
-      g_type_cleanup_push (G_CLEANUP_LOCAL, iface_type);        \
+      g_type_cleanup_push (iface_type, G_CLEANUP_LOCAL);        \
     }                                                          \
   return iface_type;                                           \
 }
diff --git a/tests/gobject/testmodule.c b/tests/gobject/testmodule.c
index 21df603..9c80b58 100644
--- a/tests/gobject/testmodule.c
+++ b/tests/gobject/testmodule.c
@@ -21,7 +21,7 @@
 #include "testmodule.h"
 #include "testcommon.h"
 
-G_CLEANUP_DEFINE
+G_CLEANUP_DEFINE (test);
 
 static gboolean test_module_load   (GTypeModule *module);
 static void     test_module_unload (GTypeModule *module);



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