• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Lua查看栈的宏

原作者: [db:作者] 来自: [db:来源] 收藏 邀请
#ifndef SHOW_STACK
#define SHOW_STACK(stack) {\
int show_stack_n = lua_gettop(stack), show_stack_i;\
printf(" _____________________STACK_____________________\n");\
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("|\t%d / %d IS A LUA_TNIL\n", show_stack_i, show_stack_n);\
break;\
case LUA_TNUMBER:\
printf("|\t%d / %d IS A LUA_TNUMBER\n", show_stack_i, show_stack_n);\
break;\
case LUA_TBOOLEAN:\
printf("|\t%d / %d IS A LUA_TBOOLEAN\n", show_stack_i, show_stack_n);\
break;\
case LUA_TSTRING:\
printf("|\t%d / %d IS A LUA_TSTRING\n", show_stack_i, show_stack_n);\
break;\
case LUA_TTABLE:\
printf("|\t%d / %d IS A LUA_TTABLE\n", show_stack_i, show_stack_n);\
break;\
case LUA_TFUNCTION:\
printf("|\t%d / %d IS A LUA_TFUNCTION\n", show_stack_i, show_stack_n);\
break;\
case LUA_TUSERDATA:\
printf("|\t%d / %d IS A LUA_TUSERDATA\n", show_stack_i, show_stack_n);\
break;\
case LUA_TTHREAD:\
printf("|\t%d / %d IS A LUA_TTHREAD\n", show_stack_i, show_stack_n);\
break;\
case LUA_TLIGHTUSERDATA:\
printf("|\t%d / %d IS A LUA_TLIGHTUSERDATA\n", show_stack_i, show_stack_n);\
break;\
default:\
printf("|\t%d / %d IS A UNKNOWN\n", show_stack_i, show_stack_n);\
break;}}
#endif // SHOW_STACK


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

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
lua的函数初识发布时间:2022-07-22
下一篇:
Lua多维表的遍历中的赋值发布时间:2022-07-22
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap