// Copyright (c) 2023 Dominic Masters // // This software is released under the MIT License. // https://opensource.org/licenses/MIT #pragma once #include "dawnsharedlibs.hpp" namespace Dawn { struct ClassGenInfo { std::vector includes; std::string clazz = "Unknown"; std::string extend = ""; std::string constructorArgs = ""; std::string extendArgs = ""; std::map classTemplates; std::vector constructorCode; std::vector protectedCode; std::vector protectedProperties; std::vector publicCode; std::vector publicProperties; }; struct MethodGenInfo { std::string name; std::string type = "void"; std::vector body; std::string args = ""; bool_t isStatic = false; bool_t isOverride = false; }; class CodeGen { protected: /** * Append a line of code to the output buffer. * * @param out Output buffer to append to. * @param contents Line of code to append to the buffer. * @param tabs Prepended string of spaces/tabs. */ static void line( std::vector *out, std::string contents, std::string tabs ); /** * Append an array of lines to the output buffer. * * @param out Output buffer to append to. * @param lines List of lines of code to append to the buffer. * @param tabs Prepended string of tabs/spaces to prepend to EACH line. */ static void lines( std::vector *out, std::vector lines, std::string tabs ); /** * Generate code of a class * * @param out Output buffer to write the class to. * @param info Information about how the class should be generated. */ static void classGen( std::vector *out, struct ClassGenInfo info ); /** * Generate code of a method/function. * * @param out Output buffer to write the method to. * @param info Information about how the method should be generated. */ static void methodGen( std::vector *out, struct MethodGenInfo info ); }; }