Merge pull request #1418 from asuessenbach/selection

Allow union member attribute "selection" to have multiple comma-separated values
This commit is contained in:
Andreas Süßenbach 2022-09-27 09:45:18 +02:00 committed by GitHub
commit a41fa7b593
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 9 deletions

View File

@ -1222,13 +1222,15 @@ void VulkanHppGenerator::checkStructMemberCorrectness( std::string const &
{
// check that each union member has a selection, that is a value of the seleting enum
assert( !unionMember.selection.empty() );
std::string const & selection = unionMember.selection;
checkForError( std::find_if( selectorEnumIt->second.values.begin(),
selectorEnumIt->second.values.end(),
[&selection]( EnumValueData const & evd ) { return evd.name == selection; } ) != selectorEnumIt->second.values.end(),
unionMember.xmlLine,
"union member <" + unionMember.name + "> uses selection <" + selection + "> that is not part of the selector type <" +
selectorIt->type.type + ">" );
for ( auto const & selection : unionMember.selection )
{
checkForError( std::find_if( selectorEnumIt->second.values.begin(),
selectorEnumIt->second.values.end(),
[&selection]( EnumValueData const & evd ) { return evd.name == selection; } ) != selectorEnumIt->second.values.end(),
unionMember.xmlLine,
"union member <" + unionMember.name + "> uses selection <" + selection + "> that is not part of the selector type <" +
selectorIt->type.type + ">" );
}
}
}
@ -12897,7 +12899,7 @@ void VulkanHppGenerator::readTypesTypeStructMember( tinyxml2::XMLElement const *
else if ( attribute.first == "selection" )
{
checkForError( isUnion, line, "attribute <selection> is used with a non-union structure." );
memberData.selection = attribute.second;
memberData.selection = tokenize( attribute.second, "," );
}
else if ( attribute.first == "selector" )
{

View File

@ -295,7 +295,7 @@ private:
std::vector<std::string> len;
bool noAutoValidity = false;
std::vector<bool> optional;
std::string selection;
std::vector<std::string> selection;
std::string selector;
std::string value;
std::string usedConstant;