summaryrefslogtreecommitdiff
path: root/src/luacxx.cpp
diff options
context:
space:
mode:
authorDominick Allen <djallen@librehumanitas.org>2024-11-10 15:14:38 -0600
committerDominick Allen <djallen@librehumanitas.org>2024-11-10 15:14:38 -0600
commit2b641aa2f4f5b894ceed8bf2a46fcef35e930d56 (patch)
treeb5decb0fcd6a225c89d2ababb0fdf2d84b39a334 /src/luacxx.cpp
parent47e0ff88edd4660513f1d4f3d731008461532a13 (diff)
Refactorings from libfud.HEADmaster
Diffstat (limited to 'src/luacxx.cpp')
-rw-r--r--src/luacxx.cpp13
1 files changed, 6 insertions, 7 deletions
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<const char*> LuaContext::getGlobalString(const char* name)
return LuaResult<const char*>::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<std::vector<std::string>> 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);