From 66b63ae887f553e1cac813546a6b827a9c85d80c Mon Sep 17 00:00:00 2001 From: rtk0c Date: Sun, 29 May 2022 16:14:26 -0700 Subject: Changeset: 43 Add tostring code gen for enums --- buildtools/codegen/CodegenOutput.inl | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'buildtools/codegen/CodegenOutput.inl') diff --git a/buildtools/codegen/CodegenOutput.inl b/buildtools/codegen/CodegenOutput.inl index 6d59301..752682c 100644 --- a/buildtools/codegen/CodegenOutput.inl +++ b/buildtools/codegen/CodegenOutput.inl @@ -15,6 +15,14 @@ struct CodegenOutputThing { class CodegenOutput { private: std::vector mOutThings; + std::vector mOutStructs; + std::vector mOutEnums; + std::vector mOutFunctions; + +public: + std::string optionOutPrefix; + // Whether to add prefixes mOutPrefix to all global names or not + bool optionAutoAddPrefix : 1 = false; public: void AddOutputThing(CodegenOutputThing thing) { @@ -22,10 +30,16 @@ public: } void MergeContents(CodegenOutput other) { - std::move(other.mOutThings.begin(), other.mOutThings.end(), this->mOutThings.begin()); + std::move(other.mOutThings.begin(), other.mOutThings.end(), std::back_inserter(this->mOutThings)); } void Write(FILE* file) { - // TODO +#define WRITE_LITERAL(str) fwrite(str, sizeof(char), sizeof(str) - 1, file) + for (auto& thing : mOutThings) { + WRITE_LITERAL("// Output thing\n"); + fwrite(thing.text.c_str(), sizeof(char), thing.text.size(), file); + WRITE_LITERAL("\n"); + } +#undef WRITE_LITERAL } }; -- cgit v1.2.3-70-g09d2