Moved C++ tools out
This commit is contained in:
87
archive/dawntools/util/CodeGen.hpp
Normal file
87
archive/dawntools/util/CodeGen.hpp
Normal file
@ -0,0 +1,87 @@
|
||||
// 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<std::string> includes;
|
||||
std::string clazz = "Unknown";
|
||||
std::string extend = "";
|
||||
std::string constructorArgs = "";
|
||||
std::string extendArgs = "";
|
||||
|
||||
std::map<std::string, std::string> classTemplates;
|
||||
|
||||
std::vector<std::string> constructorCode;
|
||||
|
||||
std::vector<std::string> protectedCode;
|
||||
std::vector<std::string> protectedProperties;
|
||||
|
||||
std::vector<std::string> publicCode;
|
||||
std::vector<std::string> publicProperties;
|
||||
};
|
||||
|
||||
struct MethodGenInfo {
|
||||
std::string name;
|
||||
std::string type = "void";
|
||||
std::vector<std::string> 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<std::string> *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<std::string> *out,
|
||||
std::vector<std::string> 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<std::string> *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<std::string> *out,
|
||||
struct MethodGenInfo info
|
||||
);
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user