revert 'add Enum:ToString'

This commit is contained in:
Chris Danford
2008-08-20 01:12:59 +00:00
parent feed4c802a
commit f4ef5a7e5d
2 changed files with 19 additions and 46 deletions
+5 -21
View File
@@ -99,24 +99,11 @@ namespace
return 1;
}
int ToString( lua_State *L )
{
luaL_checktype( L, 1, LUA_TTABLE );
/* Look up the tostring table. If there is no metafield, then we were
* called on the wrong type. */
if( !luaL_getmetafield(L, 1, "tostring") )
luaL_typerror( L, 1, "enum" );
return 1;
}
}
static const luaL_Reg EnumLib[] = {
{ "GetName", GetName },
{ "Reverse", Reverse },
{ "ToString", ToString },
{ NULL, NULL }
};
@@ -126,17 +113,14 @@ static void PushEnumMethodTable( lua_State *L )
}
/* Set up the enum table on the stack, and pop the table. */
void Enum::SetMetatable( lua_State *L, LuaReference &IndexToEnumString, LuaReference &EnumStringToZeroIndex, LuaReference &EnumStringToString, const char *szName )
void Enum::SetMetatable( lua_State *L, LuaReference &EnumTable, LuaReference &EnumIndexTable, const char *szName )
{
IndexToEnumString.PushSelf( L );
lua_newtable( L );
EnumTable.PushSelf( L );
{
EnumStringToZeroIndex.PushSelf( L );
lua_newtable( L );
EnumIndexTable.PushSelf( L );
lua_setfield( L, -2, "reverse" );
EnumStringToString.PushSelf( L );
lua_setfield( L, -2, "tostring" );
lua_pushstring( L, szName );
lua_setfield( L, -2, "name" );
@@ -148,7 +132,7 @@ void Enum::SetMetatable( lua_State *L, LuaReference &IndexToEnumString, LuaRefer
lua_setfield( L, -2, "__type" ); // for luaL_pushtype
}
lua_setmetatable( L, -2 );
lua_pop( L, 1 );
lua_pop( L, 2 );
}
/*