aboutsummaryrefslogtreecommitdiff
path: root/src/lua/thread/luaopen_Thread.cpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-08-07 00:17:24 +0800
committerchai <chaifix@163.com>2018-08-07 00:17:24 +0800
commite4eeedbd6faaef380b58236745856b50cebf4461 (patch)
tree9284fe65848c41526d1d429400c425e47b888504 /src/lua/thread/luaopen_Thread.cpp
parentf5e72dd12fc47f082a4f6d14090391410aa8a9f1 (diff)
*update
Diffstat (limited to 'src/lua/thread/luaopen_Thread.cpp')
-rw-r--r--src/lua/thread/luaopen_Thread.cpp50
1 files changed, 25 insertions, 25 deletions
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;
}