| 60 | } |
| 61 | |
| 62 | void writeHeader(std::ofstream &out, const StateDefinition &state) |
| 63 | { |
| 64 | out << "// GENERATED HEADER - generated by LuaGamestateSupportGen - do not modify directly\n\n" |
| 65 | << "#pragma once\n\n" |
| 66 | << "#include \"game/state/gamestate.h\"\n\n" |
| 67 | << "#include \"game/state/luagamestate_support.h\"\n\n" |
| 68 | << "extern \"C\"\n{\n" |
| 69 | << "#include \"dependencies/lua/lua.h\"\n" |
| 70 | << "}\n\n" |
| 71 | << "namespace OpenApoc {\n\n" |
| 72 | << "static constexpr const char* const LUAGAMESTATE_SUPPORT_VERSION = \"" |
| 73 | << state.hashString << "\";\n" |
| 74 | << "class SerializationNode;\n\n"; |
| 75 | for (auto &object : state.objects) |
| 76 | { |
| 77 | out << "void pushToLua(lua_State *L, " << object.name << " &obj);\n" |
| 78 | << "void pushToLua(lua_State *L, const " << object.name << " &obj);\n"; |
| 79 | } |
| 80 | |
| 81 | for (auto &e : state.enums) |
| 82 | { |
| 83 | if (e.external == false) |
| 84 | continue; |
| 85 | out << "void pushToLua(lua_State *L, " << e.name << " val);\n"; |
| 86 | } |
| 87 | |
| 88 | out << "\n} // namespace OpenApoc\n"; |
| 89 | } |
| 90 | |
| 91 | void writeSource(std::ofstream &out, const StateDefinition &state, |
| 92 | const std::string &outputHeaderFile) |