Mark deprecated enum values as deprecated (#1955)

This commit is contained in:
Andreas Süßenbach 2024-09-03 08:53:36 +02:00 committed by GitHub
parent 2fcbcfbefe
commit fbb62163a0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 119 additions and 30 deletions

View File

@ -760,6 +760,15 @@ void VulkanHppGenerator::generateToStringHppFile() const
#include <vulkan/${api}_enums.hpp> #include <vulkan/${api}_enums.hpp>
// ignore warnings on using deprecated enum values in this header
#if defined( __clang__ ) || defined( __GNUC__ )
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#elif defined( _MSC_VER )
# pragma warning( push )
# pragma warning( disable : 4996 )
#endif
#if __cpp_lib_format #if __cpp_lib_format
# include <format> // std::format # include <format> // std::format
#else #else
@ -771,6 +780,13 @@ namespace VULKAN_HPP_NAMESPACE
${bitmasksToString} ${bitmasksToString}
${enumsToString} ${enumsToString}
} // namespace VULKAN_HPP_NAMESPACE } // namespace VULKAN_HPP_NAMESPACE
#if defined( __clang__ ) || defined( __GNUC__ )
# pragma GCC diagnostic pop
#elif defined( _MSC_VER )
# pragma warning( pop )
#endif
#endif #endif
)"; )";
@ -6763,7 +6779,12 @@ std::string VulkanHppGenerator::generateEnum( std::pair<std::string, EnumData> c
{ {
enumValues += previousLeave + enter; enumValues += previousLeave + enter;
} }
enumValues += " " + valueName + " = " + value.name + ",\n"; enumValues += " " + valueName;
if ( value.deprecated )
{
enumValues += " VULKAN_HPP_DEPRECATED_17( \"" + valueName + " is deprecated, but no reason was given in the API XML\" )";
}
enumValues += " = " + value.name + ",\n";
for ( auto const & valueAlias : value.aliases ) for ( auto const & valueAlias : value.aliases )
{ {
@ -13464,6 +13485,7 @@ void VulkanHppGenerator::readEnumsConstants( tinyxml2::XMLElement const * elemen
void VulkanHppGenerator::readEnumsEnum( tinyxml2::XMLElement const * element, std::map<std::string, EnumData>::iterator enumIt ) void VulkanHppGenerator::readEnumsEnum( tinyxml2::XMLElement const * element, std::map<std::string, EnumData>::iterator enumIt )
{ {
const int line = element->GetLineNum(); const int line = element->GetLineNum();
bool deprecated = false;
std::map<std::string, std::string> attributes = getAttributes( element ); std::map<std::string, std::string> attributes = getAttributes( element );
if ( attributes.contains( "alias" ) ) if ( attributes.contains( "alias" ) )
{ {
@ -13484,7 +13506,7 @@ void VulkanHppGenerator::readEnumsEnum( tinyxml2::XMLElement const * element, st
} }
else if ( attribute.first == "deprecated" ) else if ( attribute.first == "deprecated" )
{ {
// the enum value is marked as deprecated/aliased but still exisits -> no modifications needed here deprecated = true;
} }
else if ( attribute.first == "name" ) else if ( attribute.first == "name" )
{ {
@ -13524,7 +13546,7 @@ void VulkanHppGenerator::readEnumsEnum( tinyxml2::XMLElement const * element, st
checkForError( name.starts_with( prefix ), line, "encountered enum value <" + name + "> that does not begin with expected prefix <" + prefix + ">" ); checkForError( name.starts_with( prefix ), line, "encountered enum value <" + name + "> that does not begin with expected prefix <" + prefix + ">" );
checkForError( bitpos.empty() ^ value.empty(), line, "both or none of \"bitpos\" and \"value\" are set for enum <" + name + "> which is invalid" ); checkForError( bitpos.empty() ^ value.empty(), line, "both or none of \"bitpos\" and \"value\" are set for enum <" + name + "> which is invalid" );
enumIt->second.addEnumValue( line, name, "", bitpos, value, true ); enumIt->second.addEnumValue( line, name, "", bitpos, value, true, deprecated );
} }
} }
@ -14365,6 +14387,7 @@ void VulkanHppGenerator::readRequireEnum(
{ { "api", { "vulkan", "vulkansc" } }, { { "api", { "vulkan", "vulkansc" } },
{ "bitpos", {} }, { "bitpos", {} },
{ "comment", {} }, { "comment", {} },
{ "deprecated", { "true" } },
{ "dir", { "-" } }, { "dir", { "-" } },
{ "extends", {} }, { "extends", {} },
{ "extnumber", {} }, { "extnumber", {} },
@ -14374,6 +14397,7 @@ void VulkanHppGenerator::readRequireEnum(
{ "value", {} } } ); { "value", {} } } );
std::string api, bitpos, extends, name, offset, protect, type, value; std::string api, bitpos, extends, name, offset, protect, type, value;
bool deprecated = false;
for ( auto const & attribute : attributes ) for ( auto const & attribute : attributes )
{ {
if ( attribute.first == "api" ) if ( attribute.first == "api" )
@ -14384,6 +14408,10 @@ void VulkanHppGenerator::readRequireEnum(
{ {
bitpos = attribute.second; bitpos = attribute.second;
} }
else if ( attribute.first == "deprecated" )
{
deprecated = true;
}
else if ( attribute.first == "extends" ) else if ( attribute.first == "extends" )
{ {
extends = attribute.second; extends = attribute.second;
@ -14451,8 +14479,13 @@ void VulkanHppGenerator::readRequireEnum(
auto enumIt = findByNameOrAlias( m_enums, extends ); auto enumIt = findByNameOrAlias( m_enums, extends );
assert( enumIt != m_enums.end() ); assert( enumIt != m_enums.end() );
enumIt->second.addEnumValue( enumIt->second.addEnumValue( line,
line, name, protect.empty() ? getProtectFromPlatform( platform ) : protect, bitpos + offset, value, ( api.empty() || ( api == m_api ) ) && supported ); name,
protect.empty() ? getProtectFromPlatform( platform ) : protect,
bitpos + offset,
value,
( api.empty() || ( api == m_api ) ) && supported,
deprecated );
} }
} }
} }
@ -16244,12 +16277,12 @@ void VulkanHppGenerator::EnumData::addEnumAlias( int line, std::string const & n
} }
void VulkanHppGenerator::EnumData::addEnumValue( void VulkanHppGenerator::EnumData::addEnumValue(
int line, std::string const & name, std::string const & protect, std::string const & bitpos, std::string const & value, bool supported ) int line, std::string const & name, std::string const & protect, std::string const & bitpos, std::string const & value, bool supported, bool deprecated )
{ {
auto valueIt = findByName( values, name ); auto valueIt = findByName( values, name );
if ( valueIt == values.end() ) if ( valueIt == values.end() )
{ {
values.push_back( { {}, bitpos, name, protect, supported, value, line } ); values.push_back( { {}, bitpos, deprecated, name, protect, supported, value, line } );
} }
else if ( supported ) // only for supported enum values, we need to check for consistency! else if ( supported ) // only for supported enum values, we need to check for consistency!
{ {

View File

@ -147,6 +147,7 @@ private:
{ {
std::map<std::string, int> aliases = {}; std::map<std::string, int> aliases = {};
std::string bitpos = {}; std::string bitpos = {};
bool deprecated = {};
std::string name = {}; std::string name = {};
std::string protect = {}; std::string protect = {};
bool supported = {}; bool supported = {};
@ -157,8 +158,13 @@ private:
struct EnumData struct EnumData
{ {
void addEnumAlias( int line, std::string const & name, std::string const & alias, std::string const & protect, bool supported ); void addEnumAlias( int line, std::string const & name, std::string const & alias, std::string const & protect, bool supported );
void addEnumValue( void addEnumValue( int line,
int line, std::string const & valueName, std::string const & protect, std::string const & bitpos, std::string const & value, bool supported ); std::string const & valueName,
std::string const & protect,
std::string const & bitpos,
std::string const & value,
bool supported,
bool deprecated );
std::map<std::string, int> aliases = {}; std::map<std::string, int> aliases = {};
std::string bitwidth = {}; std::string bitwidth = {};

View File

@ -176,6 +176,12 @@
# define VULKAN_HPP_DEPRECATED( msg ) # define VULKAN_HPP_DEPRECATED( msg )
#endif #endif
#if 17 <= VULKAN_HPP_CPP_VERSION
# define VULKAN_HPP_DEPRECATED_17( msg ) [[deprecated( msg )]]
#else
# define VULKAN_HPP_DEPRECATED_17( msg )
#endif
#if ( 17 <= VULKAN_HPP_CPP_VERSION ) && !defined( VULKAN_HPP_NO_NODISCARD_WARNINGS ) #if ( 17 <= VULKAN_HPP_CPP_VERSION ) && !defined( VULKAN_HPP_NO_NODISCARD_WARNINGS )
# define VULKAN_HPP_NODISCARD [[nodiscard]] # define VULKAN_HPP_NODISCARD [[nodiscard]]
# if defined( VULKAN_HPP_NO_EXCEPTIONS ) # if defined( VULKAN_HPP_NO_EXCEPTIONS )

View File

@ -4501,13 +4501,13 @@ namespace VULKAN_HPP_NAMESPACE
eBt709NonlinearEXT = VK_COLOR_SPACE_BT709_NONLINEAR_EXT, eBt709NonlinearEXT = VK_COLOR_SPACE_BT709_NONLINEAR_EXT,
eBt2020LinearEXT = VK_COLOR_SPACE_BT2020_LINEAR_EXT, eBt2020LinearEXT = VK_COLOR_SPACE_BT2020_LINEAR_EXT,
eHdr10St2084EXT = VK_COLOR_SPACE_HDR10_ST2084_EXT, eHdr10St2084EXT = VK_COLOR_SPACE_HDR10_ST2084_EXT,
eDolbyvisionEXT = VK_COLOR_SPACE_DOLBYVISION_EXT, eDolbyvisionEXT VULKAN_HPP_DEPRECATED_17( "eDolbyvisionEXT is deprecated, but no reason was given in the API XML" ) = VK_COLOR_SPACE_DOLBYVISION_EXT,
eHdr10HlgEXT = VK_COLOR_SPACE_HDR10_HLG_EXT, eHdr10HlgEXT = VK_COLOR_SPACE_HDR10_HLG_EXT,
eAdobergbLinearEXT = VK_COLOR_SPACE_ADOBERGB_LINEAR_EXT, eAdobergbLinearEXT = VK_COLOR_SPACE_ADOBERGB_LINEAR_EXT,
eAdobergbNonlinearEXT = VK_COLOR_SPACE_ADOBERGB_NONLINEAR_EXT, eAdobergbNonlinearEXT = VK_COLOR_SPACE_ADOBERGB_NONLINEAR_EXT,
ePassThroughEXT = VK_COLOR_SPACE_PASS_THROUGH_EXT, ePassThroughEXT = VK_COLOR_SPACE_PASS_THROUGH_EXT,
eExtendedSrgbNonlinearEXT = VK_COLOR_SPACE_EXTENDED_SRGB_NONLINEAR_EXT, eExtendedSrgbNonlinearEXT = VK_COLOR_SPACE_EXTENDED_SRGB_NONLINEAR_EXT,
eDisplayNativeAMD = VK_COLOR_SPACE_DISPLAY_NATIVE_AMD eDisplayNativeAMD = VK_COLOR_SPACE_DISPLAY_NATIVE_AMD
}; };
enum class CompositeAlphaFlagBitsKHR : VkCompositeAlphaFlagsKHR enum class CompositeAlphaFlagBitsKHR : VkCompositeAlphaFlagsKHR

View File

@ -185,6 +185,12 @@
# define VULKAN_HPP_DEPRECATED( msg ) # define VULKAN_HPP_DEPRECATED( msg )
#endif #endif
#if 17 <= VULKAN_HPP_CPP_VERSION
# define VULKAN_HPP_DEPRECATED_17( msg ) [[deprecated( msg )]]
#else
# define VULKAN_HPP_DEPRECATED_17( msg )
#endif
#if ( 17 <= VULKAN_HPP_CPP_VERSION ) && !defined( VULKAN_HPP_NO_NODISCARD_WARNINGS ) #if ( 17 <= VULKAN_HPP_CPP_VERSION ) && !defined( VULKAN_HPP_NO_NODISCARD_WARNINGS )
# define VULKAN_HPP_NODISCARD [[nodiscard]] # define VULKAN_HPP_NODISCARD [[nodiscard]]
# if defined( VULKAN_HPP_NO_EXCEPTIONS ) # if defined( VULKAN_HPP_NO_EXCEPTIONS )

View File

@ -10,6 +10,15 @@
#include <vulkan/vulkan_enums.hpp> #include <vulkan/vulkan_enums.hpp>
// ignore warnings on using deprecated enum values in this header
#if defined( __clang__ ) || defined( __GNUC__ )
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#elif defined( _MSC_VER )
# pragma warning( push )
# pragma warning( disable : 4996 )
#endif
#if __cpp_lib_format #if __cpp_lib_format
# include <format> // std::format # include <format> // std::format
#else #else
@ -9146,4 +9155,11 @@ namespace VULKAN_HPP_NAMESPACE
} }
} // namespace VULKAN_HPP_NAMESPACE } // namespace VULKAN_HPP_NAMESPACE
#if defined( __clang__ ) || defined( __GNUC__ )
# pragma GCC diagnostic pop
#elif defined( _MSC_VER )
# pragma warning( pop )
#endif
#endif #endif

View File

@ -3166,20 +3166,20 @@ namespace VULKAN_HPP_NAMESPACE
enum class ColorSpaceKHR enum class ColorSpaceKHR
{ {
eSrgbNonlinear = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR, eSrgbNonlinear = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR,
eDisplayP3NonlinearEXT = VK_COLOR_SPACE_DISPLAY_P3_NONLINEAR_EXT, eDisplayP3NonlinearEXT = VK_COLOR_SPACE_DISPLAY_P3_NONLINEAR_EXT,
eExtendedSrgbLinearEXT = VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT, eExtendedSrgbLinearEXT = VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT,
eDisplayP3LinearEXT = VK_COLOR_SPACE_DISPLAY_P3_LINEAR_EXT, eDisplayP3LinearEXT = VK_COLOR_SPACE_DISPLAY_P3_LINEAR_EXT,
eDciP3NonlinearEXT = VK_COLOR_SPACE_DCI_P3_NONLINEAR_EXT, eDciP3NonlinearEXT = VK_COLOR_SPACE_DCI_P3_NONLINEAR_EXT,
eBt709LinearEXT = VK_COLOR_SPACE_BT709_LINEAR_EXT, eBt709LinearEXT = VK_COLOR_SPACE_BT709_LINEAR_EXT,
eBt709NonlinearEXT = VK_COLOR_SPACE_BT709_NONLINEAR_EXT, eBt709NonlinearEXT = VK_COLOR_SPACE_BT709_NONLINEAR_EXT,
eBt2020LinearEXT = VK_COLOR_SPACE_BT2020_LINEAR_EXT, eBt2020LinearEXT = VK_COLOR_SPACE_BT2020_LINEAR_EXT,
eHdr10St2084EXT = VK_COLOR_SPACE_HDR10_ST2084_EXT, eHdr10St2084EXT = VK_COLOR_SPACE_HDR10_ST2084_EXT,
eDolbyvisionEXT = VK_COLOR_SPACE_DOLBYVISION_EXT, eDolbyvisionEXT VULKAN_HPP_DEPRECATED_17( "eDolbyvisionEXT is deprecated, but no reason was given in the API XML" ) = VK_COLOR_SPACE_DOLBYVISION_EXT,
eHdr10HlgEXT = VK_COLOR_SPACE_HDR10_HLG_EXT, eHdr10HlgEXT = VK_COLOR_SPACE_HDR10_HLG_EXT,
eAdobergbLinearEXT = VK_COLOR_SPACE_ADOBERGB_LINEAR_EXT, eAdobergbLinearEXT = VK_COLOR_SPACE_ADOBERGB_LINEAR_EXT,
eAdobergbNonlinearEXT = VK_COLOR_SPACE_ADOBERGB_NONLINEAR_EXT, eAdobergbNonlinearEXT = VK_COLOR_SPACE_ADOBERGB_NONLINEAR_EXT,
ePassThroughEXT = VK_COLOR_SPACE_PASS_THROUGH_EXT, ePassThroughEXT = VK_COLOR_SPACE_PASS_THROUGH_EXT,
eExtendedSrgbNonlinearEXT = VK_COLOR_SPACE_EXTENDED_SRGB_NONLINEAR_EXT eExtendedSrgbNonlinearEXT = VK_COLOR_SPACE_EXTENDED_SRGB_NONLINEAR_EXT
}; };

View File

@ -185,6 +185,12 @@
# define VULKAN_HPP_DEPRECATED( msg ) # define VULKAN_HPP_DEPRECATED( msg )
#endif #endif
#if 17 <= VULKAN_HPP_CPP_VERSION
# define VULKAN_HPP_DEPRECATED_17( msg ) [[deprecated( msg )]]
#else
# define VULKAN_HPP_DEPRECATED_17( msg )
#endif
#if ( 17 <= VULKAN_HPP_CPP_VERSION ) && !defined( VULKAN_HPP_NO_NODISCARD_WARNINGS ) #if ( 17 <= VULKAN_HPP_CPP_VERSION ) && !defined( VULKAN_HPP_NO_NODISCARD_WARNINGS )
# define VULKAN_HPP_NODISCARD [[nodiscard]] # define VULKAN_HPP_NODISCARD [[nodiscard]]
# if defined( VULKAN_HPP_NO_EXCEPTIONS ) # if defined( VULKAN_HPP_NO_EXCEPTIONS )

View File

@ -10,6 +10,15 @@
#include <vulkan/vulkansc_enums.hpp> #include <vulkan/vulkansc_enums.hpp>
// ignore warnings on using deprecated enum values in this header
#if defined( __clang__ ) || defined( __GNUC__ )
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#elif defined( _MSC_VER )
# pragma warning( push )
# pragma warning( disable : 4996 )
#endif
#if __cpp_lib_format #if __cpp_lib_format
# include <format> // std::format # include <format> // std::format
#else #else
@ -4411,4 +4420,11 @@ namespace VULKAN_HPP_NAMESPACE
} }
} // namespace VULKAN_HPP_NAMESPACE } // namespace VULKAN_HPP_NAMESPACE
#if defined( __clang__ ) || defined( __GNUC__ )
# pragma GCC diagnostic pop
#elif defined( _MSC_VER )
# pragma warning( pop )
#endif
#endif #endif