By default, don't return Invalid values from Enum::Check. It's the exception

that Invalid has a meaning for an API call; most do not.  As it was, every
function that used Enum::Check should have been checking for invalid
return values; this way, the check can be omitted.

(This applies to FromString, Pop and FromStack, too; I havn't decided
whether I want to propagate this into those.)
This commit is contained in:
Glenn Maynard
2006-10-11 05:18:12 +00:00
parent 2201d813b2
commit ed6141c48f
2 changed files with 11 additions and 5 deletions
+8 -2
View File
@@ -3,10 +3,16 @@
#include "LuaManager.h"
#include "RageUtil.h"
int CheckEnum( lua_State *L, LuaReference &table, int iPos, int iInvalid, const char *szType )
int CheckEnum( lua_State *L, LuaReference &table, int iPos, int iInvalid, const char *szType, bool bAllowInvalid )
{
if( lua_isnil(L, iPos) )
return iInvalid;
{
if( bAllowInvalid )
return iInvalid;
LuaHelpers::Push( L, ssprintf("Expected %s; got nil", szType) );
lua_error( L );
}
iPos = LuaHelpers::AbsIndex( L, iPos );