summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xacprep15
-rw-r--r--src/numerics/amount.cc10
-rw-r--r--src/numerics/commodity.cc19
-rw-r--r--src/numerics/commodity.h16
4 files changed, 25 insertions, 35 deletions
diff --git a/acprep b/acprep
index effbeb3b..80761626 100755
--- a/acprep
+++ b/acprep
@@ -1,7 +1,5 @@
#!/bin/sh
-PYTHON_HOME="/Library/Frameworks/Python.framework/Versions/2.5"
-
# acprep, version 3.0
#
# This script configures my ledger source tree on my Mac OS/X machine.
@@ -18,13 +16,14 @@ fi
autoreconf --force --install
-INCDIRS="-I/usr/local/include"
-INCDIRS="$INCDIRS -I/usr/local/include/boost"
-INCDIRS="$INCDIRS -I/sw/include"
-INCDIRS="$INCDIRS -I/usr/include/httpd/xml"
+INCDIRS="-I/sw/include"
+INCDIRS="$INCDIRS -I/usr/local/include"
+
+LIBDIRS="-L/sw/lib"
+LIBDIRS="$LIBDIRS -L/usr/local/lib"
+
+PYTHON_HOME="/Library/Frameworks/Python.framework/Versions/2.5"
-LIBDIRS="-L/usr/local/lib"
-LIBDIRS="$LIBDIRS -L/sw/lib"
SYSTEM=`uname -s`
diff --git a/src/numerics/amount.cc b/src/numerics/amount.cc
index 7bc2841c..c7139052 100644
--- a/src/numerics/amount.cc
+++ b/src/numerics/amount.cc
@@ -770,7 +770,7 @@ void amount_t::annotate_commodity(const annotation_t& details)
throw_(amount_error, "Cannot annotate an amount with no commodity");
if (commodity().annotated) {
- this_ann = &commodity().as_annotated();
+ this_ann = &as_annotated_commodity(commodity());
this_base = &this_ann->referent();
} else {
this_base = &commodity();
@@ -797,7 +797,7 @@ bool amount_t::commodity_annotated() const
throw_(amount_error,
"Cannot determine if an uninitialized amount's commodity is annotated");
- assert(! commodity().annotated || commodity().as_annotated().details);
+ assert(! commodity().annotated || as_annotated_commodity(commodity()).details);
return commodity().annotated;
}
@@ -807,10 +807,10 @@ annotation_t amount_t::annotation_details() const
throw_(amount_error,
"Cannot return commodity annotation details of an uninitialized amount");
- assert(! commodity().annotated || commodity().as_annotated().details);
+ assert(! commodity().annotated || as_annotated_commodity(commodity()).details);
if (commodity().annotated) {
- annotated_commodity_t& ann_comm(commodity().as_annotated());
+ annotated_commodity_t& ann_comm(as_annotated_commodity(commodity()));
return ann_comm.details;
}
return annotation_t();
@@ -829,7 +829,7 @@ amount_t amount_t::strip_annotations(const bool _keep_price,
return *this;
amount_t t(*this);
- t.set_commodity(commodity().as_annotated().
+ t.set_commodity(as_annotated_commodity(commodity()).
strip_annotations(_keep_price, _keep_date, _keep_tag));
return t;
}
diff --git a/src/numerics/commodity.cc b/src/numerics/commodity.cc
index 589ddd05..76614f92 100644
--- a/src/numerics/commodity.cc
+++ b/src/numerics/commodity.cc
@@ -123,18 +123,6 @@ commodity_t::operator bool() const
return this != parent().null_commodity;
}
-annotated_commodity_t& commodity_t::as_annotated()
-{
- assert(annotated);
- return downcast<annotated_commodity_t>(*this);
-}
-
-const annotated_commodity_t& commodity_t::as_annotated() const
-{
- assert(annotated);
- return downcast<const annotated_commodity_t>(*this);
-}
-
bool commodity_t::symbol_needs_quotes(const string& symbol)
{
for (const char * p = symbol.c_str(); *p; p++)
@@ -302,7 +290,7 @@ bool annotated_commodity_t::operator==(const commodity_t& comm) const
if (! comm.annotated)
return false;
- if (details != comm.as_annotated().details)
+ if (details != as_annotated_commodity(comm).details)
return false;
return true;
@@ -540,8 +528,7 @@ commodity_pool_t::find(const string& symbol, const annotation_t& details)
string name = make_qualified_name(*comm, details);
if (commodity_t * ann_comm = find(name)) {
- assert(ann_comm->annotated &&
- ann_comm->as_annotated().details);
+ assert(ann_comm->annotated && as_annotated_commodity(*ann_comm).details);
return ann_comm;
}
return NULL;
@@ -602,7 +589,7 @@ commodity_t * commodity_pool_t::find_or_create(commodity_t& comm,
assert(! name.empty());
if (commodity_t * ann_comm = find(name)) {
- assert(ann_comm->annotated && ann_comm->as_annotated().details);
+ assert(ann_comm->annotated && as_annotated_commodity(*ann_comm).details);
return ann_comm;
}
return create(comm, details, name);
diff --git a/src/numerics/commodity.h b/src/numerics/commodity.h
index 5389ed46..767023e8 100644
--- a/src/numerics/commodity.h
+++ b/src/numerics/commodity.h
@@ -39,14 +39,11 @@
* This file contains one of the most basic types in Ledger:
* commodity_t, and its annotated cousin, annotated_commodity_t.
*/
-
#ifndef _COMMODITY_H
#define _COMMODITY_H
namespace ledger {
-class annotated_commodity_t;
-
class commodity_t
: public delegates_flags<>,
public equality_comparable1<commodity_t, noncopyable>
@@ -128,9 +125,6 @@ public:
return *parent_;
}
- annotated_commodity_t& as_annotated();
- const annotated_commodity_t& as_annotated() const;
-
string base_symbol() const {
return base->symbol;
}
@@ -297,6 +291,16 @@ public:
const annotation_t& info);
};
+inline annotated_commodity_t&
+as_annotated_commodity(commodity_t& commodity) {
+ return downcast<annotated_commodity_t>(commodity);
+}
+inline const annotated_commodity_t&
+as_annotated_commodity(const commodity_t& commodity) {
+ return downcast<const annotated_commodity_t>(commodity);
+}
+
+
struct compare_amount_commodities {
bool operator()(const amount_t * left, const amount_t * right) const;
};