From e62e56c1c3120c6272ab30dbf3b5aa00f06638d4 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Sat, 19 Nov 2011 22:42:02 +0000 Subject: [PATCH] [Cruft Reduction] Remove unused functions in src/engine -- reprise Delete a bunch more functions left commented out from r21579 Remove references to deleted functions from gnucash_core.py git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21587 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/engine/Account.c | 113 +------------------ src/engine/Account.h | 70 +----------- src/engine/Split.c | 63 ----------- src/engine/gncEmployee.c | 14 --- src/engine/gncJob.c | 14 --- src/engine/gncVendor.c | 14 --- src/engine/test/utest-Account.c | 13 +-- src/optional/python-bindings/gnucash_core.py | 5 +- 8 files changed, 8 insertions(+), 298 deletions(-) diff --git a/src/engine/Account.c b/src/engine/Account.c index 87a241eb3d..9c6db66115 100644 --- a/src/engine/Account.c +++ b/src/engine/Account.c @@ -1504,14 +1504,6 @@ xaccAccountEqual(const Account *aa, const Account *ab, gboolean check_guids) /********************************************************************\ \********************************************************************/ -/* -gboolean -gnc_account_get_sort_dirty (Account *acc) -{ - g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE); - return GET_PRIVATE(acc)->sort_dirty; -} -*/ void gnc_account_set_sort_dirty (Account *acc) { @@ -1525,14 +1517,7 @@ gnc_account_set_sort_dirty (Account *acc) priv = GET_PRIVATE(acc); priv->sort_dirty = TRUE; } -/* -gboolean -gnc_account_get_balance_dirty (Account *acc) -{ - g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE); - return GET_PRIVATE(acc)->balance_dirty; -} -*/ + void gnc_account_set_balance_dirty (Account *acc) { @@ -1549,21 +1534,7 @@ gnc_account_set_balance_dirty (Account *acc) /********************************************************************\ \********************************************************************/ -/* -gboolean -gnc_account_find_split (Account *acc, Split *s) -{ - AccountPrivate *priv; - GList *node; - g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE); - g_return_val_if_fail(GNC_IS_SPLIT(s), FALSE); - - priv = GET_PRIVATE(acc); - node = g_list_find(priv->splits, s); - return node ? TRUE : FALSE; -} -*/ gboolean gnc_account_insert_split (Account *acc, Split *s) { @@ -1682,15 +1653,7 @@ xaccAccountLookup (const GncGUID *guid, QofBook *book) /********************************************************************\ \********************************************************************/ -/* -short -xaccAccountGetMark (const Account *acc) -{ - g_return_val_if_fail(GNC_IS_ACCOUNT(acc), 0); - return GET_PRIVATE(acc)->mark; -} -*/ void xaccAccountSetMark (Account *acc, short m) { @@ -2812,30 +2775,7 @@ gnc_account_foreach_child (const Account *acc, thunk (node->data, user_data); } } -/* -gpointer -gnc_account_foreach_child_until (const Account *acc, - AccountCb2 thunk, - gpointer user_data) -{ - const AccountPrivate *priv; - GList *node; - gpointer result; - g_return_val_if_fail(GNC_IS_ACCOUNT(acc), NULL); - g_return_val_if_fail(thunk, NULL); - - priv = GET_PRIVATE(acc); - for (node = priv->children; node; node = node->next) - { - result = thunk (node->data, user_data); - if (result) - return(result); - } - - return NULL; -} -*/ void gnc_account_foreach_descendant (const Account *acc, AccountCb thunk, @@ -3036,15 +2976,6 @@ xaccAccountGetCommodity (const Account *acc) /********************************************************************\ \********************************************************************/ -/* -gnc_numeric -gnc_account_get_start_balance (Account *acc) -{ - g_return_val_if_fail(GNC_IS_ACCOUNT(acc), gnc_numeric_zero()); - - return GET_PRIVATE(acc)->starting_balance; -} -*/ void gnc_account_set_start_balance (Account *acc, const gnc_numeric start_baln) { @@ -3056,15 +2987,7 @@ gnc_account_set_start_balance (Account *acc, const gnc_numeric start_baln) priv->starting_balance = start_baln; priv->balance_dirty = TRUE; } -/* -gnc_numeric -gnc_account_get_start_cleared_balance (Account *acc) -{ - g_return_val_if_fail(GNC_IS_ACCOUNT(acc), gnc_numeric_zero()); - return GET_PRIVATE(acc)->starting_cleared_balance; -} -*/ void gnc_account_set_start_cleared_balance (Account *acc, const gnc_numeric start_baln) @@ -3077,15 +3000,7 @@ gnc_account_set_start_cleared_balance (Account *acc, priv->starting_cleared_balance = start_baln; priv->balance_dirty = TRUE; } -/* -gnc_numeric -gnc_account_get_start_reconciled_balance (Account *acc) -{ - g_return_val_if_fail(GNC_IS_ACCOUNT(acc), gnc_numeric_zero()); - return GET_PRIVATE(acc)->starting_reconciled_balance; -} -*/ void gnc_account_set_start_reconciled_balance (Account *acc, const gnc_numeric start_baln) @@ -3993,24 +3908,6 @@ xaccAccountGetTypeStr(GNCAccountType type) if (type < 0 || NUM_ACCOUNT_TYPES <= type ) return ""; return _(account_type_name [type]); } -/* -GNCAccountType -xaccAccountGetTypeFromStr (const gchar *str) -{ - gint type; - - for (type = 0; type < NUM_ACCOUNT_TYPES; type++) - { - if (!safe_strcmp (str, _(account_type_name [type]))) - return type; - } - - PERR("asked to translate unknown account type string %s.\n", - str ? str : "(null)"); - - return ACCT_TYPE_INVALID; -} -*/ /********************************************************************\ \********************************************************************/ @@ -4633,15 +4530,7 @@ xaccTransactionTraverse (Transaction *trans, int stage) return FALSE; } -/* -gboolean -xaccSplitTransactionTraverse (Split *split, int stage) -{ - if (split == NULL) return FALSE; - return xaccTransactionTraverse (split->parent, stage); -} -*/ static void do_one_split (Split *s, gpointer data) { Transaction *trans = s->parent; diff --git a/src/engine/Account.h b/src/engine/Account.h index 421fd6a7b5..8dc69ad2f6 100644 --- a/src/engine/Account.h +++ b/src/engine/Account.h @@ -350,16 +350,6 @@ void gnc_account_set_balance_dirty (Account *acc); * @param acc Set the flag on this account. */ void gnc_account_set_sort_dirty (Account *acc); -/** Find the given split in an account. - * - * @param acc The account whose splits are to be searched. - * - * @param s The split to be found. - * - * @result TRUE is the split is found in the accounts list of splits. - * FALSE otherwise. -gboolean gnc_account_find_split (Account *acc, Split *s); -*/ /** Insert the given split from an account. * * @param acc The account to which the split should be added. @@ -400,35 +390,7 @@ const char * xaccAccountGetNotes (const Account *account); const char * xaccAccountGetLastNum (const Account *account); /** Get the account's lot order policy */ GNCPolicy *gnc_account_get_policy (Account *account); -/** Retrieve the starting commodity balance for this account. -gnc_numeric gnc_account_get_start_balance (Account *acc); -*/ -/** Retrieve the starting cleared commodity balance for this - * account. -gnc_numeric gnc_account_get_start_cleared_balance (Account *acc); -*/ -/** Retrieve the starting reconciled commodity balance for this - * account. -gnc_numeric gnc_account_get_start_reconciled_balance (Account *acc); -*/ -/** Get an indication of whether the account believes that the running - * balances may be incorrect and need to be recomputed. - * - * @param acc Retrieve the flag on this account. - * - * @return TRUE if the running account balances need to be recomputed. - * FALSE if they are correct. -gboolean gnc_account_get_balance_dirty (Account *acc); -*/ -/** Get an indication of whether the account believes that the splits - * may be incorrectly sorted and need to be resorted. - * - * @param acc Retrieve the flag on this account. - * - * @return TRUE if the splits in the account need to be resorted. - * FALSE if the sort order is correct. -gboolean gnc_account_get_sort_dirty (Account *acc); -*/ + /** The following recompute the partial balances (stored with the * transaction) and the total balance, for this account */ @@ -822,25 +784,6 @@ gint gnc_account_get_tree_depth (const Account *account); void gnc_account_foreach_child (const Account *account, AccountCb func, /*@ null @*/ gpointer user_data); -/** This method will traverse the immediate children of this accounts, - * calling 'func' on each account. Traversal will stop when func - * returns a non-null value, and the routine will return with that - * value. Therefore, this function will return null if func returns - * null for every account. For a simpler function that always - * traverses all children nodes, use the gnc_account_foreach_child() - * function. - * - * @param account A pointer to the account on whose children the - * function should be called. - * - * @param func A function taking two arguments, an Account and a - * gpointer. - * - * @param user_data This data will be passed to each call of func. -gpointer gnc_account_foreach_child_until (const Account *account, - AccountCb2 func, gpointer user_data); -*/ - /** This method will traverse all children of this accounts and their * descendants, calling 'func' on each account. This function * traverses all descendant nodes. To traverse only a subset of the @@ -973,11 +916,7 @@ GNCAccountType xaccAccountStringToEnum (const char* str); * use in the GUI/Interface. These strings should be translated * to the local language. */ const char * xaccAccountGetTypeStr (GNCAccountType type); -/** The xaccAccountGetTypeStr() routine returns a string suitable for - * use in the GUI/Interface. These strings should be translated - * to the local language. -GNCAccountType xaccAccountGetTypeFromStr (const gchar *str); -*/ + /** Return the bitmask of parent account types compatible with a given type. */ guint32 xaccParentAccountTypesCompatibleWith (GNCAccountType type); @@ -1325,11 +1264,6 @@ void xaccAccountBeginStagedTransactionTraversals(const Account *account); */ gboolean xaccTransactionTraverse(Transaction *trans, int stage); -/** xaccSplitTransactionTraverse() behaves as above using the parent of - * the given split. - * -gboolean xaccSplitTransactionTraverse(Split *split, int stage); -*/ /** xaccAccountStagedTransactionTraversal() calls @a thunk on each * transaction in account @a a whose current marker is less than the * given @a stage and updates each transaction's marker to be @a stage. diff --git a/src/engine/Split.c b/src/engine/Split.c index c47fd1df99..25826f1e69 100644 --- a/src/engine/Split.c +++ b/src/engine/Split.c @@ -1135,69 +1135,6 @@ xaccSplitGetBaseValue (const Split *s, const gnc_commodity * base_currency) /********************************************************************\ \********************************************************************/ -/* gnc_numeric */ -/* xaccSplitsComputeValue (GList *splits, const Split * skip_me, */ -/* const gnc_commodity * base_currency) */ -/* { */ -/* GList *node; */ -/* gnc_numeric value = gnc_numeric_zero(); */ - -/* g_return_val_if_fail (base_currency, value); */ - -/* ENTER (" currency=%s", gnc_commodity_get_mnemonic (base_currency)); */ - -/* for (node = splits; node; node = node->next) */ -/* { */ -/* const Split *s = node->data; */ -/* const gnc_commodity *currency; */ -/* const gnc_commodity *commodity; */ - -/* if (s == skip_me) continue; */ - -/* /\* value = gnc_numeric_add(value, xaccSplitGetBaseValue(s, base_currency), */ -/* GNC_DENOM_AUTO, GNC_HOW_DENOM_LCD); *\/ */ - -/* /\* The split-editor often sends us 'temp' splits whose account */ -/* * hasn't yet been set. Be lenient, and assume an implied base */ -/* * currency. If there's a problem later, the scrub routines will */ -/* * pick it up. */ -/* *\/ */ -/* commodity = s->acc ? xaccAccountGetCommodity (s->acc) : base_currency; */ -/* currency = xaccTransGetCurrency (s->parent); */ - - -/* if (gnc_commodity_equiv(currency, base_currency)) */ -/* { */ -/* value = gnc_numeric_add(value, xaccSplitGetValue(s), */ -/* GNC_DENOM_AUTO, GNC_HOW_DENOM_LCD); */ -/* } */ -/* else if (gnc_commodity_equiv(commodity, base_currency)) */ -/* { */ -/* value = gnc_numeric_add(value, xaccSplitGetAmount(s), */ -/* GNC_DENOM_AUTO, GNC_HOW_DENOM_LCD); */ -/* } */ -/* else */ -/* { */ -/* PERR ("inconsistent currencies\n" */ -/* "\tbase = '%s', curr='%s', sec='%s'\n", */ -/* gnc_commodity_get_printname(base_currency), */ -/* gnc_commodity_get_printname(currency), */ -/* gnc_commodity_get_printname(commodity)); */ -/* g_return_val_if_fail (FALSE, value); */ -/* } */ -/* } */ - -/* /\* Note that just because the currencies are equivalent */ -/* * doesn't mean the denominators are the same! *\/ */ -/* value = gnc_numeric_convert(value, */ -/* gnc_commodity_get_fraction (base_currency), */ -/* GNC_HOW_RND_ROUND_HALF_UP); */ - -/* LEAVE (" total=%" G_GINT64_FORMAT "/%" G_GINT64_FORMAT, */ -/* value.num, value.denom); */ -/* return value; */ -/* } */ - gnc_numeric xaccSplitConvertAmount (const Split *split, const Account * account) { diff --git a/src/engine/gncEmployee.c b/src/engine/gncEmployee.c index 227f046c79..d5d2dde520 100644 --- a/src/engine/gncEmployee.c +++ b/src/engine/gncEmployee.c @@ -146,20 +146,6 @@ gnc_employee_set_property (GObject *object, } } -/** Get displayable name */ -/* -static gchar* -impl_get_display_name(const QofInstance* inst) -{ - GncEmployee* emp; - - g_return_val_if_fail(inst != NULL, FALSE); - g_return_val_if_fail(GNC_IS_EMPLOYEE(inst), FALSE); - - emp = GNC_EMPLOYEE(inst); - return g_strdup_printf("Employee %s", emp->username); -} -*/ /** Does this object refer to a specific object */ static gboolean impl_refers_to_object(const QofInstance* inst, const QofInstance* ref) diff --git a/src/engine/gncJob.c b/src/engine/gncJob.c index dddaf3d611..9463169f87 100644 --- a/src/engine/gncJob.c +++ b/src/engine/gncJob.c @@ -483,20 +483,6 @@ destroy_job_on_book_close(QofInstance *ent, gpointer data) gncJobFree(job); } -/** Handles book end - frees all jobs from the book - * - * @param book Book being closed - */ -/* -static void -gnc_job_book_end(QofBook* book) -{ - QofCollection *col; - - col = qof_book_get_collection(book, GNC_ID_JOB); - qof_collection_foreach(col, destroy_job_on_book_close, NULL); -} -*/ static QofObject gncJobDesc = { DI(.interface_version = ) QOF_OBJECT_VERSION, diff --git a/src/engine/gncVendor.c b/src/engine/gncVendor.c index e271b5115a..9e48fac418 100644 --- a/src/engine/gncVendor.c +++ b/src/engine/gncVendor.c @@ -152,20 +152,6 @@ gnc_vendor_set_property (GObject *object, } } -/** Return displayable name */ -/* -static gchar* -impl_get_display_name(const QofInstance* inst) -{ - GncVendor* v; - - g_return_val_if_fail(inst != NULL, FALSE); - g_return_val_if_fail(GNC_IS_VENDOR(inst), FALSE); - - v = GNC_VENDOR(inst); - return g_strdup_printf("Vendor %s", v->name); -} -*/ /** Does this object refer to a specific object */ static gboolean impl_refers_to_object(const QofInstance* inst, const QofInstance* ref) diff --git a/src/engine/test/utest-Account.c b/src/engine/test/utest-Account.c index 8ae12a1d53..b68042ee15 100644 --- a/src/engine/test/utest-Account.c +++ b/src/engine/test/utest-Account.c @@ -974,7 +974,8 @@ test_xaccAccountEqual (Fixture *fixture, gconstpointer pData) gnc_account_set_balance_dirty */ /* gnc_account_find_split *** Test Only *** -/ * gnc_account_insert_split + */ +/* gnc_account_insert_split gboolean gnc_account_insert_split (Account *acc, Split *s)// C: 5 in 3 @@ -1715,11 +1716,8 @@ test_gnc_account_foreach_descendant_until (Fixture *fixture, gconstpointer pData * xaccAccountGetColor * xaccAccountGetNotes * xaccAccountGetCommodity - * gnc_account_get_start_balance *** Test Only *** * gnc_account_set_start_balance - * gnc_account_get_start_cleared_balance *** Test Only *** * gnc_account_set_start_cleared_balance - * gnc_account_get_start_reconciled_balance *** Test Only *** * gnc_account_set_start_reconciled_balance * xaccAccountGetBalance * xaccAccountGetClearedBalance C: 1 @@ -1977,8 +1975,7 @@ test_xaccAccountHasAncestor (Fixture *fixture, gconstpointer pData) /* xaccAccountTypeEnumAsString * xaccAccountStringToType * xaccAccountStringToEnum - * xaccAccountGetTypeStr *** Not Used *** - * xaccAccountGetTypeFromStr *** Test Only *** + * xaccAccountGetTypeStr * xaccAccountIsPriced const char * xaccAccountTypeEnumAsString (GNCAccountType type)// C: 5 in 3 */ @@ -2030,7 +2027,6 @@ test_xaccAccountType_Stuff (void) } else g_assert_cmpstr (typestr_uc, ==, typename); -// g_assert_cmpint (xaccAccountGetTypeFromStr (typestr), ==, type); g_free (typestr_uc); g_object_set (acc, "type", type, NULL); @@ -2163,7 +2159,7 @@ test_xaccAccountType_Compatibility (void) */ /* finder_help_function static void -finder_help_function (const Account *acc, const char *descrption,// 3 +finder_help_function (const Account *acc, const char *description,// 3 Helper function, fully exercised by the following two public functions */ /* xaccAccountFindSplitByDesc @@ -2404,7 +2400,6 @@ test_suite_account (void) GNC_TEST_ADD (suitename, "gnc account lookup by full name helper", Fixture, &complex, setup, test_gnc_account_lookup_by_full_name_helper, teardown ); GNC_TEST_ADD (suitename, "gnc account lookup by full name", Fixture, &complex, setup, test_gnc_account_lookup_by_full_name, teardown ); GNC_TEST_ADD (suitename, "gnc account foreach child", Fixture, &complex, setup, test_gnc_account_foreach_child, teardown ); -// GNC_TEST_ADD (suitename, "gnc account foreach child until", Fixture, &complex, setup, test_gnc_account_foreach_child_until, teardown ); GNC_TEST_ADD (suitename, "gnc account foreach descendant", Fixture, &complex, setup, test_gnc_account_foreach_descendant, teardown ); GNC_TEST_ADD (suitename, "gnc account foreach descendant until", Fixture, &complex, setup, test_gnc_account_foreach_descendant_until, teardown ); GNC_TEST_ADD (suitename, "gnc account get full name", Fixture, &good_data, setup, test_gnc_account_get_full_name, teardown ); diff --git a/src/optional/python-bindings/gnucash_core.py b/src/optional/python-bindings/gnucash_core.py index b768ca9344..8bab7152fa 100644 --- a/src/optional/python-bindings/gnucash_core.py +++ b/src/optional/python-bindings/gnucash_core.py @@ -315,7 +315,6 @@ PriceDB_dict = { 'lookup_latest_before' : GncPrice, 'convert_balance_latest_price' : GncNumeric, 'convert_balance_nearest_price' : GncNumeric, - 'convert_balance_latest_before' : GncNumeric, } methods_return_instance(GncPriceDB,PriceDB_dict) GncPriceDB.get_prices = method_function_returns_instance_list( @@ -615,8 +614,6 @@ account_dict = { 'lookup_by_full_name' : Account, 'FindTransByDesc' : Transaction, 'FindSplitByDesc' : Split, - 'get_start_balance' : GncNumeric, - 'get_start_cleared_balance' : GncNumeric, 'GetBalance' : GncNumeric, 'GetClearedBalance' : GncNumeric, 'GetReconciledBalance' : GncNumeric, @@ -666,4 +663,4 @@ from gnucash_core_c import \ class Query(GnuCashCoreClass): pass -Query.add_constructor_and_methods_with_prefix('qof_query_', 'create') \ No newline at end of file +Query.add_constructor_and_methods_with_prefix('qof_query_', 'create')