summaryrefslogtreecommitdiff
path: root/py_amount.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2007-04-15 11:17:00 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 03:35:32 -0400
commit479dd85da543b7af8e5f888ff2f2beaf6ff6923b (patch)
tree7a447b52ab366c1f5a9399f9365a45b0879305b4 /py_amount.cc
parent0ef82600e5978495cccb4eed63b1de7094deab04 (diff)
downloadfork-ledger-479dd85da543b7af8e5f888ff2f2beaf6ff6923b.tar.gz
fork-ledger-479dd85da543b7af8e5f888ff2f2beaf6ff6923b.tar.bz2
fork-ledger-479dd85da543b7af8e5f888ff2f2beaf6ff6923b.zip
Miscellaneous changes
Diffstat (limited to 'py_amount.cc')
-rw-r--r--py_amount.cc24
1 files changed, 5 insertions, 19 deletions
diff --git a/py_amount.cc b/py_amount.cc
index b4ff21d1..c310bda2 100644
--- a/py_amount.cc
+++ b/py_amount.cc
@@ -41,8 +41,8 @@ commodity_t * py_find_commodity(const std::string& symbol)
}
#define EXC_TRANSLATOR(type) \
- void exc_translate_ ## type(const type& err) { \
- PyErr_SetString(PyExc_RuntimeError, err.what()); \
+ void exc_translate_ ## type(const type * const err) { \
+ PyErr_SetString(PyExc_ArithmeticError, err->what()); \
}
EXC_TRANSLATOR(amount_error)
@@ -59,48 +59,34 @@ void export_amount()
.def(init<char *>())
.def(init<bool>())
.def(init<long>())
- .def(init<unsigned long>())
- .def(init<double>())
.def(self += self)
.def(self += long())
- .def(self += double())
.def(self + self)
.def(self + long())
.def(long() + self)
- .def(self + double())
- .def(double() + self)
.def(self -= self)
.def(self -= long())
- .def(self -= double())
.def(self - self)
.def(self - long())
.def(long() - self)
- .def(self - double())
- .def(double() - self)
.def(self *= self)
.def(self *= long())
- .def(self *= double())
.def(self * self)
.def(self * long())
.def(long() * self)
- .def(self * double())
- .def(double() * self)
.def(self /= self)
.def(self /= long())
- .def(self /= double())
.def(self / self)
.def(self / long())
.def(long() / self)
- .def(self / double())
- .def(double() / self)
.def(- self)
@@ -135,7 +121,8 @@ void export_amount()
.def(self_ns::str(self))
.def(abs(self))
-#if 0
+ .def("__repr__", &amount_t::to_string)
+
.def("has_commodity", &amount_t::has_commodity)
.add_property("commodity",
@@ -165,7 +152,6 @@ void export_amount()
.def("value", &amount_t::value)
.def("valid", &amount_t::valid)
-#endif
;
class_< commodity_base_t::updater_t, commodity_updater_wrap,
@@ -220,7 +206,7 @@ void export_amount()
;
#define EXC_TRANSLATE(type) \
- register_exception_translator<type>(&exc_translate_ ## type);
+ register_exception_translator<type *>(&exc_translate_ ## type);
EXC_TRANSLATE(amount_error);
}