]> git.r.bdr.sh - rbdr/pico-engine/blob - LuaRestoreStack.h
Update project so it compiles
[rbdr/pico-engine] / LuaRestoreStack.h
1 // ---------------------------------------------------------------------------
2 // FILE NAME : LuaRestoreStack.h
3 // ---------------------------------------------------------------------------
4 // DESCRIPTION :
5 //
6 // Restores the Lua stack to the way we found it :)
7 //
8 // ---------------------------------------------------------------------------
9 // VERSION : 1.00
10 // DATE : 1-Sep-2005
11 // AUTHOR : Richard Shephard
12 // ---------------------------------------------------------------------------
13 // LIBRARY INCLUDE FILES
14 #ifndef __LUA_RESTORE_STACK_H__
15 #define __LUA_RESTORE_STACK_H__
16
17 #include "luainc.h"
18
19 class CLuaRestoreStack
20 {
21 public:
22 CLuaRestoreStack (CLuaVirtualMachine& vm) : m_pState (NULL)
23 {
24 m_pState = (lua_State *) vm;
25 if (vm.Ok ())
26 {
27 m_iTop = lua_gettop (m_pState);
28 }
29 }
30
31 virtual ~CLuaRestoreStack (void)
32 {
33 lua_settop (m_pState, m_iTop);
34 }
35
36 protected:
37 lua_State *m_pState;
38 int m_iTop;
39 };
40
41
42 #endif // __LUA_RESTORE_STACK_H__