refactor: 'lua' namespace expansion

This commit is contained in:
MihailRis
2024-06-11 03:37:35 +03:00
parent 7973a9c32b
commit 0647bc6f90
26 changed files with 613 additions and 723 deletions
+13 -16
View File
@@ -1,34 +1,31 @@
#ifndef LOGIC_SCRIPTING_LUA_HPP_
#define LOGIC_SCRIPTING_LUA_HPP_
#include "../../../delegates.hpp"
#include "../scripting.hpp"
#ifdef __linux__
#include <luajit-2.1/luaconf.h>
#include <luajit-2.1/lua.hpp>
#else
#include <lua.hpp>
#endif
#include <glm/glm.hpp>
#include <string>
#include <stdexcept>
#ifndef LUAJIT_VERSION
#error LuaJIT required
#endif
#include <string>
#include <exception>
namespace lua {
class luaerror : public std::runtime_error {
public:
luaerror(const std::string& message);
};
template <lua_CFunction func> int lua_wrap_errors(lua_State *L) {
int result = 0;
try {
result = func(L);
}
// transform exception with description into lua_error
catch (std::exception &e) {
luaL_error(L, e.what());
}
// Rethrow any other exception (lua error for example)
catch (...) {
throw;
}
return result;
void log_error(const std::string& text);
}
#endif // LOGIC_SCRIPTING_LUA_HPP_