diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2018-11-30 06:45:16 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2018-11-30 06:45:16 +0000 |
| commit | a294546bcc7c883edd113f2c80d7f278ff8219ed (patch) | |
| tree | c876be23d46c758a38ef92efd248400fa5fe9fe2 /RenderScript/include | |
| parent | Added DRAW_FLAG_VERIFY_STATES and DISPATCH_FLAG_VERIFY_STATES flags (diff) | |
| download | DiligentTools-a294546bcc7c883edd113f2c80d7f278ff8219ed.tar.gz DiligentTools-a294546bcc7c883edd113f2c80d7f278ff8219ed.zip | |
Improved type safety of flag enums
Diffstat (limited to 'RenderScript/include')
| -rw-r--r-- | RenderScript/include/DeviceContextFuncBindings.h | 4 | ||||
| -rw-r--r-- | RenderScript/include/EnumMappings.h | 4 | ||||
| -rw-r--r-- | RenderScript/include/LuaBindings.h | 8 | ||||
| -rw-r--r-- | RenderScript/include/TextureParser.h | 4 |
4 files changed, 10 insertions, 10 deletions
diff --git a/RenderScript/include/DeviceContextFuncBindings.h b/RenderScript/include/DeviceContextFuncBindings.h index f3bfa98..85fd527 100644 --- a/RenderScript/include/DeviceContextFuncBindings.h +++ b/RenderScript/include/DeviceContextFuncBindings.h @@ -29,7 +29,7 @@ namespace std { - DEFINE_ENUM_HASH( Diligent::COMMIT_SHADER_RESOURCES_FLAG ) + DEFINE_ENUM_HASH( Diligent::COMMIT_SHADER_RESOURCES_FLAGS ) } namespace Diligent @@ -61,7 +61,7 @@ namespace Diligent int TransitionShaderResources( lua_State * ); ClassMethodCaller<DeviceContextFuncBindings> m_TransitionShaderResourcesBinding; - EnumMapping<COMMIT_SHADER_RESOURCES_FLAG> m_CommitShaderResFlagsEnumMapping; + EnumMapping<COMMIT_SHADER_RESOURCES_FLAGS> m_CommitShaderResFlagsEnumMapping; String m_TexViewMetatableName; String m_ShaderResBindingMetatableName; diff --git a/RenderScript/include/EnumMappings.h b/RenderScript/include/EnumMappings.h index 5e0231e..db0b699 100644 --- a/RenderScript/include/EnumMappings.h +++ b/RenderScript/include/EnumMappings.h @@ -43,7 +43,7 @@ namespace std // Explicit namespace declaraion is necesseary to avoid // name conflicts when building for windows store DEFINE_ENUM_HASH( Diligent::BIND_FLAGS ) - DEFINE_ENUM_HASH( Diligent::CPU_ACCESS_FLAG ) + DEFINE_ENUM_HASH( Diligent::CPU_ACCESS_FLAGS ) DEFINE_ENUM_HASH( Diligent::COMPARISON_FUNCTION ) DEFINE_ENUM_HASH( Diligent::BIND_SHADER_RESOURCES_FLAGS ) DEFINE_ENUM_HASH( Diligent::SHADER_TYPE ) @@ -65,7 +65,7 @@ namespace Diligent }; #define DEFINE_ENUM_ELEMENT_MAPPING(EnumMapping, Elem) EnumMapping.AddMapping(#Elem, Elem) - class CpuAccessFlagEnumMapping : public EnumMapping < Diligent::CPU_ACCESS_FLAG > + class CpuAccessFlagEnumMapping : public EnumMapping < Diligent::CPU_ACCESS_FLAGS > { public: CpuAccessFlagEnumMapping(); 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); } } diff --git a/RenderScript/include/TextureParser.h b/RenderScript/include/TextureParser.h index c35e3dd..0e0e542 100644 --- a/RenderScript/include/TextureParser.h +++ b/RenderScript/include/TextureParser.h @@ -30,7 +30,7 @@ namespace std { - DEFINE_ENUM_HASH( Diligent::MISC_TEXTURE_FLAG ) + DEFINE_ENUM_HASH( Diligent::MISC_TEXTURE_FLAGS ) } namespace Diligent @@ -58,7 +58,7 @@ namespace Diligent // Explicit namespace declaraion is necesseary to avoid // name conflicts when building for windows store - EnumMapping<Diligent::MISC_TEXTURE_FLAG> m_MiscFlagEnumMapping; + EnumMapping<Diligent::MISC_TEXTURE_FLAGS> m_MiscFlagEnumMapping; UsageEnumMapping m_UsageEnumMapping; CpuAccessFlagEnumMapping m_CpuAccessFlagEnumMapping; |
