From 5e2edc10e0b8ea3d9249307be8d01104ce6e5a70 Mon Sep 17 00:00:00 2001 From: asuessenbach Date: Mon, 29 Mar 2021 10:11:19 +0200 Subject: [PATCH] Reduce parents of a handle from a vector to a single element --- VulkanHppGenerator.cpp | 24 ++++++++++-------------- VulkanHppGenerator.hpp | 6 +++--- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index 05602e6..c97a639 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -10441,12 +10441,9 @@ void VulkanHppGenerator::checkCorrectness() assert( objectTypeIt != m_enums.end() ); for ( auto const & handle : m_handles ) { - for ( auto const & parent : handle.second.parents ) - { - check( m_handles.find( parent ) != m_handles.end(), - handle.second.xmlLine, - "handle <" + handle.first + "> with unknown parent <" + parent + ">" ); - } + check( m_handles.find( handle.second.parent ) != m_handles.end(), + handle.second.xmlLine, + "handle <" + handle.first + "> with unknown parent <" + handle.second.parent + ">" ); if ( !handle.first.empty() ) { @@ -12526,7 +12523,9 @@ void VulkanHppGenerator::readHandle( tinyxml2::XMLElement const * check( typeInfo.postfix == "(", line, "unexpected type postfix <" + typeInfo.postfix + ">" ); check( !objTypeEnum.empty(), line, "handle <" + nameData.name + "> does not specify attribute \"objtypeenum\"" ); - check( m_handles.insert( std::make_pair( nameData.name, HandleData( tokenize( parent, "," ), objTypeEnum, line ) ) ) + check( + parent.find( ',' ) == std::string::npos, line, "mulitple parents specified for handle <" + nameData.name + ">" ); + check( m_handles.insert( std::make_pair( nameData.name, HandleData( parent, objTypeEnum, line ) ) ) .second, line, "handle <" + nameData.name + "> already specified" ); @@ -13667,14 +13666,11 @@ void VulkanHppGenerator::rescheduleRAIIHandle( std::string & std::set const & specialFunctions ) const { listedHandles.insert( handle.first ); - for ( auto const & parent : handle.second.parents ) + if ( !handle.second.parent.empty() && ( listedHandles.find( handle.second.parent ) == listedHandles.end() ) ) { - if ( listedHandles.find( parent ) == listedHandles.end() ) - { - auto parentIt = m_handles.find( parent ); - assert( parentIt != m_handles.end() ); - appendRAIIHandle( str, commandDefinitions, *parentIt, listedHandles, specialFunctions ); - } + auto parentIt = m_handles.find( handle.second.parent ); + assert( parentIt != m_handles.end() ); + appendRAIIHandle( str, commandDefinitions, *parentIt, listedHandles, specialFunctions ); } for ( auto constructorIt : handle.second.constructorIts ) diff --git a/VulkanHppGenerator.hpp b/VulkanHppGenerator.hpp index 4c7142a..c12b05a 100644 --- a/VulkanHppGenerator.hpp +++ b/VulkanHppGenerator.hpp @@ -201,8 +201,8 @@ private: struct HandleData { - HandleData( std::vector const & p, std::string const & objType, int line ) - : objTypeEnum( objType ), parents( p ), xmlLine( line ) + HandleData( std::string const & p, std::string const & objType, int line ) + : objTypeEnum( objType ), parent( p ), xmlLine( line ) {} std::string alias; @@ -211,7 +211,7 @@ private: std::string deleteCommand; std::string deletePool; std::string objTypeEnum; - std::vector parents; + std::string parent; std::set secondLevelCommands; int xmlLine;