From ae23caa5374391fea0f6fbd2b45bd13eaa69f7fc Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Fri, 10 Nov 2023 15:06:37 +0100 Subject: [PATCH] binding-pool: Use macros for subclassing boilerplate Part-of: --- clutter/clutter/clutter-autocleanups.h | 1 - clutter/clutter/clutter-binding-pool.c | 23 +++++++---------------- clutter/clutter/clutter-binding-pool.h | 13 ++++++------- 3 files changed, 13 insertions(+), 24 deletions(-) diff --git a/clutter/clutter/clutter-autocleanups.h b/clutter/clutter/clutter-autocleanups.h index 3aaf6db7e..ce7b959dd 100644 --- a/clutter/clutter/clutter-autocleanups.h +++ b/clutter/clutter/clutter-autocleanups.h @@ -33,7 +33,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterActor, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterAlignConstraint, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterBackend, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterBindConstraint, g_object_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterBindingPool, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterBlurEffect, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterBoxLayout, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterBrightnessContrastEffect, g_object_unref) diff --git a/clutter/clutter/clutter-binding-pool.c b/clutter/clutter/clutter-binding-pool.c index 0f46c2ff5..1d2400f75 100644 --- a/clutter/clutter/clutter-binding-pool.c +++ b/clutter/clutter/clutter-binding-pool.c @@ -23,7 +23,7 @@ /** * ClutterBindingPool - * + * * Pool for key bindings * * #ClutterBindingPool is a data structure holding a set of key bindings. @@ -101,16 +101,12 @@ #include "clutter/clutter-marshal.h" #include "clutter/clutter-private.h" -#define CLUTTER_BINDING_POOL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), CLUTTER_TYPE_BINDING_POOL, ClutterBindingPoolClass)) -#define CLUTTER_IS_BINDING_POOL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CLUTTER_TYPE_BINDING_POOL)) -#define CLUTTER_BINDING_POOL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CLUTTER_TYPE_BINDING_POOL, ClutterBindingPoolClass)) - -#define BINDING_MOD_MASK ((CLUTTER_SHIFT_MASK | \ +#define BINDING_MOD_MASK ((CLUTTER_SHIFT_MASK | \ CLUTTER_CONTROL_MASK | \ - CLUTTER_MOD1_MASK | \ - CLUTTER_SUPER_MASK | \ - CLUTTER_HYPER_MASK | \ - CLUTTER_META_MASK) | CLUTTER_RELEASE_MASK) + CLUTTER_MOD1_MASK | \ + CLUTTER_SUPER_MASK | \ + CLUTTER_HYPER_MASK | \ + CLUTTER_META_MASK) | CLUTTER_RELEASE_MASK) typedef struct _ClutterBindingEntry ClutterBindingEntry; @@ -127,11 +123,6 @@ struct _ClutterBindingPool GHashTable *entries_hash; }; -struct _ClutterBindingPoolClass -{ - GObjectClass parent_class; -}; - struct _ClutterBindingEntry { gchar *name; /* interned string, do not free */ @@ -155,7 +146,7 @@ enum static GParamSpec *obj_props[PROP_LAST]; -G_DEFINE_TYPE (ClutterBindingPool, clutter_binding_pool, G_TYPE_OBJECT); +G_DEFINE_FINAL_TYPE (ClutterBindingPool, clutter_binding_pool, G_TYPE_OBJECT); static guint binding_entry_hash (gconstpointer v) diff --git a/clutter/clutter/clutter-binding-pool.h b/clutter/clutter/clutter-binding-pool.h index 181fe7f8a..341ce0b34 100644 --- a/clutter/clutter/clutter-binding-pool.h +++ b/clutter/clutter/clutter-binding-pool.h @@ -34,11 +34,13 @@ G_BEGIN_DECLS #define CLUTTER_TYPE_BINDING_POOL (clutter_binding_pool_get_type ()) -#define CLUTTER_BINDING_POOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_BINDING_POOL, ClutterBindingPool)) -#define CLUTTER_IS_BINDING_POOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_BINDING_POOL)) -typedef struct _ClutterBindingPool ClutterBindingPool; -typedef struct _ClutterBindingPoolClass ClutterBindingPoolClass; +CLUTTER_EXPORT +G_DECLARE_FINAL_TYPE (ClutterBindingPool, + clutter_binding_pool, + CLUTTER, + BINDING_POOL, + GObject) /** * ClutterBindingActionFunc: @@ -61,9 +63,6 @@ typedef gboolean (* ClutterBindingActionFunc) (GObject *gobject, ClutterModifierType modifiers, gpointer user_data); -CLUTTER_EXPORT -GType clutter_binding_pool_get_type (void) G_GNUC_CONST; - CLUTTER_EXPORT ClutterBindingPool * clutter_binding_pool_new (const gchar *name); CLUTTER_EXPORT