Lua.hpp & Js.hpp: Don't insert new lines and indentation when a function is empty

Py.hpp: Support empty functions

Signed-off-by: Username404 <w.iron.zombie@gmail.com>
This commit is contained in:
Username404 2022-04-20 19:06:09 +02:00
parent 7df47da354
commit 97a9703a1a
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
3 changed files with 8 additions and 5 deletions

View File

@ -15,9 +15,9 @@ struct JsTarget: Target {
output << "function " << parseComponent.name << '(';
separate_transpileTree(parseComponent.parameters, ", ");
output << ") {";
if (newLines) output << separator << indentation;
if (newLines and not parseComponent.empty()) output << separator << indentation;
separate_transpileTree(parseComponent, 1);
if (newLines) output << separator;
if (newLines and not parseComponent.empty()) output << separator;
output << '}';
)
};

View File

@ -18,10 +18,12 @@ struct LuaTarget: Target {
make_task(Function,
output << "function " << parseComponent.name << '(';
separate_transpileTree(parseComponent.parameters, ", ");
output << ')' << separator;
if (newLines) output << indentation;
output << ')';
if (not parseComponent.empty()) output << separator << indentation;
else output << ' ';
separate_transpileTree(parseComponent, 1);
output << separator << "end";
if (not parseComponent.empty()) output << separator;
output << "end";
)
};
}

View File

@ -13,6 +13,7 @@ struct PyTarget: Target {
output << "def " << parseComponent.name << '(';
separate_transpileTree(parseComponent.parameters, ", ");
output << "):" << separator << indentation;
if (parseComponent.empty()) output << "pass";
separate_transpileTree(parseComponent, 1);
),
};