Lua_icxx  1.02 (Aug 2011)
LuaStackSizeChecker Class Reference

Checker class to verify that stack size unchanged. More...

#include <LuaStackSizeChecker.h>

List of all members.

Public Member Functions

 LuaStackSizeChecker (lua_State *lua)
 capture current stack top level
 ~LuaStackSizeChecker ()
 do the check upon destruction
void checkNow () const
 returns true if stack top currently same as at construction

Detailed Description

Checker class to verify that stack size unchanged.

It tracks the stack top when constructed, and asserts that it is the same when destructed. Use as

        {
            LuaStackSizeChecker checker(L);
            ... use Lua C API that manipulates stack...
        } // checker destroyed, asserts no change in stack size

        // or if you don't want to use C++ block:
        LuaStackSizeChecker checker(L);
        ... use Lua C API that manipulates stack...
        checker.checkNow();

Note that the check only occurs in a Debug build (if NDEBUG not defined.

Definition at line 31 of file LuaStackSizeChecker.h.