Fix bug when passing type with holder by value to Lua.
[luabind.git] / luabind / detail / debug.hpp
blobef13bc8862f00d61c55705b780f8006eee4c6bd3
1 // Copyright (c) 2003 Daniel Wallin and Arvid Norberg
3 // Permission is hereby granted, free of charge, to any person obtaining a
4 // copy of this software and associated documentation files (the "Software"),
5 // to deal in the Software without restriction, including without limitation
6 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 // and/or sell copies of the Software, and to permit persons to whom the
8 // Software is furnished to do so, subject to the following conditions:
10 // The above copyright notice and this permission notice shall be included
11 // in all copies or substantial portions of the Software.
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
14 // ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
15 // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
16 // PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
17 // SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
18 // ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
21 // OR OTHER DEALINGS IN THE SOFTWARE.
23 #ifndef LUABIND_DEBUG_HPP_INCLUDED
24 #define LUABIND_DEBUG_HPP_INCLUDED
26 #ifndef NDEBUG
28 #include <luabind/lua_include.hpp>
29 #include <cassert>
31 namespace luabind { namespace detail
33 struct stack_checker_type
35 stack_checker_type(lua_State* L)
36 : m_L(L)
37 , m_stack(lua_gettop(m_L))
40 ~stack_checker_type()
42 assert(m_stack == lua_gettop(m_L));
45 lua_State* m_L;
46 int m_stack;
50 #define LUABIND_CHECK_STACK(L) luabind::detail::stack_checker_type stack_checker_object(L)
51 #else
52 #define LUABIND_CHECK_STACK(L) do {} while (0)
53 #endif
55 #endif // LUABIND_DEBUG_HPP_INCLUDED