diff --git a/stepmania/src/LuaBinding.h b/stepmania/src/LuaBinding.h index eb65c1d873..8ebee8f463 100644 --- a/stepmania/src/LuaBinding.h +++ b/stepmania/src/LuaBinding.h @@ -5,20 +5,7 @@ #ifndef LuaBinding_H #define LuaBinding_H -extern "C" -{ -#include -#include -} - #include "LuaManager.h" -#include - -inline bool MyLua_checkboolean (lua_State *L, int numArg) -{ - luaL_checktype(L,numArg,LUA_TBOOLEAN); - return !!lua_toboolean(L,numArg); -} template struct RegType diff --git a/stepmania/src/LuaManager.h b/stepmania/src/LuaManager.h index a8786e4395..fefa81cff9 100644 --- a/stepmania/src/LuaManager.h +++ b/stepmania/src/LuaManager.h @@ -16,32 +16,6 @@ extern "C" class LuaManager; extern LuaManager *LUA; -namespace LuaHelpers -{ - template - void Push( T *pObject, lua_State *L ); - - void Push( const bool &Object, lua_State *L ); - void Push( const float &Object, lua_State *L ); - void Push( const int &Object, lua_State *L ); - void Push( const CString &Object, lua_State *L ); - - - bool FromStack( bool &Object, int iOffset, lua_State *L ); - bool FromStack( float &Object, int iOffset, lua_State *L ); - bool FromStack( int &Object, int iOffset, lua_State *L ); - bool FromStack( CString &Object, int iOffset, lua_State *L ); - - template - void ReadArrayFromTable( vector &aOut, lua_State *L ); - template - void PushStack( const T &val, lua_State *L ); - template - bool PopStack( T &val, lua_State *L ); - template - void CreateTableFromArray( const vector &aIn, lua_State *L ); -}; - class LuaManager { public: @@ -103,6 +77,24 @@ namespace LuaHelpers /* If sStr begins with @, evaluate the rest as an expression and store the result over sStr. */ bool RunAtExpressionS( CString &sStr ); + template + void Push( T *pObject, Lua *L ); + + void Push( const bool &Object, Lua *L ); + void Push( const float &Object, Lua *L ); + void Push( const int &Object, Lua *L ); + void Push( const CString &Object, Lua *L ); + + bool FromStack( bool &Object, int iOffset, Lua *L ); + bool FromStack( float &Object, int iOffset, Lua *L ); + bool FromStack( int &Object, int iOffset, Lua *L ); + bool FromStack( CString &Object, int iOffset, Lua *L ); + + template + void PushStack( const T &val, Lua *L ); + template + bool PopStack( T &val, Lua *L ); + template void ReadArrayFromTable( vector &aOut, lua_State *L ) { @@ -150,6 +142,12 @@ namespace LuaHelpers class Register##Fn { public: Register##Fn() { LuaManager::Register( Fn ); } }; \ static Register##Fn register##Fn; +inline bool MyLua_checkboolean (lua_State *L, int numArg) +{ + luaL_checktype(L,numArg,LUA_TBOOLEAN); + return !!lua_toboolean(L,numArg); +} + #define SArg(n) (luaL_checkstring(L,n)) #define IArg(n) (luaL_checkint(L,n)) #define BArg(n) (MyLua_checkboolean(L,n))