aboutsummaryrefslogtreecommitdiff
path: root/ProjectBrussel/CodegenCompiler/CodegenOutput.cpp
diff options
context:
space:
mode:
authorrtk0c <[email protected]>2022-06-03 23:30:01 -0700
committerrtk0c <[email protected]>2022-06-03 23:30:01 -0700
commit791b3f354b378769bffe623b05f1305c91b77101 (patch)
tree5409b311e6232eb4a6d3f8259b780d76b8ee1c59 /ProjectBrussel/CodegenCompiler/CodegenOutput.cpp
parent60ccc62f4934e44ad5b905fdbcf458302b8d8a09 (diff)
Changeset: 64 [WIP] Rename directoriesmaster-switch-to-build2
Diffstat (limited to 'ProjectBrussel/CodegenCompiler/CodegenOutput.cpp')
-rw-r--r--ProjectBrussel/CodegenCompiler/CodegenOutput.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/ProjectBrussel/CodegenCompiler/CodegenOutput.cpp b/ProjectBrussel/CodegenCompiler/CodegenOutput.cpp
new file mode 100644
index 0000000..ccd163c
--- /dev/null
+++ b/ProjectBrussel/CodegenCompiler/CodegenOutput.cpp
@@ -0,0 +1,46 @@
+#include "CodegenOutput.hpp"
+
+#include "CodegenUtils.hpp"
+
+void CodegenOutput::AddRequestInclude(std::string_view include) {
+ if (!mRequestIncludes.contains(include)) {
+ mRequestIncludes.insert(std::string(include));
+ }
+}
+
+void CodegenOutput::AddOutputThing(CodegenOutputThing thing) {
+ mOutThings.push_back(std::move(thing));
+}
+
+void CodegenOutput::MergeContents(CodegenOutput other) {
+ std::move(other.mOutThings.begin(), other.mOutThings.end(), std::back_inserter(this->mOutThings));
+ std::move(other.mOutStructs.begin(), other.mOutStructs.end(), std::back_inserter(this->mOutStructs));
+ std::move(other.mOutEnums.begin(), other.mOutEnums.end(), std::back_inserter(this->mOutEnums));
+ std::move(other.mOutFunctions.begin(), other.mOutFunctions.end(), std::back_inserter(this->mOutFunctions));
+}
+
+void CodegenOutput::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_LN(file, "struct %s {", declStruct.name.c_str());
+ // TODO
+ WRITE_LIT_LN(file, "};");
+ }
+
+ for (auto& declEnum : mOutEnums) {
+ // TODO
+ }
+
+ for (auto& declFunc : mOutFunctions) {
+ // TODO
+ }
+}