From 230e03166f061387e7e25591bd2df6acad4195ee Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Wed, 2 May 2007 03:04:20 +0000 Subject: In the middle of switching to using boost/operators.hpp --- src/py_amount.cc | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'src/py_amount.cc') diff --git a/src/py_amount.cc b/src/py_amount.cc index 059322f1..e26ba35e 100644 --- a/src/py_amount.cc +++ b/src/py_amount.cc @@ -55,6 +55,21 @@ commodity_t * py_find_commodity(const string& symbol) EXC_TRANSLATOR(amount_error) +namespace { + template + amount_t operator+(const amount_t& amt, const T val) { + amount_t temp(amt); + temp += amount_t(val); + return temp; + } + template + amount_t operator+(const T val, const amount_t& amt) { + amount_t temp(val); + temp += amt; + return temp; + } +} + void export_amount() { scope().attr("AMOUNT_PARSE_NO_MIGRATE") = AMOUNT_PARSE_NO_MIGRATE; @@ -72,66 +87,86 @@ void export_amount() .def(self += double()) .def(self + self) +#if 0 .def(self + long()) .def(long() + self) .def(self + double()) .def(double() + self) +#endif .def(self -= self) .def(self -= long()) .def(self -= double()) .def(self - self) +#if 0 .def(self - long()) .def(long() - self) .def(self - double()) .def(double() - self) +#endif .def(self *= self) .def(self *= long()) .def(self *= double()) .def(self * self) +#if 0 .def(self * long()) .def(long() * self) .def(self * double()) .def(double() * self) +#endif .def(self /= self) .def(self /= long()) .def(self /= double()) .def(self / self) +#if 0 .def(self / long()) .def(long() / self) .def(self / double()) .def(double() / self) +#endif .def(- self) .def(self < self) +#if 0 .def(self < long()) .def(long() < self) +#endif .def(self <= self) +#if 0 .def(self <= long()) .def(long() <= self) +#endif .def(self > self) +#if 0 .def(self > long()) .def(long() > self) +#endif .def(self >= self) +#if 0 .def(self >= long()) .def(long() >= self) +#endif .def(self == self) +#if 0 .def(self == long()) .def(long() == self) +#endif .def(self != self) +#if 0 .def(self != long()) .def(long() != self) +#endif .def(! self) @@ -166,7 +201,7 @@ void export_amount() .def("compare", &amount_t::compare) .def("date", &amount_t::date) .def("negate", &amount_t::negate) - .def("null", &amount_t::null) + .def("is_null", &amount_t::is_null) .def("parse", py_parse_1) .def("parse", py_parse_2) .def("price", &amount_t::price) -- cgit v1.2.3