[gcr/wip/nielsdg/cleanup-type-boilerplate: 1/2] gck: Cleanup with G_DEFINE_BOXED_TYPE



commit 3c2ea60162495f593e86de5ba0f623c99bb11f3d
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Tue Mar 31 15:04:31 2020 +0200

    gck: Cleanup with G_DEFINE_BOXED_TYPE

 gck/gck-attributes.c | 45 ++++++---------------------------------------
 gck/gck-module.c     | 15 ++-------------
 gck/gck-session.c    | 15 ++-------------
 gck/gck-slot.c       | 45 ++++++---------------------------------------
 gck/gck-uri.c        | 15 ++-------------
 5 files changed, 18 insertions(+), 117 deletions(-)
---
diff --git a/gck/gck-attributes.c b/gck/gck-attributes.c
index 7d5482c..8612a28 100644
--- a/gck/gck-attributes.c
+++ b/gck/gck-attributes.c
@@ -149,19 +149,8 @@ value_unref (guchar *data)
        }
 }
 
-GType
-gck_builder_get_type (void)
-{
-       static volatile gsize initialized = 0;
-       static GType type = 0;
-       if (g_once_init_enter (&initialized)) {
-               type = g_boxed_type_register_static ("GckBuilder",
-                                                    (GBoxedCopyFunc)gck_builder_ref,
-                                                    (GBoxedFreeFunc)gck_builder_unref);
-               g_once_init_leave (&initialized, 1);
-       }
-       return type;
-}
+G_DEFINE_BOXED_TYPE (GckBuilder, gck_builder,
+                     gck_builder_ref, gck_builder_unref)
 
 /**
  * GckBuilder:
@@ -1725,19 +1714,8 @@ gck_attribute_init_string (GckAttribute *attr,
                            value ? strlen (value) : 0);
 }
 
-GType
-gck_attribute_get_type (void)
-{
-       static volatile gsize initialized = 0;
-       static GType type = 0;
-       if (g_once_init_enter (&initialized)) {
-               type = g_boxed_type_register_static ("GckAttribute",
-                                                    (GBoxedCopyFunc)gck_attribute_dup,
-                                                    (GBoxedFreeFunc)gck_attribute_free);
-               g_once_init_leave (&initialized, 1);
-       }
-       return type;
-}
+G_DEFINE_BOXED_TYPE (GckAttribute, gck_attribute,
+                     gck_attribute_dup, gck_attribute_free)
 
 /**
  * gck_attribute_new:
@@ -2063,19 +2041,8 @@ gck_attribute_hash (gconstpointer attr)
  * Returns: The allocated memory, or %NULL when freeing.
  **/
 
-GType
-gck_attributes_get_type (void)
-{
-       static volatile gsize initialized = 0;
-       static GType type = 0;
-       if (g_once_init_enter (&initialized)) {
-               type = g_boxed_type_register_static ("GckAttributes",
-                                                    (GBoxedCopyFunc)gck_attributes_ref,
-                                                    (GBoxedFreeFunc)gck_attributes_unref);
-               g_once_init_leave (&initialized, 1);
-       }
-       return type;
-}
+G_DEFINE_BOXED_TYPE (GckAttributes, gck_attributes,
+                     gck_attributes_ref, gck_attributes_unref)
 
 GType
 gck_attributes_get_boxed_type (void)
diff --git a/gck/gck-module.c b/gck/gck-module.c
index 8ac8815..5dc4ef9 100644
--- a/gck/gck-module.c
+++ b/gck/gck-module.c
@@ -272,19 +272,8 @@ gck_module_class_init (GckModuleClass *klass)
                        G_TYPE_BOOLEAN, 3, GCK_TYPE_OBJECT, G_TYPE_STRING, G_TYPE_POINTER);
 }
 
-GType
-gck_module_info_get_type (void)
-{
-       static volatile gsize initialized = 0;
-       static GType type = 0;
-       if (g_once_init_enter (&initialized)) {
-               type = g_boxed_type_register_static ("GckModuleInfo",
-                                                    (GBoxedCopyFunc)gck_module_info_copy,
-                                                    (GBoxedFreeFunc)gck_module_info_free);
-               g_once_init_leave (&initialized, 1);
-       }
-       return type;
-}
+G_DEFINE_BOXED_TYPE (GckModuleInfo, gck_module_info,
+                     gck_module_info_copy, gck_module_info_free)
 
 /**
  * gck_module_info_copy:
diff --git a/gck/gck-session.c b/gck/gck-session.c
index 38df51a..c776005 100644
--- a/gck/gck-session.c
+++ b/gck/gck-session.c
@@ -552,19 +552,8 @@ gck_session_async_initable_iface (GAsyncInitableIface *iface)
  * When done with this structure, release it using gck_session_info_free().
  */
 
