From e4eeedbd6faaef380b58236745856b50cebf4461 Mon Sep 17 00:00:00 2001 From: chai Date: Tue, 7 Aug 2018 00:17:24 +0800 Subject: *update --- src/lua/thread/luaopen_Thread.cpp | 50 +++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'src/lua/thread/luaopen_Thread.cpp') diff --git a/src/lua/thread/luaopen_Thread.cpp b/src/lua/thread/luaopen_Thread.cpp index c08c262..99ddee1 100644 --- a/src/lua/thread/luaopen_Thread.cpp +++ b/src/lua/thread/luaopen_Thread.cpp @@ -32,9 +32,9 @@ namespace jin return nullptr; } - static int threadRunner(void* p) + static void threadRunner(jin::thread::Thread* t) { - Thread* thread = (Thread*)p; + Thread* thread = (Thread*)t; lua_State* L = lua_open(); luax_openlibs(L); luaopen_jin(L); @@ -64,21 +64,21 @@ namespace jin static int l_send(lua_State* L) { Thread* t = checkThread(L); - const char* name = luax_checkstring(L, 2); + int slot = luax_checkinteger(L, 2); if (luax_isnumber(L, 3)) { float real = luax_checknumber(L, 3); - t->send(name, real); + t->send(slot, real); } else if (luax_isboolean(L, 3)) { bool bol = luax_checkbool(L, 3); - t->send(name, bol); + t->send(slot, bol); } else if (luax_isstring(L, 3)) { const char* str = luax_checkstring(L, 3); - t->send(name, str); + t->send(slot, str); } return 0; } @@ -86,8 +86,8 @@ namespace jin static int l_receive(lua_State* L) { Thread* t = checkThread(L); - const char* name = luax_checkstring(L, 2); - bool result = t->receive(name); + int slot = luax_checkinteger(L, 2); + bool result = t->receive(slot); luax_pushboolean(L, result); return 1; } @@ -95,23 +95,23 @@ namespace jin static int l_fetch(lua_State* L) { Thread* t = checkThread(L); - const char* name = luax_checkstring(L, 2); - Thread::Value v = t->fetch(name); - if (v.type == Thread::Value::INTEGER) - { - luax_pushinteger(L, v.integer); - } - else if (v.type == Thread::Value::BOOL) - { - luax_pushboolean(L, v.boolean); - } - else if (v.type == Thread::Value::STRING) - { - luax_pushstring(L, v.cstring); - } - else if (v.type == Thread::Value::POINTER) - { - } + int slot = luax_checkinteger(L, 2); + Thread::Variant v = t->fetch(slot); + //if (v.type == Thread::Value::INTEGER) + //{ + // luax_pushinteger(L, v.integer); + //} + //else if (v.type == Thread::Value::BOOL) + //{ + // luax_pushboolean(L, v.boolean); + //} + //else if (v.type == Thread::Value::STRING) + //{ + // luax_pushstring(L, v.cstring); + //} + //else if (v.type == Thread::Value::POINTER) + //{ + //} return 1; } -- cgit v1.1-26-g67d0