From 9088acabd866ee50b1c6c620569368bb46079082 Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Thu, 13 Jan 2022 18:10:38 +0800 Subject: [PATCH] [gnc-budget.cpp] convert to c++ --- libgnucash/engine/CMakeLists.txt | 2 +- libgnucash/engine/{gnc-budget.c => gnc-budget.cpp} | 12 ++++++------ libgnucash/engine/gnc-budget.h | 10 ++++++++++ po/POTFILES.in | 2 +- 4 files changed, 18 insertions(+), 8 deletions(-) rename libgnucash/engine/{gnc-budget.c => gnc-budget.cpp} (98%) diff --git a/libgnucash/engine/CMakeLists.txt b/libgnucash/engine/CMakeLists.txt index d860bd4361..8dde8461bc 100644 --- a/libgnucash/engine/CMakeLists.txt +++ b/libgnucash/engine/CMakeLists.txt @@ -139,7 +139,7 @@ set (engine_SOURCES cap-gains.c cashobjects.c gnc-aqbanking-templates.cpp - gnc-budget.c + gnc-budget.cpp gnc-commodity.c gnc-date.cpp gnc-datetime.cpp diff --git a/libgnucash/engine/gnc-budget.c b/libgnucash/engine/gnc-budget.cpp similarity index 98% rename from libgnucash/engine/gnc-budget.c rename to libgnucash/engine/gnc-budget.cpp index a6e994a15f..47f09e0ff2 100644 --- a/libgnucash/engine/gnc-budget.c +++ b/libgnucash/engine/gnc-budget.cpp @@ -33,6 +33,7 @@ #include "Account.h" +#include "guid.hpp" #include "gnc-budget.h" #include "gnc-commodity.h" @@ -196,7 +197,7 @@ gnc_budget_set_property( GObject* object, gnc_budget_set_num_periods(budget, g_value_get_uint(value)); break; case PROP_RECURRENCE: - gnc_budget_set_recurrence(budget, g_value_get_pointer(value)); + gnc_budget_set_recurrence (budget, static_cast(g_value_get_pointer(value))); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); @@ -311,12 +312,11 @@ gnc_budget_commit_edit(GncBudget *bgt) GncBudget* gnc_budget_new(QofBook *book) { - GncBudget* budget; - g_return_val_if_fail(book, NULL); ENTER(" "); - budget = g_object_new(GNC_TYPE_BUDGET, NULL); + + auto budget { static_cast(g_object_new(GNC_TYPE_BUDGET, nullptr)) }; qof_instance_init_data (&budget->inst, GNC_ID_BUDGET, book); qof_event_gen( &budget->inst, QOF_EVENT_CREATE , NULL); @@ -773,7 +773,7 @@ get_acct_array (const GncBudget *budget, const Account *account) GArray *array; if (!g_hash_table_lookup_extended (priv->acct_hash, account, NULL, - (gpointer) &array)) + (gpointer*)(&array))) { array = g_array_sized_new (FALSE, TRUE, sizeof (PeriodData), priv->num_periods); @@ -879,7 +879,7 @@ static QofObject budget_object_def = DI(.interface_version = ) QOF_OBJECT_VERSION, DI(.e_type = ) GNC_ID_BUDGET, DI(.type_label = ) "Budget", - DI(.create = ) (gpointer)gnc_budget_new, + DI(.create = ) (void*(*)(QofBook*)) gnc_budget_new, DI(.book_begin = ) NULL, DI(.book_end = ) gnc_budget_book_end, DI(.is_dirty = ) qof_collection_is_dirty, diff --git a/libgnucash/engine/gnc-budget.h b/libgnucash/engine/gnc-budget.h index f5b9a2cee2..d9c1e814d5 100644 --- a/libgnucash/engine/gnc-budget.h +++ b/libgnucash/engine/gnc-budget.h @@ -64,6 +64,11 @@ #ifndef __GNC_BUDGET_H__ #define __GNC_BUDGET_H__ +#ifdef __cplusplus +extern "C" +{ +#endif + #include /** The budget data.*/ @@ -171,6 +176,11 @@ GncBudget* gnc_budget_get_default(QofBook *book); GncBudget* gnc_budget_lookup (const GncGUID *guid, const QofBook *book); #define gnc_budget_lookup_direct(g,b) gnc_budget_lookup(&(g),(b)) +#ifdef __cplusplus +} +#endif + + #endif // __BUDGET_H__ /** @} */ diff --git a/po/POTFILES.in b/po/POTFILES.in index 365d56798f..2194e9e5e3 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -630,7 +630,7 @@ libgnucash/engine/engine-helpers.c libgnucash/engine/gncAddress.c libgnucash/engine/gnc-aqbanking-templates.cpp libgnucash/engine/gncBillTerm.c -libgnucash/engine/gnc-budget.c +libgnucash/engine/gnc-budget.cpp libgnucash/engine/gncBusiness.c libgnucash/engine/gnc-commodity.c libgnucash/engine/gnc-commodity.h