OpenGTA/lua_addon/lua_stackguard.cpp
Anonymous Maarten 78c27f03c8 2006-12-10
2015-12-03 01:37:02 +01:00

23 lines
504 B
C++

#include <cassert>
#include "lua_stackguard.h"
#include "log.h"
namespace Util {
LuaStackguard::LuaStackguard(const char* f, int l, lua_State *L) {
assert(L);
m_state = L;
i_file = f;
i_line = l;
m_top = lua_gettop(m_state);
}
LuaStackguard::~LuaStackguard() {
int now_top = lua_gettop(m_state);
if (now_top > m_top) {
Util::Log::warn(i_file, i_line) << "Stack-balance: " << now_top << " > " << m_top << std::endl;
lua_settop(m_state, m_top);
}
}
}