| 51 | stack_guard(lua_State* L, int top, std::function<void(int, int)> fx = detail::stack_fail) : L(L), top(top), on_mismatch(std::move(fx)) { |
| 52 | } |
| 53 | bool check_stack(int modification = 0) const { |
| 54 | int bottom = lua_gettop(L) + modification; |
| 55 | if (top == bottom) { |
| 56 | return true; |
| 57 | } |
| 58 | on_mismatch(top, bottom); |
| 59 | return false; |
| 60 | } |
| 61 | ~stack_guard() { |
| 62 | check_stack(); |
| 63 | } |