1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
#ifndef _Python_Parse_h_
#define _Python_Parse_h_
#include "Parse.h"
#include <boost/optional.hpp>
#include <boost/python/dict.hpp>
#include <boost/python/object_fwd.hpp>
#include <boost/filesystem/path.hpp>
class PythonCommon;
struct module_spec;
class FO_PARSE_API PythonParser {
public:
PythonParser(PythonCommon& _python, const boost::filesystem::path& scripting_dir);
~PythonParser();
PythonParser(const PythonParser&) = delete;
PythonParser(PythonParser&&) = delete;
const PythonParser& operator=(const PythonParser&) = delete;
PythonParser& operator=(PythonParser&&) = delete;
bool ParseFileCommon(const boost::filesystem::path& path,
const boost::python::dict& globals,
std::string& filename, std::string& file_contents) const;
boost::python::object type_int;
boost::python::object type_float;
boost::python::object type_bool;
boost::python::object type_str;
private:
boost::python::object find_spec(const std::string& fullname, const boost::python::object& path, const boost::python::object& target) const;
boost::python::object create_module(const module_spec& spec);
boost::python::object exec_module(boost::python::object& module);
PythonCommon& m_python;
const boost::filesystem::path& m_scripting_dir;
boost::optional<boost::python::list> m_meta_path;
int m_meta_path_len;
PyThreadState* m_parser_thread_state = nullptr;
PyThreadState* m_main_thread_state = nullptr;
};
#endif
|