xoreos  0.0.5
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Aurora::Lua::Stack Class Reference

A Lua stack wrapper. More...

#include <stack.h>

Public Member Functions

 Stack (lua_State &state)
 
 ~Stack ()
 
int getSize () const
 Return the number of elements in the stack. More...
 
void pushNil ()
 Push a nil value onto the stack. More...
 
void pushBoolean (bool value)
 Push a boolean value onto the stack. More...
 
void pushFloat (float value)
 Push a float value onto the stack. More...
 
void pushInt (int value)
 Push an integer value onto the stack. More...
 
void pushString (const char *value)
 Push a raw C string onto the stack. More...
 
void pushString (const Common::UString &value)
 Push a string onto the stack. More...
 
void pushTable (const TableRef &value)
 Push a table onto the stack. More...
 
void pushFunction (const FunctionRef &value)
 Push a function onto the stack. More...
 
void pushRawUserType (void *value, const Common::UString &type)
 Push a raw usertype value onto the stack. More...
 
void pushVariable (const Variable &var)
 
void pushVariables (const Variables &vars)
 
template<typename T >
void pushUserType (T &value, const Common::UString &type)
 Push a usertype value onto the stack. More...
 
bool getBooleanAt (int index) const
 Return a boolean value at the given index in the stack. More...
 
float getFloatAt (int index) const
 Return a float value at the given index in the stack. More...
 
int getIntAt (int index) const
 Return an integer value at the given index in the stack. More...
 
Common::UString getStringAt (int index) const
 Return a string at the given index in the stack. More...
 
TableRef getTableAt (int index) const
 Return a table at the given index in the stack. More...
 
FunctionRef getFunctionAt (int index) const
 Return a function at the given index in the stack. More...
 
void * getRawUserTypeAt (int index, const Common::UString &type="") const
 Return a raw usertype value at the given index in the stack. More...
 
template<typename T >
T * getUserTypeAt (int index, const Common::UString &type="") const
 Return a usertype value at the given index in the stack. More...
 
Variable getVariableAt (int index) const
 
Common::UString getExactTypeAt (int index) const
 Return the type of the value at the given index in the stack. More...
 
Type getTypeAt (int index) const
 
Variables getVariables () const
 
Variables getVariablesFromTop (int count) const
 
bool isNilAt (int index) const
 Check whether the value with the given index is a nil. More...
 
bool isBooleanAt (int index) const
 Check whether the value at the given index is a boolean value. More...
 
bool isNumberAt (int index) const
 Check whether the value at the given index is a number. More...
 
bool isStringAt (int index) const
 Check whether the value at the given index is a string. More...
 
bool isTableAt (int index) const
 Check whether the value at the given index is a table. More...
 
bool isFunctionAt (int index) const
 Check whether the value at the given index is a function. More...
 
bool isUserTypeAt (int index, const Common::UString &type="") const
 Check whether the value at the given index is a usertype value. More...
 
void registerGCForTopObject ()
 
lua_State & getLuaState () const
 Return the underlying Lua state. More...
 

Private Member Functions

bool checkIndex (int index) const
 Check whether the given index is valid. More...
 

Private Attributes

lua_State & _luaState
 The Lua state. More...
 

Detailed Description

A Lua stack wrapper.

Definition at line 41 of file stack.h.

Constructor & Destructor Documentation

◆ Stack()

Aurora::Lua::Stack::Stack ( lua_State &  state)

Definition at line 40 of file stack.cpp.

◆ ~Stack()

Aurora::Lua::Stack::~Stack ( )

Definition at line 44 of file stack.cpp.

Member Function Documentation

◆ checkIndex()

bool Aurora::Lua::Stack::checkIndex ( int  index) const
private

Check whether the given index is valid.

Definition at line 305 of file stack.cpp.

References getSize().

Referenced by getExactTypeAt(), getTypeAt(), isBooleanAt(), isFunctionAt(), isNilAt(), isNumberAt(), isStringAt(), isTableAt(), and isUserTypeAt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getBooleanAt()

bool Aurora::Lua::Stack::getBooleanAt ( int  index) const

Return a boolean value at the given index in the stack.

Definition at line 134 of file stack.cpp.

References _luaState, and isBooleanAt().

Referenced by getVariableAt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getExactTypeAt()

Common::UString Aurora::Lua::Stack::getExactTypeAt ( int  index) const

Return the type of the value at the given index in the stack.

Definition at line 208 of file stack.cpp.

References _luaState, and checkIndex().

