Merge pull request #728 from asuessenbach/assignment
Simplified assignment operator of structs
This commit is contained in:
commit
33b7dc8167
@ -3631,36 +3631,15 @@ ${prefix}{
|
|||||||
${prefix} *this = *reinterpret_cast<VULKAN_HPP_NAMESPACE::${structName} const *>( &rhs );
|
${prefix} *this = *reinterpret_cast<VULKAN_HPP_NAMESPACE::${structName} const *>( &rhs );
|
||||||
${prefix} return *this;
|
${prefix} return *this;
|
||||||
${prefix}}
|
${prefix}}
|
||||||
)";
|
|
||||||
str += replaceWithMap( assignmentFromVulkanType,
|
|
||||||
{ { "prefix", prefix }, { "structName", stripPrefix( structData.first, "Vk" ) } } );
|
|
||||||
|
|
||||||
// we need an assignment operator if there is constant member in this struct
|
|
||||||
if ( std::find_if( structData.second.members.begin(), structData.second.members.end(), []( MemberData const & md ) {
|
|
||||||
return md.values.size() == 1;
|
|
||||||
} ) != structData.second.members.end() )
|
|
||||||
{
|
|
||||||
std::string assignments;
|
|
||||||
for ( auto member : structData.second.members )
|
|
||||||
{
|
|
||||||
if ( member.values.size() != 1 )
|
|
||||||
{
|
|
||||||
assignments += prefix + member.name + " = rhs." + member.name + ";\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static const std::string assignmentTemplate = R"(
|
|
||||||
${prefix}${structName} & operator=( ${structName} const & rhs ) VULKAN_HPP_NOEXCEPT
|
${prefix}${structName} & operator=( ${structName} const & rhs ) VULKAN_HPP_NOEXCEPT
|
||||||
${prefix}{
|
${prefix}{
|
||||||
${assignments}
|
${prefix} memcpy( static_cast<void *>( this ), &rhs, sizeof( ${structName} ) );
|
||||||
${prefix} return *this;
|
${prefix} return *this;
|
||||||
${prefix}}
|
${prefix}}
|
||||||
)";
|
)";
|
||||||
str += replaceWithMap( assignmentTemplate,
|
str += replaceWithMap( assignmentFromVulkanType,
|
||||||
{ { "assignments", assignments },
|
{ { "prefix", prefix }, { "structName", stripPrefix( structData.first, "Vk" ) } } );
|
||||||
{ "prefix", prefix },
|
|
||||||
{ "structName", stripPrefix( structData.first, "Vk" ) } } );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VulkanHppGenerator::appendStructCompareOperators( std::string & str,
|
void VulkanHppGenerator::appendStructCompareOperators( std::string & str,
|
||||||
@ -3750,6 +3729,8 @@ ${prefix}${constexpr}${structName}(${arguments}) VULKAN_HPP_NOEXCEPT
|
|||||||
${prefix}${initializers}
|
${prefix}${initializers}
|
||||||
${prefix}{}
|
${prefix}{}
|
||||||
|
|
||||||
|
${prefix}${constexpr}${structName}( ${structName} const & rhs ) VULKAN_HPP_NOEXCEPT = default;
|
||||||
|
|
||||||
${prefix}${structName}( Vk${structName} const & rhs ) VULKAN_HPP_NOEXCEPT
|
${prefix}${structName}( Vk${structName} const & rhs ) VULKAN_HPP_NOEXCEPT
|
||||||
${prefix}{
|
${prefix}{
|
||||||
${prefix} *this = rhs;
|
${prefix} *this = rhs;
|
||||||
|
4920
vulkan/vulkan.hpp
4920
vulkan/vulkan.hpp
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user