/**
* [B] -- alias, nil [T]
* | |_________________lua_pushnil
* |________________________lua_next(_, -2)
*
*
* _________________lua_tostring(_, -2)
* |
* [B] -- alias, key, value [T]
* | |____________lua_isstring(_, -1)
* | lua_tostring(_, -1)
* | lua_isfunction(_, -1)
* |
* |_________________lua_pop(_, 1)
* luaL_ref
*
* [B] -- alias, key [T]
* |________________________lua_next(_, -2)
*/
lua_pushnil(f_L);
while (lua_next(f_L, -2) != 0) {
key = lua_tostring(f_L, -2);
if (lua_isstring(f_L, -1)) {
value = lua_tostring(f_L, -1);
printf("key(%s) = value(%s)\n", key, value);
lua_pop(f_L, 1);
} else if (lua_isfunction(f_L, -1)) {
printf("got you type(%d)\n", lua_type(f_L, -1));
// lua_call(f_L, 0, 0); // 调用后函数参数连同函数名已经被lua虚拟机自动弹出
g_agent = luaL_ref(f_L, LUA_REGISTRYINDEX); // luaL_ref也会自动弹出
}
}