summaryrefslogtreecommitdiff
path: root/amount.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2006-02-15 20:10:49 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 02:41:21 -0400
commitce3491c99f089874725999ca6d8b1fb6a15c9e5e (patch)
treec48a2bf19a954c8103a02e26f9a1a490b8095268 /amount.cc
parent2eafddc91b8d7f0b7bdfd991acdc9e0b2295e304 (diff)
downloadfork-ledger-ce3491c99f089874725999ca6d8b1fb6a15c9e5e.tar.gz
fork-ledger-ce3491c99f089874725999ca6d8b1fb6a15c9e5e.tar.bz2
fork-ledger-ce3491c99f089874725999ca6d8b1fb6a15c9e5e.zip
Removed Python integration support.
Diffstat (limited to 'amount.cc')
-rw-r--r--amount.cc165
1 files changed, 0 insertions, 165 deletions
diff --git a/amount.cc b/amount.cc
index a5ef1720..1f8aa6d1 100644
--- a/amount.cc
+++ b/amount.cc
@@ -1245,168 +1245,3 @@ amount_t commodity_t::value(const std::time_t moment)
}
} // namespace ledger
-
-#ifdef USE_BOOST_PYTHON
-
-#include <boost/python.hpp>
-#include <Python.h>
-
-using namespace boost::python;
-using namespace ledger;
-
-void py_parse_1(amount_t& amount, const std::string& str,
- unsigned short flags) {
- amount.parse(str, flags);
-}
-void py_parse_2(amount_t& amount, const std::string& str) {
- amount.parse(str);
-}
-
-struct commodity_updater_wrap : public commodity_t::updater_t
-{
- PyObject * self;
- commodity_updater_wrap(PyObject * self_) : self(self_) {}
-
- virtual void operator()(commodity_t& commodity,
- const std::time_t moment,
- const std::time_t date,
- const std::time_t last,
- amount_t& price) {
- call_method<void>(self, "__call__", commodity, moment, date, last, price);
- }
-};
-
-commodity_t * py_find_commodity_1(const std::string& symbol)
-{
- return commodity_t::find_commodity(symbol);
-}
-
-commodity_t * py_find_commodity_2(const std::string& symbol, bool auto_create)
-{
- return commodity_t::find_commodity(symbol, auto_create);
-}
-
-#define EXC_TRANSLATOR(type) \
- void exc_translate_ ## type(const type& err) { \
- PyErr_SetString(PyExc_RuntimeError, err.what()); \
- }
-
-EXC_TRANSLATOR(amount_error)
-
-void export_amount()
-{
- scope().attr("AMOUNT_PARSE_NO_MIGRATE") = AMOUNT_PARSE_NO_MIGRATE;
- scope().attr("AMOUNT_PARSE_NO_REDUCE") = AMOUNT_PARSE_NO_REDUCE;
-
- class_< amount_t > ("Amount")
- .def(init<amount_t>())
- .def(init<std::string>())
- .def(init<char *>())
- .def(init<bool>())
- .def(init<long>())
- .def(init<unsigned long>())
- .def(init<double>())
-
- .def("commodity", &amount_t::commodity,
- return_value_policy<reference_existing_object>())
- .def("set_commodity", &amount_t::set_commodity)
- .def("clear_commodity", &amount_t::clear_commodity)
- .def("quantity_string", &amount_t::quantity_string)
-
- .def(self += self)
- .def(self += long())
- .def(self + self)
- .def(self + long())
- .def(self -= self)
- .def(self -= long())
- .def(self - self)
- .def(self - long())
- .def(self *= self)
- .def(self *= long())
- .def(self * self)
- .def(self * long())
- .def(self /= self)
- .def(self /= long())
- .def(self / self)
- .def(self / long())
- .def(- self)
-
- .def(self < self)
- .def(self < long())
- .def(self <= self)
- .def(self <= long())
- .def(self > self)
- .def(self > long())
- .def(self >= self)
- .def(self >= long())
- .def(self == self)
- .def(self == long())
- .def(self != self)
- .def(self != long())
- .def(! self)
-
- .def(self_ns::int_(self))
- .def(self_ns::float_(self))
- .def(self_ns::str(self))
- .def(abs(self))
-
- .def("negate", &amount_t::negate)
- .def("parse", py_parse_1)
- .def("parse", py_parse_2)
- .def("reduce", &amount_t::reduce)
- .def("valid", &amount_t::valid)
- ;
-
- class_< commodity_t::updater_t, commodity_updater_wrap, boost::noncopyable >
- ("Updater")
- ;
-
- scope().attr("COMMODITY_STYLE_DEFAULTS") = COMMODITY_STYLE_DEFAULTS;
- scope().attr("COMMODITY_STYLE_SUFFIXED") = COMMODITY_STYLE_SUFFIXED;
- scope().attr("COMMODITY_STYLE_SEPARATED") = COMMODITY_STYLE_SEPARATED;
- scope().attr("COMMODITY_STYLE_EUROPEAN") = COMMODITY_STYLE_EUROPEAN;
- scope().attr("COMMODITY_STYLE_THOUSANDS") = COMMODITY_STYLE_THOUSANDS;
- scope().attr("COMMODITY_STYLE_NOMARKET") = COMMODITY_STYLE_NOMARKET;
- scope().attr("COMMODITY_STYLE_VARIABLE") = COMMODITY_STYLE_VARIABLE;
-
- class_< commodity_t > ("Commodity")
- .def(init<std::string, optional<unsigned int, unsigned int> >())
-
- .def_readonly("symbol", &commodity_t::symbol)
- .def("set_symbol", &commodity_t::set_symbol)
- .def_readwrite("name", &commodity_t::name)
- .def_readwrite("note", &commodity_t::name)
- .def_readwrite("precision", &commodity_t::precision)
- .def_readwrite("flags", &commodity_t::flags)
- .def_readwrite("ident", &commodity_t::ident)
- .def_readwrite("updater", &commodity_t::updater)
- .add_property("smaller",
- make_getter(&commodity_t::smaller,
- return_value_policy<reference_existing_object>()))
- .add_property("larger",
- make_getter(&commodity_t::larger,
- return_value_policy<reference_existing_object>()))
-
- .def(self_ns::str(self))
-
- .def("add_price", &commodity_t::add_price)
- .def("remove_price", &commodity_t::remove_price)
- .def("value", &commodity_t::value)
-
- .def("valid", &commodity_t::valid)
- ;
-
- def("add_commodity", &commodity_t::add_commodity);
- def("remove_commodity", &commodity_t::remove_commodity);
- def("find_commodity", py_find_commodity_1,
- return_value_policy<reference_existing_object>());
- def("find_commodity", py_find_commodity_2,
- return_value_policy<reference_existing_object>());
-
-#define EXC_TRANSLATE(type) \
- register_exception_translator<type>(&exc_translate_ ## type);
-
- EXC_TRANSLATE(amount_error);
-}
-
-#endif // USE_BOOST_PYTHON