From 2b641aa2f4f5b894ceed8bf2a46fcef35e930d56 Mon Sep 17 00:00:00 2001 From: Dominick Allen Date: Sun, 10 Nov 2024 15:14:38 -0600 Subject: Refactorings from libfud. --- src/luacxx.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/luacxx.cpp') diff --git a/src/luacxx.cpp b/src/luacxx.cpp index 0a6db82..c76bddc 100644 --- a/src/luacxx.cpp +++ b/src/luacxx.cpp @@ -9,9 +9,8 @@ namespace getsuyomi { using fud::FudStatus; -LuaContext::LuaContext() +LuaContext::LuaContext() : m_state{luaL_newstate()} { - m_state = luaL_newstate(); if (m_state != nullptr) { luaL_openlibs(m_state); } @@ -25,12 +24,12 @@ LuaContext::~LuaContext() } } -LuaContext::LuaContext(LuaContext&& rhs) : m_state{rhs.m_state} +LuaContext::LuaContext(LuaContext&& rhs) noexcept : m_state{rhs.m_state} { rhs.m_state = nullptr; } -LuaContext& LuaContext::operator=(LuaContext&& rhs) +LuaContext& LuaContext::operator=(LuaContext&& rhs) noexcept { if (m_state != nullptr) { lua_close(m_state); @@ -83,7 +82,7 @@ LuaResult LuaContext::getGlobalString(const char* name) return LuaResult::error(FudStatus::ObjectInvalid); } - size_t length; + size_t length{}; const char* result{nullptr}; auto luaType = lua_getglobal(m_state, name); @@ -114,10 +113,10 @@ LuaResult> LuaContext::getGlobalStringArray(const char* if (luaType != LUA_TTABLE) { lua_pop(m_state, 1); - return RetType::error(FudStatus::InvalidInput); + return RetType::error(FudStatus::ArgumentInvalid); } - int64_t length; + int64_t length{}; int isNumber{}; lua_len(m_state, -1); length = lua_tointegerx(m_state, -1, &isNumber); -- cgit v1.2.3