cleanup
This commit is contained in:
@@ -5,20 +5,7 @@
|
||||
#ifndef LuaBinding_H
|
||||
#define LuaBinding_H
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include <lua.h>
|
||||
#include <lauxlib.h>
|
||||
}
|
||||
|
||||
#include "LuaManager.h"
|
||||
#include <vector>
|
||||
|
||||
inline bool MyLua_checkboolean (lua_State *L, int numArg)
|
||||
{
|
||||
luaL_checktype(L,numArg,LUA_TBOOLEAN);
|
||||
return !!lua_toboolean(L,numArg);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct RegType
|
||||
|
||||
+24
-26
@@ -16,32 +16,6 @@ extern "C"
|
||||
class LuaManager;
|
||||
extern LuaManager *LUA;
|
||||
|
||||
namespace LuaHelpers
|
||||
{
|
||||
template<class T>
|
||||
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<class T>
|
||||
void ReadArrayFromTable( vector<T> &aOut, lua_State *L );
|
||||
template<class T>
|
||||
void PushStack( const T &val, lua_State *L );
|
||||
template<class T>
|
||||
bool PopStack( T &val, lua_State *L );
|
||||
template<class T>
|
||||
void CreateTableFromArray( const vector<T> &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<class T>
|
||||
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<class T>
|
||||
void PushStack( const T &val, Lua *L );
|
||||
template<class T>
|
||||
bool PopStack( T &val, Lua *L );
|
||||
|
||||
template<class T>
|
||||
void ReadArrayFromTable( vector<T> &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))
|
||||
|
||||
Reference in New Issue
Block a user