aboutsummaryrefslogtreecommitdiff
path: root/buildtools/codegen/CodegenOutput.inl
diff options
context:
space:
mode:
Diffstat (limited to 'buildtools/codegen/CodegenOutput.inl')
-rw-r--r--buildtools/codegen/CodegenOutput.inl19
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) {