From 10a0e290ac07524dc129cc2b227b0f9e95df0f8e Mon Sep 17 00:00:00 2001 From: Ben Beltran Date: Mon, 16 Apr 2012 09:39:52 -0500 Subject: first commit --- LuaRestoreStack.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 LuaRestoreStack.h (limited to 'LuaRestoreStack.h') 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 -- cgit