Add checks on member sType of structs:

- only members named <sType> are supposed to have a <values> attribute
- no <values> attribute is allowed to occur more than once.
This commit is contained in:
asuessenbach 2020-04-29 09:04:21 +02:00
parent 285c1d5e8a
commit 89190683c8
2 changed files with 13 additions and 6 deletions

View File

@ -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 <sType> with attribute <values> 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 )

View File

@ -592,6 +592,7 @@ private:
std::map<std::string, std::string> m_platforms;
std::map<std::string, std::string> m_structureAliases;
std::map<std::string, StructureData> m_structures;
std::set<std::string> m_sTypeValues;
std::set<std::string> m_tags;
std::map<std::string, TypeCategory> m_types;
std::string m_typesafeCheck;