From 89f692cd73e6fa6963ebdedd62fb13171daeaca5 Mon Sep 17 00:00:00 2001 From: Niels De Graef Date: Wed, 17 Jul 2019 06:35:00 +0200 Subject: [PATCH 1/4] libgimpcolor: Use G_DEFINE_BOXED_TYPE() This isn't any functional change, but allows us to get rid of some of the GObject boilerplate. --- libgimpcolor/gimpcmyk.c | 13 +------------ libgimpcolor/gimphsl.c | 13 +------------ libgimpcolor/gimphsv.c | 13 +------------ libgimpcolor/gimprgb.c | 13 +------------ 4 files changed, 4 insertions(+), 48 deletions(-) diff --git a/libgimpcolor/gimpcmyk.c b/libgimpcolor/gimpcmyk.c index 28b08eb6ca0..def52dddd0e 100644 --- a/libgimpcolor/gimpcmyk.c +++ b/libgimpcolor/gimpcmyk.c @@ -43,18 +43,7 @@ static GimpCMYK * gimp_cmyk_copy (const GimpCMYK *cmyk); -GType -gimp_cmyk_get_type (void) -{ - static GType cmyk_type = 0; - - if (!cmyk_type) - cmyk_type = g_boxed_type_register_static ("GimpCMYK", - (GBoxedCopyFunc) gimp_cmyk_copy, - (GBoxedFreeFunc) g_free); - - return cmyk_type; -} +G_DEFINE_BOXED_TYPE (GimpCMYK, gimp_cmyk, gimp_cmyk_copy, g_free) static GimpCMYK * gimp_cmyk_copy (const GimpCMYK *cmyk) diff --git a/libgimpcolor/gimphsl.c b/libgimpcolor/gimphsl.c index 050a40d3b50..84575edeb3f 100644 --- a/libgimpcolor/gimphsl.c +++ b/libgimpcolor/gimphsl.c @@ -32,18 +32,7 @@ static GimpHSL * gimp_hsl_copy (const GimpHSL *hsl); -GType -gimp_hsl_get_type (void) -{ - static GType hsl_type = 0; - - if (!hsl_type) - hsl_type = g_boxed_type_register_static ("GimpHSL", - (GBoxedCopyFunc) gimp_hsl_copy, - (GBoxedFreeFunc) g_free); - - return hsl_type; -} +G_DEFINE_BOXED_TYPE (GimpHSL, gimp_hsl, gimp_hsl_copy, g_free) static GimpHSL * gimp_hsl_copy (const GimpHSL *hsl) diff --git a/libgimpcolor/gimphsv.c b/libgimpcolor/gimphsv.c index 56bfbd7ed18..6cb430067fc 100644 --- a/libgimpcolor/gimphsv.c +++ b/libgimpcolor/gimphsv.c @@ -41,18 +41,7 @@ static GimpHSV * gimp_hsv_copy (const GimpHSV *hsv); -GType -gimp_hsv_get_type (void) -{ - static GType hsv_type = 0; - - if (!hsv_type) - hsv_type = g_boxed_type_register_static ("GimpHSV", - (GBoxedCopyFunc) gimp_hsv_copy, - (GBoxedFreeFunc) g_free); - - return hsv_type; -} +G_DEFINE_BOXED_TYPE (GimpHSV, gimp_hsv, gimp_hsv_copy, g_free) static GimpHSV * gimp_hsv_copy (const GimpHSV *hsv) diff --git a/libgimpcolor/gimprgb.c b/libgimpcolor/gimprgb.c index 64c4767a1a3..695d5e8b205 100644 --- a/libgimpcolor/gimprgb.c +++ b/libgimpcolor/gimprgb.c @@ -43,18 +43,7 @@ static GimpRGB * gimp_rgb_copy (const GimpRGB *rgb); -GType -gimp_rgb_get_type (void) -{ - static GType rgb_type = 0; - - if (!rgb_type) - rgb_type = g_boxed_type_register_static ("GimpRGB", - (GBoxedCopyFunc) gimp_rgb_copy, - (GBoxedFreeFunc) g_free); - - return rgb_type; -} +G_DEFINE_BOXED_TYPE (GimpRGB, gimp_rgb, gimp_rgb_copy, g_free) void gimp_value_get_rgb (const GValue *value, -- GitLab From cb0ae619d1a8e8ffa950837f7bbd8bf4b54f2928 Mon Sep 17 00:00:00 2001 From: Niels De Graef Date: Wed, 17 Jul 2019 06:59:53 +0200 Subject: [PATCH 2/4] app: Use G_DEFINE_BOXED_TYPE() This isn't any functional change, but allows us to get rid of some of the GObject boilerplate. --- app/core/gimpbezierdesc.c | 13 +------------ app/core/gimpdashpattern.c | 14 ++------------ app/vectors/gimpanchor.c | 13 +------------ 3 files changed, 4 insertions(+), 36 deletions(-) diff --git a/app/core/gimpbezierdesc.c b/app/core/gimpbezierdesc.c index 6047544a67d..65acd9f24f7 100644 --- a/app/core/gimpbezierdesc.c +++ b/app/core/gimpbezierdesc.c @@ -29,18 +29,7 @@ #include "gimpboundary.h" -GType -gimp_bezier_desc_get_type (void) -{ - static GType type = 0; - - if (! type) - type = g_boxed_type_register_static ("GimpBezierDesc", - (GBoxedCopyFunc) gimp_bezier_desc_copy, - (GBoxedFreeFunc) gimp_bezier_desc_free); - - return type; -} +G_DEFINE_BOXED_TYPE (GimpBezierDesc, gimp_bezier_desc, gimp_bezier_desc_copy, gimp_bezier_desc_free) GimpBezierDesc * gimp_bezier_desc_new (cairo_path_data_t *data, diff --git a/app/core/gimpdashpattern.c b/app/core/gimpdashpattern.c index e9fb9fc9a27..4ed756b97ad 100644 --- a/app/core/gimpdashpattern.c +++ b/app/core/gimpdashpattern.c @@ -30,18 +30,8 @@ #include "gimpdashpattern.h" -GType -gimp_dash_pattern_get_type (void) -{ - static GType type = 0; - - if (! type) - type = g_boxed_type_register_static ("GimpDashPattern", - (GBoxedCopyFunc) gimp_dash_pattern_copy, - (GBoxedFreeFunc) gimp_dash_pattern_free); - - return type; -} +typedef GArray GimpDashPattern; +G_DEFINE_BOXED_TYPE (GimpDashPattern, gimp_dash_pattern, gimp_dash_pattern_copy, gimp_dash_pattern_free) GArray * gimp_dash_pattern_new_from_preset (GimpDashPreset preset) diff --git a/app/vectors/gimpanchor.c b/app/vectors/gimpanchor.c index f5085cdb602..fa348ae798c 100644 --- a/app/vectors/gimpanchor.c +++ b/app/vectors/gimpanchor.c @@ -27,18 +27,7 @@ #include "gimpanchor.h" -GType -gimp_anchor_get_type (void) -{ - static GType anchor_type = 0; - - if (!anchor_type) - anchor_type = g_boxed_type_register_static ("GimpAnchor", - (GBoxedCopyFunc) gimp_anchor_copy, - (GBoxedFreeFunc) gimp_anchor_free); - - return anchor_type; -} +G_DEFINE_BOXED_TYPE (GimpAnchor, gimp_anchor, gimp_anchor_copy, gimp_anchor_free) GimpAnchor * gimp_anchor_new (GimpAnchorType type, -- GitLab From a551043ffecc1d83eb7ec69a49d0f3a259d7429f Mon Sep 17 00:00:00 2001 From: Niels De Graef Date: Wed, 17 Jul 2019 07:02:04 +0200 Subject: [PATCH 3/4] 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 1b3e46b1fb6..c0c4d5220c6 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 bf9f219cee6..ddfd352f123 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 -- GitLab From cc21ec304fafdb198f22cafa13a60834ad52c85e Mon Sep 17 00:00:00 2001 From: Niels De Graef Date: Wed, 17 Jul 2019 07:04:59 +0200 Subject: [PATCH 4/4] libgimpmath: Use G_DEFINE_BOXED_TYPE() This isn't any functional change, but allows us to get rid of some of the GObject boilerplate. --- libgimpmath/gimpmatrix.c | 44 ++-------------------------------------- 1 file changed, 2 insertions(+), 42 deletions(-) diff --git a/libgimpmath/gimpmatrix.c b/libgimpmath/gimpmatrix.c index 8ede5b26f64..836978ab1c1 100644 --- a/libgimpmath/gimpmatrix.c +++ b/libgimpmath/gimpmatrix.c @@ -49,27 +49,7 @@ static GimpMatrix2 * matrix2_copy (const GimpMatrix2 *matrix); -/** - * gimp_matrix2_get_type: - * - * Reveals the object type - * - * Returns: the #GType for Matrix2 objects - * - * Since: 2.4 - **/ -GType -gimp_matrix2_get_type (void) -{ - static GType matrix_type = 0; - - if (!matrix_type) - matrix_type = g_boxed_type_register_static ("GimpMatrix2", - (GBoxedCopyFunc) matrix2_copy, - (GBoxedFreeFunc) g_free); - - return matrix_type; -} +G_DEFINE_BOXED_TYPE (GimpMatrix2, gimp_matrix2, matrix2_copy, g_free) /* @@ -267,27 +247,7 @@ gimp_matrix2_mult (const GimpMatrix2 *matrix1, static GimpMatrix3 * matrix3_copy (const GimpMatrix3 *matrix); -/** - * gimp_matrix3_get_type: - * - * Reveals the object type - * - * Returns: the #GType for Matrix3 objects - * - * Since: 2.8 - **/ -GType -gimp_matrix3_get_type (void) -{ - static GType matrix_type = 0; - - if (!matrix_type) - matrix_type = g_boxed_type_register_static ("GimpMatrix3", - (GBoxedCopyFunc) matrix3_copy, - (GBoxedFreeFunc) g_free); - - return matrix_type; -} +G_DEFINE_BOXED_TYPE (GimpMatrix3, gimp_matrix3, matrix3_copy, g_free) /* -- GitLab