From 6fa59ce5afeede8a47921c2f960297a63e3b5f89 Mon Sep 17 00:00:00 2001 From: asuessenbach Date: Thu, 24 Jun 2021 14:00:47 +0200 Subject: [PATCH] Improve handling of struct members of type pointer-to-pointer-to-something --- VulkanHppGenerator.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index 4b11987..06ff819 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -9631,10 +9631,6 @@ void VulkanHppGenerator::appendStructConstructorsEnhanced( std::string & { return !md.len.empty() && ( ignoreLens.find( md.len.front() ) == ignoreLens.end() ); } ); if ( !memberIts.empty() ) { - // maximal one member to be handled by an ArrayProxyNoTemporaries is of type void - assert( std::count_if( memberIts.begin(), memberIts.end(), []( auto it ) { return it->type.type == "void"; } ) <= - 1 ); - // map from len-members to all the array members using that len std::map::const_iterator, std::vector::const_iterator>> lenIts; for ( auto const & mit : memberIts ) @@ -9672,9 +9668,11 @@ void VulkanHppGenerator::appendStructConstructorsEnhanced( std::string & std::string argumentName = startLowerCase( stripPrefix( mit->name, "p" ) ) + "_"; assert( endsWith( mit->type.postfix, "*" ) ); - std::string argumentType = stripPostfix( mit->type.compose(), "*" ); - if ( mit->type.type == "void" ) + std::string argumentType = trimEnd( stripPostfix( mit->type.compose(), "*" ) ); + if ( ( mit->type.type == "void" ) && ( argumentType.find( '*' ) == std::string::npos ) ) { + // the argument after stripping one pointer is just void + assert( templateHeader.empty() ); templateHeader = prefix + "template \n"; size_t pos = argumentType.find( "void" ); @@ -9909,11 +9907,12 @@ void VulkanHppGenerator::appendStructSetter( std::string & str } assert( memberType.back() == '*' ); - memberType.pop_back(); + memberType = trimEnd( stripPostfix( memberType, "*" ) ); std::string templateHeader; - if ( member.type.type == "void" ) + if ( ( member.type.type == "void" ) && ( memberType.find( '*' ) == std::string::npos ) ) { + assert( templateHeader.empty() ); templateHeader = "template \n "; size_t pos = memberType.find( "void" ); @@ -12055,7 +12054,9 @@ std::string VulkanHppGenerator::generateLenInitializer( { initializer += " * 4"; } - if ( arrayIt->type.type == "void" ) + if ( ( arrayIt->type.type == "void" ) && + ( std::count_if( + arrayIt->type.postfix.begin(), arrayIt->type.postfix.end(), []( char c ) { return c == '*'; } ) < 2 ) ) { initializer += " * sizeof(T)"; }