This commit is contained in:
Glenn Maynard
2005-06-20 04:32:24 +00:00
parent 77ee110e65
commit 72e7a4b1e4
2 changed files with 24 additions and 39 deletions
-13
View File
@@ -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
View File
@@ -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))