diff options
Diffstat (limited to 'src/lua/common/je_lua_reference.cpp')
-rw-r--r-- | src/lua/common/je_lua_reference.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/lua/common/je_lua_reference.cpp b/src/lua/common/je_lua_reference.cpp new file mode 100644 index 0000000..90223de --- /dev/null +++ b/src/lua/common/je_lua_reference.cpp @@ -0,0 +1,31 @@ +#include "je_lua_reference.h" + +namespace JinEngine +{ + namespace Lua + { + + LuaRef::LuaRef(lua_State* L, int i) + : mL(L) + { + luax_pushvalue(mL, i); + mIndex = luax_ref(mL, LUA_REGISTRYINDEX); + } + + LuaRef::~LuaRef() + { + unref(); + } + + void LuaRef::unref() + { + luax_unref(mL, LUA_REGISTRYINDEX, mIndex); + } + + void LuaRef::push() + { + luax_rawgeti(mL, LUA_REGISTRYINDEX, mIndex); + } + + } +}
\ No newline at end of file |