25 #include "toluapp/tolua++.h" 57 lua_pushboolean(&
_luaState, value ? 1 : 0);
77 const int ref = value.
getRef();
78 if (ref != LUA_REFNIL) {
86 const int ref = value.
getRef();
87 if (ref != LUA_REFNIL) {
122 warning(
"Pushing a varible of type \"%s\" not supported",
129 for (Variables::const_iterator v = vars.begin(); v != vars.end(); ++v) {
136 throw Common::Exception(
"Failed to get a boolean value from the Lua stack (index: %d)", index);
138 return lua_toboolean(&
_luaState, index) != 0;
143 throw Common::Exception(
"Failed to get a number from the Lua stack (index: %d)", index);
150 throw Common::Exception(
"Failed to get a number from the Lua stack (index: %d)", index);
157 throw Common::Exception(
"Failed to get a string from the Lua stack (index: %d)", index);
164 throw Common::Exception(
"Failed to get a table from the Lua stack (index: %d)", index);
171 throw Common::Exception(
"Failed to get a function from the Lua stack (index: %d)", index);
178 const char *msg =
"Failed to get a usertype value from the Lua stack (type: %s, index: %d)";
182 return tolua_tousertype(&
_luaState, index, 0);
248 for (
int i = 1; i <=
getSize(); ++i) {
256 const int start = std::max(0, getSize() - count) + 1;
257 for (
int i = start; i <= getSize(); ++i) {
258 vars.push_back(getVariableAt(i));
306 index = std::abs(index);
307 return index > 0 && index <=
getSize();
bool isNilAt(int index) const
Check whether the value with the given index is a nil.
bool isStringAt(int index) const
Check whether the value at the given index is a string.
void * getRawUserType() const
Variables getVariablesFromTop(int count) const
TableRef getTableAt(int index) const
Return a table at the given index in the stack.
bool checkIndex(int index) const
Check whether the given index is valid.
A class holding an UTF-8 string.
void pushVariables(const Variables &vars)
Common::UString getStringAt(int index) const
Return a string at the given index in the stack.
A reference to a Lua function.
void pushInt(int value)
Push an integer value onto the stack.
Variable getVariableAt(int index) const
bool isBooleanAt(int index) const
Check whether the value at the given index is a boolean value.
const FunctionRef & getFunction() const
int getSize() const
Return the number of elements in the stack.
FunctionRef getFunctionAt(int index) const
Return a function at the given index in the stack.
Common::UString getExactTypeAt(int index) const
Return the type of the value at the given index in the stack.
void pushFunction(const FunctionRef &value)
Push a function onto the stack.
void pushFloat(float value)
Push a float value onto the stack.
Basic exceptions to throw.
const char * c_str() const
Return the (utf8 encoded) string data.
void registerGCForTopObject()
Utility templates and functions.
Common::UString & getString()
bool getBooleanAt(int index) const
Return a boolean value at the given index in the stack.
void * getRawUserTypeAt(int index, const Common::UString &type="") const
Return a raw usertype value at the given index in the stack.
void pushTable(const TableRef &value)
Push a table onto the stack.
Type getTypeAt(int index) const
bool empty() const
Is the string empty?
std::vector< Variable > Variables
void pushRawUserType(void *value, const Common::UString &type)
Push a raw usertype value onto the stack.
void warning(const char *s,...)
A reference to a Lua function.
void pushBoolean(bool value)
Push a boolean value onto the stack.
lua_State & _luaState
The Lua state.
Variables getVariables() const
bool isFunctionAt(int index) const
Check whether the value at the given index is a function.
const Common::UString & getExactType() const
void pushNil()
Push a nil value onto the stack.
A reference to a Lua table.
A reference to a Lua table.
void pushVariable(const Variable &var)
int getIntAt(int index) const
Return an integer value at the given index in the stack.
float getFloatAt(int index) const
Return a float value at the given index in the stack.
void NORETURN_PRE error(const char *s,...)
bool isTableAt(int index) const
Check whether the value at the given index is a table.
bool isNumberAt(int index) const
Check whether the value at the given index is a number.
bool isUserTypeAt(int index, const Common::UString &type="") const
Check whether the value at the given index is a usertype value.
lua_State & getLuaState() const
Return the underlying Lua state.
void pushString(const char *value)
Push a raw C string onto the stack.