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 << '('; output << "function " << parseComponent.name << '(';
separate_transpileTree(parseComponent.parameters, ", "); separate_transpileTree(parseComponent.parameters, ", ");
output << ") {"; output << ") {";
if (newLines) output << separator << indentation; if (newLines and not parseComponent.empty()) output << separator << indentation;
separate_transpileTree(parseComponent, 1); separate_transpileTree(parseComponent, 1);
if (newLines) output << separator; if (newLines and not parseComponent.empty()) output << separator;
output << '}'; output << '}';
) )
}; };

View File

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