[Gnucash-changes] r12229 - gnucash/trunk/src/engine - Constify some
Split and Transaction functions.
Chris Shoemaker
chris at cvs.gnucash.org
Sat Dec 31 18:36:03 EST 2005
Author: chris
Date: 2005-12-31 18:35:55 -0500 (Sat, 31 Dec 2005)
New Revision: 12229
Trac: http://svn.gnucash.org/trac/changeset/12229
Modified:
gnucash/trunk/src/engine/Transaction.c
gnucash/trunk/src/engine/Transaction.h
gnucash/trunk/src/engine/TransactionP.h
gnucash/trunk/src/engine/cap-gains.c
gnucash/trunk/src/engine/cap-gains.h
Log:
Constify some Split and Transaction functions.
Modified: gnucash/trunk/src/engine/Transaction.c
===================================================================
--- gnucash/trunk/src/engine/Transaction.c 2005-12-31 22:28:42 UTC (rev 12228)
+++ gnucash/trunk/src/engine/Transaction.c 2005-12-31 23:35:55 UTC (rev 12229)
@@ -78,8 +78,8 @@
/* This static indicates the debugging module that this .o belongs to. */
static QofLogModule log_module = GNC_MOD_ENGINE;
-G_INLINE_FUNC void check_open (Transaction *trans);
-void check_open (Transaction *trans)
+G_INLINE_FUNC void check_open (const Transaction *trans);
+void check_open (const Transaction *trans)
{
if (trans && 0 >= trans->inst.editlevel)
{
@@ -152,7 +152,7 @@
*/
static Split *
-xaccDupeSplit (Split *s)
+xaccDupeSplit (const Split *s)
{
Split *split = g_new0 (Split, 1);
@@ -190,7 +190,7 @@
}
static Split *
-xaccSplitClone (Split *s)
+xaccSplitClone (const Split *s)
{
QofCollection *col;
Split *split = g_new0 (Split, 1);
@@ -218,6 +218,7 @@
xaccAccountInsertSplit(s->acc, split);
if (s->lot)
{
+ /* FIXME: Doesn't look right. */
s->lot->splits = g_list_append (s->lot->splits, split);
s->lot->is_closed = -1;
}
@@ -226,7 +227,7 @@
#ifdef DUMP_FUNCTIONS
static void
-xaccSplitDump (Split *split, const char *tag)
+xaccSplitDump (const Split *split, const char *tag)
{
printf(" %s Split %p", tag, split);
printf(" GUID: %s\n", guid_to_string(&split->guid));
@@ -538,8 +539,8 @@
}
}
-G_INLINE_FUNC void gen_event (Split *split);
-void gen_event (Split *split)
+G_INLINE_FUNC void gen_event (const Split *split);
+void gen_event (const Split *split)
{
Account *account = split->acc;
Transaction *trans = split->parent;
@@ -866,7 +867,7 @@
#ifdef DUMP_FUNCTIONS
void
-xaccTransDump (Transaction *trans, const char *tag)
+xaccTransDump (const Transaction *trans, const char *tag)
{
GList *node;
@@ -932,7 +933,7 @@
*/
Transaction *
-xaccDupeTransaction (Transaction *t)
+xaccDupeTransaction (const Transaction *t)
{
Transaction *trans;
GList *node;
@@ -976,7 +977,7 @@
* a full fledged transaction with unique guid, splits, etc.
*/
Transaction *
-xaccTransClone (Transaction *t)
+xaccTransClone (const Transaction *t)
{
Transaction *trans;
Split *split;
@@ -1079,8 +1080,8 @@
static gint
compare_split_guids (gconstpointer a, gconstpointer b)
{
- Split *sa = (Split *) a;
- Split *sb = (Split *) b;
+ const Split *sa = a;
+ const Split *sb = b;
if (sa == sb) return 0;
if (!sa || !sb) return 1;
@@ -1945,7 +1946,7 @@
\********************************************************************/
static void
-xaccTransRemoveSplit (Transaction *trans, Split *split)
+xaccTransRemoveSplit (Transaction *trans, const Split *split)
{
if (trans == NULL)
return;
@@ -2285,7 +2286,7 @@
}
int
-xaccSplitCompareAccountFullNames(Split *sa, Split *sb)
+xaccSplitCompareAccountFullNames(const Split *sa, const Split *sb)
{
Account *aa, *ab;
char *full_a, *full_b;
@@ -2308,7 +2309,7 @@
int
-xaccSplitCompareAccountCodes(Split *sa, Split *sb)
+xaccSplitCompareAccountCodes(const Split *sa, const Split *sb)
{
Account *aa, *ab;
if (!sa && !sb) return 0;
@@ -2322,7 +2323,7 @@
}
int
-xaccSplitCompareOtherAccountFullNames(Split *sa, Split *sb)
+xaccSplitCompareOtherAccountFullNames(const Split *sa, const Split *sb)
{
char *ca, *cb;
int retval;
@@ -2343,7 +2344,7 @@
}
int
-xaccSplitCompareOtherAccountCodes(Split *sa, Split *sb)
+xaccSplitCompareOtherAccountCodes(const Split *sa, const Split *sb)
{
const char *ca, *cb;
if (!sa && !sb) return 0;
@@ -3016,7 +3017,7 @@
\********************************************************************/
Account *
-xaccGetAccountByName (Transaction *trans, const char * name)
+xaccGetAccountByName (const Transaction *trans, const char * name)
{
Account *acc = NULL;
GList *node;
@@ -3043,7 +3044,7 @@
\********************************************************************/
Account *
-xaccGetAccountByFullName (Transaction *trans, const char * name,
+xaccGetAccountByFullName (const Transaction *trans, const char * name,
const char separator)
{
Account *acc = NULL;
Modified: gnucash/trunk/src/engine/Transaction.h
===================================================================
--- gnucash/trunk/src/engine/Transaction.h 2005-12-31 22:28:42 UTC (rev 12228)
+++ gnucash/trunk/src/engine/Transaction.h 2005-12-31 23:35:55 UTC (rev 12229)
@@ -140,7 +140,7 @@
The xaccTransClone() method will create a complete copy of an
existing transaction.
*/
-Transaction * xaccTransClone (Transaction *t);
+Transaction * xaccTransClone (const Transaction *t);
/** Equality.
*
@@ -729,18 +729,18 @@
/** Compare two splits by full name of account. Returns similar to
* strcmp. */
-int xaccSplitCompareAccountFullNames(Split *sa, Split *sb);
+int xaccSplitCompareAccountFullNames(const Split *sa, const Split *sb);
/** Compare two splits by code of account. Returns similar to
* strcmp. */
-int xaccSplitCompareAccountCodes(Split *sa, Split *sb);
+int xaccSplitCompareAccountCodes(const Split *sa, const Split *sb);
/** Compare two splits by full name of the other account. Returns
* similar to strcmp. This function attempts to find the split on the
* other side of a transaction and compare on it. */
-int xaccSplitCompareOtherAccountFullNames(Split *sa, Split *sb);
+int xaccSplitCompareOtherAccountFullNames(const Split *sa, const Split *sb);
/** Compare two splits by code of the other account. Returns similar
* to strcmp. This function attempts to find the split on the
* other side of a transaction and compare on it. */
-int xaccSplitCompareOtherAccountCodes(Split *sa, Split *sb);
+int xaccSplitCompareOtherAccountCodes(const Split *sa, const Split *sb);
/**
@@ -782,10 +782,10 @@
/** The xaccGetAccountByName() is a convenience routine that
* is essentially identical to xaccGetPeerAccountFromName(),
* except that it accepts the handy transaction as root.*/
-Account * xaccGetAccountByName (Transaction *trans, const char *name);
+Account * xaccGetAccountByName (const Transaction *trans, const char *name);
/** The xaccGetAccountByFullName routine is similar to xaccGetAccountByName, but uses
* full names using the given separator.*/
-Account * xaccGetAccountByFullName (Transaction *trans,
+Account * xaccGetAccountByFullName (const Transaction *trans,
const char *name,
const char separator);
Modified: gnucash/trunk/src/engine/TransactionP.h
===================================================================
--- gnucash/trunk/src/engine/TransactionP.h 2005-12-31 22:28:42 UTC (rev 12228)
+++ gnucash/trunk/src/engine/TransactionP.h 2005-12-31 23:35:55 UTC (rev 12229)
@@ -230,7 +230,7 @@
* Another 'feature': the splits point at the old transaction
* as the parent, not the new transaction.
*/
-Transaction * xaccDupeTransaction (Transaction *t);
+Transaction * xaccDupeTransaction (const Transaction *t);
/* Compute the value of a list of splits in the given currency,
* excluding the skip_me split. */
Modified: gnucash/trunk/src/engine/cap-gains.c
===================================================================
--- gnucash/trunk/src/engine/cap-gains.c 2005-12-31 22:28:42 UTC (rev 12228)
+++ gnucash/trunk/src/engine/cap-gains.c 2005-12-31 23:35:55 UTC (rev 12229)
@@ -625,7 +625,7 @@
/* ============================================================== */
Split *
-xaccSplitGetCapGainsSplit (Split *split)
+xaccSplitGetCapGainsSplit (const Split *split)
{
KvpValue *val;
GUID *gains_guid;
Modified: gnucash/trunk/src/engine/cap-gains.h
===================================================================
--- gnucash/trunk/src/engine/cap-gains.h 2005-12-31 22:28:42 UTC (rev 12228)
+++ gnucash/trunk/src/engine/cap-gains.h 2005-12-31 23:35:55 UTC (rev 12229)
@@ -147,9 +147,8 @@
* that records the cap gains for this split. It returns NULL
* if not found. This routine does nothing more than search for
* the split recorded in the KVP key "/gains-split"
- */
-
-Split * xaccSplitGetCapGainsSplit (Split *);
+ */
+Split * xaccSplitGetCapGainsSplit (const Split *);
/** The`xaccSplitAssign() routine will take the indicated
* split and, if it doesn't already belong to a lot, it will attempt
More information about the gnucash-changes
mailing list