mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-05-30 01:05:24 +00:00
should close on the lua state encapsulation to use it in labmdas
This commit is contained in:
@@ -7,19 +7,20 @@
|
||||
namespace LuaG
|
||||
{
|
||||
State::State()
|
||||
: _state(luaL_newstate())
|
||||
: _state(luaL_newstate()), _shouldClose(true)
|
||||
{
|
||||
luaL_openlibs(_state);
|
||||
}
|
||||
|
||||
State::State(lua_State *L)
|
||||
: _state(L)
|
||||
State::State(lua_State *L, bool shouldClose)
|
||||
: _state(L), _shouldClose(shouldClose)
|
||||
{
|
||||
}
|
||||
|
||||
State::~State()
|
||||
{
|
||||
lua_close(_state);
|
||||
if (_shouldClose)
|
||||
lua_close(_state);
|
||||
}
|
||||
|
||||
lua_State *State::getState(void)
|
||||
|
||||
@@ -14,12 +14,15 @@ namespace LuaG
|
||||
private:
|
||||
//! @brief Lua state
|
||||
lua_State *_state;
|
||||
|
||||
//! @brief Should close the state at destruction
|
||||
bool _shouldClose;
|
||||
public:
|
||||
//! @brief ctor
|
||||
State();
|
||||
|
||||
//! @brief ctor
|
||||
State(lua_State *L);
|
||||
State(lua_State *L, bool shouldClose = false);
|
||||
|
||||
|
||||
//! @brief dtor
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace BBM
|
||||
//! @brief push table of table of the map
|
||||
static int getMap(lua_State *L)
|
||||
{
|
||||
//LuaG::State state(L);
|
||||
LuaG::State state(L);
|
||||
int index = 1;
|
||||
const LuaMap *map = (const LuaMap *) lua_topointer(L, lua_upvalueindex(1));
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace BBM
|
||||
//! @brief get array of nodes, path from a to b
|
||||
static int getPath(lua_State *L)
|
||||
{
|
||||
//LuaG::State state(L);
|
||||
LuaG::State state(L);
|
||||
const LuaMap *map = (const LuaMap *) lua_topointer(L, lua_upvalueindex(1));
|
||||
lua_settop(L, 1);
|
||||
luaL_checktype(L, 1, LUA_TTABLE);
|
||||
|
||||
Reference in New Issue
Block a user