summaryrefslogtreecommitdiff
path: root/py_parser.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2007-04-27 10:09:00 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 03:38:32 -0400
commitd0e9822ed16cb36de4cb1171a89d4049c615f1a0 (patch)
treefa48eba60a56dee5bcf1ebd266d822c5a96e4323 /py_parser.cc
parent0eb597a681115d6d5dd2ea4511fa3b8c7b3d9c9f (diff)
downloadfork-ledger-d0e9822ed16cb36de4cb1171a89d4049c615f1a0.tar.gz
fork-ledger-d0e9822ed16cb36de4cb1171a89d4049c615f1a0.tar.bz2
fork-ledger-d0e9822ed16cb36de4cb1171a89d4049c615f1a0.zip
Moved around the Python code.
Diffstat (limited to 'py_parser.cc')
-rw-r--r--py_parser.cc48
1 files changed, 48 insertions, 0 deletions
diff --git a/py_parser.cc b/py_parser.cc
new file mode 100644
index 00000000..f119a0ef
--- /dev/null
+++ b/py_parser.cc
@@ -0,0 +1,48 @@
+#include "parser.h"
+
+#if 0
+#ifdef USE_BOOST_PYTHON
+
+using namespace boost::python;
+using namespace ledger;
+
+struct py_parser_t : public parser_t
+{
+ PyObject * self;
+ py_parser_t(PyObject * self_) : self(self_) {}
+
+ virtual bool test(std::istream& in) const {
+ return call_method<bool>(self, "test", in);
+ }
+
+ virtual repitem_t * parse(std::istream& in,
+ journal_t * journal,
+ account_t * master = NULL,
+ const string * original_file = NULL) {
+ return call_method<unsigned int>(self, "parse", in, journal, master,
+ original_file);
+ }
+};
+
+BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(parser_parse_overloads,
+ py_parser_t::parse, 2, 4)
+
+BOOST_PYTHON_FUNCTION_OVERLOADS(parse_journal_overloads, parse_journal, 2, 4)
+BOOST_PYTHON_FUNCTION_OVERLOADS(parse_journal_file_overloads,
+ parse_journal_file, 2, 4)
+
+void export_parser() {
+ class_< parser_t, py_parser_t, boost::noncopyable > ("Parser")
+ .def("test", &py_parser_t::test)
+ .def("parse", &py_parser_t::parse, parser_parse_overloads())
+ ;
+
+ def("register_parser", register_parser);
+ def("unregister_parser", unregister_parser);
+
+ def("parse_journal", parse_journal, parse_journal_overloads());
+ def("parse_journal_file", parse_journal_file, parse_journal_file_overloads());
+}
+
+#endif // USE_BOOST_PYTHON
+#endif