diff options
author | Benoit Germain <bnt.germain@gmail.com> | 2013-01-28 19:44:43 +0100 |
---|---|---|
committer | Benoit Germain <bnt.germain@gmail.com> | 2013-01-28 19:44:43 +0100 |
commit | 3377b95704e611a288791fee6a7bc59c5ecebf2d (patch) | |
tree | 35deabd01dc7c7095c3a11bef5f09456ffb503aa /src/tools.h | |
parent | fb0c67b1c95b6a595c0cd34a66136af6193b4d1b (diff) | |
download | lanes-3377b95704e611a288791fee6a7bc59c5ecebf2d.tar.gz lanes-3377b95704e611a288791fee6a7bc59c5ecebf2d.tar.bz2 lanes-3377b95704e611a288791fee6a7bc59c5ecebf2d.zip |
* More detailed DEBUG_SPEW logs
* A bit of code cosmetics
Diffstat (limited to 'src/tools.h')
-rw-r--r-- | src/tools.h | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/tools.h b/src/tools.h index e4fbd94..f79d2ad 100644 --- a/src/tools.h +++ b/src/tools.h | |||
@@ -38,6 +38,9 @@ | |||
38 | #define USE_DEBUG_SPEW 0 | 38 | #define USE_DEBUG_SPEW 0 |
39 | #if USE_DEBUG_SPEW | 39 | #if USE_DEBUG_SPEW |
40 | extern char const* debugspew_indent; | 40 | extern char const* debugspew_indent; |
41 | extern int debugspew_indent_depth; | ||
42 | #define INDENT_BEGIN "%.*s " | ||
43 | #define INDENT_END , debugspew_indent_depth, debugspew_indent | ||
41 | #define DEBUGSPEW_CODE(_code) _code | 44 | #define DEBUGSPEW_CODE(_code) _code |
42 | #else // USE_DEBUG_SPEW | 45 | #else // USE_DEBUG_SPEW |
43 | #define DEBUGSPEW_CODE(_code) | 46 | #define DEBUGSPEW_CODE(_code) |
@@ -53,10 +56,16 @@ extern char const* debugspew_indent; | |||
53 | #else | 56 | #else |
54 | #define _ASSERT_L(lua,c) do { if (!(c)) luaL_error( lua, "ASSERT failed: %s:%d '%s'", __FILE__, __LINE__, #c ); } while( 0) | 57 | #define _ASSERT_L(lua,c) do { if (!(c)) luaL_error( lua, "ASSERT failed: %s:%d '%s'", __FILE__, __LINE__, #c ); } while( 0) |
55 | // | 58 | // |
56 | #define STACK_CHECK(L) { int _oldtop_##L = lua_gettop(L); | 59 | #define STACK_CHECK(L) { int const _oldtop_##L = lua_gettop( L) |
57 | #define STACK_MID(L,change) { int a= lua_gettop(L)-_oldtop_##L; int b= (change); \ | 60 | #define STACK_MID(L,change) \ |
58 | if (a != b) luaL_error( L, "STACK ASSERT failed (%d not %d): %s:%d", a, b, __FILE__, __LINE__ ); } | 61 | do \ |
59 | #define STACK_END(L,change) STACK_MID(L,change) } | 62 | { \ |
63 | int a = lua_gettop( L) - _oldtop_##L; \ | ||
64 | int b = (change); \ | ||
65 | if( a != b) \ | ||
66 | luaL_error( L, "STACK ASSERT failed (%d not %d): %s:%d", a, b, __FILE__, __LINE__ ); \ | ||
67 | } while( 0) | ||
68 | #define STACK_END(L,change) STACK_MID(L,change); } | ||
60 | 69 | ||
61 | #define STACK_DUMP(L) luaG_dump(L); | 70 | #define STACK_DUMP(L) luaG_dump(L); |
62 | #endif | 71 | #endif |