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:
@@ -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 );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user