#ifndef SHOW_STACK #define SHOW_STACK(stack) { int show_stack_n = lua_gettop(stack), show_stack_i; printf(" _____________________STACK_____________________ "); for(show_stack_i=show_stack_n;show_stack_i>0;--show_stack_i) switch(lua_type(L, show_stack_i)) { case LUA_TNIL: printf("| %d / %d IS A LUA_TNIL ", show_stack_i, show_stack_n); break; case LUA_TNUMBER: printf("| %d / %d IS A LUA_TNUMBER ", show_stack_i, show_stack_n); break; case LUA_TBOOLEAN: printf("| %d / %d IS A LUA_TBOOLEAN ", show_stack_i, show_stack_n); break; case LUA_TSTRING: printf("| %d / %d IS A LUA_TSTRING ", show_stack_i, show_stack_n); break; case LUA_TTABLE: printf("| %d / %d IS A LUA_TTABLE ", show_stack_i, show_stack_n); break; case LUA_TFUNCTION: printf("| %d / %d IS A LUA_TFUNCTION ", show_stack_i, show_stack_n); break; case LUA_TUSERDATA: printf("| %d / %d IS A LUA_TUSERDATA ", show_stack_i, show_stack_n); break; case LUA_TTHREAD: printf("| %d / %d IS A LUA_TTHREAD ", show_stack_i, show_stack_n); break; case LUA_TLIGHTUSERDATA: printf("| %d / %d IS A LUA_TLIGHTUSERDATA ", show_stack_i, show_stack_n); break; default: printf("| %d / %d IS A UNKNOWN ", show_stack_i, show_stack_n); break;}} #endif // SHOW_STACK #ifndef EXPAND_TABLE #define EXPAND_TABLE(stack) do{ printf(" _____________________TABLE_____________________ "); if(!lua_gettop(stack)) { printf("| STACK IS EMPTY ");break;} int stack_table_idx = lua_gettop(stack); if(!lua_istable(stack, stack_table_idx)){ printf("| STACK TOP IS NOT TABLE ");break;} lua_pushnil(stack); while (lua_next(stack, stack_table_idx)!=0){ printf("|%20s ", lua_tostring(stack, -2)); switch(lua_type(L, -1)) { case LUA_TNIL: printf("LUA_TNIL "); break; case LUA_TNUMBER: printf("LUA_TNUMBER "); break; case LUA_TBOOLEAN: printf("LUA_TBOOLEAN "); break; case LUA_TSTRING: printf("LUA_TSTRING "); break; case LUA_TTABLE: printf("LUA_TTABLE "); break; case LUA_TFUNCTION: printf("LUA_TFUNCTION "); break; case LUA_TUSERDATA: printf("LUA_TUSERDATA "); break; case LUA_TTHREAD: printf("LUA_TTHREAD "); break; case LUA_TLIGHTUSERDATA: printf("LUA_TLIGHTUSERDATA "); break; default: printf("UNKNOWN "); break;}lua_pop(L, 1); }}while(0); #endif // EXPAND_TABLE