iface-port-at: use G_DECLARE|DEFINE_INTERFACE() macros

This commit is contained in:
Aleksander Morgado
2024-05-06 13:27:04 +00:00
parent 1e26e16168
commit 9aab129759
4 changed files with 24 additions and 51 deletions
+16 -38
View File
@@ -17,10 +17,11 @@
#define _LIBMM_INSIDE_MM
#include <libmm-glib.h>
#include "mm-port.h"
#include "mm-iface-port-at.h"
#include "mm-log-object.h"
G_DEFINE_INTERFACE (MMIfacePortAt, mm_iface_port_at, MM_TYPE_PORT)
/*****************************************************************************/
gboolean
@@ -32,12 +33,12 @@ mm_iface_port_at_check_support (MMIfacePortAt *self,
/* If the object implementing the interface doesn't provide a check_support() method,
* we assume the feature is unconditionally supported. */
if (!MM_IFACE_PORT_AT_GET_INTERFACE (self)->check_support) {
if (!MM_IFACE_PORT_AT_GET_IFACE (self)->check_support) {
*out_supported = TRUE;
return TRUE;
}
return MM_IFACE_PORT_AT_GET_INTERFACE (self)->check_support (self, out_supported, error);
return MM_IFACE_PORT_AT_GET_IFACE (self)->check_support (self, out_supported, error);
}
/*****************************************************************************/
@@ -47,7 +48,7 @@ mm_iface_port_at_command_finish (MMIfacePortAt *self,
GAsyncResult *res,
GError **error)
{
return MM_IFACE_PORT_AT_GET_INTERFACE (self)->command_finish (self, res, error);
return MM_IFACE_PORT_AT_GET_IFACE (self)->command_finish (self, res, error);
}
void
@@ -60,45 +61,22 @@ mm_iface_port_at_command (MMIfacePortAt *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
g_assert (MM_IFACE_PORT_AT_GET_INTERFACE (self)->command);
g_assert (MM_IFACE_PORT_AT_GET_INTERFACE (self)->command_finish);
g_assert (MM_IFACE_PORT_AT_GET_IFACE (self)->command);
g_assert (MM_IFACE_PORT_AT_GET_IFACE (self)->command_finish);
MM_IFACE_PORT_AT_GET_INTERFACE (self)->command (self,
command,
timeout_seconds,
is_raw,
allow_cached,
cancellable,
callback,
user_data);
MM_IFACE_PORT_AT_GET_IFACE (self)->command (self,
command,
timeout_seconds,
is_raw,
allow_cached,
cancellable,
callback,
user_data);
}
/*****************************************************************************/
static void
iface_port_at_init (gpointer g_iface)
mm_iface_port_at_default_init (MMIfacePortAtInterface *iface)
{
}
GType
mm_iface_port_at_get_type (void)
{
static GType iface_port_at_type = 0;
if (!G_UNLIKELY (iface_port_at_type)) {
static const GTypeInfo info = {
sizeof (MMIfacePortAt), /* class_size */
iface_port_at_init, /* base_init */
NULL, /* base_finalize */
};
iface_port_at_type = g_type_register_static (G_TYPE_INTERFACE,
"MMIfacePortAt",
&info,
0);
g_type_interface_add_prerequisite (iface_port_at_type, MM_TYPE_PORT);
}
return iface_port_at_type;
}
+4 -9
View File
@@ -22,14 +22,12 @@
#define _LIBMM_INSIDE_MM
#include <libmm-glib.h>
#define MM_TYPE_IFACE_PORT_AT (mm_iface_port_at_get_type ())
#define MM_IFACE_PORT_AT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_IFACE_PORT_AT, MMIfacePortAt))
#define MM_IS_IFACE_PORT_AT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_IFACE_PORT_AT))
#define MM_IFACE_PORT_AT_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), MM_TYPE_IFACE_PORT_AT, MMIfacePortAt))
#include "mm-port.h"
typedef struct _MMIfacePortAt MMIfacePortAt;
#define MM_TYPE_IFACE_PORT_AT mm_iface_port_at_get_type ()
G_DECLARE_INTERFACE (MMIfacePortAt, mm_iface_port_at, MM, IFACE_PORT_AT, MMPort)
struct _MMIfacePortAt {
struct _MMIfacePortAtInterface {
GTypeInterface g_iface;
gboolean (* check_support) (MMIfacePortAt *self,
@@ -49,9 +47,6 @@ struct _MMIfacePortAt {
GError **error);
};
GType mm_iface_port_at_get_type (void);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MMIfacePortAt, g_object_unref)
gboolean mm_iface_port_at_check_support (MMIfacePortAt *self,
gboolean *out_supported,
GError **error);
+2 -2
View File
@@ -25,7 +25,7 @@
#include "mm-port-serial-at.h"
#include "mm-log-object.h"
static void iface_port_at_init (MMIfacePortAt *iface);
static void iface_port_at_init (MMIfacePortAtInterface *iface);
G_DEFINE_TYPE_EXTENDED (MMPortSerialAt, mm_port_serial_at, MM_TYPE_PORT_SERIAL, 0,
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_PORT_AT, iface_port_at_init))
@@ -625,7 +625,7 @@ finalize (GObject *object)
}
static void
iface_port_at_init (MMIfacePortAt *iface)
iface_port_at_init (MMIfacePortAtInterface *iface)
{
iface->check_support = NULL;
iface->command = iface_port_at_command;
+2 -2
View File
@@ -26,7 +26,7 @@
#include "mm-port-mbim-fibocom.h"
#include "mm-log-object.h"
static void iface_port_at_init (MMIfacePortAt *iface);
static void iface_port_at_init (MMIfacePortAtInterface *iface);
G_DEFINE_TYPE_EXTENDED (MMPortMbimFibocom, mm_port_mbim_fibocom, MM_TYPE_PORT_MBIM, 0,
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_PORT_AT, iface_port_at_init))
@@ -260,7 +260,7 @@ finalize (GObject *object)
}
static void
iface_port_at_init (MMIfacePortAt *iface)
iface_port_at_init (MMIfacePortAtInterface *iface)
{
iface->check_support = iface_port_at_check_support;
iface->command = iface_port_at_command;