diff options
author | chai <chaifix@163.com> | 2018-11-15 08:32:38 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-11-15 08:32:38 +0800 |
commit | a6f2d5fff89b7322009c46a9272668ca4c32ce64 (patch) | |
tree | ff81127c3be8bde426e57db544d69b9616ddc25b /src/lua/modules/thread | |
parent | 611d12bdd245dd43b7434661d3e24f2b435378cb (diff) |
*修改代码结构
Diffstat (limited to 'src/lua/modules/thread')
-rw-r--r-- | src/lua/modules/thread/je_lua_thread.cpp | 16 | ||||
-rw-r--r-- | src/lua/modules/thread/je_lua_thread.h | 2 |
2 files changed, 11 insertions, 7 deletions
diff --git a/src/lua/modules/thread/je_lua_thread.cpp b/src/lua/modules/thread/je_lua_thread.cpp index 290de6e..19b3374 100644 --- a/src/lua/modules/thread/je_lua_thread.cpp +++ b/src/lua/modules/thread/je_lua_thread.cpp @@ -1,5 +1,5 @@ #include "lua/modules/luax.h" -#include "lua/modules/types.h" + #include "libjin/jin.h" #include "lua/jin.h" #include "lua/common/je_lua_common.h" @@ -10,13 +10,15 @@ namespace JinEngine namespace Lua { + const char* Jin_Lua_Thread = "Thread"; + typedef Shared<Thread>& SharedThread; int luaopen_thread(lua_State* L); static inline SharedThread checkThread(lua_State* L) { - Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_THREAD_THREAD); + Proxy* proxy = (Proxy*)luax_checktype(L, 1, Jin_Lua_Thread); return proxy->getShared<Thread>(); } @@ -27,7 +29,7 @@ namespace JinEngine luax_openlibs(L); luaopen_jin(L); luax_getglobal(L, MODULE_NAME); - Proxy* proxy = luax_newinstance(L, JIN_THREAD_THREAD); + Proxy* proxy = luax_newinstance(L, Jin_Lua_Thread); shared.retain(); proxy->bind(&shared); luax_setfield(L, -2, "_curThread"); @@ -38,7 +40,7 @@ namespace JinEngine LUA_IMPLEMENT int l_thread_gc(lua_State* L) { - Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_THREAD_THREAD); + Proxy* proxy = (Proxy*)luax_checktype(L, 1, Jin_Lua_Thread); proxy->release(); return 0; } @@ -209,7 +211,7 @@ namespace JinEngine { 0, 0 } }; - luax_newtype(L, JIN_THREAD_THREAD, thread_function); + luax_newtype(L, Jin_Lua_Thread, thread_function); return 0; } @@ -218,9 +220,9 @@ namespace JinEngine { const char* name = luax_checkstring(L, 1); const char* code = luax_checkstring(L, 2); - Proxy* proxy = luax_newinstance(L, JIN_THREAD_THREAD); + Proxy* proxy = luax_newinstance(L, Jin_Lua_Thread); Thread* thread = new Thread(name, code, threadRunner); - proxy->bind(new Shared<Thread>(thread, JIN_THREAD_THREAD)); + proxy->bind(new Shared<Thread>(thread, Jin_Lua_Thread)); return 1; } diff --git a/src/lua/modules/thread/je_lua_thread.h b/src/lua/modules/thread/je_lua_thread.h index 112af94..a3e4e76 100644 --- a/src/lua/modules/thread/je_lua_thread.h +++ b/src/lua/modules/thread/je_lua_thread.h @@ -6,6 +6,8 @@ namespace JinEngine namespace Lua { + extern const char* Jin_Lua_Thread; + class Thread { public: |