| 10657 | } |
| 10658 | |
| 10659 | std::string VulkanHppGenerator::generateStructConstructors( std::pair<std::string, StructData> const & structData ) const |
| 10660 | { |
| 10661 | // the constructor with all the elements as arguments, with defaults |
| 10662 | // and the simple copy constructor from the corresponding vulkan structure |
| 10663 | static std::string const constructors = R"(${constexpr}${structName}(${arguments}) VULKAN_HPP_NOEXCEPT |
| 10664 | ${initializers} |
| 10665 | {${ignores}} |
| 10666 | |
| 10667 | ${constexpr}${structName}( ${structName} const & rhs ) VULKAN_HPP_NOEXCEPT = default; |
| 10668 | |
| 10669 | ${structName}( Vk${structName} const & rhs ) VULKAN_HPP_NOEXCEPT |
| 10670 | : ${structName}( *reinterpret_cast<${structName} const *>( &rhs ) ) |
| 10671 | {} |
| 10672 | |
| 10673 | ${enhancedConstructors} |
| 10674 | )"; |
| 10675 | |
| 10676 | std::vector<std::string> arguments, initializers; |
| 10677 | std::string ignores; |
| 10678 | for ( auto const & member : structData.second.members ) |
| 10679 | { |
| 10680 | // gather the arguments |
| 10681 | std::string argument = generateStructConstructorArgument( member, true ); |
| 10682 | if ( !argument.empty() ) |
| 10683 | { |
| 10684 | arguments.push_back( argument ); |
| 10685 | } |
| 10686 | |
| 10687 | // gather the initializers; skip members with exactly one legal value |
| 10688 | if ( member.value.empty() ) |
| 10689 | { |
| 10690 | initializers.push_back( member.name + "{ " + member.name + "_ }" ); |
| 10691 | } |
| 10692 | } |
| 10693 | |
| 10694 | auto pNextIt = std::ranges::find_if( structData.second.members, []( MemberData const & md ) { return md.name == "pNext"; } ); |
| 10695 | if ( pNextIt != structData.second.members.end() ) |
| 10696 | { |
| 10697 | // add pNext as a last optional argument to the constructor |
| 10698 | arguments.push_back( pNextIt->type.compose( "Vk" ) + " pNext_ = nullptr" ); |
| 10699 | } |
| 10700 | |
| 10701 | std::string str = replaceWithMap( constructors, |
| 10702 | { { "arguments", generateList( arguments, "", ", " ) }, |
| 10703 | { "constexpr", generateConstexprString( structData ) }, |
| 10704 | { "enhancedConstructors", structData.second.returnedOnly ? "" : generateStructConstructorsEnhanced( structData ) }, |
| 10705 | { "structName", stripPrefix( structData.first, "Vk" ) }, |
| 10706 | { "ignores", ignores }, |
| 10707 | { "initializers", generateList( initializers, ": ", ", " ) }, |
| 10708 | { "structName", stripPrefix( structData.first, "Vk" ) } } ); |
| 10709 | return str; |
| 10710 | } |
| 10711 | |
| 10712 | std::string VulkanHppGenerator::generateStructConstructorsEnhanced( std::pair<std::string, StructData> const & structData ) const |
| 10713 | { |
nothing calls this directly
no test coverage detected