]> git.alsa-project.org Git - alsa-gobject.git/commitdiff
timer: user_instance: use an utility macro to declare GObject-derived object
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Mon, 11 Apr 2022 08:42:26 +0000 (17:42 +0900)
committerTakashi Sakamoto <o-takashi@sakamocchi.jp>
Mon, 11 Apr 2022 08:42:26 +0000 (17:42 +0900)
Since gobject v2.44, an utility macro is available to declare
GObject-derived objects.

This commit replaces existent boireplates with it.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
src/timer/user-instance.c
src/timer/user-instance.h

index 98d797139696b5e5e384e82eadecf5d6b5acac47..68b7cec9f568b69341c77111931c22deeccd09f0 100644 (file)
  * the user instance is attached to any timer device or the other instance as
  * slave.
  */
-struct _ALSATimerUserInstancePrivate {
+typedef struct {
     int fd;
     ALSATimerEventDataType event_data_type;
     guint16 proto_ver_triplet[3];
-};
+} ALSATimerUserInstancePrivate;
 G_DEFINE_TYPE_WITH_PRIVATE(ALSATimerUserInstance, alsatimer_user_instance, G_TYPE_OBJECT)
 
 /**
index a2694d352aedc60fff12c4a9d64d45cc305f3fed..85023264d70b3eaf9cff633fa88f71de37890c4b 100644 (file)
@@ -8,40 +8,13 @@ G_BEGIN_DECLS
 
 #define ALSATIMER_TYPE_USER_INSTANCE    (alsatimer_user_instance_get_type())
 
-#define ALSATIMER_USER_INSTANCE(obj)                            \
-    (G_TYPE_CHECK_INSTANCE_CAST((obj),                          \
-                                ALSATIMER_TYPE_USER_INSTANCE,   \
-                                ALSATimerUserInstance))
-#define ALSATIMER_IS_USER_INSTANCE(obj)                         \
-    (G_TYPE_CHECK_INSTANCE_TYPE((obj),                          \
-                                ALSATIMER_TYPE_USER_INSTANCE))
-
-#define ALSATIMER_USER_INSTANCE_CLASS(klass)                    \
-    (G_TYPE_CHECK_CLASS_CAST((klass),                           \
-                             ALSATIMER_TYPE_USER_INSTANCE,      \
-                             ALSATimerUserInstanceClass))
-#define ALSATIMER_IS_USER_INSTANCE_CLASS(klass)                 \
-    (G_TYPE_CHECK_CLASS_TYPE((klass),                           \
-                             ALSATIMER_TYPE_USER_INSTANCE))
-#define ALSATIMER_USER_INSTANCE_GET_CLASS(obj)                  \
-    (G_TYPE_INSTANCE_GET_CLASS((obj),                           \
-                               ALSATIMER_TYPE_USER_INSTANCE,    \
-                               ALSATimerUserInstanceClass))
+G_DECLARE_DERIVABLE_TYPE(ALSATimerUserInstance, alsatimer_user_instance, ALSATIMER, USER_INSTANCE,
+                         GObject);
 
 #define ALSATIMER_USER_INSTANCE_ERROR   alsatimer_user_instance_error_quark()
 
 GQuark alsatimer_user_instance_error_quark();
 
-typedef struct _ALSATimerUserInstance           ALSATimerUserInstance;
-typedef struct _ALSATimerUserInstanceClass      ALSATimerUserInstanceClass;
-typedef struct _ALSATimerUserInstancePrivate    ALSATimerUserInstancePrivate;
-
-struct _ALSATimerUserInstance {
-    GObject parent_instance;
-
-    ALSATimerUserInstancePrivate *priv;
-};
-
 struct _ALSATimerUserInstanceClass {
     GObjectClass parent_class;
 
@@ -67,8 +40,6 @@ struct _ALSATimerUserInstanceClass {
     void (*handle_disconnection)(ALSATimerUserInstance *self);
 };
 
-GType alsatimer_user_instance_get_type() G_GNUC_CONST;
-
 ALSATimerUserInstance *alsatimer_user_instance_new();
 
 void alsatimer_user_instance_open(ALSATimerUserInstance *self, gint open_flag,