From 1173c9ab779a4aa0e51a470c44a49de881ffd98c Mon Sep 17 00:00:00 2001 From: asuessenbach Date: Tue, 27 Sep 2022 08:50:36 +0200 Subject: [PATCH] Allow union attribute "selection" to have multiple comma-separted values. --- VulkanHppGenerator.cpp | 18 ++++++++++-------- VulkanHppGenerator.hpp | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index 678d9f4..235042d 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -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 is used with a non-union structure." ); - memberData.selection = attribute.second; + memberData.selection = tokenize( attribute.second, "," ); } else if ( attribute.first == "selector" ) { diff --git a/VulkanHppGenerator.hpp b/VulkanHppGenerator.hpp index 42f6ef7..734c608 100644 --- a/VulkanHppGenerator.hpp +++ b/VulkanHppGenerator.hpp @@ -295,7 +295,7 @@ private: std::vector len; bool noAutoValidity = false; std::vector optional; - std::string selection; + std::vector selection; std::string selector; std::string value; std::string usedConstant;