VR-Engage  2.2
Loading...
Searching...
No Matches
makVre::DtLuaStackCleaner Class Reference

Detailed Description

The DtLuaStackCleaner class implements the RAII (Resource Acquisition Is Initialization) pattern for managing the Lua stack. It saves the current stack top on construction and restores it on destruction, ensuring the stack is properly cleaned up after operations that might modify it.

This is particularly useful for operations that push values onto the stack but need to ensure the stack returns to its original state, even in the presence of exceptions.

#include <luaStackCleaner.h>

Public Member Functions

 DtLuaStackCleaner (lua_State &vm)
 
 ~DtLuaStackCleaner ()
 

Protected Attributes

lua_State & myState
 
int myTop
 

Constructor & Destructor Documentation

◆ DtLuaStackCleaner()

makVre::DtLuaStackCleaner::DtLuaStackCleaner ( lua_State & vm)

Constructor.

Records the current top of the Lua stack to restore it later.

Parameters
vmReference to the Lua state

◆ ~DtLuaStackCleaner()

makVre::DtLuaStackCleaner::~DtLuaStackCleaner ( )

Destructor.

Restores the Lua stack to the position it was at when the cleaner was constructed

Member Data Documentation

◆ myState

lua_State& makVre::DtLuaStackCleaner::myState
protected

Reference to the Lua state being managed.

◆ myTop

int makVre::DtLuaStackCleaner::myTop
protected

The original top position of the stack.


The documentation for this class was generated from the following file: