diff options
Diffstat (limited to 'buildtools/codegen/CodegenUtils.inl')
-rw-r--r-- | buildtools/codegen/CodegenUtils.inl | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/buildtools/codegen/CodegenUtils.inl b/buildtools/codegen/CodegenUtils.inl index ea46ac1..f9d913e 100644 --- a/buildtools/codegen/CodegenUtils.inl +++ b/buildtools/codegen/CodegenUtils.inl @@ -46,6 +46,34 @@ bool WriteOutputFile(const CodegenOutput& output, std::string_view dir, std::str return true; } +std::string MakeFullName(std::string_view name, DeclNamespace* ns = nullptr) { + size_t length = 0; + std::vector<std::string_view> components; + if (!name.empty()) { + components.push_back(name); + length += name.length(); + } + + DeclNamespace* currentNamespace = ns; + while (currentNamespace) { + components.push_back(currentNamespace->name); + length += currentNamespace->name.size() + /*::*/ 2; + currentNamespace = currentNamespace->container; + } + + std::string fullname; + fullname.reserve(length); + for (auto it = components.rbegin(); it != components.rend(); ++it) { + fullname += *it; + fullname += "::"; + } + // Get rid of the last "::" + fullname.pop_back(); + fullname.pop_back(); + + return fullname; +} + void ProduceGeneratedHeaderFileHeader(CodegenOutput& output) { output.AddOutputThing(CodegenOutputThing{ .text = &R"""( @@ -53,6 +81,9 @@ void ProduceGeneratedHeaderFileHeader(CodegenOutput& output) { #pragma once #include <MetadataBase.hpp> + +#include <cstddef> +#include <cstdint> )"""[1], }); } @@ -63,6 +94,8 @@ void ProduceGeneratedSourceFileHeader(CodegenOutput& output) { // This file is generated. Any changes will be overidden when building. #include "GeneratedCode.hpp" +#include <cstddef> +#include <cstdint> #include <frozen/string.h> #include <frozen/unordered_map.h> using namespace std::literals; |