aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2022-04-11 17:41:05 +0900
committer坂本 貴史 <o-takashi@sakamocchi.jp>2022-04-12 12:42:41 +0900
commite345bec401d492b68a00cbebf8e35f8cb19dc1c8 (patch)
treed125b29e89fa11a7ed6730b4de765ae6bf3b53e5
parent86982992a44c29c8b2e6d0360128084f41f53e69 (diff)
downloadlibhinawa-e345bec401d492b68a00cbebf8e35f8cb19dc1c8.tar.gz
fw_resp: use an utility macro to declare GObject-derived object
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>
-rw-r--r--src/fw_node.c4
-rw-r--r--src/fw_resp.c4
-rw-r--r--src/fw_resp.h32
3 files changed, 5 insertions, 35 deletions
diff --git a/src/fw_node.c b/src/fw_node.c
index 511e483..e6b5b39 100644
--- a/src/fw_node.c
+++ b/src/fw_node.c
@@ -462,8 +462,8 @@ static gboolean dispatch_src(GSource *gsrc, GSourceFunc cb, gpointer user_data)
if (HINAWA_IS_FW_NODE((gpointer)common->closure) && common->type == FW_CDEV_EVENT_BUS_RESET) {
handle_update(src->self);
- } else if (HINAWA_IS_FW_RESP(common->closure) && common->type == FW_CDEV_EVENT_REQUEST2) {
- hinawa_fw_resp_handle_request(HINAWA_FW_RESP(common->closure),
+ } else if (HINAWA_IS_FW_RESP((gpointer)common->closure) && common->type == FW_CDEV_EVENT_REQUEST2) {
+ hinawa_fw_resp_handle_request(HINAWA_FW_RESP((gpointer)common->closure),
(struct fw_cdev_event_request2 *)common);
} else if (HINAWA_IS_FW_REQ((gpointer)common->closure) && common->type == FW_CDEV_EVENT_RESPONSE) {
struct fw_cdev_event_response *ev = (struct fw_cdev_event_response *)common;
diff --git a/src/fw_resp.c b/src/fw_resp.c
index 0775f8f..122eb4e 100644
--- a/src/fw_resp.c
+++ b/src/fw_resp.c
@@ -40,7 +40,7 @@ static const char *const err_msgs[] = {
g_set_error(exception, HINAWA_FW_RESP_ERROR, HINAWA_FW_RESP_ERROR_FAILED, \
format " %d(%s)", arg, errno, strerror(errno))
-struct _HinawaFwRespPrivate {
+typedef struct {
HinawaFwNode *node;
guint64 offset;
@@ -51,7 +51,7 @@ struct _HinawaFwRespPrivate {
gsize req_length;
guint8 *resp_frame;
gsize resp_length;
-};
+} HinawaFwRespPrivate;
G_DEFINE_TYPE_WITH_PRIVATE(HinawaFwResp, hinawa_fw_resp, G_TYPE_OBJECT)
// This object has one property.
diff --git a/src/fw_resp.h b/src/fw_resp.h
index 9116b48..89d5d31 100644
--- a/src/fw_resp.h
+++ b/src/fw_resp.h
@@ -8,40 +8,12 @@ G_BEGIN_DECLS
#define HINAWA_TYPE_FW_RESP (hinawa_fw_resp_get_type())
-#define HINAWA_FW_RESP(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj), \
- HINAWA_TYPE_FW_RESP, \
- HinawaFwResp))
-#define HINAWA_IS_FW_RESP(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
- HINAWA_TYPE_FW_RESP))
-
-#define HINAWA_FW_RESP_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass), \
- HINAWA_TYPE_FW_RESP, \
- HinawaFwRespClass))
-#define HINAWA_IS_FW_RESP_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass), \
- HINAWA_TYPE_FW_RESP))
-#define HINAWA_FW_RESP_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS((obj), \
- HINAWA_TYPE_FW_RESP, \
- HinawaFwRespClass))
+G_DECLARE_DERIVABLE_TYPE(HinawaFwResp, hinawa_fw_resp, HINAWA, FW_RESP, GObject);
#define HINAWA_FW_RESP_ERROR hinawa_fw_resp_error_quark()
GQuark hinawa_fw_resp_error_quark();
-typedef struct _HinawaFwResp HinawaFwResp;
-typedef struct _HinawaFwRespClass HinawaFwRespClass;
-typedef struct _HinawaFwRespPrivate HinawaFwRespPrivate;
-
-struct _HinawaFwResp {
- GObject parent_instance;
-
- HinawaFwRespPrivate *priv;
-};
-
struct _HinawaFwRespClass {
GObjectClass parent_class;
@@ -92,8 +64,6 @@ struct _HinawaFwRespClass {
const guint8 *frame, guint length);
};
-GType hinawa_fw_resp_get_type(void) G_GNUC_CONST;
-
HinawaFwResp *hinawa_fw_resp_new(void);
void hinawa_fw_resp_reserve_within_region(HinawaFwResp *self, HinawaFwNode *node,