mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-06-05 10:59:48 +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
|
||||
|
||||
Reference in New Issue
Block a user