Introduce additional constructor for unions holding a fixed size array of data.

This commit is contained in:
asuessenbach
2022-11-24 08:59:50 +01:00
parent fc0568ea37
commit 556c0d3434
37 changed files with 94 additions and 47 deletions

View File

@@ -10131,6 +10131,39 @@ std::string VulkanHppGenerator::generateUnion( std::pair<std::string, StructureD
{ "memberType", memberType },
{ "unionName", stripPrefix( structure.first, "Vk" ) } } );
firstMember = false;
if ( !memberIt->arraySizes.empty() )
{
assert( !multipleType );
assert( memberIt->arraySizes.size() == 1 );
int size = std::stoi( memberIt->arraySizes[0] );
assert( std::to_string( size ) == memberIt->arraySizes[0] );
std::string arguments, callArguments;
bool firstArgument = true;
for ( int i = 0; i < size; i++ )
{
if ( !firstArgument )
{
arguments += ", ";
callArguments += ", ";
}
std::string argumentIndex = std::to_string( i );
arguments += memberIt->type.type + " " + memberIt->name + "_" + argumentIndex;
callArguments += memberIt->name + "_" + argumentIndex;
firstArgument = false;
}
static const std::string constructorBySequenceTemplate = R"(
VULKAN_HPP_CONSTEXPR ${unionName}( ${arguments} )
: ${memberName}( { ${callArguments} } )
{})";
constructors += "\n" + replaceWithMap( constructorBySequenceTemplate,
{ { "arguments", arguments },
{ "callArguments", callArguments },
{ "memberName", memberIt->name },
{ "unionName", stripPrefix( structure.first, "Vk" ) } } );
}
}
}