diff options
author | John Wiegley <johnw@newartisans.com> | 2006-02-15 20:10:49 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-04-13 02:41:21 -0400 |
commit | ce3491c99f089874725999ca6d8b1fb6a15c9e5e (patch) | |
tree | c48a2bf19a954c8103a02e26f9a1a490b8095268 /option.cc | |
parent | 2eafddc91b8d7f0b7bdfd991acdc9e0b2295e304 (diff) | |
download | fork-ledger-ce3491c99f089874725999ca6d8b1fb6a15c9e5e.tar.gz fork-ledger-ce3491c99f089874725999ca6d8b1fb6a15c9e5e.tar.bz2 fork-ledger-ce3491c99f089874725999ca6d8b1fb6a15c9e5e.zip |
Removed Python integration support.
Diffstat (limited to 'option.cc')
-rw-r--r-- | option.cc | 91 |
1 files changed, 0 insertions, 91 deletions
@@ -168,94 +168,3 @@ void process_environment(std::list<option_t>& options, process_option(options, buf, q + 1); } } - -#ifdef USE_BOOST_PYTHON - -#include <boost/python.hpp> -#include <boost/python/detail/api_placeholder.hpp> -#include <vector> - -using namespace boost::python; - -struct func_option_wrapper : public option_handler -{ - object self; - func_option_wrapper(object _self) : self(_self) {} - - virtual void operator()(const char * arg) { - call<void>(self.ptr(), arg); - } -}; - -namespace { - std::list<func_option_wrapper> wrappers; - std::list<option_t> options; -} - -void py_add_option_handler(const std::string& long_opt, - const std::string& short_opt, object func) -{ - wrappers.push_back(func_option_wrapper(func)); - add_option_handler(options, long_opt, short_opt, wrappers.back()); -} - -void add_other_option_handlers(const std::list<option_t>& other) -{ - options.insert(options.begin(), other.begin(), other.end()); -} - -bool py_process_option(const std::string& opt, const char * arg) -{ - return process_option(options, opt, arg); -} - -list py_process_arguments(list args, bool anywhere = false) -{ - std::vector<char *> strs; - - int l = len(args); - for (int i = 0; i < l; i++) - strs.push_back(extract<char *>(args[i])); - - std::list<std::string> newargs; - process_arguments(options, strs.size(), &strs.front(), anywhere, newargs); - - list py_newargs; - for (std::list<std::string>::iterator i = newargs.begin(); - i != newargs.end(); - i++) - py_newargs.append(*i); - return py_newargs; -} - -BOOST_PYTHON_FUNCTION_OVERLOADS(py_proc_args_overloads, - py_process_arguments, 1, 2) - -void py_process_environment(object env, const std::string& tag) -{ - std::vector<char *> strs; - std::vector<std::string> storage; - - list items = call_method<list>(env.ptr(), "items"); - int l = len(items); - for (int i = 0; i < l; i++) { - tuple pair = extract<tuple>(items[i]); - std::string s = extract<std::string>(pair[0]); - s += "="; - s += extract<std::string>(pair[1]); - storage.push_back(s); - strs.push_back(const_cast<char *>(storage.back().c_str())); - } - - process_environment(options, &strs.front(), tag); -} - -void export_option() -{ - def("add_option_handler", py_add_option_handler); - def("process_option", py_process_option); - def("process_arguments", py_process_arguments, py_proc_args_overloads()); - def("process_environment", py_process_environment); -} - -#endif // USE_BOOST_PYTHON |