diff options
author | John Wiegley <johnw@newartisans.com> | 2004-08-03 04:34:50 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-04-13 02:40:47 -0400 |
commit | a32173ace60df5a1e9414f5e95b556c436f62718 (patch) | |
tree | fff5b881c657fddb8543b0f787bfa75cf009a0b7 /python.h | |
parent | cc98b59d1e99238270eb307b117da8b0b35e6f27 (diff) | |
download | ledger-a32173ace60df5a1e9414f5e95b556c436f62718.tar.gz ledger-a32173ace60df5a1e9414f5e95b556c436f62718.tar.bz2 ledger-a32173ace60df5a1e9414f5e95b556c436f62718.zip |
changes
Diffstat (limited to 'python.h')
-rw-r--r-- | python.h | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/python.h b/python.h deleted file mode 100644 index c560170b..00000000 --- a/python.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef _PYTHON_H -#define _PYTHON_H - -#include "error.h" - -#include <boost/python.hpp> - -using namespace boost::python; - -namespace ledger { - -struct python_support -{ - handle<> main_module; - dict main_namespace; - - python_support() - : main_module(borrowed(PyImport_AddModule("__main__"))), - main_namespace(handle<>(borrowed(PyModule_GetDict(main_module.get())))) - {} - ~python_support() { - } -}; - -extern python_support * python_interpretor; - -void init_python(); - -inline void python_eval(std::istream& in) -{ - if (! python_interpretor) - init_python(); - - std::string buffer; - buffer.reserve(4096); - while (! in.eof()) { - char buf[256]; - in.getline(buf, 255); - if (buf[0] == '!') - break; - buffer += buf; - buffer += "\n"; - } - - try { - handle<>(borrowed(PyRun_String(buffer.c_str(), Py_file_input, - python_interpretor->main_namespace.ptr(), - python_interpretor->main_namespace.ptr()))); - } - catch(const boost::python::error_already_set&) { - PyErr_Print(); - throw error("Evaluating Python code"); - } -} - -} // namespace ledger - -#endif // _PYTHON_H |