Simplify handling of structextends (#1866)

This commit is contained in:
Andreas Süßenbach 2024-05-06 10:31:43 +02:00 committed by GitHub
parent c1fb25264d
commit 2518f528c0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 5 deletions

View File

@ -12531,7 +12531,7 @@ bool VulkanHppGenerator::isStructureChainAnchor( std::string const & type ) cons
auto it = findByNameOrAlias( m_structs, type );
if ( it != m_structs.end() )
{
return m_extendedStructs.contains( it->first );
return it->second.isExtended;
}
}
return false;
@ -12605,6 +12605,19 @@ bool VulkanHppGenerator::isTypeUsed( std::string const & type ) const
return false;
}
void VulkanHppGenerator::markExtendedStructs()
{
for (auto const& s : m_structs)
{
for (auto const& extends : s.second.structExtends)
{
auto structIt = m_structs.find( extends );
checkForError( structIt != m_structs.end(), s.second.xmlLine, "struct <" + s.first + "> extends unknown struct <" + extends + ">" );
structIt->second.isExtended = true;
}
}
}
bool VulkanHppGenerator::needsStructureChainResize( std::map<size_t, VectorParamData> const & vectorParams,
std::vector<size_t> const & chainedReturnParams ) const
{
@ -13760,6 +13773,7 @@ void VulkanHppGenerator::readRegistry( tinyxml2::XMLElement const * element )
else if ( value == "types" )
{
readTypes( child );
markExtendedStructs();
}
}
}
@ -14954,7 +14968,6 @@ void VulkanHppGenerator::readTypeStruct( tinyxml2::XMLElement const * element, b
checkForError( m_types.insert( { name, TypeData{ TypeCategory::Struct, {}, line } } ).second, line, "struct <" + name + "> already specified" );
checkForError( m_structsAliases.insert( { name, { alias, line } } ).second, line, "struct alias <" + name + "> already listed" );
}
else
{
checkAttributes( line,
@ -15075,8 +15088,6 @@ void VulkanHppGenerator::readTypeStruct( tinyxml2::XMLElement const * element, b
}
}
}
m_extendedStructs.insert( structureData.structExtends.begin(), structureData.structExtends.end() );
}
}

View File

@ -366,6 +366,7 @@ private:
{
std::map<std::string, int> aliases = {};
bool allowDuplicate = {};
bool isExtended = {};
bool isUnion = {};
bool returnedOnly = {};
bool mutualExclusiveLens = {};
@ -953,6 +954,7 @@ private:
bool isSupportedFeature( std::string const & name ) const;
bool isTypeRequired( std::string const & type ) const;
bool isTypeUsed( std::string const & type ) const;
void markExtendedStructs();
bool needsStructureChainResize( std::map<size_t, VectorParamData> const & vectorParams, std::vector<size_t> const & chainedReturnParams ) const;
std::pair<bool, std::map<size_t, std::vector<size_t>>> needsVectorSizeCheck( std::vector<ParamData> const & params,
std::map<size_t, VectorParamData> const & vectorParams,
@ -1042,7 +1044,6 @@ private:
std::map<std::string, DefineData> m_defines;
DefinesPartition m_definesPartition; // partition defined macros into mutually-exclusive sets of callees, callers, and values
std::map<std::string, EnumData> m_enums;
std::set<std::string> m_extendedStructs; // structs which are referenced by the structextends tag
std::vector<ExtensionData> m_extensions;
std::map<std::string, ExternalTypeData> m_externalTypes;
std::vector<FeatureData> m_features;