gnucash stable: Multiple changes pushed
Christopher Lam
clam at code.gnucash.org
Fri Feb 9 05:57:42 EST 2024
Updated via https://github.com/Gnucash/gnucash/commit/03c53096 (commit)
via https://github.com/Gnucash/gnucash/commit/7d8d8f83 (commit)
via https://github.com/Gnucash/gnucash/commit/783c3df3 (commit)
via https://github.com/Gnucash/gnucash/commit/fc5d7f87 (commit)
from https://github.com/Gnucash/gnucash/commit/698cc230 (commit)
commit 03c530966647c1b0e757c6501d7f82fd03eceac5
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Mon Feb 5 22:51:37 2024 +0800
[gnc-lot.cpp] convert to cpp
diff --git a/libgnucash/engine/CMakeLists.txt b/libgnucash/engine/CMakeLists.txt
index 7639012ec7..2f3feddf53 100644
--- a/libgnucash/engine/CMakeLists.txt
+++ b/libgnucash/engine/CMakeLists.txt
@@ -164,7 +164,7 @@ set (engine_SOURCES
gnc-features.cpp
gnc-hooks.c
gnc-int128.cpp
- gnc-lot.c
+ gnc-lot.cpp
gnc-numeric.cpp
gnc-option-date.cpp
gnc-option.cpp
diff --git a/libgnucash/engine/gnc-lot.c b/libgnucash/engine/gnc-lot.cpp
similarity index 98%
rename from libgnucash/engine/gnc-lot.c
rename to libgnucash/engine/gnc-lot.cpp
index 7489256966..15457f20df 100644
--- a/libgnucash/engine/gnc-lot.c
+++ b/libgnucash/engine/gnc-lot.cpp
@@ -269,7 +269,7 @@ gnc_lot_new (QofBook *book)
GNCLot *lot;
g_return_val_if_fail (book, NULL);
- lot = g_object_new (GNC_TYPE_LOT, NULL);
+ lot = GNC_LOT(g_object_new (GNC_TYPE_LOT, NULL));
qof_instance_init_data(QOF_INSTANCE(lot), GNC_ID_LOT, book);
qof_event_gen (QOF_INSTANCE(lot), QOF_EVENT_CREATE, NULL);
return lot;
@@ -288,7 +288,7 @@ gnc_lot_free(GNCLot* lot)
priv = GET_PRIVATE(lot);
for (node = priv->splits; node; node = node->next)
{
- Split *s = node->data;
+ Split *s = GNC_SPLIT(node->data);
s->lot = NULL;
}
g_list_free (priv->splits);
@@ -519,7 +519,7 @@ gnc_lot_get_balance (GNCLot *lot)
*/
for (node = priv->splits; node; node = node->next)
{
- Split *s = node->data;
+ Split *s = GNC_SPLIT(node->data);
gnc_numeric amt = xaccSplitGetAmount (s);
baln = gnc_numeric_add_fixed (baln, amt);
g_assert (gnc_numeric_check (baln) == GNC_ERROR_OK);
@@ -568,7 +568,7 @@ gnc_lot_get_balance_before (const GNCLot *lot, const Split *split,
tb = xaccSplitGetParent (target);
for (node = priv->splits; node; node = node->next)
{
- Split *s = node->data;
+ Split *s = GNC_SPLIT(node->data);
Split *source = xaccSplitGetGainsSourceSplit (s);
if (source == NULL)
source = s;
@@ -677,7 +677,7 @@ gnc_lot_get_earliest_split (GNCLot *lot)
priv = GET_PRIVATE(lot);
if (! priv->splits) return NULL;
priv->splits = g_list_sort (priv->splits, (GCompareFunc) xaccSplitOrderDateOnly);
- return priv->splits->data;
+ return GNC_SPLIT(priv->splits->data);
}
/* Utility function, get latest split in lot */
@@ -695,7 +695,7 @@ gnc_lot_get_latest_split (GNCLot *lot)
for (node = priv->splits; node->next; node = node->next)
;
- return node->data;
+ return GNC_SPLIT(node->data);
}
/* ============================================================= */
@@ -729,7 +729,7 @@ static QofObject gncLotDesc =
DI(.interface_version = ) QOF_OBJECT_VERSION,
DI(.e_type = ) GNC_ID_LOT,
DI(.type_label = ) "Lot",
- DI(.create = ) (gpointer)gnc_lot_new,
+ DI(.create = ) (void* (*)(QofBook*))gnc_lot_new,
DI(.book_begin = ) NULL,
DI(.book_end = ) gnc_lot_book_end,
DI(.is_dirty = ) qof_collection_is_dirty,
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 6370bf2da4..7a45a22348 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -647,7 +647,7 @@ libgnucash/engine/gncIDSearch.c
libgnucash/engine/gnc-int128.cpp
libgnucash/engine/gncInvoice.c
libgnucash/engine/gncJob.c
-libgnucash/engine/gnc-lot.c
+libgnucash/engine/gnc-lot.cpp
libgnucash/engine/gnc-numeric.cpp
libgnucash/engine/gnc-option.cpp
libgnucash/engine/gnc-option-date.cpp
commit 7d8d8f83be1d9a9eebe38f1306f114b06f1c795f
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Mon Feb 5 22:44:49 2024 +0800
[Recurrence.cpp] convert to cpp
diff --git a/libgnucash/engine/CMakeLists.txt b/libgnucash/engine/CMakeLists.txt
index ba85668b02..7639012ec7 100644
--- a/libgnucash/engine/CMakeLists.txt
+++ b/libgnucash/engine/CMakeLists.txt
@@ -137,7 +137,7 @@ add_custom_target(iso-4217-c DEPENDS ${ISO_4217_C})
set (engine_SOURCES
Account.cpp
- Recurrence.c
+ Recurrence.cpp
Query.c
SchedXaction.c
SX-book.c
diff --git a/libgnucash/engine/Recurrence.c b/libgnucash/engine/Recurrence.cpp
similarity index 98%
rename from libgnucash/engine/Recurrence.c
rename to libgnucash/engine/Recurrence.cpp
index f507396acf..e4f378a0c2 100644
--- a/libgnucash/engine/Recurrence.c
+++ b/libgnucash/engine/Recurrence.cpp
@@ -41,12 +41,12 @@ static QofLogModule log_module = LOG_MOD;
static GDate invalid_gdate;
/* Do not intl. These are used for xml storage. */
-static gchar *period_type_strings[NUM_PERIOD_TYPES] =
+static const gchar *period_type_strings[NUM_PERIOD_TYPES] =
{
"once", "day", "week", "month", "end of month",
"nth weekday", "last weekday", "year",
};
-static gchar *weekend_adj_strings[NUM_WEEKEND_ADJS] =
+static const gchar *weekend_adj_strings[NUM_WEEKEND_ADJS] =
{
"none", "back", "forward",
};
@@ -447,7 +447,7 @@ recurrenceListNextInstance(const GList *rlist, const GDate *ref, GDate *next)
for (iter = rlist; iter; iter = iter->next)
{
- const Recurrence *r = iter->data;
+ auto r = static_cast<const Recurrence *>(iter->data);
recurrenceNextInstance(r, ref, &nextSingle);
if (!g_date_valid(&nextSingle)) continue;
@@ -463,8 +463,8 @@ recurrenceListNextInstance(const GList *rlist, const GDate *ref, GDate *next)
gchar *
recurrenceToString(const Recurrence *r)
{
- gchar *tmpDate;
- gchar *tmpPeriod, *ret;
+ gchar *tmpDate, *ret;
+ const gchar *tmpPeriod;
g_return_val_if_fail(g_date_valid(&r->start), NULL);
tmpDate = g_new0(gchar, MAX_DATE_LENGTH + 1);
@@ -531,8 +531,8 @@ recurrencePeriodTypeFromString(const gchar *str)
for (i = 0; i < NUM_PERIOD_TYPES; i++)
if (g_strcmp0(period_type_strings[i], str) == 0)
- return i;
- return -1;
+ return static_cast<PeriodType>(i);
+ return static_cast<PeriodType>(-1);
}
const gchar *
@@ -548,8 +548,8 @@ recurrenceWeekendAdjustFromString(const gchar *str)
for (i = 0; i < NUM_WEEKEND_ADJS; i++)
if (g_strcmp0(weekend_adj_strings[i], str) == 0)
- return i;
- return -1;
+ return static_cast<WeekendAdjust>(i);
+ return static_cast<WeekendAdjust>(-1);
}
gboolean
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 0bf47323ed..6370bf2da4 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -683,7 +683,7 @@ libgnucash/engine/qof-string-cache.cpp
libgnucash/engine/qofutil.cpp
libgnucash/engine/qof-win32.cpp
libgnucash/engine/Query.c
-libgnucash/engine/Recurrence.c
+libgnucash/engine/Recurrence.cpp
libgnucash/engine/SchedXaction.c
libgnucash/engine/Scrub2.c
libgnucash/engine/Scrub3.c
commit 783c3df3c0d07f03b299a4b4a641a82c1d801dd5
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Mon Feb 5 21:33:42 2024 +0800
[Transaction.cpp] convert to cpp
diff --git a/libgnucash/engine/CMakeLists.txt b/libgnucash/engine/CMakeLists.txt
index 46874ad740..ba85668b02 100644
--- a/libgnucash/engine/CMakeLists.txt
+++ b/libgnucash/engine/CMakeLists.txt
@@ -149,7 +149,7 @@ set (engine_SOURCES
ScrubBudget.c
Split.cpp
TransLog.c
- Transaction.c
+ Transaction.cpp
cap-gains.c
cashobjects.c
gnc-accounting-period.c
diff --git a/libgnucash/engine/Transaction.c b/libgnucash/engine/Transaction.cpp
similarity index 97%
rename from libgnucash/engine/Transaction.c
rename to libgnucash/engine/Transaction.cpp
index 2ea78062ff..899adaa9d0 100644
--- a/libgnucash/engine/Transaction.c
+++ b/libgnucash/engine/Transaction.cpp
@@ -221,7 +221,7 @@ xaccTransStillHasSplit(const Transaction *trans, const Split *s)
#define FOR_EACH_SPLIT(trans, cmd_block) if (trans->splits) { \
GList *splits; \
for (splits = (trans)->splits; splits; splits = splits->next) { \
- Split *s = splits->data; \
+ Split *s = GNC_SPLIT(splits->data); \
if (xaccTransStillHasSplit(trans, s)) { \
cmd_block; \
} \
@@ -241,7 +241,7 @@ void gen_event_trans (Transaction *trans)
for (node = trans->splits; node; node = node->next)
{
- Split *s = node->data;
+ Split *s = GNC_SPLIT(node->data);
Account *account = s->acc;
GNCLot *lot = s->lot;
if (account)
@@ -362,7 +362,7 @@ gnc_transaction_set_property(GObject* object,
xaccTransSetDescription(tx, g_value_get_string(value));
break;
case PROP_CURRENCY:
- xaccTransSetCurrency(tx, g_value_get_object(value));
+ xaccTransSetCurrency(tx, GNC_COMMODITY(g_value_get_object(value)));
break;
case PROP_POST_DATE:
t = (Time64*)g_value_get_boxed(value);
@@ -504,7 +504,7 @@ xaccMallocTransaction (QofBook *book)
g_return_val_if_fail (book, NULL);
- trans = g_object_new(GNC_TYPE_TRANSACTION, NULL);
+ trans = GNC_TRANSACTION(g_object_new(GNC_TYPE_TRANSACTION, NULL));
xaccInitTransaction (trans, book);
qof_event_gen (&trans->inst, QOF_EVENT_CREATE, NULL);
@@ -547,7 +547,7 @@ xaccTransDump (const Transaction *trans, const char *tag)
printf("\n");
for (node = trans->splits; node; node = node->next)
{
- xaccSplitDump(node->data, tag);
+ xaccSplitDump(GNC_SPLIT(node->data), tag);
}
printf("\n");
}
@@ -562,7 +562,7 @@ xaccTransSortSplits (Transaction *trans)
/* first debits */
for (node = trans->splits; node; node = node->next)
{
- split = node->data;
+ split = GNC_SPLIT(node->data);
if (gnc_numeric_negative_p (xaccSplitGetValue(split)))
continue;
new_list = g_list_prepend (new_list, split);
@@ -571,7 +571,7 @@ xaccTransSortSplits (Transaction *trans)
/* then credits */
for (node = trans->splits; node; node = node->next)
{
- split = node->data;
+ split = GNC_SPLIT(node->data);
if (!gnc_numeric_negative_p (xaccSplitGetValue(split)))
continue;
new_list = g_list_prepend (new_list, split);
@@ -596,7 +596,7 @@ dupe_trans (const Transaction *from)
Transaction *to;
GList *node;
- to = g_object_new (GNC_TYPE_TRANSACTION, NULL);
+ to = GNC_TRANSACTION(g_object_new (GNC_TYPE_TRANSACTION, NULL));
CACHE_REPLACE (to->num, from->num);
CACHE_REPLACE (to->description, from->description);
@@ -604,7 +604,7 @@ dupe_trans (const Transaction *from)
to->splits = g_list_copy (from->splits);
for (node = to->splits; node; node = node->next)
{
- node->data = xaccDupeSplit (node->data);
+ node->data = xaccDupeSplit (GNC_SPLIT(node->data));
}
to->date_entered = from->date_entered;
@@ -639,7 +639,7 @@ xaccTransCloneNoKvp (const Transaction *from)
GList *node;
qof_event_suspend();
- to = g_object_new (GNC_TYPE_TRANSACTION, NULL);
+ to = GNC_TRANSACTION(g_object_new (GNC_TYPE_TRANSACTION, NULL));
to->date_entered = from->date_entered;
to->date_posted = from->date_posted;
@@ -657,7 +657,7 @@ xaccTransCloneNoKvp (const Transaction *from)
xaccTransBeginEdit(to);
for (node = from->splits; node; node = node->next)
{
- split = xaccSplitCloneNoKvp(node->data);
+ split = xaccSplitCloneNoKvp(GNC_SPLIT(node->data));
split->parent = to;
to->splits = g_list_append (to->splits, split);
}
@@ -688,7 +688,7 @@ xaccTransClone (const Transaction *from)
for (GList* lfrom = from->splits, *lto = to->splits; lfrom && lto;
lfrom = g_list_next (lfrom), lto = g_list_next (lto))
- xaccSplitCopyKvp (lfrom->data, lto->data);
+ xaccSplitCopyKvp (GNC_SPLIT(lfrom->data), GNC_SPLIT(lto->data));
xaccTransCommitEdit (to);
return to;
@@ -774,8 +774,8 @@ xaccTransCopyFromClipBoard(const Transaction *from_trans, Transaction *to_trans,
for (node = from_trans->splits; node; node = node->next)
{
Split *new_split = xaccMallocSplit( qof_instance_get_book(QOF_INSTANCE(from_trans)));
- xaccSplitCopyOnto(node->data, new_split);
- if (change_accounts && xaccSplitGetAccount(node->data) == from_acc)
+ xaccSplitCopyOnto(GNC_SPLIT(node->data), new_split);
+ if (change_accounts && xaccSplitGetAccount(GNC_SPLIT(node->data)) == from_acc)
xaccSplitSetAccount(new_split, to_acc);
xaccSplitSetParent(new_split, to_trans);
}
@@ -790,8 +790,6 @@ xaccTransCopyFromClipBoard(const Transaction *from_trans, Transaction *to_trans,
static void
xaccFreeTransaction (Transaction *trans)
{
- GList *node;
-
if (!trans) return;
ENTER ("(addr=%p)", trans);
@@ -803,9 +801,7 @@ xaccFreeTransaction (Transaction *trans)
}
/* free up the destination splits */
- for (node = trans->splits; node; node = node->next)
- xaccFreeSplit (node->data);
- g_list_free (trans->splits);
+ g_list_free_full (trans->splits, (GDestroyNotify)xaccFreeSplit);
trans->splits = NULL;
/* free up transaction strings */
@@ -843,8 +839,8 @@ xaccFreeTransaction (Transaction *trans)
static gint
compare_split_guids (gconstpointer a, gconstpointer b)
{
- const Split *sa = a;
- const Split *sb = b;
+ const Split *sa = GNC_SPLIT(a);
+ const Split *sb = GNC_SPLIT(b);
if (sa == sb) return 0;
if (!sa || !sb) return 1;
@@ -961,7 +957,7 @@ xaccTransEqual(const Transaction *ta, const Transaction *tb,
node_a;
node_a = node_a->next, node_b = node_b->next)
{
- Split *split_a = node_a->data;
+ Split *split_a = GNC_SPLIT(node_a->data);
Split *split_b;
/* don't presume that the splits are in the same order */
@@ -978,7 +974,7 @@ xaccTransEqual(const Transaction *ta, const Transaction *tb,
return FALSE;
}
- split_b = node_b->data;
+ split_b = GNC_SPLIT(node_b->data);
if (!xaccSplitEqual (split_a, split_b, check_guids, check_balances,
FALSE))
@@ -1218,7 +1214,7 @@ xaccTransGetRateForCommodity(const Transaction *trans,
for (splits = trans->splits; splits; splits = splits->next)
{
- Split *s = splits->data;
+ Split *s = GNC_SPLIT(splits->data);
gnc_commodity *comm;
if (!xaccTransStillHasSplit (trans, s)) continue;
@@ -1268,7 +1264,7 @@ xaccTransGetAccountConvRate(const Transaction *txn, const Account *acc)
Account *split_acc;
gnc_commodity *split_commod;
- s = splits->data;
+ s = GNC_SPLIT(splits->data);
if (!xaccTransStillHasSplit(txn, s))
continue;
@@ -1318,7 +1314,7 @@ xaccTransGetAccountBalance (const Transaction *trans,
for (node = trans->splits; node; node = node->next)
{
- Split *split = node->data;
+ Split *split = GNC_SPLIT(node->data);
if (!xaccTransStillHasSplit(trans, split))
continue;
@@ -1474,7 +1470,7 @@ destroy_gains (Transaction *trans)
SplitList *node;
for (node = trans->splits; node; node = node->next)
{
- Split *s = node->data;
+ Split *s = GNC_SPLIT(node->data);
if (!xaccTransStillHasSplit(trans, s))
continue;
@@ -1515,7 +1511,7 @@ do_destroy (Transaction *trans)
to reference the split after it has been freed. */
for (node = trans->splits; node; node = node->next)
{
- Split *s = node->data;
+ Split *s = GNC_SPLIT(node->data);
if (s && s->parent == trans)
{
xaccSplitDestroy(s);
@@ -1523,7 +1519,7 @@ do_destroy (Transaction *trans)
}
for (node = trans->splits; node; node = node->next)
{
- Split *s = node->data;
+ Split *s = GNC_SPLIT(node->data);
if (s && s->parent == trans)
{
xaccSplitCommitEdit(s);
@@ -1584,7 +1580,7 @@ static void trans_cleanup_commit(Transaction *trans)
slist = g_list_copy(trans->splits);
for (node = slist; node; node = node->next)
{
- Split *s = node->data;
+ Split *s = GNC_SPLIT(node->data);
if (!qof_instance_is_dirty(QOF_INSTANCE(s)))
continue;
@@ -1740,7 +1736,7 @@ xaccTransRollbackEdit (Transaction *trans)
SWAP_STR(trans->description, orig->description);
trans->date_entered = orig->date_entered;
trans->date_posted = orig->date_posted;
- SWAP(trans->common_currency, orig->common_currency);
+ std::swap (trans->common_currency, orig->common_currency);
qof_instance_swap_kvp (QOF_INSTANCE (trans), QOF_INSTANCE (orig));
/* The splits at the front of trans->splits are exactly the same
@@ -1754,14 +1750,14 @@ xaccTransRollbackEdit (Transaction *trans)
for (i = 0, node = slist, onode = orig->splits; node;
i++, node = node->next, onode = onode ? onode->next : NULL)
{
- Split *s = node->data;
+ Split *s = GNC_SPLIT(node->data);
if (!qof_instance_is_dirty(QOF_INSTANCE(s)))
continue;
if (i < num_preexist && onode)
{
- Split *so = onode->data;
+ Split *so = GNC_SPLIT(onode->data);
xaccSplitRollbackEdit(s);
SWAP_STR(s->action, so->action);
@@ -1803,9 +1799,7 @@ xaccTransRollbackEdit (Transaction *trans)
g_list_free(slist);
// orig->splits may still have duped splits so free them
- for (node = orig->splits; node; node = node->next)
- xaccFreeSplit(node->data);
- g_list_free(orig->splits);
+ g_list_free_full (orig->splits, (GDestroyNotify)xaccFreeSplit);
orig->splits = NULL;
/* Now that the engine copy is back to its original version,
@@ -2045,7 +2039,7 @@ xaccTransSetDate (Transaction *trans, int day, int mon, int year)
{
GDate *date;
if (!trans) return;
- date = g_date_new_dmy(day, mon, year);
+ date = g_date_new_dmy(day, static_cast<GDateMonth>(mon), year);
if (!g_date_valid(date))
{
PWARN("Attempted to set invalid date %d-%d-%d; set today's date instead.",
@@ -2503,7 +2497,7 @@ xaccTransGetTxnType (Transaction *trans)
trans->txn_type = TXN_TYPE_NONE;
for (GList *n = xaccTransGetSplitList (trans); n; n = g_list_next (n))
{
- Account *acc = xaccSplitGetAccount (n->data);
+ Account *acc = xaccSplitGetAccount (GNC_SPLIT(n->data));
if (!acc)
continue;
@@ -2512,7 +2506,7 @@ xaccTransGetTxnType (Transaction *trans)
has_nonAPAR_split = TRUE;
else if (trans->txn_type == TXN_TYPE_NONE)
{
- GNCLot *lot = xaccSplitGetLot (n->data);
+ GNCLot *lot = xaccSplitGetLot (GNC_SPLIT(n->data));
GncInvoice *invoice = gncInvoiceGetInvoiceFromLot (lot);
GncOwner owner;
@@ -2632,7 +2626,7 @@ xaccTransHasReconciledSplitsByAccount (const Transaction *trans,
for (node = xaccTransGetSplitList (trans); node; node = node->next)
{
- Split *split = node->data;
+ Split *split = GNC_SPLIT(node->data);
if (!xaccTransStillHasSplit(trans, split))
continue;
@@ -2669,7 +2663,7 @@ xaccTransHasSplitsInStateByAccount (const Transaction *trans,
for (node = xaccTransGetSplitList (trans); node; node = node->next)
{
- Split *split = node->data;
+ Split *split = GNC_SPLIT(node->data);
if (!xaccTransStillHasSplit(trans, split))
continue;
@@ -2869,7 +2863,7 @@ xaccTransGetReversedBy(const Transaction *trans)
qof_instance_get_kvp (QOF_INSTANCE(trans), &v, 1, TRANS_REVERSED_BY);
if (G_VALUE_HOLDS_BOXED (&v))
{
- GncGUID* guid = g_value_get_boxed (&v);
+ GncGUID* guid = static_cast<GncGUID*>(g_value_get_boxed (&v));
retval = xaccTransLookup(guid, qof_instance_get_book (trans));
}
g_value_unset (&v);
@@ -2896,7 +2890,7 @@ xaccTransScrubGainsDate (Transaction *trans)
SplitList *splits_copy = g_list_copy(trans->splits);
for (node = splits_copy; node; node = node->next)
{
- Split *s = node->data;
+ Split *s = GNC_SPLIT(node->data);
if (!xaccTransStillHasSplit(trans, s)) continue;
xaccSplitDetermineGainStatus(s);
@@ -2932,7 +2926,7 @@ xaccTransScrubGains (Transaction *trans, Account *gain_acc)
restart:
for (node = trans->splits; node; node = node->next)
{
- Split *s = node->data;
+ Split *s = GNC_SPLIT(node->data);
if (!xaccTransStillHasSplit(trans, s)) continue;
@@ -3062,8 +3056,7 @@ void
xaccTransRecordPrice (Transaction *trans, PriceSource source)
{
/* XXX: This should have been part of xaccSplitCommitEdit. */
- for (GList *n = xaccTransGetSplitList (trans); n; n = n->next)
- record_price (n->data, source);
+ g_list_foreach (xaccTransGetSplitList (trans), (GFunc)record_price, (gpointer)source);
}
/********************************************************************\
@@ -3105,7 +3098,7 @@ static QofObject trans_object_def =
DI(.interface_version = ) QOF_OBJECT_VERSION,
DI(.e_type = ) GNC_ID_TRANS,
DI(.type_label = ) "Transaction",
- DI(.create = ) (gpointer)xaccMallocTransaction,
+ DI(.create = ) (void* (*)(QofBook*))xaccMallocTransaction,
DI(.book_begin = ) NULL,
DI(.book_end = ) gnc_transaction_book_end,
DI(.is_dirty = ) qof_collection_is_dirty,
diff --git a/libgnucash/engine/test/utest-Account.cpp b/libgnucash/engine/test/utest-Account.cpp
index fbabc77f93..d9e2d70901 100644
--- a/libgnucash/engine/test/utest-Account.cpp
+++ b/libgnucash/engine/test/utest-Account.cpp
@@ -35,7 +35,7 @@
#include "../Transaction.h"
#include "../gnc-lot.h"
-#if defined(__clang__) && (__clang_major__ == 5 || (__clang_major__ == 3 && __clang_minor__ < 5))
+#if defined(__clang__)
#define USE_CLANG_FUNC_SIG 1
#endif
static const gchar *suitename = "/engine/Account";
@@ -861,7 +861,7 @@ test_xaccFreeAccount (Fixture *fixture, gconstpointer pData)
#ifdef USE_CLANG_FUNC_SIG
#define _func "int xaccTransGetSplitIndex(const Transaction *, const Split *)"
#else
-#define _func "xaccTransGetSplitIndex"
+#define _func "int xaccTransGetSplitIndex(const Transaction*, const Split*)"
#endif
auto msg2 = _func ": assertion 'trans && split' failed";
#undef _func
@@ -975,7 +975,7 @@ test_xaccAccountCommitEdit (Fixture *fixture, gconstpointer pData)
#ifdef USE_CLANG_FUNC_SIG
#define _func "int xaccTransGetSplitIndex(const Transaction *, const Split *)"
#else
-#define _func "xaccTransGetSplitIndex"
+#define _func "int xaccTransGetSplitIndex(const Transaction*, const Split*)"
#endif
auto msg2 = _func ": assertion 'trans && split' failed";
#undef _func
diff --git a/libgnucash/engine/test/utest-Transaction.cpp b/libgnucash/engine/test/utest-Transaction.cpp
index a9adae24ac..e3f31fdac8 100644
--- a/libgnucash/engine/test/utest-Transaction.cpp
+++ b/libgnucash/engine/test/utest-Transaction.cpp
@@ -35,7 +35,7 @@
#include "../gnc-event.h"
#include <qof.h>
-#if defined(__clang__) && (__clang_major__ == 5 || (__clang_major__ == 3 && __clang_minor__ < 5))
+#if defined(__clang__)
#define USE_CLANG_FUNC_SIG 1
#endif
@@ -459,7 +459,7 @@ test_xaccMallocTransaction (Fixture *fixture, gconstpointer pData)
#ifdef USE_CLANG_FUNC_SIG
#define _func "Transaction *xaccMallocTransaction(QofBook *)"
#else
-#define _func "xaccMallocTransaction"
+#define _func "Transaction* xaccMallocTransaction(QofBook*)"
#endif
auto msg = _func ": assertion 'book' failed";
#undef _func
@@ -1242,7 +1242,7 @@ test_xaccTransGetAccountBalance (Fixture *fixture, gconstpointer pData)
#ifdef USE_CLANG_FUNC_SIG
#define _func "gnc_numeric xaccTransGetAccountBalance(const Transaction *, const Account *)"
#else
-#define _func "xaccTransGetAccountBalance"
+#define _func "gnc_numeric xaccTransGetAccountBalance(const Transaction*, const Account*)"
#endif
auto msg1 = _func ": assertion 'account && trans' failed";
#undef _func
diff --git a/po/POTFILES.in b/po/POTFILES.in
index f41b3ab493..0bf47323ed 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -693,7 +693,7 @@ libgnucash/engine/Scrub.c
libgnucash/engine/Split.cpp
libgnucash/engine/SX-book.c
libgnucash/engine/SX-ttinfo.c
-libgnucash/engine/Transaction.c
+libgnucash/engine/Transaction.cpp
libgnucash/engine/TransLog.c
libgnucash/gnc-module/example/gncmod-example.c
libgnucash/gnc-module/gnc-module.c
commit fc5d7f872e00197a79fc7cb262e615a767cc39c6
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Mon Feb 5 21:22:23 2024 +0800
[Split.cpp] convert to cpp
diff --git a/libgnucash/engine/CMakeLists.txt b/libgnucash/engine/CMakeLists.txt
index 6fc7f8b118..46874ad740 100644
--- a/libgnucash/engine/CMakeLists.txt
+++ b/libgnucash/engine/CMakeLists.txt
@@ -147,7 +147,7 @@ set (engine_SOURCES
Scrub3.c
ScrubBusiness.c
ScrubBudget.c
- Split.c
+ Split.cpp
TransLog.c
Transaction.c
cap-gains.c
diff --git a/libgnucash/engine/Split.c b/libgnucash/engine/Split.cpp
similarity index 98%
rename from libgnucash/engine/Split.c
rename to libgnucash/engine/Split.cpp
index 0272b020a5..2da0c51b9f 100644
--- a/libgnucash/engine/Split.c
+++ b/libgnucash/engine/Split.cpp
@@ -242,25 +242,25 @@ gnc_split_set_property(GObject *object,
xaccSplitSetMemo(split, g_value_get_string(value));
break;
case PROP_VALUE:
- number = g_value_get_boxed(value);
+ number = static_cast<gnc_numeric*>(g_value_get_boxed(value));
xaccSplitSetValue(split, *number);
break;
case PROP_AMOUNT:
- number = g_value_get_boxed(value);
+ number = static_cast<gnc_numeric*>(g_value_get_boxed(value));
xaccSplitSetAmount(split, *number);
break;
case PROP_RECONCILE_DATE:
- t = g_value_get_boxed(value);
+ t = static_cast<Time64*>(g_value_get_boxed(value));
xaccSplitSetDateReconciledSecs(split, t->t);
break;
case PROP_TX:
- xaccSplitSetParent(split, g_value_get_object(value));
+ xaccSplitSetParent(split, GNC_TRANSACTION(g_value_get_object(value)));
break;
case PROP_ACCOUNT:
- xaccSplitSetAccount(split, g_value_get_object(value));
+ xaccSplitSetAccount(split, GNC_ACCOUNT(g_value_get_object(value)));
break;
case PROP_LOT:
- xaccSplitSetLot(split, g_value_get_object(value));
+ xaccSplitSetLot(split, GNC_LOT(g_value_get_object(value)));
break;
case PROP_SX_CREDIT_FORMULA:
qof_instance_set_kvp (QOF_INSTANCE (split), value, 2, GNC_SX_ID, GNC_SX_CREDIT_FORMULA);
@@ -532,7 +532,7 @@ xaccMallocSplit(QofBook *book)
Split *split;
g_return_val_if_fail (book, NULL);
- split = g_object_new (GNC_TYPE_SPLIT, NULL);
+ split = GNC_SPLIT(g_object_new (GNC_TYPE_SPLIT, NULL));
xaccInitSplit (split, book);
return split;
@@ -550,7 +550,7 @@ xaccMallocSplit(QofBook *book)
Split *
xaccDupeSplit (const Split *s)
{
- Split *split = g_object_new (GNC_TYPE_SPLIT, NULL);
+ Split *split = GNC_SPLIT(g_object_new (GNC_TYPE_SPLIT, NULL));
/* Trash the entity table. We don't want to mistake the cloned
* splits as something official. If we ever use this split, we'll
@@ -588,7 +588,7 @@ xaccDupeSplit (const Split *s)
Split *
xaccSplitCloneNoKvp (const Split *s)
{
- Split *split = g_object_new (GNC_TYPE_SPLIT, NULL);
+ Split *split = GNC_SPLIT(g_object_new (GNC_TYPE_SPLIT, NULL));
split->parent = NULL;
split->memo = CACHE_INSERT(s->memo);
@@ -2104,7 +2104,7 @@ xaccSplitGetOtherSplit (const Split *split)
for (GList *n = xaccTransGetSplitList (trans); n; n = n->next)
{
- Split *s = n->data;
+ Split *s = GNC_SPLIT(n->data);
if ((s == split) ||
(!xaccTransStillHasSplit(trans, s)) ||
(xaccAccountGetType (xaccSplitGetAccount (s)) == ACCT_TYPE_TRADING) ||
@@ -2203,7 +2203,7 @@ static QofObject split_object_def =
DI(.interface_version = ) QOF_OBJECT_VERSION,
DI(.e_type = ) GNC_ID_SPLIT,
DI(.type_label = ) "Split",
- DI(.create = ) (gpointer)xaccMallocSplit,
+ DI(.create = ) (void* (*)(QofBook*))xaccMallocSplit,
DI(.book_begin = ) NULL,
DI(.book_end = ) NULL,
DI(.is_dirty = ) qof_collection_is_dirty,
@@ -2216,7 +2216,7 @@ static QofObject split_object_def =
static gpointer
split_account_guid_getter (gpointer obj, const QofParam *p)
{
- Split *s = obj;
+ Split *s = GNC_SPLIT(obj);
Account *acc;
if (!s) return NULL;
diff --git a/libgnucash/engine/test/utest-Split.cpp b/libgnucash/engine/test/utest-Split.cpp
index fbf56fa2ed..a1535ba79d 100644
--- a/libgnucash/engine/test/utest-Split.cpp
+++ b/libgnucash/engine/test/utest-Split.cpp
@@ -35,7 +35,7 @@
#include <gnc-lot.h>
#include <gnc-event.h>
-#if defined(__clang__) && (__clang_major__ == 5 || (__clang_major__ == 3 && __clang_minor__ < 5))
+#if defined(__clang__)
#define USE_CLANG_FUNC_SIG 1
#endif
@@ -1282,7 +1282,7 @@ test_get_corr_account_split (Fixture *fixture, gconstpointer pData)
#ifdef USE_CLANG_FUNC_SIG
#define _func "gboolean get_corr_account_split(const Split *, const Split **)"
#else
-#define _func "get_corr_account_split"
+#define _func "gboolean get_corr_account_split(const Split*, const Split**)"
#endif
gchar *msg = _func ": assertion 'sa' failed";
#undef _func
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 94fbc6f70a..f41b3ab493 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -690,7 +690,7 @@ libgnucash/engine/Scrub3.c
libgnucash/engine/ScrubBudget.c
libgnucash/engine/ScrubBusiness.c
libgnucash/engine/Scrub.c
-libgnucash/engine/Split.c
+libgnucash/engine/Split.cpp
libgnucash/engine/SX-book.c
libgnucash/engine/SX-ttinfo.c
libgnucash/engine/Transaction.c
Summary of changes:
libgnucash/engine/CMakeLists.txt | 8 +-
libgnucash/engine/{Recurrence.c => Recurrence.cpp} | 18 ++---
libgnucash/engine/{Split.c => Split.cpp} | 24 +++---
.../engine/{Transaction.c => Transaction.cpp} | 87 ++++++++++------------
libgnucash/engine/{gnc-lot.c => gnc-lot.cpp} | 14 ++--
libgnucash/engine/test/utest-Account.cpp | 6 +-
libgnucash/engine/test/utest-Split.cpp | 4 +-
libgnucash/engine/test/utest-Transaction.cpp | 6 +-
po/POTFILES.in | 8 +-
9 files changed, 84 insertions(+), 91 deletions(-)
rename libgnucash/engine/{Recurrence.c => Recurrence.cpp} (98%)
rename libgnucash/engine/{Split.c => Split.cpp} (98%)
rename libgnucash/engine/{Transaction.c => Transaction.cpp} (97%)
rename libgnucash/engine/{gnc-lot.c => gnc-lot.cpp} (98%)
More information about the gnucash-changes
mailing list