aboutsummaryrefslogtreecommitdiff
path: root/src/lua/common/je_lua_reference.cpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-11-12 21:58:05 +0800
committerchai <chaifix@163.com>2018-11-12 21:58:05 +0800
commitaf62f267a24091a16cbafe844d59cdbd4e78f5b1 (patch)
tree3862cee497b30a9c54761c7cd60c5de5af4a78d3 /src/lua/common/je_lua_reference.cpp
parent72e45f0062d727cedd576d1e1251f6722454a119 (diff)
*使用int做状态机key
Diffstat (limited to 'src/lua/common/je_lua_reference.cpp')
-rw-r--r--src/lua/common/je_lua_reference.cpp31
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