diff options
author | rtk0c <[email protected]> | 2022-05-30 13:09:26 -0700 |
---|---|---|
committer | rtk0c <[email protected]> | 2022-05-30 13:09:26 -0700 |
commit | ce9559e8c2b69d46cff064241bd9a04c014af44f (patch) | |
tree | 370c793d4fde63f4bd4d988d73a3c4d9353ede56 /buildtools/codegen/CodegenOutput.inl | |
parent | cdd84f25ab1d2a57ee5c7b4c954e35a8d7e2dca3 (diff) |
Changeset: 51 Add integration into the main game
Diffstat (limited to 'buildtools/codegen/CodegenOutput.inl')
-rw-r--r-- | buildtools/codegen/CodegenOutput.inl | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/buildtools/codegen/CodegenOutput.inl b/buildtools/codegen/CodegenOutput.inl index edd9abc..ff7b912 100644 --- a/buildtools/codegen/CodegenOutput.inl +++ b/buildtools/codegen/CodegenOutput.inl @@ -3,6 +3,9 @@ #include "CodegenDecl.hpp" #include "CodegenMacros.hpp" +#include <Utils.hpp> + +#include <robin_hood.h> #include <algorithm> #include <cstdio> #include <cstdlib> @@ -16,6 +19,7 @@ struct CodegenOutputThing { class CodegenOutput { private: + robin_hood::unordered_set<std::string, StringHash, StringEqual> mRequestIncludes; std::vector<CodegenOutputThing> mOutThings; std::vector<DeclStruct> mOutStructs; std::vector<DeclEnum> mOutEnums; @@ -27,6 +31,12 @@ public: bool optionAutoAddPrefix : 1 = false; public: + void AddRequestInclude(std::string_view include) { + if (!mRequestIncludes.contains(include)) { + mRequestIncludes.insert(std::string(include)); + } + } + void AddOutputThing(CodegenOutputThing thing) { mOutThings.push_back(std::move(thing)); } @@ -39,15 +49,20 @@ public: } void Write(FILE* file) const { + for (auto& include : mRequestIncludes) { + // TODO how to resolve to the correct include paths? + WRITE_FMT_LN(file, "#include <%s>", include.c_str()); + } + for (auto& thing : mOutThings) { fwrite(thing.text.c_str(), sizeof(char), thing.text.size(), file); WRITE_LIT(file, "\n"); } for (auto& declStruct : mOutStructs) { - WRITE_FMT(file, "struct %s {\n", declStruct.name.c_str()); + WRITE_FMT_LN(file, "struct %s {", declStruct.name.c_str()); // TODO - WRITE_LIT(file, "}\n"); + WRITE_LIT_LN(file, "};"); } for (auto& declEnum : mOutEnums) { |