mirror of
https://github.com/KhronosGroup/Vulkan-Hpp.git
synced 2025-09-10 12:28:48 -04:00
Fix struct constructor with deprecated members (#2236)
This commit is contained in:
parent
d6eb36b132
commit
621c713cf8
@ -11484,18 +11484,17 @@ std::string VulkanHppGenerator::generateStructConstructors( std::pair<std::strin
|
|||||||
{
|
{
|
||||||
// the constructor with all the elements as arguments, with defaults
|
// the constructor with all the elements as arguments, with defaults
|
||||||
// and the simple copy constructor from the corresponding vulkan structure
|
// and the simple copy constructor from the corresponding vulkan structure
|
||||||
static const std::string constructors = R"(${pushIgnored}${constexpr}${structName}(${arguments}) VULKAN_HPP_NOEXCEPT
|
static const std::string constructors = R"(${constexpr}${structName}(${arguments}) VULKAN_HPP_NOEXCEPT
|
||||||
${initializers}
|
${initializers}
|
||||||
{${ignores}}
|
{${ignores}}
|
||||||
|
|
||||||
${copyConstructor}
|
${constexpr}${structName}( ${structName} const & rhs ) VULKAN_HPP_NOEXCEPT = default;
|
||||||
|
|
||||||
${structName}( Vk${structName} const & rhs ) VULKAN_HPP_NOEXCEPT
|
${structName}( Vk${structName} const & rhs ) VULKAN_HPP_NOEXCEPT
|
||||||
: ${structName}( *reinterpret_cast<${structName} const *>( &rhs ) )
|
: ${structName}( *reinterpret_cast<${structName} const *>( &rhs ) )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
${enhancedConstructors}
|
${enhancedConstructors}
|
||||||
${popIgnored}
|
|
||||||
)";
|
)";
|
||||||
|
|
||||||
std::vector<std::string> arguments, initializers;
|
std::vector<std::string> arguments, initializers;
|
||||||
@ -11509,46 +11508,11 @@ ${popIgnored}
|
|||||||
arguments.push_back( argument );
|
arguments.push_back( argument );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( member.deprecated.empty() )
|
// gather the initializers; skip members with exactly one legal value
|
||||||
|
if ( member.value.empty() )
|
||||||
{
|
{
|
||||||
// gather the initializers; skip members with exactly one legal value
|
initializers.push_back( member.name + "{ " + member.name + "_ }" );
|
||||||
if ( member.value.empty() )
|
|
||||||
{
|
|
||||||
initializers.push_back( member.name + "{ " + member.name + "_ }" );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
ignores += "detail::ignore( " + member.name + "_ );\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string pushIgnored, popIgnored;
|
|
||||||
if ( !ignores.empty() )
|
|
||||||
{
|
|
||||||
pushIgnored = R"(
|
|
||||||
#if defined( _MSC_VER )
|
|
||||||
// no need to ignore this warning with MSVC
|
|
||||||
#elif defined( __clang__ )
|
|
||||||
// no need to ignore this warning with clang
|
|
||||||
#elif defined( __GNUC__ )
|
|
||||||
# pragma GCC diagnostic push
|
|
||||||
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
|
||||||
#else
|
|
||||||
// unknown compiler... just ignore the warnings for yourselves ;)
|
|
||||||
#endif
|
|
||||||
)";
|
|
||||||
popIgnored = R"(
|
|
||||||
#if defined( _MSC_VER )
|
|
||||||
// no need to ignore this warning with MSVC
|
|
||||||
#elif defined( __clang__ )
|
|
||||||
// no need to ignore this warning with clang
|
|
||||||
#elif defined( __GNUC__ )
|
|
||||||
# pragma GCC diagnostic pop
|
|
||||||
#else
|
|
||||||
// unknown compiler... just ignore the warnings for yourselves ;)
|
|
||||||
#endif
|
|
||||||
)";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pNextIt = std::ranges::find_if( structData.second.members, []( MemberData const & md ) { return md.name == "pNext"; } );
|
auto pNextIt = std::ranges::find_if( structData.second.members, []( MemberData const & md ) { return md.name == "pNext"; } );
|
||||||
@ -11561,10 +11525,7 @@ ${popIgnored}
|
|||||||
std::string str = replaceWithMap( constructors,
|
std::string str = replaceWithMap( constructors,
|
||||||
{ { "arguments", generateList( arguments, "", ", " ) },
|
{ { "arguments", generateList( arguments, "", ", " ) },
|
||||||
{ "constexpr", generateConstexprString( structData ) },
|
{ "constexpr", generateConstexprString( structData ) },
|
||||||
{ "copyConstructor", generateStructCopyConstructor( structData ) },
|
|
||||||
{ "enhancedConstructors", structData.second.returnedOnly ? "" : generateStructConstructorsEnhanced( structData ) },
|
{ "enhancedConstructors", structData.second.returnedOnly ? "" : generateStructConstructorsEnhanced( structData ) },
|
||||||
{ "popIgnored", popIgnored },
|
|
||||||
{ "pushIgnored", pushIgnored },
|
|
||||||
{ "structName", stripPrefix( structData.first, "Vk" ) },
|
{ "structName", stripPrefix( structData.first, "Vk" ) },
|
||||||
{ "ignores", ignores },
|
{ "ignores", ignores },
|
||||||
{ "initializers", generateList( initializers, ": ", ", " ) },
|
{ "initializers", generateList( initializers, ": ", ", " ) },
|
||||||
@ -11828,77 +11789,6 @@ std::string VulkanHppGenerator::generateStructConstructorArgument( MemberData co
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string VulkanHppGenerator::generateStructCopyAssignment( std::pair<std::string, StructureData> const & structData ) const
|
|
||||||
{
|
|
||||||
std::string copyAssignment;
|
|
||||||
if ( containsDeprecated( structData.second.members ) )
|
|
||||||
{
|
|
||||||
static const std::string copyAssignmentTemplate = R"(${structName} & operator=( ${structName} const & rhs ) VULKAN_HPP_NOEXCEPT
|
|
||||||
{
|
|
||||||
if ( this != &rhs )
|
|
||||||
{
|
|
||||||
${initializers}
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
})";
|
|
||||||
|
|
||||||
std::vector<std::string> initializers;
|
|
||||||
for ( auto const & member : structData.second.members )
|
|
||||||
{
|
|
||||||
if ( member.deprecated.empty() && ( member.type.type != "VkStructureType" ) )
|
|
||||||
{
|
|
||||||
initializers.push_back( member.name + " = rhs." + member.name + ";" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
copyAssignment = replaceWithMap( copyAssignmentTemplate,
|
|
||||||
{ { "initializers", generateList( initializers, "", "\n" ) }, { "structName", stripPrefix( structData.first, "Vk" ) } } );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
static const std::string copyAssignmentTemplate = R"(
|
|
||||||
${structName} & operator=( ${structName} const & rhs ) VULKAN_HPP_NOEXCEPT = default;)";
|
|
||||||
|
|
||||||
copyAssignment = replaceWithMap( copyAssignmentTemplate, { { "structName", stripPrefix( structData.first, "Vk" ) } } );
|
|
||||||
}
|
|
||||||
return copyAssignment;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string VulkanHppGenerator::generateStructCopyConstructor( std::pair<std::string, StructureData> const & structData ) const
|
|
||||||
{
|
|
||||||
std::string copyConstructor;
|
|
||||||
if ( containsDeprecated( structData.second.members ) )
|
|
||||||
{
|
|
||||||
static const std::string copyConstructorTemplate = R"(${constexpr}${structName}( ${structName} const & rhs ) VULKAN_HPP_NOEXCEPT
|
|
||||||
${initializers}
|
|
||||||
{})";
|
|
||||||
|
|
||||||
std::vector<std::string> initializers;
|
|
||||||
for ( auto const & member : structData.second.members )
|
|
||||||
{
|
|
||||||
if ( member.deprecated.empty() && ( member.type.type != "VkStructureType" ) )
|
|
||||||
{
|
|
||||||
initializers.push_back( member.name + "{ rhs." + member.name + " }" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
copyConstructor = replaceWithMap( copyConstructorTemplate,
|
|
||||||
{ { "constexpr", generateConstexprString( structData ) },
|
|
||||||
{ "initializers", generateList( initializers, ": ", ", " ) },
|
|
||||||
{ "structName", stripPrefix( structData.first, "Vk" ) } } );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
static const std::string copyConstructorTemplate = R"(
|
|
||||||
${constexpr}${structName}( ${structName} const & rhs ) VULKAN_HPP_NOEXCEPT = default;
|
|
||||||
)";
|
|
||||||
|
|
||||||
copyConstructor = replaceWithMap( copyConstructorTemplate,
|
|
||||||
{ { "constexpr", generateConstexprString( structData ) }, { "structName", stripPrefix( structData.first, "Vk" ) } } );
|
|
||||||
}
|
|
||||||
|
|
||||||
return copyConstructor;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string VulkanHppGenerator::generateStructHashStructure( std::pair<std::string, StructureData> const & structure,
|
std::string VulkanHppGenerator::generateStructHashStructure( std::pair<std::string, StructureData> const & structure,
|
||||||
std::set<std::string> & listedStructs ) const
|
std::set<std::string> & listedStructs ) const
|
||||||
{
|
{
|
||||||
@ -12140,10 +12030,10 @@ std::string VulkanHppGenerator::generateStructure( std::pair<std::string, Struct
|
|||||||
{
|
{
|
||||||
static const std::string constructorsTemplate = R"(
|
static const std::string constructorsTemplate = R"(
|
||||||
#if !defined( VULKAN_HPP_NO_CONSTRUCTORS ) && !defined( VULKAN_HPP_NO_STRUCT_CONSTRUCTORS )
|
#if !defined( VULKAN_HPP_NO_CONSTRUCTORS ) && !defined( VULKAN_HPP_NO_STRUCT_CONSTRUCTORS )
|
||||||
${constructors}
|
${pushIgnored}${constructors}
|
||||||
${subConstructors}
|
${subConstructors}
|
||||||
${deprecatedConstructors}
|
${deprecatedConstructors}
|
||||||
${copyAssignment}
|
${structName} & operator=( ${structName} const & rhs ) VULKAN_HPP_NOEXCEPT = default;${popIgnored}
|
||||||
#endif /*VULKAN_HPP_NO_CONSTRUCTORS*/
|
#endif /*VULKAN_HPP_NO_CONSTRUCTORS*/
|
||||||
|
|
||||||
${structName} & operator=( Vk${structName} const & rhs ) VULKAN_HPP_NOEXCEPT
|
${structName} & operator=( Vk${structName} const & rhs ) VULKAN_HPP_NOEXCEPT
|
||||||
@ -12153,11 +12043,44 @@ ${copyAssignment}
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
|
std::string pushIgnored, popIgnored;
|
||||||
|
if ( containsDeprecated( structure.second.members ) )
|
||||||
|
{
|
||||||
|
pushIgnored = R"(
|
||||||
|
#if defined( _MSC_VER )
|
||||||
|
# pragma warning( push )
|
||||||
|
# pragma warning( disable : 4996 ) // 'function': was declared deprecated
|
||||||
|
#elif defined( __clang__ )
|
||||||
|
# pragma clang diagnostic push
|
||||||
|
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
#elif defined( __GNUC__ )
|
||||||
|
# pragma GCC diagnostic push
|
||||||
|
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
#else
|
||||||
|
// unknown compiler... just ignore the warnings for yourselves ;)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
)";
|
||||||
|
popIgnored = R"(
|
||||||
|
|
||||||
|
#if defined( _MSC_VER )
|
||||||
|
# pragma warning( pop )
|
||||||
|
#elif defined( __clang__ )
|
||||||
|
# pragma clang diagnostic pop
|
||||||
|
#elif defined( __GNUC__ )
|
||||||
|
# pragma GCC diagnostic pop
|
||||||
|
#else
|
||||||
|
// unknown compiler... just ignore the warnings for yourselves ;)
|
||||||
|
#endif
|
||||||
|
)";
|
||||||
|
}
|
||||||
|
|
||||||
constructorsAndSetters = replaceWithMap( constructorsTemplate,
|
constructorsAndSetters = replaceWithMap( constructorsTemplate,
|
||||||
{ { "castAssignments", generateStructCastAssignments( structure ) },
|
{ { "castAssignments", generateStructCastAssignments( structure ) },
|
||||||
{ "constructors", generateStructConstructors( structure ) },
|
{ "constructors", generateStructConstructors( structure ) },
|
||||||
{ "copyAssignment", generateStructCopyAssignment( structure ) },
|
|
||||||
{ "deprecatedConstructors", generateDeprecatedConstructors( structure.first ) },
|
{ "deprecatedConstructors", generateDeprecatedConstructors( structure.first ) },
|
||||||
|
{ "popIgnored", popIgnored },
|
||||||
|
{ "pushIgnored", pushIgnored },
|
||||||
{ "structName", stripPrefix( structure.first, "Vk" ) },
|
{ "structName", stripPrefix( structure.first, "Vk" ) },
|
||||||
{ "subConstructors", generateStructSubConstructor( structure ) } } );
|
{ "subConstructors", generateStructSubConstructor( structure ) } } );
|
||||||
}
|
}
|
||||||
|
@ -1044,8 +1044,6 @@ private:
|
|||||||
std::string generateStructConstructors( std::pair<std::string, StructureData> const & structData ) const;
|
std::string generateStructConstructors( std::pair<std::string, StructureData> const & structData ) const;
|
||||||
std::string generateStructConstructorsEnhanced( std::pair<std::string, StructureData> const & structData ) const;
|
std::string generateStructConstructorsEnhanced( std::pair<std::string, StructureData> const & structData ) const;
|
||||||
std::string generateStructConstructorArgument( MemberData const & memberData, bool withDefault ) const;
|
std::string generateStructConstructorArgument( MemberData const & memberData, bool withDefault ) const;
|
||||||
std::string generateStructCopyAssignment( std::pair<std::string, StructureData> const & structData ) const;
|
|
||||||
std::string generateStructCopyConstructor( std::pair<std::string, StructureData> const & structData ) const;
|
|
||||||
std::string generateStructHashStructure( std::pair<std::string, StructureData> const & structure, std::set<std::string> & listedStructs ) const;
|
std::string generateStructHashStructure( std::pair<std::string, StructureData> const & structure, std::set<std::string> & listedStructs ) const;
|
||||||
std::string generateStructHashStructures() const;
|
std::string generateStructHashStructures() const;
|
||||||
std::string generateStructHashSum( std::string const & structName, std::vector<MemberData> const & members ) const;
|
std::string generateStructHashSum( std::string const & structName, std::vector<MemberData> const & members ) const;
|
||||||
|
@ -35997,15 +35997,18 @@ namespace VULKAN_HPP_NAMESPACE
|
|||||||
#if !defined( VULKAN_HPP_NO_CONSTRUCTORS ) && !defined( VULKAN_HPP_NO_STRUCT_CONSTRUCTORS )
|
#if !defined( VULKAN_HPP_NO_CONSTRUCTORS ) && !defined( VULKAN_HPP_NO_STRUCT_CONSTRUCTORS )
|
||||||
|
|
||||||
# if defined( _MSC_VER )
|
# if defined( _MSC_VER )
|
||||||
// no need to ignore this warning with MSVC
|
# pragma warning( push )
|
||||||
|
# pragma warning( disable : 4996 ) // 'function': was declared deprecated
|
||||||
# elif defined( __clang__ )
|
# elif defined( __clang__ )
|
||||||
// no need to ignore this warning with clang
|
# pragma clang diagnostic push
|
||||||
|
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||||
# elif defined( __GNUC__ )
|
# elif defined( __GNUC__ )
|
||||||
# pragma GCC diagnostic push
|
# pragma GCC diagnostic push
|
||||||
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||||
# else
|
# else
|
||||||
// unknown compiler... just ignore the warnings for yourselves ;)
|
// unknown compiler... just ignore the warnings for yourselves ;)
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
VULKAN_HPP_CONSTEXPR_17 DeviceCreateInfo( DeviceCreateFlags flags_ = {},
|
VULKAN_HPP_CONSTEXPR_17 DeviceCreateInfo( DeviceCreateFlags flags_ = {},
|
||||||
uint32_t queueCreateInfoCount_ = {},
|
uint32_t queueCreateInfoCount_ = {},
|
||||||
const DeviceQueueCreateInfo * pQueueCreateInfos_ = {},
|
const DeviceQueueCreateInfo * pQueueCreateInfos_ = {},
|
||||||
@ -36019,24 +36022,15 @@ namespace VULKAN_HPP_NAMESPACE
|
|||||||
, flags{ flags_ }
|
, flags{ flags_ }
|
||||||
, queueCreateInfoCount{ queueCreateInfoCount_ }
|
, queueCreateInfoCount{ queueCreateInfoCount_ }
|
||||||
, pQueueCreateInfos{ pQueueCreateInfos_ }
|
, pQueueCreateInfos{ pQueueCreateInfos_ }
|
||||||
|
, enabledLayerCount{ enabledLayerCount_ }
|
||||||
|
, ppEnabledLayerNames{ ppEnabledLayerNames_ }
|
||||||
, enabledExtensionCount{ enabledExtensionCount_ }
|
, enabledExtensionCount{ enabledExtensionCount_ }
|
||||||
, ppEnabledExtensionNames{ ppEnabledExtensionNames_ }
|
, ppEnabledExtensionNames{ ppEnabledExtensionNames_ }
|
||||||
, pEnabledFeatures{ pEnabledFeatures_ }
|
, pEnabledFeatures{ pEnabledFeatures_ }
|
||||||
{
|
{
|
||||||
detail::ignore( enabledLayerCount_ );
|
|
||||||
detail::ignore( ppEnabledLayerNames_ );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VULKAN_HPP_CONSTEXPR_17 DeviceCreateInfo( DeviceCreateInfo const & rhs ) VULKAN_HPP_NOEXCEPT
|
VULKAN_HPP_CONSTEXPR_17 DeviceCreateInfo( DeviceCreateInfo const & rhs ) VULKAN_HPP_NOEXCEPT = default;
|
||||||
: pNext{ rhs.pNext }
|
|
||||||
, flags{ rhs.flags }
|
|
||||||
, queueCreateInfoCount{ rhs.queueCreateInfoCount }
|
|
||||||
, pQueueCreateInfos{ rhs.pQueueCreateInfos }
|
|
||||||
, enabledExtensionCount{ rhs.enabledExtensionCount }
|
|
||||||
, ppEnabledExtensionNames{ rhs.ppEnabledExtensionNames }
|
|
||||||
, pEnabledFeatures{ rhs.pEnabledFeatures }
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
DeviceCreateInfo( VkDeviceCreateInfo const & rhs ) VULKAN_HPP_NOEXCEPT : DeviceCreateInfo( *reinterpret_cast<DeviceCreateInfo const *>( &rhs ) ) {}
|
DeviceCreateInfo( VkDeviceCreateInfo const & rhs ) VULKAN_HPP_NOEXCEPT : DeviceCreateInfo( *reinterpret_cast<DeviceCreateInfo const *>( &rhs ) ) {}
|
||||||
|
|
||||||
@ -36059,30 +36053,18 @@ namespace VULKAN_HPP_NAMESPACE
|
|||||||
}
|
}
|
||||||
# endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
|
# endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
|
||||||
|
|
||||||
|
DeviceCreateInfo & operator=( DeviceCreateInfo const & rhs ) VULKAN_HPP_NOEXCEPT = default;
|
||||||
|
|
||||||
# if defined( _MSC_VER )
|
# if defined( _MSC_VER )
|
||||||
// no need to ignore this warning with MSVC
|
# pragma warning( pop )
|
||||||
# elif defined( __clang__ )
|
# elif defined( __clang__ )
|
||||||
// no need to ignore this warning with clang
|
# pragma clang diagnostic pop
|
||||||
# elif defined( __GNUC__ )
|
# elif defined( __GNUC__ )
|
||||||
# pragma GCC diagnostic pop
|
# pragma GCC diagnostic pop
|
||||||
# else
|
# else
|
||||||
// unknown compiler... just ignore the warnings for yourselves ;)
|
// unknown compiler... just ignore the warnings for yourselves ;)
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
DeviceCreateInfo & operator=( DeviceCreateInfo const & rhs ) VULKAN_HPP_NOEXCEPT
|
|
||||||
{
|
|
||||||
if ( this != &rhs )
|
|
||||||
{
|
|
||||||
pNext = rhs.pNext;
|
|
||||||
flags = rhs.flags;
|
|
||||||
queueCreateInfoCount = rhs.queueCreateInfoCount;
|
|
||||||
pQueueCreateInfos = rhs.pQueueCreateInfos;
|
|
||||||
enabledExtensionCount = rhs.enabledExtensionCount;
|
|
||||||
ppEnabledExtensionNames = rhs.ppEnabledExtensionNames;
|
|
||||||
pEnabledFeatures = rhs.pEnabledFeatures;
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
#endif /*VULKAN_HPP_NO_CONSTRUCTORS*/
|
#endif /*VULKAN_HPP_NO_CONSTRUCTORS*/
|
||||||
|
|
||||||
DeviceCreateInfo & operator=( VkDeviceCreateInfo const & rhs ) VULKAN_HPP_NOEXCEPT
|
DeviceCreateInfo & operator=( VkDeviceCreateInfo const & rhs ) VULKAN_HPP_NOEXCEPT
|
||||||
|
Loading…
x
Reference in New Issue
Block a user