summaryrefslogtreecommitdiffstats
path: root/src/Bindings
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2021-01-26 10:41:55 +0100
committerGitHub <noreply@github.com>2021-01-26 10:41:55 +0100
commit50a94f972d26ee15fc22cce657d13023d1022905 (patch)
tree24417c741cf85061b73098a32e61ecd3749be05e /src/Bindings
parentRedstone: inline -> static (diff)
downloadcuberite-50a94f972d26ee15fc22cce657d13023d1022905.tar
cuberite-50a94f972d26ee15fc22cce657d13023d1022905.tar.gz
cuberite-50a94f972d26ee15fc22cce657d13023d1022905.tar.bz2
cuberite-50a94f972d26ee15fc22cce657d13023d1022905.tar.lz
cuberite-50a94f972d26ee15fc22cce657d13023d1022905.tar.xz
cuberite-50a94f972d26ee15fc22cce657d13023d1022905.tar.zst
cuberite-50a94f972d26ee15fc22cce657d13023d1022905.zip
Diffstat (limited to 'src/Bindings')
-rw-r--r--src/Bindings/LuaState.cpp17
-rw-r--r--src/Bindings/LuaState.h2
2 files changed, 7 insertions, 12 deletions
diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp
index 81dcb0e67..8c47ab322 100644
--- a/src/Bindings/LuaState.cpp
+++ b/src/Bindings/LuaState.cpp
@@ -388,10 +388,8 @@ cLuaState::cStackTable::cStackTable(cLuaState & a_LuaState, int a_StackPos):
void cLuaState::cStackTable::ForEachArrayElement(cFunctionRef<bool(cLuaState & a_LuaState, int a_Index)> a_ElementCallback) const
{
- auto numElements = luaL_getn(m_LuaState, m_StackPos);
- #ifdef _DEBUG
- auto stackTop = lua_gettop(m_LuaState);
- #endif
+ const auto numElements = luaL_getn(m_LuaState, m_StackPos);
+ [[maybe_unused]] const auto stackTop = lua_gettop(m_LuaState);
for (int idx = 1; idx <= numElements; idx++)
{
// Push the idx-th element of the array onto stack top and call the callback:
@@ -413,9 +411,7 @@ void cLuaState::cStackTable::ForEachArrayElement(cFunctionRef<bool(cLuaState & a
void cLuaState::cStackTable::ForEachElement(cFunctionRef<bool(cLuaState & a_LuaState)> a_ElementCallback) const
{
- #ifdef _DEBUG
- auto stackTop = lua_gettop(m_LuaState);
- #endif
+ [[maybe_unused]] const auto stackTop = lua_gettop(m_LuaState);
lua_pushvalue(m_LuaState, m_StackPos); // Stk: <table>
lua_pushnil(m_LuaState); // Stk: <table> nil
while (lua_next(m_LuaState, -2)) // Stk: <table> <key> <val>
@@ -2255,11 +2251,10 @@ int cLuaState::CopyStackFrom(cLuaState & a_SrcLuaState, int a_SrcStart, int a_Sr
bool cLuaState::CopyTableFrom(cLuaState & a_SrcLuaState, int a_SrcStackIdx, int a_NumAllowedNestingLevels)
{
+ [[maybe_unused]] const auto srcTop = lua_gettop(a_SrcLuaState);
+ [[maybe_unused]] const auto dstTop = lua_gettop(m_LuaState);
+
// Create the dest table:
- #ifdef _DEBUG
- auto srcTop = lua_gettop(a_SrcLuaState);
- auto dstTop = lua_gettop(m_LuaState);
- #endif
lua_createtable(m_LuaState, 0, 0); // DST: <table>
lua_pushvalue(a_SrcLuaState, a_SrcStackIdx); // SRC: <table>
lua_pushnil(a_SrcLuaState); // SRC: <table> <key>
diff --git a/src/Bindings/LuaState.h b/src/Bindings/LuaState.h
index b3f567ecb..8798b2b68 100644
--- a/src/Bindings/LuaState.h
+++ b/src/Bindings/LuaState.h
@@ -58,7 +58,7 @@ class cLuaState
{
public:
- #ifdef _DEBUG
+ #ifndef NDEBUG
/** Asserts that the Lua stack has the same amount of entries when this object is destructed, as when it was constructed.
Used for checking functions that should preserve Lua stack balance. */
class cStackBalanceCheck