osb/source/utility/game_repl.cpp
Kai Blaschke 431a9c00a5
Fixed a huge amount of Clang warnings
On Linux and macOS, using Clang to compile OpenStarbound produces about 400 MB worth of warnings during the build, making the compiler output unreadable and slowing the build down considerably.

99% of the warnings were unqualified uses of std::move and std::forward, which are now all properly qualified.

Fixed a few other minor warnings about non-virtual destructors and some uses of std::move preventing copy elision on temporary objects.

Most remaining warnings are now unused parameters.
2024-02-19 16:55:19 +01:00

54 lines
1.4 KiB
C++

#include "StarRootLoader.hpp"
#include "StarRootLuaBindings.hpp"
#include "StarUtilityLuaBindings.hpp"
#include "StarRootLuaBindings.hpp"
using namespace Star;
int main(int argc, char** argv) {
RootLoader rootLoader({{}, {}, {}, LogLevel::Error, false, {}});
RootUPtr root;
OptionParser::Options options;
tie(root, options) = rootLoader.commandInitOrDie(argc, argv);
auto engine = LuaEngine::create(true);
auto context = engine->createContext();
context.setCallbacks("sb", LuaBindings::makeUtilityCallbacks());
context.setCallbacks("root", LuaBindings::makeRootCallbacks());
String code;
bool continuation = false;
while (!std::cin.eof()) {
auto getline = [](std::istream& stream) -> String {
std::string line;
std::getline(stream, line);
return String(std::move(line));
};
if (continuation) {
std::cout << ">> ";
std::cout.flush();
code += getline(std::cin);
code += '\n';
} else {
std::cout << "> ";
std::cout.flush();
code = getline(std::cin);
code += '\n';
}
try {
auto result = context.eval<LuaVariadic<LuaValue>>(code);
for (auto r : result)
coutf("{}\n", r);
continuation = false;
} catch (LuaIncompleteStatementException const&) {
continuation = true;
} catch (std::exception const& e) {
coutf("Error: {}\n", outputException(e, false));
continuation = false;
}
}
return 0;
}