diff options
| author | Ben Beltran <ben@nsovocal.com> | 2012-04-16 09:39:52 -0500 |
|---|---|---|
| committer | Ben Beltran <ben@nsovocal.com> | 2012-04-16 09:39:52 -0500 |
| commit | 10a0e290ac07524dc129cc2b227b0f9e95df0f8e (patch) | |
| tree | ed518c45c45d96e37e28640f745496fffb8e1325 /LuaRestoreStack.h | |
first commit
Diffstat (limited to 'LuaRestoreStack.h')
| -rw-r--r-- | LuaRestoreStack.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/LuaRestoreStack.h b/LuaRestoreStack.h new file mode 100644 index 0000000..b529d22 --- /dev/null +++ b/LuaRestoreStack.h @@ -0,0 +1,42 @@ +// ---------------------------------------------------------------------------
+// FILE NAME : LuaRestoreStack.h
+// ---------------------------------------------------------------------------
+// DESCRIPTION :
+//
+// Restores the Lua stack to the way we found it :)
+//
+// ---------------------------------------------------------------------------
+// VERSION : 1.00
+// DATE : 1-Sep-2005
+// AUTHOR : Richard Shephard
+// ---------------------------------------------------------------------------
+// LIBRARY INCLUDE FILES
+#ifndef __LUA_RESTORE_STACK_H__
+#define __LUA_RESTORE_STACK_H__
+
+#include "luainc.h"
+
+class CLuaRestoreStack
+{
+public:
+ CLuaRestoreStack (CLuaVirtualMachine& vm) : m_pState (NULL)
+ {
+ m_pState = (lua_State *) vm;
+ if (vm.Ok ())
+ {
+ m_iTop = lua_gettop (m_pState);
+ }
+ }
+
+ virtual ~CLuaRestoreStack (void)
+ {
+ lua_settop (m_pState, m_iTop);
+ }
+
+protected:
+ lua_State *m_pState;
+ int m_iTop;
+};
+
+
+#endif // __LUA_RESTORE_STACK_H__
\ No newline at end of file |