From 89190683c859ddf427a0d0f4427c8ee8588e59ab Mon Sep 17 00:00:00 2001 From: asuessenbach Date: Wed, 29 Apr 2020 09:04:21 +0200 Subject: [PATCH] Add checks on member sType of structs: - only members named are supposed to have a attribute - no attribute is allowed to occur more than once. --- VulkanHppGenerator.cpp | 18 ++++++++++++------ VulkanHppGenerator.hpp | 1 + 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index 3e209eb..7a1ea63 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -6339,12 +6339,6 @@ void VulkanHppGenerator::readStructMember( tinyxml2::XMLElement const * element, members.push_back( MemberData( line ) ); MemberData & memberData = members.back(); - auto valuesIt = attributes.find( "values" ); - if ( valuesIt != attributes.end() ) - { - memberData.values = valuesIt->second; - } - for ( auto child : children ) { std::string value = child->Value(); @@ -6361,6 +6355,18 @@ void VulkanHppGenerator::readStructMember( tinyxml2::XMLElement const * element, readStructMemberType( child, memberData ); } } + + auto valuesIt = attributes.find( "values" ); + if ( valuesIt != attributes.end() ) + { + check( memberData.name == "sType", + line, + "Structure member named differently than with attribute encountered: " ); + check( m_sTypeValues.insert( valuesIt->second ).second, + line, + "<" + valuesIt->second + "> already encountered as values for the sType member of a struct" ); + memberData.values = valuesIt->second; + } } void VulkanHppGenerator::readStructMemberEnum( tinyxml2::XMLElement const * element, MemberData & memberData ) diff --git a/VulkanHppGenerator.hpp b/VulkanHppGenerator.hpp index 5a30cf6..6adc775 100644 --- a/VulkanHppGenerator.hpp +++ b/VulkanHppGenerator.hpp @@ -592,6 +592,7 @@ private: std::map m_platforms; std::map m_structureAliases; std::map m_structures; + std::set m_sTypeValues; std::set m_tags; std::map m_types; std::string m_typesafeCheck;