mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-25 12:43:09 +00:00
change wb_table to call wb_table_metapairs for keeping consistent style
This commit is contained in:
@@ -255,17 +255,12 @@ wb_table_hash(lua_State *L, struct write_block * wb, int index, int depth, int a
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
wb_table(lua_State *L, struct write_block *wb, int index, int depth) {
|
wb_table_metapairs(lua_State *L, struct write_block *wb, int index, int depth) {
|
||||||
luaL_checkstack(L, LUA_MINSTACK, NULL);
|
|
||||||
if (index < 0) {
|
|
||||||
index = lua_gettop(L) + index + 1;
|
|
||||||
}
|
|
||||||
if (luaL_getmetafield(L, index, "__pairs") != LUA_TNIL) {
|
|
||||||
uint8_t n = COMBINE_TYPE(TYPE_TABLE, 0);
|
uint8_t n = COMBINE_TYPE(TYPE_TABLE, 0);
|
||||||
wb_push(wb, &n, 1);
|
wb_push(wb, &n, 1);
|
||||||
lua_pushvalue(L, index);
|
lua_pushvalue(L, index);
|
||||||
lua_call(L, 1, 3);
|
lua_call(L, 1, 3);
|
||||||
while (1) {
|
for(;;) {
|
||||||
lua_pushvalue(L, -2);
|
lua_pushvalue(L, -2);
|
||||||
lua_pushvalue(L, -2);
|
lua_pushvalue(L, -2);
|
||||||
lua_copy(L, -5, -3);
|
lua_copy(L, -5, -3);
|
||||||
@@ -278,6 +273,16 @@ wb_table(lua_State *L, struct write_block *wb, int index, int depth) {
|
|||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
wb_nil(wb);
|
wb_nil(wb);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
wb_table(lua_State *L, struct write_block *wb, int index, int depth) {
|
||||||
|
luaL_checkstack(L, LUA_MINSTACK, NULL);
|
||||||
|
if (index < 0) {
|
||||||
|
index = lua_gettop(L) + index + 1;
|
||||||
|
}
|
||||||
|
if (luaL_getmetafield(L, index, "__pairs") != LUA_TNIL) {
|
||||||
|
wb_table_metapairs(L, wb, index, depth);
|
||||||
} else {
|
} else {
|
||||||
int array_size = wb_table_array(L, wb, index, depth);
|
int array_size = wb_table_array(L, wb, index, depth);
|
||||||
wb_table_hash(L, wb, index, depth, array_size);
|
wb_table_hash(L, wb, index, depth, array_size);
|
||||||
|
|||||||
Reference in New Issue
Block a user