mirror of
https://github.com/KhronosGroup/Vulkan-Hpp.git
synced 2024-10-14 16:32:17 +00:00
Mark deprecated enum values as deprecated (#1955)
Some checks are pending
Set Version Tag / set-version-tag (push) Waiting to run
Some checks are pending
Set Version Tag / set-version-tag (push) Waiting to run
This commit is contained in:
parent
2fcbcfbefe
commit
fbb62163a0
@ -760,6 +760,15 @@ void VulkanHppGenerator::generateToStringHppFile() const
|
||||
|
||||
#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
|
||||
# include <format> // std::format
|
||||
#else
|
||||
@ -771,6 +780,13 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
${bitmasksToString}
|
||||
${enumsToString}
|
||||
} // namespace VULKAN_HPP_NAMESPACE
|
||||
|
||||
#if defined( __clang__ ) || defined( __GNUC__ )
|
||||
# pragma GCC diagnostic pop
|
||||
#elif defined( _MSC_VER )
|
||||
# pragma warning( pop )
|
||||
#endif
|
||||
|
||||
#endif
|
||||
)";
|
||||
|
||||
@ -6763,7 +6779,12 @@ std::string VulkanHppGenerator::generateEnum( std::pair<std::string, EnumData> c
|
||||
{
|
||||
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 )
|
||||
{
|
||||
@ -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 )
|
||||
{
|
||||
const int line = element->GetLineNum();
|
||||
bool deprecated = false;
|
||||
std::map<std::string, std::string> attributes = getAttributes( element );
|
||||
if ( attributes.contains( "alias" ) )
|
||||
{
|
||||
@ -13484,7 +13506,7 @@ void VulkanHppGenerator::readEnumsEnum( tinyxml2::XMLElement const * element, st
|
||||
}
|
||||
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" )
|
||||
{
|
||||
@ -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( 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" } },
|
||||
{ "bitpos", {} },
|
||||
{ "comment", {} },
|
||||
{ "deprecated", { "true" } },
|
||||
{ "dir", { "-" } },
|
||||
{ "extends", {} },
|
||||
{ "extnumber", {} },
|
||||
@ -14374,6 +14397,7 @@ void VulkanHppGenerator::readRequireEnum(
|
||||
{ "value", {} } } );
|
||||
|
||||
std::string api, bitpos, extends, name, offset, protect, type, value;
|
||||
bool deprecated = false;
|
||||
for ( auto const & attribute : attributes )
|
||||
{
|
||||
if ( attribute.first == "api" )
|
||||
@ -14384,6 +14408,10 @@ void VulkanHppGenerator::readRequireEnum(
|
||||
{
|
||||
bitpos = attribute.second;
|
||||
}
|
||||
else if ( attribute.first == "deprecated" )
|
||||
{
|
||||
deprecated = true;
|
||||
}
|
||||
else if ( attribute.first == "extends" )
|
||||
{
|
||||
extends = attribute.second;
|
||||
@ -14451,8 +14479,13 @@ void VulkanHppGenerator::readRequireEnum(
|
||||
auto enumIt = findByNameOrAlias( m_enums, extends );
|
||||
assert( enumIt != m_enums.end() );
|
||||
|
||||
enumIt->second.addEnumValue(
|
||||
line, name, protect.empty() ? getProtectFromPlatform( platform ) : protect, bitpos + offset, value, ( api.empty() || ( api == m_api ) ) && supported );
|
||||
enumIt->second.addEnumValue( line,
|
||||
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(
|
||||
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 );
|
||||
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!
|
||||
{
|
||||
|
@ -147,6 +147,7 @@ private:
|
||||
{
|
||||
std::map<std::string, int> aliases = {};
|
||||
std::string bitpos = {};
|
||||
bool deprecated = {};
|
||||
std::string name = {};
|
||||
std::string protect = {};
|
||||
bool supported = {};
|
||||
@ -157,8 +158,13 @@ private:
|
||||
struct EnumData
|
||||
{
|
||||
void addEnumAlias( int line, std::string const & name, std::string const & alias, std::string const & protect, bool supported );
|
||||
void addEnumValue(
|
||||
int line, std::string const & valueName, std::string const & protect, std::string const & bitpos, std::string const & value, bool supported );
|
||||
void addEnumValue( int line,
|
||||
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::string bitwidth = {};
|
||||
|
@ -176,6 +176,12 @@
|
||||
# define VULKAN_HPP_DEPRECATED( msg )
|
||||
#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 )
|
||||
# define VULKAN_HPP_NODISCARD [[nodiscard]]
|
||||
# if defined( VULKAN_HPP_NO_EXCEPTIONS )
|
||||
|
@ -4501,7 +4501,7 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
eBt709NonlinearEXT = VK_COLOR_SPACE_BT709_NONLINEAR_EXT,
|
||||
eBt2020LinearEXT = VK_COLOR_SPACE_BT2020_LINEAR_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,
|
||||
eAdobergbLinearEXT = VK_COLOR_SPACE_ADOBERGB_LINEAR_EXT,
|
||||
eAdobergbNonlinearEXT = VK_COLOR_SPACE_ADOBERGB_NONLINEAR_EXT,
|
||||
|
@ -185,6 +185,12 @@
|
||||
# define VULKAN_HPP_DEPRECATED( msg )
|
||||
#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 )
|
||||
# define VULKAN_HPP_NODISCARD [[nodiscard]]
|
||||
# if defined( VULKAN_HPP_NO_EXCEPTIONS )
|
||||
|
@ -10,6 +10,15 @@
|
||||
|
||||
#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
|
||||
# include <format> // std::format
|
||||
#else
|
||||
@ -9146,4 +9155,11 @@ 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
|
||||
|
@ -3175,7 +3175,7 @@ namespace VULKAN_HPP_NAMESPACE
|
||||
eBt709NonlinearEXT = VK_COLOR_SPACE_BT709_NONLINEAR_EXT,
|
||||
eBt2020LinearEXT = VK_COLOR_SPACE_BT2020_LINEAR_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,
|
||||
eAdobergbLinearEXT = VK_COLOR_SPACE_ADOBERGB_LINEAR_EXT,
|
||||
eAdobergbNonlinearEXT = VK_COLOR_SPACE_ADOBERGB_NONLINEAR_EXT,
|
||||
|
@ -185,6 +185,12 @@
|
||||
# define VULKAN_HPP_DEPRECATED( msg )
|
||||
#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 )
|
||||
# define VULKAN_HPP_NODISCARD [[nodiscard]]
|
||||
# if defined( VULKAN_HPP_NO_EXCEPTIONS )
|
||||
|
@ -10,6 +10,15 @@
|
||||
|
||||
#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
|
||||
# include <format> // std::format
|
||||
#else
|
||||
@ -4411,4 +4420,11 @@ 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
|
||||
|
Loading…
Reference in New Issue
Block a user