Referenced by Aurora::Lua::TableRef::getExactType(), Aurora::Lua::TableRef::getExactTypeAt(), and getVariableAt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFloatAt()

float Aurora::Lua::Stack::getFloatAt ( int  index) const

Return a float value at the given index in the stack.

Definition at line 141 of file stack.cpp.

References _luaState, and isNumberAt().

Referenced by getVariableAt(), and Engines::Witcher::LuaBindings::Vector::luaNewLocal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFunctionAt()

FunctionRef Aurora::Lua::Stack::getFunctionAt ( int  index) const

Return a function at the given index in the stack.

Definition at line 169 of file stack.cpp.

References _luaState, and isFunctionAt().

Referenced by getVariableAt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getIntAt()

int Aurora::Lua::Stack::getIntAt ( int  index) const

Return an integer value at the given index in the stack.

Definition at line 148 of file stack.cpp.

References _luaState, and isNumberAt().

Here is the call graph for this function:

◆ getLuaState()

lua_State & Aurora::Lua::Stack::getLuaState ( ) const

Return the underlying Lua state.

Definition at line 301 of file stack.cpp.

References _luaState.

Referenced by Aurora::Lua::FunctionRef::call().

Here is the caller graph for this function:

◆ getRawUserTypeAt()

void * Aurora::Lua::Stack::getRawUserTypeAt ( int  index,
const Common::UString type = "" 
) const

Return a raw usertype value at the given index in the stack.

Definition at line 176 of file stack.cpp.

References _luaState, Common::UString::c_str(), and isUserTypeAt().

Referenced by Aurora::Lua::getRawCppObjectFromStack(), getUserTypeAt(), getVariableAt(), Aurora::Lua::ScriptManager::luaRegisterSubst(), and Aurora::Lua::ScriptManager::luaUnregisterSubst().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSize()

int Aurora::Lua::Stack::getSize ( ) const

◆ getStringAt()

Common::UString Aurora::Lua::Stack::getStringAt ( int  index) const

Return a string at the given index in the stack.

Definition at line 155 of file stack.cpp.

References _luaState, and isStringAt().

Referenced by getVariableAt(), and Aurora::Lua::ScriptManager::luaPlayFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTableAt()

TableRef Aurora::Lua::Stack::getTableAt ( int  index) const

Return a table at the given index in the stack.

Definition at line 162 of file stack.cpp.

References _luaState, and isTableAt().

Referenced by Aurora::Lua::TableRef::getMetaTable(), Aurora::Lua::getRawCppObjectFromStack(), getVariableAt(), and Aurora::Lua::ScriptManager::luaRegisterSubst().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTypeAt()

Type Aurora::Lua::Stack::getTypeAt ( int  index) const

◆ getUserTypeAt()

template<typename T >
T * Aurora::Lua::Stack::getUserTypeAt ( int  index,
const Common::UString type = "" 
) const

Return a usertype value at the given index in the stack.

If type is not empty, perform a type check.

Definition at line 143 of file stack.h.

References getRawUserTypeAt().

Referenced by Aurora::Lua::ScriptManager::luaRegisterSubst(), and Aurora::Lua::ScriptManager::luaUnregisterSubst().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getVariableAt()

Variable Aurora::Lua::Stack::getVariableAt ( int  index) const

◆ getVariables()

Variables Aurora::Lua::Stack::getVariables ( ) const

Definition at line 246 of file stack.cpp.

References getSize(), and getVariableAt().

Here is the call graph for this function:

◆ getVariablesFromTop()

Aurora::Lua::Variables Aurora::Lua::Stack::getVariablesFromTop ( int  count) const

Definition at line 254 of file stack.cpp.

Referenced by Aurora::Lua::FunctionRef::call().

Here is the caller graph for this function:

◆ isBooleanAt()

bool Aurora::Lua::Stack::isBooleanAt ( int  index) const

Check whether the value at the given index is a boolean value.

Definition at line 267 of file stack.cpp.

References _luaState, and checkIndex().

Referenced by getBooleanAt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isFunctionAt()

bool Aurora::Lua::Stack::isFunctionAt ( int  index) const

Check whether the value at the given index is a function.

Definition at line 283 of file stack.cpp.

References _luaState, and checkIndex().

Referenced by getFunctionAt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isNilAt()

bool Aurora::Lua::Stack::isNilAt ( int  index) const

Check whether the value with the given index is a nil.

Definition at line 263 of file stack.cpp.

References _luaState, and checkIndex().

Here is the call graph for this function:

◆ isNumberAt()

bool Aurora::Lua::Stack::isNumberAt ( int  index) const

