From 3569de342e415c887537d811a0df373cfdb85bc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jard=C3=B3n?= Date: Tue, 20 Apr 2010 05:38:02 +0200 Subject: [PATCH] [gio] Use G_DEFINE_INTERFACE macro Use this macro in gasyncinitable, gconverter, ginitable and gsocketconnectable https://bugzilla.gnome.org/show_bug.cgi?id=616245 --- gio/gasyncinitable.c | 35 +++-------------------------------- gio/gconverter.c | 35 +++-------------------------------- gio/ginitable.c | 33 +++++---------------------------- gio/gsocketconnectable.c | 34 ++++++---------------------------- 4 files changed, 17 insertions(+), 120 deletions(-) diff --git a/gio/gasyncinitable.c b/gio/gasyncinitable.c index c369a4e6a..ba24abc4f 100644 --- a/gio/gasyncinitable.c +++ b/gio/gasyncinitable.c @@ -48,7 +48,6 @@ * a set %GError on failure. */ -static void g_async_initable_base_init (gpointer g_iface); static void g_async_initable_real_init_async (GAsyncInitable *initable, int io_priority, GCancellable *cancellable, @@ -58,42 +57,14 @@ static gboolean g_async_initable_real_init_finish (GAsyncInitable *initabl GAsyncResult *res, GError **error); -GType -g_async_initable_get_type (void) -{ - static volatile gsize g_define_type_id__volatile = 0; - if (g_once_init_enter (&g_define_type_id__volatile)) - { - const GTypeInfo initable_info = - { - sizeof (GAsyncInitableIface), /* class_size */ - g_async_initable_base_init, /* base_init */ - NULL, /* base_finalize */ - NULL, - NULL, /* class_finalize */ - NULL, /* class_data */ - 0, - 0, /* n_preallocs */ - NULL - }; - GType g_define_type_id = - g_type_register_static (G_TYPE_INTERFACE, I_("GAsyncInitable"), - &initable_info, 0); +typedef GAsyncInitableIface GAsyncInitableInterface; +G_DEFINE_INTERFACE (GAsyncInitable, g_async_initable, G_TYPE_OBJECT) - g_type_interface_add_prerequisite (g_define_type_id, G_TYPE_OBJECT); - - g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); - } - - return g_define_type_id__volatile; -} static void -g_async_initable_base_init (gpointer g_iface) +g_async_initable_default_init (GAsyncInitableInterface *iface) { - GAsyncInitableIface *iface = g_iface; - iface->init_async = g_async_initable_real_init_async; iface->init_finish = g_async_initable_real_init_finish; } diff --git a/gio/gconverter.c b/gio/gconverter.c index 8305b001b..930bd036a 100644 --- a/gio/gconverter.c +++ b/gio/gconverter.c @@ -43,41 +43,12 @@ * Since: 2.24 **/ -static void g_converter_base_init (gpointer g_class); -GType -g_converter_get_type (void) -{ - static volatile gsize g_define_type_id__volatile = 0; - - if (g_once_init_enter (&g_define_type_id__volatile)) - { - const GTypeInfo converter_info = - { - sizeof (GConverterIface), /* class_size */ - g_converter_base_init, /* base_init */ - NULL, /* base_finalize */ - NULL, - NULL, /* class_finalize */ - NULL, /* class_data */ - 0, - 0, /* n_preallocs */ - NULL - }; - GType g_define_type_id = - g_type_register_static (G_TYPE_INTERFACE, I_("GConverter"), - &converter_info, 0); - - g_type_interface_add_prerequisite (g_define_type_id, G_TYPE_OBJECT); - - g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); - } - - return g_define_type_id__volatile; -} +typedef GConverterIface GConverterInterface; +G_DEFINE_INTERFACE (GConverter, g_converter, G_TYPE_OBJECT) static void -g_converter_base_init (gpointer g_class) +g_converter_default_init (GConverterInterface *iface) { } diff --git a/gio/ginitable.c b/gio/ginitable.c index f243b73f8..dbf8e7594 100644 --- a/gio/ginitable.c +++ b/gio/ginitable.c @@ -52,35 +52,12 @@ * an exception on failure. */ -GType -g_initable_get_type (void) +typedef GInitableIface GInitableInterface; +G_DEFINE_INTERFACE (GInitable, g_initable, G_TYPE_OBJECT) + +static void +g_initable_default_init (GInitableInterface *iface) { - static volatile gsize g_define_type_id__volatile = 0; - - if (g_once_init_enter (&g_define_type_id__volatile)) - { - const GTypeInfo initable_info = - { - sizeof (GInitableIface), /* class_size */ - NULL, /* base_init */ - NULL, /* base_finalize */ - NULL, - NULL, /* class_finalize */ - NULL, /* class_data */ - 0, - 0, /* n_preallocs */ - NULL - }; - GType g_define_type_id = - g_type_register_static (G_TYPE_INTERFACE, I_("GInitable"), - &initable_info, 0); - - g_type_interface_add_prerequisite (g_define_type_id, G_TYPE_OBJECT); - - g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); - } - - return g_define_type_id__volatile; } /** diff --git a/gio/gsocketconnectable.c b/gio/gsocketconnectable.c index a57a00197..c58d6e037 100644 --- a/gio/gsocketconnectable.c +++ b/gio/gsocketconnectable.c @@ -91,35 +91,13 @@ * ]| */ -GType -g_socket_connectable_get_type (void) + +typedef GSocketConnectableIface GSocketConnectableInterface; +G_DEFINE_INTERFACE (GSocketConnectable, g_socket_connectable, G_TYPE_OBJECT) + +static void +g_socket_connectable_default_init (GSocketConnectableInterface *iface) { - static volatile gsize g_define_type_id__volatile = 0; - - if (g_once_init_enter (&g_define_type_id__volatile)) - { - const GTypeInfo connectable_info = - { - sizeof (GSocketConnectableIface), /* class_size */ - NULL, /* base_init */ - NULL, /* base_finalize */ - NULL, - NULL, /* class_finalize */ - NULL, /* class_data */ - 0, - 0, /* n_preallocs */ - NULL - }; - GType g_define_type_id = - g_type_register_static (G_TYPE_INTERFACE, I_("GSocketConnectable"), - &connectable_info, 0); - - g_type_interface_add_prerequisite (g_define_type_id, G_TYPE_OBJECT); - - g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); - } - - return g_define_type_id__volatile; } /**