Add a GodotScript target
Signed-off-by: Username404 <w.iron.zombie@gmail.com>
This commit is contained in:
parent
4e08c0cf05
commit
22d1599237
|
@ -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
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue