[glib/fix-freeze-count-underflow: 4/6] tests: Simplify singleton test code using G_DECLARE_FINAL_TYPE
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/fix-freeze-count-underflow: 4/6] tests: Simplify singleton test code using G_DECLARE_FINAL_TYPE
- Date: Fri, 10 Jun 2022 13:07:01 +0000 (UTC)
commit 2b93488f3652f99d1cbaeb1eba9fd82dc0a0deda
Author: Philip Withnall <pwithnall endlessos org>
Date: Fri Jun 10 13:52:37 2022 +0100
tests: Simplify singleton test code using G_DECLARE_FINAL_TYPE
This doesn’t functionally change the test, just drops some boilerplate.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
gobject/tests/singleton.c | 25 ++++++-------------------
1 file changed, 6 insertions(+), 19 deletions(-)
---
diff --git a/gobject/tests/singleton.c b/gobject/tests/singleton.c
index c5e151dbf4..faebd23dee 100644
--- a/gobject/tests/singleton.c
+++ b/gobject/tests/singleton.c
@@ -18,27 +18,14 @@
#include <glib-object.h>
/* --- MySingleton class --- */
-typedef struct {
- GObject parent_instance;
-} MySingleton;
-typedef struct {
- GObjectClass parent_class;
-} MySingletonClass;
-static GType my_singleton_get_type (void);
-#define MY_TYPE_SINGLETON (my_singleton_get_type ())
-#define MY_SINGLETON(o) \
- (G_TYPE_CHECK_INSTANCE_CAST ((o), MY_TYPE_SINGLETON, MySingleton))
-#define MY_IS_SINGLETON(o) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((o), MY_TYPE_SINGLETON))
-#define MY_SINGLETON_CLASS(c) \
- (G_TYPE_CHECK_CLASS_CAST ((c), MY_TYPE_SINGLETON, MySingletonClass))
-#define MY_IS_SINGLETON_CLASS(c) \
- (G_TYPE_CHECK_CLASS_TYPE ((c), MY_TYPE_SINGLETON))
-#define MY_SINGLETON_GET_CLASS(o) \
- (G_TYPE_INSTANCE_GET_CLASS ((o), MY_TYPE_SINGLETON, MySingletonClass))
+struct _MySingleton {
+ GObject parent_instance;
+};
-G_DEFINE_TYPE (MySingleton, my_singleton, G_TYPE_OBJECT)
+#define MY_TYPE_SINGLETON my_singleton_get_type ()
+G_DECLARE_FINAL_TYPE (MySingleton, my_singleton, MY, SINGLETON, GObject)
+G_DEFINE_FINAL_TYPE (MySingleton, my_singleton, G_TYPE_OBJECT)
static MySingleton *the_one_and_only = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]