aboutsummaryrefslogtreecommitdiff
path: root/source/20-codegen-compiler/CodegenOutput.inl
diff options
context:
space:
mode:
authorrtk0c <[email protected]>2022-06-02 21:34:16 -0700
committerrtk0c <[email protected]>2022-06-02 21:34:16 -0700
commitbd07ae3f4e1bcdedc3e373460671ca9713a03de5 (patch)
tree15c897891474a97983f247196923f8e4f2184083 /source/20-codegen-compiler/CodegenOutput.inl
parent8a0f2cd0b398ee0b7740e44a0e5fb2f75d090ccb (diff)
Changeset: 60 Add struct/class scanning to codegen
Diffstat (limited to 'source/20-codegen-compiler/CodegenOutput.inl')
-rw-r--r--source/20-codegen-compiler/CodegenOutput.inl76
1 files changed, 0 insertions, 76 deletions
diff --git a/source/20-codegen-compiler/CodegenOutput.inl b/source/20-codegen-compiler/CodegenOutput.inl
deleted file mode 100644
index ff7b912..0000000
--- a/source/20-codegen-compiler/CodegenOutput.inl
+++ /dev/null
@@ -1,76 +0,0 @@
-#pragma once
-
-#include "CodegenDecl.hpp"
-#include "CodegenMacros.hpp"
-
-#include <Utils.hpp>
-
-#include <robin_hood.h>
-#include <algorithm>
-#include <cstdio>
-#include <cstdlib>
-#include <string>
-#include <vector>
-
-// A generic "thing" (could be anything, comments, string-concated functionsm, etc.) to spit into the output file
-struct CodegenOutputThing {
- std::string text;
-};
-
-class CodegenOutput {
-private:
- robin_hood::unordered_set<std::string, StringHash, StringEqual> mRequestIncludes;
- std::vector<CodegenOutputThing> mOutThings;
- std::vector<DeclStruct> mOutStructs;
- std::vector<DeclEnum> mOutEnums;
- std::vector<DeclFunction> mOutFunctions;
-
-public:
- std::string optionOutPrefix;
- // Whether to add prefixes mOutPrefix to all global names or not
- 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));
- }
-
- void 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 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
- }
- }
-};