Add support of attribute "values" for struct members of type uint32_t.

This commit is contained in:
asuessenbach 2021-06-23 10:59:55 +02:00
parent da2ecae452
commit e05bea9f13

View File

@ -9567,7 +9567,7 @@ ${prefix}{}
// gather the arguments // gather the arguments
listedArgument = appendStructConstructorArgument( arguments, listedArgument, member, true ); listedArgument = appendStructConstructorArgument( arguments, listedArgument, member, true );
// gather the initializers; skip member 'pNext' and constant members // gather the initializers; skip member 'pNext' and members with exactly one legal value
if ( ( member.name != "pNext" ) && ( member.values.size() != 1 ) ) if ( ( member.name != "pNext" ) && ( member.values.size() != 1 ) )
{ {
initializers += ( firstArgument ? ":" : "," ) + std::string( " " ) + member.name + "( " + member.name + "_ )"; initializers += ( firstArgument ? ":" : "," ) + std::string( " " ) + member.name + "( " + member.name + "_ )";
@ -9750,16 +9750,22 @@ std::string VulkanHppGenerator::appendStructMembers( std::string &
if ( !member.values.empty() ) if ( !member.values.empty() )
{ {
// special handling for members with legal value: arbitrarily use the first one as the default // special handling for members with legal value: arbitrarily use the first one as the default
auto enumIt = m_enums.find( member.type.type ); str += " = ";
assert( enumIt != m_enums.end() ); if ( member.type.type == "uint32_t" )
{ {
str += member.values.front();
}
else
{
auto enumIt = m_enums.find( member.type.type );
assert( enumIt != m_enums.end() );
std::string enumValue = member.values.front(); std::string enumValue = member.values.front();
auto valueIt = std::find_if( enumIt->second.values.begin(), auto valueIt = std::find_if( enumIt->second.values.begin(),
enumIt->second.values.end(), enumIt->second.values.end(),
[&enumValue]( EnumValueData const & evd ) { return enumValue == evd.name; } ); [&enumValue]( EnumValueData const & evd ) { return enumValue == evd.name; } );
assert( valueIt != enumIt->second.values.end() ); assert( valueIt != enumIt->second.values.end() );
std::string valueName = generateEnumValueName( enumIt->first, valueIt->name, enumIt->second.isBitmask, m_tags ); std::string valueName = generateEnumValueName( enumIt->first, valueIt->name, enumIt->second.isBitmask, m_tags );
str += " = " + stripPrefix( member.type.type, "Vk" ) + "::" + valueName; str += stripPrefix( member.type.type, "Vk" ) + "::" + valueName;
if ( member.name == "sType" ) if ( member.name == "sType" )
{ {
sTypeValue = valueName; sTypeValue = valueName;