fix match thread, table key

This commit is contained in:
zixun
2019-10-19 11:25:42 +08:00
committed by 云风
parent 4ddc1577ef
commit 8a1d7006eb
2 changed files with 83 additions and 2 deletions

View File

@@ -83,6 +83,34 @@ clone_table(lua_State *L) {
return 1;
}
static int
lco_stackvalues(lua_State* L) {
lua_State *cL = lua_tothread(L, 1);
luaL_argcheck(L, cL, 1, "thread expected");
int n = 0;
if(cL != L) {
luaL_checktype(L, 2, LUA_TTABLE);
n = lua_gettop(cL);
if(n > 0) {
lua_checkstack(L, n+1);
int top = lua_gettop(L);
lua_xmove(cL, L, n);
int i=0;
for(i=0; i<n; i++) {
lua_pushvalue(L, top+1+i);
lua_seti(L, 2, i+1);
}
lua_xmove(L, cL, n);
} else {
n = 0;
}
}
lua_pushinteger(L, n);
return 1;
}
struct state_ud {
lua_State *L;
};
@@ -218,6 +246,7 @@ luaopen_skynet_sharetable_core(lua_State *L) {
luaL_checkversion(L);
luaL_Reg l[] = {
{ "clone", clone_table },
{ "stackvalues", lco_stackvalues },
{ "matrix", matrix_from_file },
{ "is_sharedtable", lis_sharedtable },
{ NULL, NULL },