Add a GodotScript target

Signed-off-by: Username404 <w.iron.zombie@gmail.com>
This commit is contained in:
Username404 2022-07-07 17:21:59 +02:00
parent 4e08c0cf05
commit 22d1599237
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
2 changed files with 27 additions and 0 deletions

View File

@ -156,12 +156,14 @@ public:
#include "implementations/Lua.hpp"
#include "implementations/Js.hpp"
#include "implementations/Py.hpp"
#include "implementations/GodotScript.hpp"
unique_ptr<Target> Target::forName(string_view name, const bool newLines = true) {
#define ADDTARGET(X, target_class) if (name == X) return unique_ptr<target_class>(new target_class(newLines))
ADDTARGET("lua", LuaTarget);
ADDTARGET("js", JsTarget);
ADDTARGET("py", PyTarget);
ADDTARGET("gd", GsTarget);
#undef ADDTARGET
#undef make_nonlocal_task
#undef make_task_noR

View File

@ -0,0 +1,25 @@
#ifndef GODOTSCRIPT_HPP
#define GODOTSCRIPT_HPP
struct GsTarget: Target {
print_functions_pair printFunctions() final { return make_pair("printraw", "print"); }
unordered_task_map getTaskMap() final {
return {
make_task(Define,
output << (parseComponent.final ? "const " : "var ") << parseComponent.name << " = ";
transpileTree(parseComponent.content);
),
make_task(types::String, stringInterpolation(R"(""")", parseComponent.content);),
make_task(Function,
output << "func " << parseComponent.name << '(';
separate_transpileTree(parseComponent.parameters, ", ");
output << "):" << separator << indentation;
if (parseComponent.empty()) output << "pass";
separate_transpileTree(parseComponent, 1);
)
};
}
using Target::Target;
};
#endif