From 6261da4660a6602345c19d5a948124991bda86dc Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Fri, 10 Sep 2004 04:38:38 -0400 Subject: slight changed semantics of item_handler, to play better with Boost.Python --- walk.cc | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) (limited to 'walk.cc') diff --git a/walk.cc b/walk.cc index 0e0fd0ab..b80dfbc0 100644 --- a/walk.cc +++ b/walk.cc @@ -312,18 +312,19 @@ 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_) {} - void flush() { + virtual void flush() { call_method(self, "flush"); } void default_flush() { item_handler::flush(); } - void operator()(T& item) { + virtual void operator()(T& item) { call_method(self, "__call__", item); } void default_call(T& item) { @@ -357,65 +358,76 @@ void export_walk() ; class_< set_account_value > - ("SetAccountValue", init *>()) + ("SetAccountValue", init *>() + [with_custodian_and_ward<1, 2>()]) .def("flush", &item_handler::flush) .def("__call__", &set_account_value::operator()); ; #if 0 class_< sort_transactions > - ("SortTransactions", init *>()) + ("SortTransactions", init *>() + [with_custodian_and_ward<1, 2>()]) .def("flush", &sort_transactions::flush) .def("__call__", &sort_transactions::operator()); ; #endif class_< filter_transactions > - ("FilterTransactions", init *, std::string>()) + ("FilterTransactions", init *, std::string>() + [with_custodian_and_ward<1, 2>()]) .def("flush", &item_handler::flush) .def("__call__", &filter_transactions::operator()); ; class_< calc_transactions > - ("CalcTransactions", init *, optional >()) + ("CalcTransactions", init *, optional >() + [with_custodian_and_ward<1, 2>()]) .def("flush", &item_handler::flush) .def("__call__", &calc_transactions::operator()); ; class_< collapse_transactions > - ("CollapseTransactions", init *>()) + ("CollapseTransactions", init *>() + [with_custodian_and_ward<1, 2>()]) .def("flush", &collapse_transactions::flush) .def("__call__", &collapse_transactions::operator()); ; class_< changed_value_transactions > - ("ChangeValueTransactions", init *, bool>()) + ("ChangeValueTransactions", init *, bool>() + [with_custodian_and_ward<1, 2>()]) .def("flush", &changed_value_transactions::flush) .def("__call__", &changed_value_transactions::operator()); ; class_< subtotal_transactions > - ("SubtotalTransactions", init *>()) + ("SubtotalTransactions", init *>() + [with_custodian_and_ward<1, 2>()]) .def("flush", subtotal_transactions_flush) .def("__call__", &subtotal_transactions::operator()); ; #if 0 class_< interval_transactions > - ("IntervalTransactions", init *>()) + ("IntervalTransactions", init *>() + [with_custodian_and_ward<1, 2>()]) .def("flush", &item_handler::flush) .def("__call__", &interval_transactions::operator()); ; #endif class_< dow_transactions > - ("DowTransactions", init *>()) + ("DowTransactions", init *>() + [with_custodian_and_ward<1, 2>()]) .def("flush", &dow_transactions::flush) .def("__call__", &dow_transactions::operator()); ; class_< related_transactions > - ("RelatedTransactions", init *, optional >()) + ("RelatedTransactions", + init *, optional >() + [with_custodian_and_ward<1, 2>()]) .def("flush", &item_handler::flush) .def("__call__", &related_transactions::operator()); ; -- cgit v1.2.3