From ce3491c99f089874725999ca6d8b1fb6a15c9e5e Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Wed, 15 Feb 2006 20:10:49 +0000 Subject: Removed Python integration support. --- option.cc | 91 --------------------------------------------------------------- 1 file changed, 91 deletions(-) (limited to 'option.cc') diff --git a/option.cc b/option.cc index 3207b8ee..c9000a20 100644 --- a/option.cc +++ b/option.cc @@ -168,94 +168,3 @@ void process_environment(std::list& options, process_option(options, buf, q + 1); } } - -#ifdef USE_BOOST_PYTHON - -#include -#include -#include - -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(self.ptr(), arg); - } -}; - -namespace { - std::list wrappers; - std::list 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& 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 strs; - - int l = len(args); - for (int i = 0; i < l; i++) - strs.push_back(extract(args[i])); - - std::list newargs; - process_arguments(options, strs.size(), &strs.front(), anywhere, newargs); - - list py_newargs; - for (std::list::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 strs; - std::vector storage; - - list items = call_method(env.ptr(), "items"); - int l = len(items); - for (int i = 0; i < l; i++) { - tuple pair = extract(items[i]); - std::string s = extract(pair[0]); - s += "="; - s += extract(pair[1]); - storage.push_back(s); - strs.push_back(const_cast(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 -- cgit v1.2.3