diff options
Diffstat (limited to 'src/lua/common/je_lua_reference.h')
-rw-r--r-- | src/lua/common/je_lua_reference.h | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/src/lua/common/je_lua_reference.h b/src/lua/common/je_lua_reference.h index 28c3bc3..bde61b6 100644 --- a/src/lua/common/je_lua_reference.h +++ b/src/lua/common/je_lua_reference.h @@ -12,33 +12,18 @@ namespace JinEngine /// This class wraps the reference functionality built into Lua, which allows C++ code to refer to Lua /// variables. /// - class Reference + class LuaRef { public: - Reference(lua_State* L, unsigned int i) - : mL(L) - { - luax_pushvalue(mL, i); - mIndex = luax_ref(mL, LUA_REGISTRYINDEX); - } - - ~Reference() - { - unref(); - } - - void unref() - { - luax_unref(mL, LUA_REGISTRYINDEX, mIndex); - } + LuaRef(lua_State* L, int i); + ~LuaRef(); + + void unref(); /// /// Push value onto the stack. /// - void push() - { - luax_rawgeti(mL, LUA_REGISTRYINDEX, mIndex); - } + void push(); private: lua_State* const mL; |