[glib] [gio] Use G_DEFINE_INTERFACE macro
- From: Javier Jardón <jjardon src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] [gio] Use G_DEFINE_INTERFACE macro
- Date: Wed, 21 Apr 2010 00:32:58 +0000 (UTC)
commit 3569de342e415c887537d811a0df373cfdb85bc6
Author: Javier Jardón <jjardon gnome org>
Date: Tue Apr 20 05:38:02 2010 +0200
[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 | 32 +++++---------------------------
4 files changed, 16 insertions(+), 119 deletions(-)
---
diff --git a/gio/gasyncinitable.c b/gio/gasyncinitable.c
index c369a4e..ba24abc 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);
-
- 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);
- }
+typedef GAsyncInitableIface GAsyncInitableInterface;
+G_DEFINE_INTERFACE (GAsyncInitable, g_async_initable, G_TYPE_OBJECT)
- 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 8305b00..930bd03 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 f243b73..dbf8e75 100644
--- a/gio/ginitable.c
+++ b/gio/ginitable.c
@@ -52,35 +52,12 @@
* an exception on failure.
*/
-GType
-g_initable_get_type (void)
-{
- static volatile gsize g_define_type_id__volatile = 0;
+typedef GInitableIface GInitableInterface;
+G_DEFINE_INTERFACE (GInitable, g_initable, G_TYPE_OBJECT)
- 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;
+static void
+g_initable_default_init (GInitableInterface *iface)
+{
}
/**
diff --git a/gio/gsocketconnectable.c b/gio/gsocketconnectable.c
index a57a001..c58d6e0 100644
--- a/gio/gsocketconnectable.c
+++ b/gio/gsocketconnectable.c
@@ -91,35 +91,13 @@
* ]|
*/
-GType
-g_socket_connectable_get_type (void)
-{
- 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);
+typedef GSocketConnectableIface GSocketConnectableInterface;
+G_DEFINE_INTERFACE (GSocketConnectable, g_socket_connectable, 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_socket_connectable_default_init (GSocketConnectableInterface *iface)
+{
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]