Expose the Parser class properly to Python
This commit is contained in:
@@ -38,8 +38,6 @@ namespace {
|
||||
return new SunbeamState(false, filename, context, parser);
|
||||
}
|
||||
|
||||
void (ParseContext::*ctx_update)(const std::string&, InputError::Action) = &ParseContext::update;
|
||||
|
||||
void add_keyword(Parser* parser, const std::string& json_string) {
|
||||
const Json::JsonObject keyword(json_string);
|
||||
parser->addParserKeyword(keyword);
|
||||
@@ -53,24 +51,19 @@ void opmcommon_python::export_Parser(py::module& module) {
|
||||
module.def( "create_deck", &create_deck );
|
||||
module.def( "create_deck_string", &create_deck_string);
|
||||
|
||||
|
||||
py::class_<SunbeamState>(module, "SunbeamState")
|
||||
.def("_schedule", &SunbeamState::getSchedule, ref_internal)
|
||||
.def("_state", &SunbeamState::getEclipseState, ref_internal)
|
||||
.def("_deck", &SunbeamState::getDeck, ref_internal)
|
||||
.def("_summary_config", &SunbeamState::getSummmaryConfig, ref_internal);
|
||||
|
||||
py::class_< ParseContext >(module, "ParseContext" )
|
||||
.def(py::init<>())
|
||||
.def(py::init<const std::vector<std::pair<std::string, InputError::Action>>>())
|
||||
.def( "update", ctx_update );
|
||||
|
||||
py::enum_< InputError::Action >( module, "action" )
|
||||
.value( "throw", InputError::Action::THROW_EXCEPTION )
|
||||
.value( "warn", InputError::Action::WARN )
|
||||
.value( "ignore", InputError::Action::IGNORE );
|
||||
|
||||
|
||||
py::class_<Parser>(module, "Parser")
|
||||
.def(py::init<>())
|
||||
.def("parse", py::overload_cast<const std::string&>(&Parser::parseFile, py::const_))
|
||||
.def("parse" , py::overload_cast<const std::string&, const ParseContext&>(&Parser::parseFile, py::const_))
|
||||
.def("parse_string", py::overload_cast<const std::string&>(&Parser::parseString, py::const_))
|
||||
.def("parse_string", py::overload_cast<const std::string&, const ParseContext&>(&Parser::parseString, py::const_))
|
||||
.def("add_keyword", add_keyword);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user