Check whether the value at the given index is a number.

Definition at line 271 of file stack.cpp.

References _luaState, and checkIndex().

Referenced by getFloatAt(), and getIntAt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isStringAt()

bool Aurora::Lua::Stack::isStringAt ( int  index) const

Check whether the value at the given index is a string.

Definition at line 275 of file stack.cpp.

References _luaState, and checkIndex().

Referenced by getStringAt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isTableAt()

bool Aurora::Lua::Stack::isTableAt ( int  index) const

Check whether the value at the given index is a table.

Definition at line 279 of file stack.cpp.

References _luaState, and checkIndex().

Referenced by getTableAt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isUserTypeAt()

bool Aurora::Lua::Stack::isUserTypeAt ( int  index,
const Common::UString type = "" 
) const

Check whether the value at the given index is a usertype value.

If type is not empty, perform a type check.

Definition at line 287 of file stack.cpp.

References _luaState, Common::UString::c_str(), checkIndex(), Common::UString::empty(), error(), getTypeAt(), and Aurora::Lua::kTypeUserType.

Referenced by getRawUserTypeAt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pushBoolean()

void Aurora::Lua::Stack::pushBoolean ( bool  value)

◆ pushFloat()

void Aurora::Lua::Stack::pushFloat ( float  value)

Push a float value onto the stack.

Definition at line 60 of file stack.cpp.

References _luaState.

Referenced by pushVariable().

Here is the caller graph for this function:

◆ pushFunction()

void Aurora::Lua::Stack::pushFunction ( const FunctionRef value)

Push a function onto the stack.

Definition at line 85 of file stack.cpp.

References _luaState, and Aurora::Lua::FunctionRef::getRef().

Referenced by pushVariable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pushInt()

void Aurora::Lua::Stack::pushInt ( int  value)

◆ pushNil()

void Aurora::Lua::Stack::pushNil ( )

Push a nil value onto the stack.

Definition at line 52 of file stack.cpp.

References _luaState.

Referenced by Engines::Witcher::LuaBindings::C2DA::luaGetCExoStringEntry(), Engines::Witcher::LuaBindings::C2DA::luaGetIntEntry(), and pushVariable().

Here is the caller graph for this function:

◆ pushRawUserType()

void Aurora::Lua::Stack::pushRawUserType ( void *  value,
const Common::UString type 
)

Push a raw usertype value onto the stack.

Definition at line 94 of file stack.cpp.

References _luaState, and Common::UString::c_str().

Referenced by pushUserType(), and pushVariable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pushString() [1/2]

void Aurora::Lua::Stack::pushString ( const char *  value)

Push a raw C string onto the stack.

Definition at line 68 of file stack.cpp.

References _luaState.

Referenced by Engines::Witcher::LuaBindings::C2DA::luaGetCExoStringEntry(), and pushVariable().

Here is the caller graph for this function:

◆ pushString() [2/2]

void Aurora::Lua::Stack::pushString ( const Common::UString value)

Push a string onto the stack.

Definition at line 72 of file stack.cpp.

References _luaState, and Common::UString::c_str().

Here is the call graph for this function:

◆ pushTable()

void Aurora::Lua::Stack::pushTable ( const TableRef value)

Push a table onto the stack.

Definition at line 76 of file stack.cpp.

References _luaState, and Aurora::Lua::TableRef::getRef().

Referenced by pushVariable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pushUserType()

template<typename T >
void Aurora::Lua::Stack::pushUserType ( T &  value,
const Common::UString type 
)

Push a usertype value onto the stack.

Expect that type is a name of the registered type in the script subsystem.

Definition at line 138 of file stack.h.

References pushRawUserType().

Referenced by Aurora::Lua::ScriptManager::luaGetLua(), Engines::Witcher::LuaBindings::Vector::luaNewLocal(), and Engines::Witcher::pushFakeObject().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pushVariable()

void Aurora::Lua::Stack::pushVariable ( const Variable var)

◆ pushVariables()

void Aurora::Lua::Stack::pushVariables ( const Variables vars)

Definition at line 128 of file stack.cpp.

References pushVariable().

Referenced by Aurora::Lua::FunctionRef::call().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ registerGCForTopObject()

void Aurora::Lua::Stack::registerGCForTopObject ( )

Definition at line 296 of file stack.cpp.

References _luaState, getSize(), getTypeAt(), and Aurora::Lua::kTypeUserType.

Referenced by Engines::Witcher::LuaBindings::Vector::luaNewLocal().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _luaState

lua_State& Aurora::Lua::Stack::_luaState
private

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