From 600fdfea63ac658a346ab9c1568d64c801004639 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Tue, 26 Sep 2006 07:13:54 +0000 Subject: [PATCH] simplify LuaXType --- stepmania/src/Course.cpp | 2 +- stepmania/src/Difficulty.cpp | 2 +- stepmania/src/EnumHelper.h | 12 ++++++------ stepmania/src/GameConstantsAndTypes.cpp | 8 ++++---- stepmania/src/Grade.cpp | 2 +- stepmania/src/ModsGroup.cpp | 2 +- stepmania/src/NoteTypes.cpp | 2 +- stepmania/src/UnlockManager.cpp | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/stepmania/src/Course.cpp b/stepmania/src/Course.cpp index 621e7493c1..da1666ef7d 100644 --- a/stepmania/src/Course.cpp +++ b/stepmania/src/Course.cpp @@ -27,7 +27,7 @@ static const char *CourseTypeNames[] = { }; XToString( CourseType, NUM_CourseType ); XToLocalizedString( CourseType ); -LuaXType( CourseType, NUM_CourseType, "CourseType_" ); +LuaXType( CourseType ); LuaFunction( CourseTypeToLocalizedString, CourseTypeToLocalizedString( Enum::Check( L, 1 ) ) ); diff --git a/stepmania/src/Difficulty.cpp b/stepmania/src/Difficulty.cpp index 1e51d22650..e7d0069466 100644 --- a/stepmania/src/Difficulty.cpp +++ b/stepmania/src/Difficulty.cpp @@ -17,7 +17,7 @@ static const char *DifficultyNames[] = { }; XToString( Difficulty, NUM_Difficulty ); XToLocalizedString( Difficulty ); -LuaXType( Difficulty, NUM_Difficulty , "Difficulty_" ); +LuaXType( Difficulty ); LuaFunction( DifficultyToLocalizedString, DifficultyToLocalizedString( Enum::Check(L, 1)) ); diff --git a/stepmania/src/EnumHelper.h b/stepmania/src/EnumHelper.h index 10006a2061..91511cfa63 100644 --- a/stepmania/src/EnumHelper.h +++ b/stepmania/src/EnumHelper.h @@ -134,16 +134,16 @@ static const RString EMPTY_STRING; namespace LuaHelpers { bool FromStack( lua_State *L, X &Object, int iOffset ); } \ namespace LuaHelpers { void Push( const X &Object, lua_State *L ); } -#define LuaXType(X, CNT, Prefix) \ +#define LuaXType(X) \ static void Lua##X(lua_State* L) \ { \ - EnumTraits::Invalid = enum_add2( CNT, 1 ); \ + EnumTraits::Invalid = enum_add2( NUM_##X, 1 ); \ /* Create the EnumToString table: { "UnlockEntry_ArcadePoints", "UnlockEntry_DancePoints" } */ \ lua_newtable( L ); \ - FOREACH_ENUM( X, CNT, i ) \ + FOREACH_ENUM( X, NUM_##X, i ) \ { \ RString s = X##Names[i]; \ - lua_pushstring( L, Prefix+s ); \ + lua_pushstring( L, (#X "_")+s ); \ lua_rawseti( L, -2, i+1 ); /* 1-based */ \ } \ EnumTraits::EnumToString.SetFromStack( L ); \ @@ -151,10 +151,10 @@ static void Lua##X(lua_State* L) \ lua_setglobal( L, #X ); \ /* Create the StringToEnum table: { "UnlockEntry_ArcadePoints" = 0, "UnlockEntry_DancePoints" = 1 } */ \ lua_newtable( L ); \ - FOREACH_ENUM( X, CNT, i ) \ + FOREACH_ENUM( X, NUM_##X, i ) \ { \ RString s = X##Names[i]; \ - lua_pushstring( L, Prefix+s ); \ + lua_pushstring( L, (#X "_")+s ); \ lua_pushnumber( L, i ); /* 0-based */ \ lua_rawset( L, -3 ); \ } \ diff --git a/stepmania/src/GameConstantsAndTypes.cpp b/stepmania/src/GameConstantsAndTypes.cpp index 848682dcdb..1766918022 100644 --- a/stepmania/src/GameConstantsAndTypes.cpp +++ b/stepmania/src/GameConstantsAndTypes.cpp @@ -69,7 +69,7 @@ XToString( PlayMode, NUM_PlayMode ); XToLocalizedString( PlayMode ); StringToX( PlayMode ); LuaFunction( PlayModeToLocalizedString, PlayModeToLocalizedString((PlayMode) IArg(1)) ); -LuaXType( PlayMode, NUM_PlayMode, "PlayMode_" ) +LuaXType( PlayMode ); RankingCategory AverageMeterToRankingCategory( int iAverageMeter ) { @@ -193,7 +193,7 @@ static const char *TapNoteScoreNames[] = { "W1", }; XToString( TapNoteScore, NUM_TapNoteScore ); -LuaXType( TapNoteScore, NUM_TapNoteScore, "TapNoteScore_" ); +LuaXType( TapNoteScore ); TapNoteScore StringToTapNoteScore( const RString &s ) { // new style @@ -403,7 +403,7 @@ static const char *EditModeNames[] = { }; XToString( EditMode, NUM_EditMode ); StringToX( EditMode ); -LuaXType( EditMode, NUM_EditMode, "EditMode_" ); +LuaXType( EditMode ); static const char *StageNames[] = { "1", @@ -422,7 +422,7 @@ static const char *StageNames[] = { "Demo", }; XToString( Stage, NUM_Stage ); -LuaXType( Stage, NUM_Stage, "Stage_" ); +LuaXType( Stage ); static const char *MultiPlayerStatusNames[] = { diff --git a/stepmania/src/Grade.cpp b/stepmania/src/Grade.cpp index 578fab9b55..99f4404bce 100644 --- a/stepmania/src/Grade.cpp +++ b/stepmania/src/Grade.cpp @@ -30,7 +30,7 @@ static const char *GradeNames[] = { "Tier20", "Failed", }; -LuaXType( Grade, NUM_Grade, "Grade_" ); +LuaXType( Grade ); RString GradeToLocalizedString( Grade g ) { diff --git a/stepmania/src/ModsGroup.cpp b/stepmania/src/ModsGroup.cpp index 3e05838fdb..d7be9b1f69 100644 --- a/stepmania/src/ModsGroup.cpp +++ b/stepmania/src/ModsGroup.cpp @@ -8,7 +8,7 @@ static const char *ModsLevelNames[] = { "Stage", "Song", }; -LuaXType( ModsLevel, NUM_ModsLevel, "ModsLevel_" ) +LuaXType( ModsLevel ); /* * (c) 2006 Steve Checkoway diff --git a/stepmania/src/NoteTypes.cpp b/stepmania/src/NoteTypes.cpp index 60aae67967..175957e240 100644 --- a/stepmania/src/NoteTypes.cpp +++ b/stepmania/src/NoteTypes.cpp @@ -29,7 +29,7 @@ static const char *NoteTypeNames[] = { "192nd", }; XToString( NoteType, NUM_NoteType ); -LuaXType( NoteType, NUM_NoteType, "NoteType_" ) +LuaXType( NoteType ) XToLocalizedString( NoteType ); float NoteTypeToBeat( NoteType nt ) diff --git a/stepmania/src/UnlockManager.cpp b/stepmania/src/UnlockManager.cpp index db6c18c977..2a2fbaa3cb 100644 --- a/stepmania/src/UnlockManager.cpp +++ b/stepmania/src/UnlockManager.cpp @@ -36,7 +36,7 @@ static const char *UnlockRequirementNames[] = }; XToString( UnlockRequirement, NUM_UnlockRequirement ); StringToX( UnlockRequirement ); -LuaXType( UnlockRequirement, NUM_UnlockRequirement, "UnlockRequirement_" ); +LuaXType( UnlockRequirement ); static const char *UnlockRewardTypeNames[] = {