From a8012940f4d15a2e1d8fbdac02a631dae6231b1e Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Wed, 15 Feb 2006 20:10:49 +0000 Subject: Removed Python integration support. --- walk.cc | 305 ---------------------------------------------------------------- 1 file changed, 305 deletions(-) (limited to 'walk.cc') 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 - -using namespace boost::python; -using namespace ledger; - -template -struct item_handler_wrap : public item_handler -{ - PyObject * self; - - item_handler_wrap(PyObject * self_) : self(self_) {} - item_handler_wrap(PyObject * self_, const item_handler& _handler) - : item_handler(const_cast *>(&_handler)), - self(self_) {} - item_handler_wrap(PyObject * self_, item_handler * _handler) - : item_handler(_handler), self(self_) {} - - virtual void flush() { - call_method(self, "flush"); - } - void default_flush() { - item_handler::flush(); - } - - virtual void operator()(T& item) { - call_method(self, "__call__", ptr(&item)); - } - void default_call(T& item) { - item_handler::operator()(item); - } -}; - -void (subtotal_transactions::*subtotal_transactions_flush)() = - &subtotal_transactions::flush; - -void py_walk_entries(journal_t& journal, - item_handler& handler) { - walk_entries(journal.entries, handler); -} - -void py_walk_transactions(entry_t& entry, - item_handler& handler) { - walk_transactions(entry.transactions, handler); -} - -void py_walk_accounts_1(account_t& account, - item_handler& handler) { - walk_accounts(account, handler); -} - -void py_walk_accounts_2(account_t& account, - item_handler& handler, - const value_expr_t * sort_order) { - walk_accounts(account, handler, sort_order); -} - -void py_walk_accounts_3(account_t& account, - item_handler& handler, - const std::string& sort_string) { - walk_accounts(account, handler, sort_string); -} - -void py_walk_commodities(item_handler& 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 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 > - ("TransactionHandler") - .def(init()[with_custodian_and_ward<1, 2>()]) - - .def("flush", &xact_handler_t::flush, - &item_handler_wrap::default_flush) - .def("__call__", &xact_handler_t::operator(), - &item_handler_wrap::default_call) - ; - - class_< ignore_transactions, bases > - ("IgnoreTransactions") - .def("flush", &xact_handler_t::flush) - .def("__call__", &ignore_transactions::operator()); - ; - - class_< clear_transaction_xdata, bases > - ("ClearTransactionXData") - .def("flush", &xact_handler_t::flush) - .def("__call__", &clear_transaction_xdata::operator()); - ; - - class_< truncate_entries, bases > - ("TruncateEntries", init() - [with_custodian_and_ward<1, 2>()]) - .def("flush", &truncate_entries::flush) - .def("__call__", &truncate_entries::operator()); - ; - - class_< set_account_value, bases > ("SetAccountValue") - .def(init()[with_custodian_and_ward<1, 2>()]) - .def("flush", &xact_handler_t::flush) - .def("__call__", &set_account_value::operator()); - ; - - class_< sort_transactions, bases > - ("SortTransactions", init() - [with_custodian_and_ward<1, 2>()]) - .def(init() - [with_custodian_and_ward<1, 2>()]) - .def("flush", &sort_transactions::flush) - .def("__call__", &sort_transactions::operator()); - ; - - class_< filter_transactions, bases > - ("FilterTransactions", init() - [with_custodian_and_ward<1, 2>()]) - .def(init() - [with_custodian_and_ward<1, 2>()]) - .def("flush", &xact_handler_t::flush) - .def("__call__", &filter_transactions::operator()); - ; - - class_< calc_transactions, bases > - ("CalcTransactions", init() - [with_custodian_and_ward<1, 2>()]) - .def("flush", &xact_handler_t::flush) - .def("__call__", &calc_transactions::operator()); - ; - - class_< invert_transactions, bases > - ("InvertTransactions", init() - [with_custodian_and_ward<1, 2>()]) - .def("flush", &xact_handler_t::flush) - .def("__call__", &invert_transactions::operator()); - ; - - class_< collapse_transactions, bases > - ("CollapseTransactions", init() - [with_custodian_and_ward<1, 2>()]) - .def("flush", &collapse_transactions::flush) - .def("__call__", &collapse_transactions::operator()); - ; - - class_< related_transactions, bases > - ("RelatedTransactions", init >() - [with_custodian_and_ward<1, 2>()]) - .def("flush", &xact_handler_t::flush) - .def("__call__", &related_transactions::operator()); - ; - - class_< changed_value_transactions, bases > - ("ChangeValueTransactions", init() - [with_custodian_and_ward<1, 2>()]) - .def("flush", &changed_value_transactions::flush) - .def("__call__", &changed_value_transactions::operator()); - ; - - class_< subtotal_transactions, bases > - ("SubtotalTransactions", init() - [with_custodian_and_ward<1, 2>()]) - .def("flush", subtotal_transactions_flush) - .def("__call__", &subtotal_transactions::operator()); - ; - - class_< interval_transactions, bases > - ("IntervalTransactions", - init >() - [with_custodian_and_ward<1, 2>()]) - .def(init >() - [with_custodian_and_ward<1, 2>()]) - .def("flush", &xact_handler_t::flush) - .def("__call__", &interval_transactions::operator()); - ; - - class_< by_payee_transactions, bases > - ("ByPayeeTransactions", init() - [with_custodian_and_ward<1, 2>()]) - .def("flush", &by_payee_transactions::flush) - .def("__call__", &by_payee_transactions::operator()); - ; - - class_< set_comm_as_payee, bases > - ("SetCommAsPayee", init() - [with_custodian_and_ward<1, 2>()]) - .def("flush", &xact_handler_t::flush) - .def("__call__", &xact_handler_t::operator()); - ; - - class_< dow_transactions, bases > - ("DowTransactions", init() - [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 > - ("GenerateTransactions", init() - [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 > - ("BudgetTransactions", - init() - [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 > - ("ForecastTransactions", - init() - [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_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 > - ("AccountHandler") - .def(init()[with_custodian_and_ward<1, 2>()]) - - .def("flush", &account_handler_t::flush, - &item_handler_wrap::default_flush) - .def("__call__", &account_handler_t::operator(), - &item_handler_wrap::default_call) - ; - - class_< clear_account_xdata, bases > - ("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 -- cgit v1.2.3