gnucash stable: Multiple changes pushed
John Ralls
jralls at code.gnucash.org
Thu May 25 10:52:05 EDT 2023
Updated via https://github.com/Gnucash/gnucash/commit/3d30e597 (commit)
via https://github.com/Gnucash/gnucash/commit/eb2d5df7 (commit)
via https://github.com/Gnucash/gnucash/commit/c514f61a (commit)
via https://github.com/Gnucash/gnucash/commit/14f2efcf (commit)
from https://github.com/Gnucash/gnucash/commit/23c208e1 (commit)
commit 3d30e5978a4ef4ac7317be74202e5631835d2a56
Merge: 23c208e1a0 eb2d5df778
Author: John Ralls <jralls at ceridwen.us>
Date: Thu May 25 10:50:08 2023 -0400
Merge Richard Cohen's 'define-boxed' into stable.
commit eb2d5df778969e95dd1095f3b60b711f7272ecf9
Author: Richard Cohen <richard at daijobu.co.uk>
Date: Thu May 4 17:32:49 2023 +0100
Refactor: DEFINE_BOXED GncGUID
diff --git a/libgnucash/engine/guid.cpp b/libgnucash/engine/guid.cpp
index 4ec3421ded..d854b45a02 100644
--- a/libgnucash/engine/guid.cpp
+++ b/libgnucash/engine/guid.cpp
@@ -286,28 +286,15 @@ gnc_guid_to_string (const GValue *src, GValue *dest)
g_value_set_string (dest, str);
}
-GType
-gnc_guid_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- type = g_boxed_type_register_static ("GncGUID",
- (GBoxedCopyFunc)guid_copy,
- (GBoxedFreeFunc)guid_free);
-
+G_DEFINE_BOXED_TYPE_WITH_CODE (GncGUID, gnc_guid, guid_copy, guid_free,
g_value_register_transform_func (G_TYPE_STRING,
- type,
+ g_define_type_id,
gnc_string_to_guid);
- g_value_register_transform_func (type,
+ g_value_register_transform_func (g_define_type_id,
G_TYPE_STRING,
gnc_guid_to_string);
- }
-
- return type;
-}
+ )
namespace gnc
{
commit c514f61a7a06c31a3dd97a99596502ce26033f9e
Author: Richard Cohen <richard at daijobu.co.uk>
Date: Fri May 12 11:07:15 2023 +0100
Refactor: DEFINE_BOXED Time64
diff --git a/libgnucash/engine/gnc-date.cpp b/libgnucash/engine/gnc-date.cpp
index 202b5dbb01..56383edcf3 100644
--- a/libgnucash/engine/gnc-date.cpp
+++ b/libgnucash/engine/gnc-date.cpp
@@ -1379,36 +1379,22 @@ gnc_dow_abbrev(gchar *buf, int buf_len, int dow)
* GValue handling
********************************************************************/
-static gpointer
-time64_boxed_copy_func (gpointer in_time64)
+static Time64*
+time64_boxed_copy_func (Time64 *in_time64)
{
- Time64* newvalue;
-
- newvalue = static_cast<Time64*>(g_malloc (sizeof (Time64)));
- memcpy (newvalue, in_time64, sizeof(Time64));
+ Time64* newvalue = g_new (Time64, 1);
+ *newvalue = *in_time64;
return newvalue;
}
static void
-time64_boxed_free_func (gpointer in_time64)
+time64_boxed_free_func (Time64 *in_time64)
{
g_free (in_time64);
}
-GType
-time64_get_type( void )
-{
- static GType type = 0;
-
- if ( type == 0 )
- {
- type = g_boxed_type_register_static( "time64",
- time64_boxed_copy_func,
- time64_boxed_free_func );
- }
- return type;
-}
+G_DEFINE_BOXED_TYPE (Time64, time64, time64_boxed_copy_func, time64_boxed_free_func)
/* ================================================= */
commit 14f2efcfb7bd43b541fd88e3c170d683dd84afb9
Author: Richard Cohen <richard at daijobu.co.uk>
Date: Fri May 12 10:58:37 2023 +0100
Refactor: DEFINE_BOXED gnc_numeric
diff --git a/libgnucash/engine/gnc-numeric.cpp b/libgnucash/engine/gnc-numeric.cpp
index 163776a449..2bea303fd1 100644
--- a/libgnucash/engine/gnc-numeric.cpp
+++ b/libgnucash/engine/gnc-numeric.cpp
@@ -1249,10 +1249,9 @@ string_to_gnc_numeric(const gchar* str, gnc_numeric *n)
/* *******************************************************************
* GValue handling
********************************************************************/
-static gpointer
-gnc_numeric_boxed_copy_func( gpointer in_ptr )
+static gnc_numeric*
+gnc_numeric_boxed_copy_func( gnc_numeric *in_gnc_numeric )
{
- auto in_gnc_numeric = static_cast<gnc_numeric*>(in_ptr);
if (!in_gnc_numeric)
return nullptr;
@@ -1264,25 +1263,12 @@ gnc_numeric_boxed_copy_func( gpointer in_ptr )
}
static void
-gnc_numeric_boxed_free_func( gpointer in_gnc_numeric )
+gnc_numeric_boxed_free_func( gnc_numeric *in_gnc_numeric )
{
g_free( in_gnc_numeric );
}
-GType
-gnc_numeric_get_type( void )
-{
- static GType type = 0;
-
- if ( type == 0 )
- {
- type = g_boxed_type_register_static( "gnc_numeric",
- gnc_numeric_boxed_copy_func,
- gnc_numeric_boxed_free_func );
- }
-
- return type;
-}
+G_DEFINE_BOXED_TYPE (gnc_numeric, gnc_numeric, gnc_numeric_boxed_copy_func, gnc_numeric_boxed_free_func)
/* *******************************************************************
* gnc_numeric misc testing
Summary of changes:
libgnucash/engine/gnc-date.cpp | 26 ++++++--------------------
libgnucash/engine/gnc-numeric.cpp | 22 ++++------------------
libgnucash/engine/guid.cpp | 21 ++++-----------------
3 files changed, 14 insertions(+), 55 deletions(-)
More information about the gnucash-changes
mailing list