cosmetic
This commit is contained in:
@@ -16,14 +16,14 @@ protected:
|
|||||||
|
|
||||||
struct RegType
|
struct RegType
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *szName;
|
||||||
int (*mfunc)(T *p, lua_State *L);
|
int (*mfunc)(T *p, lua_State *L);
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct { T *pT; } userdataType;
|
typedef struct { T *pT; } userdataType;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void Register(lua_State *L)
|
static void Register( Lua *L )
|
||||||
{
|
{
|
||||||
/* Create the methods table, if it doesn't already exist. */
|
/* Create the methods table, if it doesn't already exist. */
|
||||||
CreateGlobalTable( L, m_sClassName );
|
CreateGlobalTable( L, m_sClassName );
|
||||||
@@ -54,7 +54,7 @@ public:
|
|||||||
for( unsigned i=0; s_pvMethods && i < s_pvMethods->size(); i++ )
|
for( unsigned i=0; s_pvMethods && i < s_pvMethods->size(); i++ )
|
||||||
{
|
{
|
||||||
const RegType *l = &(*s_pvMethods)[i];
|
const RegType *l = &(*s_pvMethods)[i];
|
||||||
lua_pushstring(L, l->name);
|
lua_pushstring( L, l->szName );
|
||||||
lua_pushlightuserdata( L, (void*)l );
|
lua_pushlightuserdata( L, (void*)l );
|
||||||
lua_pushcclosure( L, thunk, 1 );
|
lua_pushcclosure( L, thunk, 1 );
|
||||||
lua_settable( L, methods );
|
lua_settable( L, methods );
|
||||||
@@ -107,7 +107,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// member function dispatcher
|
// member function dispatcher
|
||||||
static int thunk(lua_State *L)
|
static int thunk( Lua *L )
|
||||||
{
|
{
|
||||||
// stack has userdata, followed by method args
|
// stack has userdata, followed by method args
|
||||||
T *obj = check( L, 1, true ); // get self
|
T *obj = check( L, 1, true ); // get self
|
||||||
@@ -128,7 +128,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// push a userdata containing a pointer to T object
|
// push a userdata containing a pointer to T object
|
||||||
static int Push(lua_State *L, T* p )
|
static int Push( Lua *L, T* p )
|
||||||
{
|
{
|
||||||
userdataType *ud = static_cast<userdataType*>( lua_newuserdata(L, sizeof(userdataType)) );
|
userdataType *ud = static_cast<userdataType*>( lua_newuserdata(L, sizeof(userdataType)) );
|
||||||
ud->pT = p; // store pointer to object in userdata
|
ud->pT = p; // store pointer to object in userdata
|
||||||
@@ -141,8 +141,9 @@ public:
|
|||||||
{
|
{
|
||||||
if( s_pvMethods == NULL )
|
if( s_pvMethods == NULL )
|
||||||
s_pvMethods = new RegTypeVector;
|
s_pvMethods = new RegTypeVector;
|
||||||
|
|
||||||
RegType r = { szName, pFunc };
|
RegType r = { szName, pFunc };
|
||||||
Luna<T>::s_pvMethods->push_back(r);
|
s_pvMethods->push_back(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user