summaryrefslogtreecommitdiff
path: root/walk.cc
diff options
context:
space:
mode:
Diffstat (limited to 'walk.cc')
-rw-r--r--walk.cc305
1 files changed, 0 insertions, 305 deletions
diff --git a/walk.cc b/walk.cc
index 0b128261..606ce126 100644
--- a/walk.cc
+++ b/walk.cc
@@ -843,308 +843,3 @@ void walk_commodities(commodities_map& commodities,
}
} // namespace ledger
-
-#ifdef USE_BOOST_PYTHON
-
-#include <boost/python.hpp>
-
-using namespace boost::python;
-using namespace ledger;
-
-template <typename T>
-struct item_handler_wrap : public item_handler<T>
-{
- PyObject * self;
-
- item_handler_wrap(PyObject * self_) : self(self_) {}
- item_handler_wrap(PyObject * self_, const item_handler<T>& _handler)
- : item_handler<T>(const_cast<item_handler<T> *>(&_handler)),
- self(self_) {}
- item_handler_wrap(PyObject * self_, item_handler<T> * _handler)
- : item_handler<T>(_handler), self(self_) {}
-
- virtual void flush() {
- call_method<void>(self, "flush");
- }
- void default_flush() {
- item_handler<T>::flush();
- }
-
- virtual void operator()(T& item) {
- call_method<void>(self, "__call__", ptr(&item));
- }
- void default_call(T& item) {
- item_handler<T>::operator()(item);
- }
-};
-
-void (subtotal_transactions::*subtotal_transactions_flush)() =
- &subtotal_transactions::flush;
-
-void py_walk_entries(journal_t& journal,
- item_handler<transaction_t>& handler) {
- walk_entries(journal.entries, handler);
-}
-
-void py_walk_transactions(entry_t& entry,
- item_handler<transaction_t>& handler) {
- walk_transactions(entry.transactions, handler);
-}
-
-void py_walk_accounts_1(account_t& account,
- item_handler<account_t>& handler) {
- walk_accounts(account, handler);
-}
-
-void py_walk_accounts_2(account_t& account,
- item_handler<account_t>& handler,
- const value_expr_t * sort_order) {
- walk_accounts(account, handler, sort_order);
-}
-
-void py_walk_accounts_3(account_t& account,
- item_handler<account_t>& handler,
- const std::string& sort_string) {
- walk_accounts(account, handler, sort_string);
-}
-
-void py_walk_commodities(item_handler<transaction_t>& handler) {
- walk_commodities(commodity_t::commodities, handler);
-}
-
-void py_add_period_entries(generate_transactions& handler,
- journal_t * journal) {
- handler.add_period_entries(journal->period_entries);
-}
-
-void export_walk()
-{
- typedef item_handler<transaction_t> xact_handler_t;
-
- scope().attr("TRANSACTION_RECEIVED") = TRANSACTION_RECEIVED;
- scope().attr("TRANSACTION_HANDLED") = TRANSACTION_HANDLED;
- scope().attr("TRANSACTION_TO_DISPLAY") = TRANSACTION_TO_DISPLAY;
- scope().attr("TRANSACTION_DISPLAYED") = TRANSACTION_DISPLAYED;
- scope().attr("TRANSACTION_NO_TOTAL") = TRANSACTION_NO_TOTAL;
- scope().attr("TRANSACTION_SORT_CALC") = TRANSACTION_SORT_CALC;
- scope().attr("TRANSACTION_COMPOSITE") = TRANSACTION_COMPOSITE;
- scope().attr("TRANSACTION_MATCHES") = TRANSACTION_MATCHES;
-
- class_< transaction_xdata_t > ("TransactionXData")
- .def_readwrite("total", &transaction_xdata_t::total)
- .def_readwrite("sort_value", &transaction_xdata_t::sort_value)
- .def_readwrite("composite_amount", &transaction_xdata_t::composite_amount)
- .def_readwrite("index", &transaction_xdata_t::index)
- .def_readwrite("dflags", &transaction_xdata_t::dflags)
- ;
-
- def("transaction_has_xdata", transaction_has_xdata);
- def("transaction_xdata", transaction_xdata, return_internal_reference<1>());
- def("add_transaction_to", add_transaction_to);
-
- class_< xact_handler_t, item_handler_wrap<transaction_t> >
- ("TransactionHandler")
- .def(init<xact_handler_t *>()[with_custodian_and_ward<1, 2>()])
-
- .def("flush", &xact_handler_t::flush,
- &item_handler_wrap<transaction_t>::default_flush)
- .def("__call__", &xact_handler_t::operator(),
- &item_handler_wrap<transaction_t>::default_call)
- ;
-
- class_< ignore_transactions, bases<xact_handler_t> >
- ("IgnoreTransactions")
- .def("flush", &xact_handler_t::flush)
- .def("__call__", &ignore_transactions::operator());
- ;
-
- class_< clear_transaction_xdata, bases<xact_handler_t> >
- ("ClearTransactionXData")
- .def("flush", &xact_handler_t::flush)
- .def("__call__", &clear_transaction_xdata::operator());
- ;
-
- class_< truncate_entries, bases<xact_handler_t> >
- ("TruncateEntries", init<xact_handler_t *, int, int>()
- [with_custodian_and_ward<1, 2>()])
- .def("flush", &truncate_entries::flush)
- .def("__call__", &truncate_entries::operator());
- ;
-
- class_< set_account_value, bases<xact_handler_t> > ("SetAccountValue")
- .def(init<xact_handler_t *>()[with_custodian_and_ward<1, 2>()])
- .def("flush", &xact_handler_t::flush)
- .def("__call__", &set_account_value::operator());
- ;
-
- class_< sort_transactions, bases<xact_handler_t> >
- ("SortTransactions", init<xact_handler_t *, const value_expr_t *>()
- [with_custodian_and_ward<1, 2>()])
- .def(init<xact_handler_t *, const std::string&>()
- [with_custodian_and_ward<1, 2>()])
- .def("flush", &sort_transactions::flush)
- .def("__call__", &sort_transactions::operator());
- ;
-
- class_< filter_transactions, bases<xact_handler_t> >
- ("FilterTransactions", init<xact_handler_t *, std::string>()
- [with_custodian_and_ward<1, 2>()])
- .def(init<xact_handler_t *, const std::string&>()
- [with_custodian_and_ward<1, 2>()])
- .def("flush", &xact_handler_t::flush)
- .def("__call__", &filter_transactions::operator());
- ;
-
- class_< calc_transactions, bases<xact_handler_t> >
- ("CalcTransactions", init<xact_handler_t *>()
- [with_custodian_and_ward<1, 2>()])
- .def("flush", &xact_handler_t::flush)
- .def("__call__", &calc_transactions::operator());
- ;
-
- class_< invert_transactions, bases<xact_handler_t> >
- ("InvertTransactions", init<xact_handler_t *>()
- [with_custodian_and_ward<1, 2>()])
- .def("flush", &xact_handler_t::flush)
- .def("__call__", &invert_transactions::operator());
- ;
-
- class_< collapse_transactions, bases<xact_handler_t> >
- ("CollapseTransactions", init<xact_handler_t *>()
- [with_custodian_and_ward<1, 2>()])
- .def("flush", &collapse_transactions::flush)
- .def("__call__", &collapse_transactions::operator());
- ;
-
- class_< related_transactions, bases<xact_handler_t> >
- ("RelatedTransactions", init<xact_handler_t *, optional<bool> >()
- [with_custodian_and_ward<1, 2>()])
- .def("flush", &xact_handler_t::flush)
- .def("__call__", &related_transactions::operator());
- ;
-
- class_< changed_value_transactions, bases<xact_handler_t> >
- ("ChangeValueTransactions", init<xact_handler_t *, bool>()
- [with_custodian_and_ward<1, 2>()])
- .def("flush", &changed_value_transactions::flush)
- .def("__call__", &changed_value_transactions::operator());
- ;
-
- class_< subtotal_transactions, bases<xact_handler_t> >
- ("SubtotalTransactions", init<xact_handler_t *>()
- [with_custodian_and_ward<1, 2>()])
- .def("flush", subtotal_transactions_flush)
- .def("__call__", &subtotal_transactions::operator());
- ;
-
- class_< interval_transactions, bases<xact_handler_t> >
- ("IntervalTransactions",
- init<xact_handler_t *, interval_t, optional<value_expr_t *> >()
- [with_custodian_and_ward<1, 2>()])
- .def(init<xact_handler_t *, const std::string&,
- optional<const std::string&> >()
- [with_custodian_and_ward<1, 2>()])
- .def("flush", &xact_handler_t::flush)
- .def("__call__", &interval_transactions::operator());
- ;
-
- class_< by_payee_transactions, bases<xact_handler_t> >
- ("ByPayeeTransactions", init<xact_handler_t *>()
- [with_custodian_and_ward<1, 2>()])
- .def("flush", &by_payee_transactions::flush)
- .def("__call__", &by_payee_transactions::operator());
- ;
-
- class_< set_comm_as_payee, bases<xact_handler_t> >
- ("SetCommAsPayee", init<xact_handler_t *>()
- [with_custodian_and_ward<1, 2>()])
- .def("flush", &xact_handler_t::flush)
- .def("__call__", &xact_handler_t::operator());
- ;
-
- class_< dow_transactions, bases<xact_handler_t> >
- ("DowTransactions", init<xact_handler_t *>()
- [with_custodian_and_ward<1, 2>()])
- .def("flush", &dow_transactions::flush)
- .def("__call__", &dow_transactions::operator());
- ;
-
- scope().attr("BUDGET_BUDGETED") = BUDGET_BUDGETED;
- scope().attr("BUDGET_UNBUDGETED") = BUDGET_UNBUDGETED;
-
- class_< generate_transactions, bases<xact_handler_t> >
- ("GenerateTransactions", init<xact_handler_t *>()
- [with_custodian_and_ward<1, 2>()])
- .def("add_transaction", &generate_transactions::add_transaction)
- .def("add_period_entries", py_add_period_entries)
- .def("flush", &xact_handler_t::flush)
- .def("__call__", &xact_handler_t::operator());
- ;
-
- class_< budget_transactions, bases<generate_transactions> >
- ("BudgetTransactions",
- init<xact_handler_t *, unsigned long>()
- [with_custodian_and_ward<1, 2>()])
- .def("add_transaction", &generate_transactions::add_transaction)
- .def("add_period_entries", py_add_period_entries)
- .def("flush", &budget_transactions::flush)
- .def("__call__", &xact_handler_t::operator());
- ;
-
- class_< forecast_transactions, bases<generate_transactions> >
- ("ForecastTransactions",
- init<xact_handler_t *, std::string>()
- [with_custodian_and_ward<1, 2>()])
- .def("add_transaction", &forecast_transactions::add_transaction)
- .def("add_period_entries", py_add_period_entries)
- .def("flush", &forecast_transactions::flush)
- .def("__call__", &xact_handler_t::operator());
- ;
-
- def("walk_entries", py_walk_entries);
- def("walk_transactions", py_walk_transactions);
-
- typedef item_handler<account_t> account_handler_t;
-
- scope().attr("ACCOUNT_TO_DISPLAY") = ACCOUNT_TO_DISPLAY;
- scope().attr("ACCOUNT_DISPLAYED") = ACCOUNT_DISPLAYED;
- scope().attr("ACCOUNT_SORT_CALC") = ACCOUNT_SORT_CALC;
-
- class_< account_xdata_t > ("AccountXData")
- .def_readwrite("value", &account_xdata_t::value)
- .def_readwrite("total", &account_xdata_t::total)
- .def_readwrite("sort_value", &account_xdata_t::sort_value)
- .def_readwrite("count", &account_xdata_t::count)
- .def_readwrite("total_count", &account_xdata_t::total_count)
- .def_readwrite("virtuals", &account_xdata_t::virtuals)
- .def_readwrite("dflags", &account_xdata_t::dflags)
- ;
-
- def("account_has_xdata", account_has_xdata);
- def("account_xdata", account_xdata, return_internal_reference<1>());
-
- class_< account_handler_t, item_handler_wrap<account_t> >
- ("AccountHandler")
- .def(init<account_handler_t *>()[with_custodian_and_ward<1, 2>()])
-
- .def("flush", &account_handler_t::flush,
- &item_handler_wrap<account_t>::default_flush)
- .def("__call__", &account_handler_t::operator(),
- &item_handler_wrap<account_t>::default_call)
- ;
-
- class_< clear_account_xdata, bases<account_handler_t> >
- ("ClearAccountXData")
- .def("flush", &account_handler_t::flush)
- .def("__call__", &clear_account_xdata::operator());
- ;
-
- def("sum_accounts", sum_accounts);
- def("walk_accounts", py_walk_accounts_1);
- def("walk_accounts", py_walk_accounts_2);
- def("walk_accounts", py_walk_accounts_3);
-
- def("walk_commodities", py_walk_commodities);
-}
-
-#endif // USE_BOOST_PYTHON