[gimp/wip/nielsdg/g-define-boxed-type: 14/15] libgimpbase: Use G_DEFINE_BOXED_TYPE()



commit 9bc63058e67400774dd4d8c6a9bdf22ef4aab0ce
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Wed Jul 17 07:02:04 2019 +0200

    libgimpbase: Use G_DEFINE_BOXED_TYPE()
    
    This isn't any functional change, but allows us to get rid of some of
    the GObject boilerplate.

 libgimpbase/gimpparamspecs.c | 113 +++++--------------------------------------
 libgimpbase/gimpparasite.c   |  14 +-----
 2 files changed, 14 insertions(+), 113 deletions(-)
---
diff --git a/libgimpbase/gimpparamspecs.c b/libgimpbase/gimpparamspecs.c
index 1b3e46b1fb..c0c4d5220c 100644
--- a/libgimpbase/gimpparamspecs.c
+++ b/libgimpbase/gimpparamspecs.c
@@ -69,18 +69,7 @@ gimp_array_free (GimpArray *array)
     }
 }
 
-GType
-gimp_array_get_type (void)
-{
-  static GType type = 0;
-
-  if (! type)
-    type = g_boxed_type_register_static ("GimpArray",
-                                         (GBoxedCopyFunc) gimp_array_copy,
-                                         (GBoxedFreeFunc) gimp_array_free);
-
-  return type;
-}
+G_DEFINE_BOXED_TYPE (GimpArray, gimp_array, gimp_array_copy, gimp_array_free)
 
 
 /*
@@ -263,19 +252,8 @@ gimp_value_take_array (GValue *value,
  * GIMP_TYPE_UINT8_ARRAY
  */
 
-GType
-gimp_uint8_array_get_type (void)
-{
-  static GType type = 0;
-
-  if (! type)
-    type = g_boxed_type_register_static ("GimpUInt8Array",
-                                         (GBoxedCopyFunc) gimp_array_copy,
-                                         (GBoxedFreeFunc) gimp_array_free);
-
-  return type;
-}
-
+typedef GimpArray GimpUint8Array;
+G_DEFINE_BOXED_TYPE (GimpUint8Array, gimp_uint8_array, gimp_array_copy, gimp_array_free)
 
 /*
  * GIMP_TYPE_PARAM_UINT8_ARRAY
@@ -401,18 +379,8 @@ gimp_value_take_uint8_array (GValue *value,
  * GIMP_TYPE_INT16_ARRAY
  */
 
-GType
-gimp_int16_array_get_type (void)
-{
-  static GType type = 0;
-
-  if (! type)
-    type = g_boxed_type_register_static ("GimpInt16Array",
-                                         (GBoxedCopyFunc) gimp_array_copy,
-                                         (GBoxedFreeFunc) gimp_array_free);
-
-  return type;
-}
+typedef GimpArray GimpInt16Array;
+G_DEFINE_BOXED_TYPE (GimpInt16Array, gimp_int16_array, gimp_array_copy, gimp_array_free)
 
 
 /*
@@ -542,19 +510,8 @@ gimp_value_take_int16_array (GValue *value,
  * GIMP_TYPE_INT32_ARRAY
  */
 
-GType
-gimp_int32_array_get_type (void)
-{
-  static GType type = 0;
-
-  if (! type)
-    type = g_boxed_type_register_static ("GimpInt32Array",
-                                         (GBoxedCopyFunc) gimp_array_copy,
-                                         (GBoxedFreeFunc) gimp_array_free);
-
-  return type;
-}
-
+typedef GimpArray GimpInt32Array;
+G_DEFINE_BOXED_TYPE (GimpInt32Array, gimp_int32_array, gimp_array_copy, gimp_array_free)
 
 /*
  * GIMP_TYPE_PARAM_INT32_ARRAY
@@ -683,19 +640,8 @@ gimp_value_take_int32_array (GValue *value,
  * GIMP_TYPE_FLOAT_ARRAY
  */
 
-GType
-gimp_float_array_get_type (void)
-{
-  static GType type = 0;
-
-  if (! type)
-    type = g_boxed_type_register_static ("GimpFloatArray",
-                                         (GBoxedCopyFunc) gimp_array_copy,
-                                         (GBoxedFreeFunc) gimp_array_free);
-
-  return type;
-}
-
+typedef GimpArray GimpFloatArray;
+G_DEFINE_BOXED_TYPE (GimpFloatArray, gimp_float_array, gimp_array_copy, gimp_array_free)
 
 /*
  * GIMP_TYPE_PARAM_FLOAT_ARRAY
@@ -911,19 +857,7 @@ gimp_string_array_free (GimpStringArray *array)
     }
 }
 
-GType
-gimp_string_array_get_type (void)
-{
-  static GType type = 0;
-
-  if (! type)
-    type = g_boxed_type_register_static ("GimpStringArray",
-                                         (GBoxedCopyFunc) gimp_string_array_copy,
-                                         (GBoxedFreeFunc) gimp_string_array_free);
-
-  return type;
-}
-
+G_DEFINE_BOXED_TYPE (GimpStringArray, gimp_string_array, gimp_string_array_copy, gimp_string_array_free)
 
 /*
  * GIMP_TYPE_PARAM_STRING_ARRAY
@@ -1146,18 +1080,8 @@ gimp_value_take_string_array (GValue  *value,
  * GIMP_TYPE_RGB_ARRAY
  */
 
-GType
-gimp_rgb_array_get_type (void)
-{
-  static GType type = 0;
-
-  if (! type)
-    type = g_boxed_type_register_static ("GimpRGBArray",
-                                         (GBoxedCopyFunc) gimp_array_copy,
-                                         (GBoxedFreeFunc) gimp_array_free);
-
-  return type;
-}
+typedef GimpArray GimpRGBArray;
+G_DEFINE_BOXED_TYPE (GimpRGBArray, gimp_rgb_array, gimp_array_copy, gimp_array_free)
 
 
 /*
@@ -1380,18 +1304,7 @@ gimp_object_array_free (GimpObjectArray *array)
     }
 }
 
-GType
-gimp_object_array_get_type (void)
-{
-  static GType type = 0;
-
-  if (! type)
-    type = g_boxed_type_register_static ("GimpObjectArray",
-                                         (GBoxedCopyFunc) gimp_object_array_copy,
-                                         (GBoxedFreeFunc) gimp_object_array_free);
-
-  return type;
-}
+G_DEFINE_BOXED_TYPE (GimpObjectArray, gimp_object_array, gimp_object_array_copy, gimp_object_array_free)
 
 
 /*
diff --git a/libgimpbase/gimpparasite.c b/libgimpbase/gimpparasite.c
index bf9f219cee..ddfd352f12 100644
--- a/libgimpbase/gimpparasite.c
+++ b/libgimpbase/gimpparasite.c
@@ -55,19 +55,7 @@
  * GIMP_TYPE_PARASITE
  */
 
-GType
-gimp_parasite_get_type (void)
-{
-  static GType type = 0;
-
-  if (! type)
-    type = g_boxed_type_register_static ("GimpParasite",
-                                         (GBoxedCopyFunc) gimp_parasite_copy,
-                                         (GBoxedFreeFunc) gimp_parasite_free);
-
-  return type;
-}
-
+G_DEFINE_BOXED_TYPE (GimpParasite, gimp_parasite, gimp_parasite_copy, gimp_parasite_free)
 
 /*
  * GIMP_TYPE_PARAM_PARASITE


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