diff options
author | Richard Hughes <richard@hughsie.com> | 2015-11-17 09:06:09 +0000 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2015-11-17 09:06:09 +0000 |
commit | 2082634f9b402e55365e150042929837317ba8f3 (patch) | |
tree | 71d67c9ff43bb1e14bf28f3995d5e8405aa12012 | |
parent | ccf253cfa0e87a257208219ee5744d149fe833d6 (diff) | |
parent | d36a51d38edb899e8d4c477b6b756b8a379b7c19 (diff) | |
download | gusb-2082634f9b402e55365e150042929837317ba8f3.tar.gz |
Merge pull request #5 from nacho/master
Convert GUsbInterface to user the G_DECLARE_FINAL_TYPE macro
-rw-r--r-- | gusb/gusb-autocleanups.h | 1 | ||||
-rw-r--r-- | gusb/gusb-interface.c | 42 | ||||
-rw-r--r-- | gusb/gusb-interface.h | 28 |
3 files changed, 21 insertions, 50 deletions
diff --git a/gusb/gusb-autocleanups.h b/gusb/gusb-autocleanups.h index ce7dc45..0adf613 100644 --- a/gusb/gusb-autocleanups.h +++ b/gusb/gusb-autocleanups.h @@ -29,7 +29,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(GUsbContext, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GUsbDevice, g_object_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GUsbInterface, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GUsbDeviceList, g_object_unref) #endif diff --git a/gusb/gusb-interface.c b/gusb/gusb-interface.c index 0614679..b7b0238 100644 --- a/gusb/gusb-interface.c +++ b/gusb/gusb-interface.c @@ -35,26 +35,22 @@ #include "gusb-interface.h" #include "gusb-interface-private.h" -/** - * GUsbInterfacePrivate: - * - * Private #GUsbInterface data - **/ -struct _GUsbInterfacePrivate +struct _GUsbInterface { - struct libusb_interface_descriptor iface; - GBytes *extra; + GObject parent_instance; + + struct libusb_interface_descriptor iface; + GBytes *extra; }; -G_DEFINE_TYPE_WITH_PRIVATE (GUsbInterface, g_usb_interface, G_TYPE_OBJECT) +G_DEFINE_TYPE (GUsbInterface, g_usb_interface, G_TYPE_OBJECT) static void g_usb_interface_finalize (GObject *object) { GUsbInterface *interface = G_USB_INTERFACE (object); - GUsbInterfacePrivate *priv = interface->priv; - g_bytes_unref (priv->extra); + g_bytes_unref (interface->extra); G_OBJECT_CLASS (g_usb_interface_parent_class)->finalize (object); } @@ -63,13 +59,13 @@ static void g_usb_interface_class_init (GUsbInterfaceClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); + object_class->finalize = g_usb_interface_finalize; } static void g_usb_interface_init (GUsbInterface *interface) { - interface->priv = g_usb_interface_get_instance_private (interface); } /** @@ -86,10 +82,10 @@ _g_usb_interface_new (const struct libusb_interface_descriptor *iface) interface = g_object_new (G_USB_TYPE_INTERFACE, NULL); /* copy the data */ - memcpy (&interface->priv->iface, + memcpy (&interface->iface, iface, sizeof (struct libusb_interface_descriptor)); - interface->priv->extra = g_bytes_new (iface->extra, iface->extra_length); + interface->extra = g_bytes_new (iface->extra, iface->extra_length); return G_USB_INTERFACE (interface); } @@ -108,7 +104,7 @@ guint8 g_usb_interface_get_length (GUsbInterface *interface) { g_return_val_if_fail (G_USB_IS_INTERFACE (interface), 0); - return interface->priv->iface.bLength; + return interface->iface.bLength; } /** @@ -125,7 +121,7 @@ guint8 g_usb_interface_get_kind (GUsbInterface *interface) { g_return_val_if_fail (G_USB_IS_INTERFACE (interface), 0); - return interface->priv->iface.bDescriptorType; + return interface->iface.bDescriptorType; } /** @@ -142,7 +138,7 @@ guint8 g_usb_interface_get_number (GUsbInterface *interface) { g_return_val_if_fail (G_USB_IS_INTERFACE (interface), 0); - return interface->priv->iface.bInterfaceNumber; + return interface->iface.bInterfaceNumber; } /** @@ -159,7 +155,7 @@ guint8 g_usb_interface_get_alternate (GUsbInterface *interface) { g_return_val_if_fail (G_USB_IS_INTERFACE (interface), 0); - return interface->priv->iface.bAlternateSetting; + return interface->iface.bAlternateSetting; } /** @@ -176,7 +172,7 @@ guint8 g_usb_interface_get_class (GUsbInterface *interface) { g_return_val_if_fail (G_USB_IS_INTERFACE (interface), 0); - return interface->priv->iface.bInterfaceClass; + return interface->iface.bInterfaceClass; } /** @@ -194,7 +190,7 @@ guint8 g_usb_interface_get_subclass (GUsbInterface *interface) { g_return_val_if_fail (G_USB_IS_INTERFACE (interface), 0); - return interface->priv->iface.bInterfaceSubClass; + return interface->iface.bInterfaceSubClass; } /** @@ -212,7 +208,7 @@ guint8 g_usb_interface_get_protocol (GUsbInterface *interface) { g_return_val_if_fail (G_USB_IS_INTERFACE (interface), 0); - return interface->priv->iface.bInterfaceProtocol; + return interface->iface.bInterfaceProtocol; } /** @@ -229,7 +225,7 @@ guint8 g_usb_interface_get_index (GUsbInterface *interface) { g_return_val_if_fail (G_USB_IS_INTERFACE (interface), 0); - return interface->priv->iface.iInterface; + return interface->iface.iInterface; } /** @@ -246,5 +242,5 @@ GBytes * g_usb_interface_get_extra (GUsbInterface *interface) { g_return_val_if_fail (G_USB_IS_INTERFACE (interface), NULL); - return interface->priv->extra; + return interface->extra; } diff --git a/gusb/gusb-interface.h b/gusb/gusb-interface.h index 816373b..74905c6 100644 --- a/gusb/gusb-interface.h +++ b/gusb/gusb-interface.h @@ -26,32 +26,8 @@ G_BEGIN_DECLS -#define G_USB_TYPE_INTERFACE (g_usb_interface_get_type ()) -#define G_USB_INTERFACE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_USB_TYPE_INTERFACE, GUsbInterface)) -#define G_USB_IS_INTERFACE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_USB_TYPE_INTERFACE)) - -typedef struct _GUsbInterfacePrivate GUsbInterfacePrivate; -typedef struct _GUsbInterface GUsbInterface; -typedef struct _GUsbInterfaceClass GUsbInterfaceClass; - -struct _GUsbInterface -{ - GObject parent; - GUsbInterfacePrivate *priv; -}; - -struct _GUsbInterfaceClass -{ - GObjectClass parent_class; - /*< private >*/ - /* - * If adding fields to this struct, remove corresponding - * amount of padding to avoid changing overall struct size - */ - gpointer _gusb_reserved[31]; -}; - -GType g_usb_interface_get_type (void); +#define G_USB_TYPE_INTERFACE (g_usb_interface_get_type ()) +G_DECLARE_FINAL_TYPE (GUsbInterface, g_usb_interface, G_USB, INTERFACE, GObject) guint8 g_usb_interface_get_length (GUsbInterface *interface); guint8 g_usb_interface_get_kind (GUsbInterface *interface); |