summaryrefslogtreecommitdiffstats
path: root/RenderScript/include/LuaBindings.h
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2018-11-30 06:45:16 +0000
committerEgor Yusov <egor.yusov@gmail.com>2018-11-30 06:45:16 +0000
commita294546bcc7c883edd113f2c80d7f278ff8219ed (patch)
treec876be23d46c758a38ef92efd248400fa5fe9fe2 /RenderScript/include/LuaBindings.h
parentAdded DRAW_FLAG_VERIFY_STATES and DISPATCH_FLAG_VERIFY_STATES flags (diff)
downloadDiligentTools-a294546bcc7c883edd113f2c80d7f278ff8219ed.tar.gz
DiligentTools-a294546bcc7c883edd113f2c80d7f278ff8219ed.zip
Improved type safety of flag enums
Diffstat (limited to 'RenderScript/include/LuaBindings.h')
-rw-r--r--RenderScript/include/LuaBindings.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/RenderScript/include/LuaBindings.h b/RenderScript/include/LuaBindings.h
index e43b9a3..a09e1d0 100644
--- a/RenderScript/include/LuaBindings.h
+++ b/RenderScript/include/LuaBindings.h
@@ -461,7 +461,7 @@ namespace Diligent
BindingsMap.insert( std::make_pair( #Member, std::unique_ptr<MemberBinderBase>(pNewBinder) ) ); \
}while(false)
- template< typename EnumType, typename FlagsType = Uint32 >
+ template< typename EnumType, typename FlagsType = std::underlying_type<EnumType>::type >
class FlagsLoader : public MemberBinderBase
{
public:
@@ -478,7 +478,7 @@ namespace Diligent
int ArrayInd = 1;
for( auto it = m_EnumMapping.m_Val2StrMap.begin(); it != m_EnumMapping.m_Val2StrMap.end(); ++it )
{
- if( static_cast<EnumType>(Flags & it->first) == it->first )
+ if( it->first != 0 && static_cast<EnumType>(Flags & it->first) == it->first || Flags == 0 && it->first == 0)
{
lua_pushnumber( L, ArrayInd ); // -0 | +1 -> +1
PushValue<const String&>( L, it->second ); // -0 | +1 -> +1
@@ -490,7 +490,7 @@ namespace Diligent
virtual void SetValue( lua_State *L, int Index, void* pBasePointer )
{
- FlagsType Flags = 0;
+ FlagsType Flags = static_cast<FlagsType>(0);
if( lua_isnumber( L, Index ) )
{
Flags = static_cast<FlagsType>( ReadValueFromLua<Uint32>( L, Index ) );
@@ -528,7 +528,7 @@ namespace Diligent
{
String AllowableValues = GetEnumMappingsString<EnumType>( m_EnumMapping );
SCRIPT_PARSING_ERROR( L, "Unknown flag (\"", CurrFlagName, "\") provided for parameter ", m_MemberName, ". Only the following flags are allowed:\n", AllowableValues );
- return 0;
+ return static_cast<FlagsType>(0);
}
}