17 #ifndef AGXLUA_LUAUTILS_H
18 #define AGXLUA_LUAUTILS_H
20 #include <agx/config/AGX_USE_LUA.h>
21 #include <agx/config.h>
43 class LuaError :
public std::runtime_error
46 explicit LuaError( lua_State *L ) : std::runtime_error(
""), m_msg(
"")
48 if (lua_isstring(L, -1)) {
49 m_msg = lua_tostring(L, -1);
53 const char *what()
const throw() {
return m_msg; }
55 explicit LuaError(
const char *msg ) : std::runtime_error(msg), m_msg(msg)
63 AGXLUA_EXPORT bool pushusertype (lua_State *L,
void *p,
const char *name);
65 AGXLUA_EXPORT void ensurepointer (lua_State *L,
const void *p);
69 AGXLUA_EXPORT void pushstring (lua_State* L,
const char* value);
71 AGXLUA_EXPORT const char* tostring (lua_State* L,
int narg,
const char* def=
"");
73 AGXLUA_EXPORT bool testuserdata (lua_State *L,
int index,
const char *name);
75 AGXLUA_EXPORT int pcall (lua_State *L,
int nargs,
int nresults,
int errfunc);
107 AGXLUA_EXPORT void *_tousertype(lua_State *L,
int index,
const char *type);
110 T *tousertype (lua_State *L,
int index,
const char *type) {
111 return static_cast<T *
>(_tousertype(L, index, type));
126 T *tousertype (lua_State *L,
const char *variableName,
const char *type) {
127 lua_getglobal(L, variableName);
131 return tousertype<T>(L, -1, type);
135 AGXLUA_EXPORT void error(lua_State* L,
const char* msg, tolua_Error* err);