diff options
| author | chai <chaifix@163.com> | 2018-11-12 21:58:05 +0800 |
|---|---|---|
| committer | chai <chaifix@163.com> | 2018-11-12 21:58:05 +0800 |
| commit | af62f267a24091a16cbafe844d59cdbd4e78f5b1 (patch) | |
| tree | 3862cee497b30a9c54761c7cd60c5de5af4a78d3 /src/lua/common/je_lua_reference.h | |
| parent | 72e45f0062d727cedd576d1e1251f6722454a119 (diff) | |
*使用int做状态机key
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; |