-GType
-gck_session_info_get_type (void)
-{
-       static volatile gsize initialized = 0;
-       static GType type = 0;
-       if (g_once_init_enter (&initialized)) {
-               type = g_boxed_type_register_static ("GckSessionInfo",
-                                                    (GBoxedCopyFunc)gck_session_info_copy,
-                                                    (GBoxedFreeFunc)gck_session_info_free);
-               g_once_init_leave (&initialized, 1);
-       }
-       return type;
-}
+G_DEFINE_BOXED_TYPE (GckSessionInfo, gck_session_info,
+                     gck_session_info_copy, gck_session_info_free)
 
 /**
  * gck_session_info_copy:
diff --git a/gck/gck-slot.c b/gck/gck-slot.c
index f00857f..8ef960e 100644
--- a/gck/gck-slot.c
+++ b/gck/gck-slot.c
@@ -176,19 +176,8 @@ gck_slot_class_init (GckSlotClass *klass)
  * gck_slot_info_free().
  */
 
-GType
-gck_slot_info_get_type (void)
-{
-       static volatile gsize initialized = 0;
-       static GType type = 0;
-       if (g_once_init_enter (&initialized)) {
-               type = g_boxed_type_register_static ("GckSlotInfo",
-                                                    (GBoxedCopyFunc)gck_slot_info_copy,
-                                                    (GBoxedFreeFunc)gck_slot_info_free);
-               g_once_init_leave (&initialized, 1);
-       }
-       return type;
-}
+G_DEFINE_BOXED_TYPE (GckSlotInfo, gck_slot_info,
+                     gck_slot_info_copy, gck_slot_info_free)
 
 /**
  * gck_slot_info_copy:
@@ -260,19 +249,8 @@ gck_slot_info_free (GckSlotInfo *slot_info)
  * gck_token_info_free().
  */
 
-GType
-gck_token_info_get_type (void)
-{
-       static volatile gsize initialized = 0;
-       static GType type = 0;
-       if (g_once_init_enter (&initialized)) {
-               type = g_boxed_type_register_static ("GckTokenInfo",
-                                                    (GBoxedCopyFunc)gck_token_info_copy,
-                                                    (GBoxedFreeFunc)gck_token_info_free);
-               g_once_init_leave (&initialized, 1);
-       }
-       return type;
-}
+G_DEFINE_BOXED_TYPE (GckTokenInfo, gck_token_info,
+                     gck_token_info_copy, gck_token_info_free)
 
 /**
  * gck_token_info_copy:
@@ -328,19 +306,8 @@ gck_token_info_free (GckTokenInfo *token_info)
  * gck_mechanism_info_free().
  */
 
-GType
-gck_mechanism_info_get_type (void)
-{
-       static volatile gsize initialized = 0;
-       static GType type = 0;
-       if (g_once_init_enter (&initialized)) {
-               type = g_boxed_type_register_static ("GckMechanismInfo",
-                                                    (GBoxedCopyFunc)gck_mechanism_info_copy,
-                                                    (GBoxedFreeFunc)gck_mechanism_info_free);
-               g_once_init_leave (&initialized, 1);
-       }
-       return type;
-}
+G_DEFINE_BOXED_TYPE (GckMechanismInfo, gck_mechanism_info,
+                     gck_mechanism_info_copy, gck_mechanism_info_free)
 
 /**
  * gck_mechanism_info_copy:
diff --git a/gck/gck-uri.c b/gck/gck-uri.c
index 8d75a1e..6c7c7dc 100644
--- a/gck/gck-uri.c
+++ b/gck/gck-uri.c
@@ -311,19 +311,8 @@ gck_uri_build (GckUriData *uri_data, GckUriFlags flags)
        return string;
 }
 
-GType
-gck_uri_data_get_type (void)
-{
-       static volatile gsize initialized = 0;
-       static GType type = 0;
-       if (g_once_init_enter (&initialized)) {
-               type = g_boxed_type_register_static ("GckUriData",
-                                                    (GBoxedCopyFunc)gck_uri_data_copy,
-                                                    (GBoxedFreeFunc)gck_uri_data_free);
-               g_once_init_leave (&initialized, 1);
-       }
-       return type;
-}
+G_DEFINE_BOXED_TYPE (GckUriData, gck_uri_data,
+                     gck_uri_data_copy, gck_uri_data_free)
 
 /**
  * gck_uri_data_copy:


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