Skip to content

Instantly share code, notes, and snippets.

@billyquith
Last active May 23, 2016 08:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billyquith/2c5dff02d174604266dfc99d7493f1e0 to your computer and use it in GitHub Desktop.
Save billyquith/2c5dff02d174604266dfc99d7493f1e0 to your computer and use it in GitHub Desktop.
Useful Lua C API debug macros
// Put at start of function
#define LUDB_DECL int db_top(0),zz_ltop=lua_gettop(L),db_d_top(0),db_typei(-1),db_idx(0); \
const char *db_type(0), *db_valstr(0);
// Put after each line Lua API was used
#define LUDB(I) db_top=lua_gettop(L); db_d_top=db_top-zz_ltop; zz_ltop=db_top; \
db_typei=lua_type(L,I); db_type=lua_typename(L,db_typei); \
db_valstr=lua_tostring(L,I); db_idx= I>=0 ? I : db_top+I+1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment