[json-glib] Use G_DEFINE_INTERFACE()



commit dc262a09572328342164ebb23ad698b5cb3cd8ff
Author: Emmanuele Bassi <ebassi linux intel com>
Date:   Tue Oct 19 09:49:20 2010 +0100

    Use G_DEFINE_INTERFACE()

 json-glib/json-serializable.c |   35 +++++++----------------------------
 1 files changed, 7 insertions(+), 28 deletions(-)
---
diff --git a/json-glib/json-serializable.c b/json-glib/json-serializable.c
index 1263eec..4a15f3f 100644
--- a/json-glib/json-serializable.c
+++ b/json-glib/json-serializable.c
@@ -126,38 +126,17 @@ json_serializable_real_serialize (JsonSerializable *serializable,
   return json_serialize_pspec (value, pspec);
 }
 
+/* typedef to satisfy G_DEFINE_INTERFACE's naming */
+typedef JsonSerializableIface   JsonSerializableInterface;
+
 static void
-json_serializable_base_init (gpointer g_class,
-                             gpointer data)
+json_serializable_default_init (JsonSerializableInterface *iface)
 {
-  static gboolean is_initialized = FALSE;
-
-  if (G_UNLIKELY (!is_initialized))
-    {
-      JsonSerializableIface *iface = g_class;
-
-      iface->serialize_property = json_serializable_real_serialize;
-      iface->deserialize_property = json_serializable_real_deserialize;
-
-      is_initialized = TRUE;
-    }
+  iface->serialize_property = json_serializable_real_serialize;
+  iface->deserialize_property = json_serializable_real_deserialize;
 }
 
-GType
-json_serializable_get_type (void)
-{
-  static GType iface_type = 0;
-
-  if (!iface_type)
-    iface_type =
-      g_type_register_static_simple (G_TYPE_INTERFACE,
-                                     g_intern_static_string ("JsonSerializable"),
-                                     sizeof (JsonSerializableIface),
-                                     json_serializable_base_init,
-                                     0, NULL, 0);
-
-  return iface_type;
-}
+G_DEFINE_INTERFACE (JsonSerializable, json_serializable, G_TYPE_OBJECT);
 
 /**
  * json_serializable_default_serialize_property:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]