Changeset 7653 in orxonox.OLD for branches/script_engine/src/lib/script_engine/RestoreStack.h
- Timestamp:
- May 17, 2006, 7:55:59 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/script_engine/src/lib/script_engine/RestoreStack.h
r7645 r7653 4 4 #include "luaincl.h" 5 5 6 //! Class to restore the stack to the way we found it. 7 class LuaRestoreStack 6 namespace OrxScript 8 7 { 9 public: 10 /** 11 * @brief Stores the stack and the index to the top element 12 * 13 * @param virtualMachine the virtual machine to save 14 */ 15 LuaRestoreStack (LuaVirtualMachine& virtualMachine) : savedState (NULL) 16 { 8 9 //! Class to restore the stack to the way we found it. 10 class LuaRestoreStack 11 { 12 public: 13 /** 14 * @brief Stores the stack and the index to the top element 15 * 16 * @param virtualMachine the virtual machine to save 17 */ 18 LuaRestoreStack (LuaVirtualMachine& virtualMachine) : savedState (NULL) 19 { 17 20 savedState = (lua_State *) virtualMachine; 18 21 if (virtualMachine.isOk ()) 19 22 { 20 23 savedTopIndex = lua_gettop (savedState); 21 24 } 22 }23 /**24 * @brief Restores the virtual machine25 *26 *27 */28 virtual ~LuaRestoreStack (void)29 {25 } 26 /** 27 * @brief Restores the virtual machine 28 * 29 * 30 */ 31 virtual ~LuaRestoreStack (void) 32 { 30 33 lua_settop (savedState, savedTopIndex); 31 }34 } 32 35 33 protected:34 lua_State* savedState;35 int savedTopIndex;36 };36 protected: 37 lua_State* savedState; 38 int savedTopIndex; 39 }; 37 40 41 } 38 42 39 43 #endif // __RESTORE_STACK_H__
Note: See TracChangeset
for help on using the changeset viewer.