| 12292 | } |
| 12293 | |
| 12294 | std::string VulkanHppGenerator::generateVectorSizeCheck( std::string const & name, |
| 12295 | CommandData const & commandData, |
| 12296 | size_t initialSkipCount, |
| 12297 | std::map<size_t, std::vector<size_t>> const & countToVectorMap, |
| 12298 | std::set<size_t> const & skippedParams, |
| 12299 | bool onlyThrows ) const |
| 12300 | { |
| 12301 | std::string const assertTemplate = " VULKAN_HPP_ASSERT( ${zeroSizeCheck}${firstVectorName}.size() == ${secondVectorName}.size() );"; |
| 12302 | std::string const assertTemplateVoid = |
| 12303 | " VULKAN_HPP_ASSERT( ${zeroSizeCheck}${firstVectorName}.size() * sizeof( ${firstDataType} ) == ${secondVectorName}.size() * sizeof( ${secondDataType} ) );"; |
| 12304 | std::string const assertTemplateSingle = " VULKAN_HPP_ASSERT( ${vectorName}.size() == ${sizeValue} );"; |
| 12305 | std::string const throwTemplate = |
| 12306 | R"#( if ( ${zeroSizeCheck}${firstVectorName}.size() != ${secondVectorName}.size() ) |
| 12307 | { |
| 12308 | throw LogicError( VULKAN_HPP_NAMESPACE_STRING "::${className}::${commandName}: ${firstVectorName}.size() != ${secondVectorName}.size()" ); |
| 12309 | })#"; |
| 12310 | std::string const throwTemplateVoid = |
| 12311 | R"#( if ( ${zeroSizeCheck}${firstVectorName}.size() * sizeof( ${firstDataType} ) != ${secondVectorName}.size() * sizeof( ${secondDataType} ) ) |
| 12312 | { |
| 12313 | throw LogicError( VULKAN_HPP_NAMESPACE_STRING "::${className}::${commandName}: ${firstVectorName}.size() * sizeof( ${firstDataType} ) != ${secondVectorName}.size() * sizeof( ${secondDataType} )" ); |
| 12314 | })#"; |
| 12315 | std::string const throwTemplateSingle = R"#( if ( ${vectorName}.size() != ${sizeValue} ) |
| 12316 | { |
| 12317 | throw LogicError( VULKAN_HPP_NAMESPACE_STRING "::${className}::${commandName}: ${vectorName}.size() != ${sizeValue}" ); |
| 12318 | })#"; |
| 12319 | |
| 12320 | std::string className = stripPrefix( commandData.params[initialSkipCount - 1].type.name, "Vk" ); |
| 12321 | std::string commandName = generateCommandName( name, commandData.params, initialSkipCount ); |
| 12322 | |
| 12323 | std::string assertions, throws; |
| 12324 | for ( auto const & cvm : countToVectorMap ) |
| 12325 | { |
| 12326 | size_t const defaultStartIndex = determineDefaultStartIndex( commandData.params, skippedParams ); |
| 12327 | std::string firstVectorName = startLowerCase( stripPrefix( commandData.params[cvm.second[0]].name, "p" ) ); |
| 12328 | |
| 12329 | if ( cvm.second.size() == 1 ) |
| 12330 | { |
| 12331 | std::string sizeValue; |
| 12332 | if ( isLenByStructMember( commandData.params[cvm.second[0]].lenExpression, commandData.params[cvm.first] ) ) |
| 12333 | { |
| 12334 | std::vector<std::string> lenParts = tokenize( commandData.params[cvm.second[0]].lenExpression, "->" ); |
| 12335 | assert( lenParts.size() == 2 ); |
| 12336 | sizeValue = startLowerCase( stripPrefix( lenParts[0], "p" ) ) + "." + lenParts[1]; |
| 12337 | } |
| 12338 | else |
| 12339 | { |
| 12340 | assert( !commandData.params[cvm.second[0]].lenParams.empty() ); |
| 12341 | if ( commandData.params[cvm.first].type.name == "VkSampleCountFlagBits" ) |
| 12342 | { |
| 12343 | assert( commandData.params[cvm.second[0]].lenExpression == "(" + commandData.params[cvm.second[0]].lenParams[0].first + " + 31) / 32" ); |
| 12344 | sizeValue = "( static_cast<uint32_t>( " + commandData.params[cvm.second[0]].lenParams[0].first + " ) + 31 ) / 32"; |
| 12345 | } |
| 12346 | else |
| 12347 | { |
| 12348 | sizeValue = commandData.params[cvm.second[0]].lenExpression; |
| 12349 | } |
| 12350 | } |
| 12351 | assertions += replaceWithMap( assertTemplateSingle, { { "sizeValue", sizeValue }, { "vectorName", firstVectorName } } ); |
nothing calls this directly
no test coverage detected