mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-15 00:05:02 +02:00
vcmi: modernize lua
This commit is contained in:
@ -34,13 +34,12 @@ namespace scripting
|
||||
|
||||
const std::string LuaContext::STATE_FIELD = "DATA";
|
||||
|
||||
LuaContext::LuaContext(const Script * source, const Environment * env_)
|
||||
: ContextBase(env_->logger()),
|
||||
LuaContext::LuaContext(const Script * source, const Environment * env_):
|
||||
ContextBase(env_->logger()),
|
||||
L(luaL_newstate()),
|
||||
script(source),
|
||||
env(env_)
|
||||
{
|
||||
L = luaL_newstate();
|
||||
|
||||
static const std::vector<luaL_Reg> STD_LIBS =
|
||||
{
|
||||
{"", luaopen_base},
|
||||
@ -417,7 +416,7 @@ void LuaContext::popAll()
|
||||
std::string LuaContext::toStringRaw(int index)
|
||||
{
|
||||
size_t len = 0;
|
||||
auto raw = lua_tolstring(L, index, &len);
|
||||
const auto *raw = lua_tolstring(L, index, &len);
|
||||
return std::string(raw, len);
|
||||
}
|
||||
|
||||
@ -431,7 +430,7 @@ void LuaContext::registerCore()
|
||||
|
||||
popAll();//just in case
|
||||
|
||||
for(auto & registar : api::Registry::get()->getCoreData())
|
||||
for(const auto & registar : api::Registry::get()->getCoreData())
|
||||
{
|
||||
registar.second->pushMetatable(L); //table
|
||||
|
||||
@ -446,7 +445,7 @@ void LuaContext::registerCore()
|
||||
|
||||
int LuaContext::require(lua_State * L)
|
||||
{
|
||||
LuaContext * self = static_cast<LuaContext *>(lua_touserdata(L, lua_upvalueindex(1)));
|
||||
auto * self = static_cast<LuaContext *>(lua_touserdata(L, lua_upvalueindex(1)));
|
||||
|
||||
if(!self)
|
||||
{
|
||||
@ -503,7 +502,7 @@ int LuaContext::loadModule()
|
||||
|
||||
if(scope.empty())
|
||||
{
|
||||
auto registar = api::Registry::get()->find(modulePath);
|
||||
const auto *registar = api::Registry::get()->find(modulePath);
|
||||
|
||||
if(!registar)
|
||||
{
|
||||
@ -519,7 +518,7 @@ int LuaContext::loadModule()
|
||||
|
||||
boost::algorithm::replace_all(modulePath, ".", "/");
|
||||
|
||||
auto loader = CResourceHandler::get(CModHandler::scopeBuiltin());
|
||||
auto *loader = CResourceHandler::get(CModHandler::scopeBuiltin());
|
||||
|
||||
modulePath = "scripts/lib/" + modulePath;
|
||||
|
||||
@ -582,7 +581,7 @@ int LuaContext::printImpl()
|
||||
|
||||
int LuaContext::logError(lua_State * L)
|
||||
{
|
||||
LuaContext * self = static_cast<LuaContext *>(lua_touserdata(L, lua_upvalueindex(1)));
|
||||
auto * self = static_cast<LuaContext *>(lua_touserdata(L, lua_upvalueindex(1)));
|
||||
|
||||
if(!self)
|
||||
{
|
||||
|
Reference in New Issue
Block a user