diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index 92d68f8..4a35020 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -957,7 +957,7 @@ void VulkanHppGenerator::appendDispatchLoaderDynamicCommand( std::string & CommandData const & commandData ) { std::string enter, leave; - std::tie( enter, leave ) = generateProtection( commandData.referencedIn ); + std::tie( enter, leave ) = generateProtection( commandData.referencedIn, std::string() ); std::string command = " PFN_" + commandName + " " + commandName + " = 0;\n"; if ( !enter.empty() ) { @@ -1023,16 +1023,7 @@ void VulkanHppGenerator::appendEnum( std::string & str, std::pairsecond.name == evd.name; } ); } assert( enumIt != enumData.second.values.end() ); - assert( enumIt->extension.empty() || generateProtection( enumIt->extension ).first.empty() ); + assert( enumIt->extension.empty() || generateProtection( enumIt->extension, enumIt->protect ).first.empty() ); #endif enumList += " " + aliasName + " = " + alias.first + ",\n"; @@ -1249,16 +1240,7 @@ void VulkanHppGenerator::appendEnumToString( std::string & for ( auto const & value : enumData.second.values ) { std::string enter, leave; - if ( !value.extension.empty() ) - { - assert( value.protect.empty() ); - std::tie( enter, leave ) = generateProtection( value.extension ); - } - else if ( !value.protect.empty() ) - { - enter = "#if defined( " + value.protect + " )\n"; - leave = "#endif /*" + value.protect + "*/\n"; - } + std::tie( enter, leave ) = generateProtection( value.extension, value.protect ); if ( previousEnter != enter ) { str += previousLeave + enter; @@ -1628,7 +1610,7 @@ void VulkanHppGenerator::appendHandle( std::string & str, std::pairfirst ); + std::tie( enter, leave ) = generateProtection( extIt.second->first, std::string() ); commands += "\n" + enter + " //=== " + extIt.second->first + " ===\n"; for ( auto const & command : commandNames ) { @@ -1855,7 +1837,7 @@ void VulkanHppGenerator::appendHandlesCommandDefinitions( std::string & str ) co if ( !extIt.second->second.commands.empty() ) { std::string enter, leave; - std::tie( enter, leave ) = generateProtection( extIt.second->first ); + std::tie( enter, leave ) = generateProtection( extIt.second->first, std::string() ); str += "\n" + enter + " //=== " + extIt.second->first + " ===\n"; for ( auto const & command : extIt.second->second.commands ) { @@ -1937,7 +1919,7 @@ void VulkanHppGenerator::appendRAIICommands( std::string & str, std::setfirst ); + std::tie( enter, leave ) = generateProtection( extIt.second->first, std::string() ); str += "\n" + enter + " //=== " + extIt.second->first + " ===\n"; for ( auto const & command : commands ) { @@ -1957,7 +1939,7 @@ void VulkanHppGenerator::appendRAIIDispatchers( std::string & str ) const for ( auto const & command : m_commands ) { std::string enter, leave; - std::tie( enter, leave ) = generateProtection( command.second.referencedIn ); + std::tie( enter, leave ) = generateProtection( command.second.referencedIn, std::string() ); if ( command.second.handle.empty() ) { @@ -2105,7 +2087,7 @@ ${leave})"; if ( beginsWith( value.name, "VK_ERROR" ) ) { std::string enter, leave; - std::tie( enter, leave ) = generateProtection( value.extension ); + std::tie( enter, leave ) = generateProtection( value.extension, value.protect ); std::string valueName = generateEnumValueName( enumIt->first, value.name, false, m_tags ); str += replaceWithMap( templateString, { { "className", stripPrefix( valueName, "eError" ) + "Error" }, @@ -5862,7 +5844,8 @@ std::pair // check for additional enter/leave guards for the constructors std::string constructorEnter, constructorLeave; - std::tie( constructorEnter, constructorLeave ) = generateProtection( constructorIt->second.referencedIn ); + std::tie( constructorEnter, constructorLeave ) = + generateProtection( constructorIt->second.referencedIn, std::string() ); if ( constructorEnter == enter ) { constructorEnter.clear(); @@ -6048,7 +6031,7 @@ std::pair std::string const & enter ) const { std::string destructorEnter, destructorLeave; - std::tie( destructorEnter, destructorLeave ) = generateProtection( destructorIt->second.referencedIn ); + std::tie( destructorEnter, destructorLeave ) = generateProtection( destructorIt->second.referencedIn, std::string() ); bool doProtect = !destructorEnter.empty() && ( destructorEnter != enter ); if ( !doProtect ) { @@ -6467,7 +6450,7 @@ std::pair VulkanHppGenerator::constructRAIIHandleMembe std::string commandName = generateCommandName( commandIt->first, initialSkipCount ? commandIt->second.params[initialSkipCount - 1].type.type : "", m_tags ); std::string enter, leave; - std::tie( enter, leave ) = generateProtection( commandIt->second.referencedIn ); + std::tie( enter, leave ) = generateProtection( commandIt->second.referencedIn, std::string() ); std::string callArguments = constructCallArgumentsEnhanced( commandIt->second.params, initialSkipCount, false, {}, nonConstPointerParamIndices, true ); std::string firstReturnName = @@ -7451,7 +7434,7 @@ std::pair VulkanHppGenerator::constructRAIIHandleMembe std::string commandName = generateCommandName( commandIt->first, commandIt->second.params[initialSkipCount - 1].type.type, m_tags ); std::string enter, leave; - std::tie( enter, leave ) = generateProtection( commandIt->second.referencedIn ); + std::tie( enter, leave ) = generateProtection( commandIt->second.referencedIn, std::string() ); std::string returnType = stripPostfix( commandIt->second.params[nonConstPointerParamIndices[0]].type.compose(), "*" ); std::pair>> vectorSizeCheck = needsVectorSizeCheck( vectorParamIndices ); std::string noexceptString = vectorSizeCheck.first ? "VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS" : "VULKAN_HPP_NOEXCEPT"; @@ -7846,7 +7829,7 @@ std::string VulkanHppGenerator::constructRAIIHandleMemberFunctionDeclarations( std::string enter, leave; if ( extIt.second->first != m_types.find( handle.first )->second.referencedIn ) { - std::tie( enter, leave ) = generateProtection( extIt.second->first ); + std::tie( enter, leave ) = generateProtection( extIt.second->first, std::string() ); } functionDeclarations += "\n" + enter + " //=== " + extIt.second->first + " ===\n"; for ( auto const & command : firstLevelCommands ) @@ -9366,7 +9349,7 @@ void VulkanHppGenerator::appendThrowExceptions( std::string & str ) const if ( beginsWith( value.name, "VK_ERROR" ) ) { std::string enter, leave; - std::tie( enter, leave ) = generateProtection( value.extension ); + std::tie( enter, leave ) = generateProtection( value.extension, value.protect ); std::string valueName = generateEnumValueName( enumIt->first, value.name, false, m_tags ); str += enter + " case Result::" + valueName + ": throw " + stripPrefix( valueName, "eError" ) + "Error( message );\n" + leave; @@ -10664,7 +10647,7 @@ std::string VulkanHppGenerator::generateDispatchLoaderStatic() std::string referencedIn = commandIt->second.referencedIn; std::string enter, leave; - std::tie( enter, leave ) = generateProtection( referencedIn ); + std::tie( enter, leave ) = generateProtection( referencedIn, std::string() ); str += "\n" + enter + " //=== " + extIt.second->first + " ===\n"; for ( auto const & commandName : extIt.second->second.commands ) { @@ -10740,14 +10723,14 @@ std::string VulkanHppGenerator::generateBitmask( std::mapsecond.values ) { std::string enter, leave; - std::tie( enter, leave ) = generateProtection( value.extension ); + std::tie( enter, leave ) = generateProtection( value.extension, value.protect ); std::string valueName = generateEnumValueName( bitmaskBits->first, value.name, true, m_tags ); allFlags += ( ( previousEnter != enter ) ? ( "\n" + previousLeave + enter ) : "\n" ) + " " + ( encounteredFlag ? "| " : " " ) + bitmaskIt->second.type + "( " + strippedEnumName + "::" + valueName + " )"; encounteredFlag = true; previousEnter = enter; - previousLeave = leave; + previousLeave = leave; } if ( !previousLeave.empty() ) { @@ -10819,17 +10802,30 @@ std::string VulkanHppGenerator::generateBitmask( std::mapsecond.values ) { if ( evd.singleBit ) { std::string enter, leave; - std::tie( enter, leave ) = generateProtection( evd.extension ); + std::tie( enter, leave ) = generateProtection( evd.extension, evd.protect ); std::string valueName = generateEnumValueName( bitmaskBits->first, evd.name, true, m_tags ); - str += enter + " if ( value & " + strippedEnumName + "::" + valueName + " ) result += \"" + - valueName.substr( 1 ) + " | \";\n" + leave; + if ( previousEnter != enter ) + { + str += previousLeave + enter; + } + str += " if ( value & " + strippedEnumName + "::" + valueName + " ) result += \"" + valueName.substr( 1 ) + + " | \";\n"; + previousEnter = enter; + previousLeave = leave; } } + if ( !previousLeave.empty() ) + { + assert( endsWith( previousLeave, "\n" ) ); + previousLeave.resize( previousLeave.size() - strlen( "\n" ) ); + str += previousLeave + "\n"; + } str += " return \"{ \" + result.substr(0, result.size() - 3) + \" }\";\n"; } @@ -12001,23 +11997,32 @@ std::string VulkanHppGenerator::generateLenInitializer( return initializer; } -std::pair VulkanHppGenerator::generateProtection( std::string const & referencedIn ) const +std::pair VulkanHppGenerator::generateProtection( std::string const & referencedIn, + std::string const & protect ) const { - if ( !referencedIn.empty() && m_features.find( referencedIn ) == m_features.end() ) + if ( !referencedIn.empty() ) { - auto extensionIt = m_extensions.find( referencedIn ); - assert( extensionIt != m_extensions.end() ); - if ( !extensionIt->second.platform.empty() ) + assert( protect.empty() ); + if ( m_features.find( referencedIn ) == m_features.end() ) { - auto platformIt = m_platforms.find( extensionIt->second.platform ); - assert( platformIt != m_platforms.end() ); - std::string const & protect = platformIt->second.protect; - if ( !protect.empty() ) + auto extensionIt = m_extensions.find( referencedIn ); + assert( extensionIt != m_extensions.end() ); + if ( !extensionIt->second.platform.empty() ) { - return std::make_pair( "#if defined( " + protect + " )\n", "#endif /*" + protect + "*/\n" ); + auto platformIt = m_platforms.find( extensionIt->second.platform ); + assert( platformIt != m_platforms.end() ); + if ( !platformIt->second.protect.empty() ) + { + return std::make_pair( "#if defined( " + platformIt->second.protect + " )\n", + "#endif /*" + platformIt->second.protect + "*/\n" ); + } } } } + else if ( !protect.empty() ) + { + return std::make_pair( "#if defined( " + protect + " )\n", "#endif /*" + protect + "*/\n" ); + } return std::make_pair( "", "" ); } @@ -12032,7 +12037,7 @@ std::pair VulkanHppGenerator::generateProtection( std: { auto typeIt = m_types.find( type ); assert( typeIt != m_types.end() ); - return generateProtection( typeIt->second.referencedIn ); + return generateProtection( typeIt->second.referencedIn, std::string() ); } } diff --git a/VulkanHppGenerator.hpp b/VulkanHppGenerator.hpp index 20a4ea2..626347c 100644 --- a/VulkanHppGenerator.hpp +++ b/VulkanHppGenerator.hpp @@ -1065,7 +1065,7 @@ private: std::map::const_iterator, std::vector::const_iterator>>::const_iterator litit, bool mutualExclusiveLens ) const; - std::pair generateProtection( std::string const & referencedIn ) const; + std::pair generateProtection( std::string const & referencedIn, std::string const & protect ) const; std::pair generateProtection( std::string const & type, bool isAliased ) const; std::string generateSizeCheck( std::vector::const_iterator> const & arrayIts, std::string const & structName, diff --git a/vulkan/vulkan_enums.hpp b/vulkan/vulkan_enums.hpp index 5586bf9..f98b587 100644 --- a/vulkan/vulkan_enums.hpp +++ b/vulkan/vulkan_enums.hpp @@ -8014,8 +8014,6 @@ namespace VULKAN_HPP_NAMESPACE #if defined( VK_ENABLE_BETA_EXTENSIONS ) if ( value & FormatFeatureFlagBits::eVideoDecodeOutputKHR ) result += "VideoDecodeOutputKHR | "; -#endif /*VK_ENABLE_BETA_EXTENSIONS*/ -#if defined( VK_ENABLE_BETA_EXTENSIONS ) if ( value & FormatFeatureFlagBits::eVideoDecodeDpbKHR ) result += "VideoDecodeDpbKHR | "; #endif /*VK_ENABLE_BETA_EXTENSIONS*/ @@ -8028,8 +8026,6 @@ namespace VULKAN_HPP_NAMESPACE #if defined( VK_ENABLE_BETA_EXTENSIONS ) if ( value & FormatFeatureFlagBits::eVideoEncodeInputKHR ) result += "VideoEncodeInputKHR | "; -#endif /*VK_ENABLE_BETA_EXTENSIONS*/ -#if defined( VK_ENABLE_BETA_EXTENSIONS ) if ( value & FormatFeatureFlagBits::eVideoEncodeDpbKHR ) result += "VideoEncodeDpbKHR | "; #endif /*VK_ENABLE_BETA_EXTENSIONS*/ @@ -8191,12 +8187,8 @@ namespace VULKAN_HPP_NAMESPACE #if defined( VK_ENABLE_BETA_EXTENSIONS ) if ( value & ImageUsageFlagBits::eVideoDecodeDstKHR ) result += "VideoDecodeDstKHR | "; -#endif /*VK_ENABLE_BETA_EXTENSIONS*/ -#if defined( VK_ENABLE_BETA_EXTENSIONS ) if ( value & ImageUsageFlagBits::eVideoDecodeSrcKHR ) result += "VideoDecodeSrcKHR | "; -#endif /*VK_ENABLE_BETA_EXTENSIONS*/ -#if defined( VK_ENABLE_BETA_EXTENSIONS ) if ( value & ImageUsageFlagBits::eVideoDecodeDpbKHR ) result += "VideoDecodeDpbKHR | "; #endif /*VK_ENABLE_BETA_EXTENSIONS*/ @@ -8207,12 +8199,8 @@ namespace VULKAN_HPP_NAMESPACE #if defined( VK_ENABLE_BETA_EXTENSIONS ) if ( value & ImageUsageFlagBits::eVideoEncodeDstKHR ) result += "VideoEncodeDstKHR | "; -#endif /*VK_ENABLE_BETA_EXTENSIONS*/ -#if defined( VK_ENABLE_BETA_EXTENSIONS ) if ( value & ImageUsageFlagBits::eVideoEncodeSrcKHR ) result += "VideoEncodeSrcKHR | "; -#endif /*VK_ENABLE_BETA_EXTENSIONS*/ -#if defined( VK_ENABLE_BETA_EXTENSIONS ) if ( value & ImageUsageFlagBits::eVideoEncodeDpbKHR ) result += "VideoEncodeDpbKHR | "; #endif /*VK_ENABLE_BETA_EXTENSIONS*/ @@ -8395,8 +8383,6 @@ namespace VULKAN_HPP_NAMESPACE #if defined( VK_ENABLE_BETA_EXTENSIONS ) if ( value & QueueFlagBits::eVideoDecodeKHR ) result += "VideoDecodeKHR | "; -#endif /*VK_ENABLE_BETA_EXTENSIONS*/ -#if defined( VK_ENABLE_BETA_EXTENSIONS ) if ( value & QueueFlagBits::eVideoEncodeKHR ) result += "VideoEncodeKHR | "; #endif /*VK_ENABLE_BETA_EXTENSIONS*/ @@ -9176,8 +9162,6 @@ namespace VULKAN_HPP_NAMESPACE #if defined( VK_ENABLE_BETA_EXTENSIONS ) if ( value & BufferUsageFlagBits::eVideoDecodeSrcKHR ) result += "VideoDecodeSrcKHR | "; -#endif /*VK_ENABLE_BETA_EXTENSIONS*/ -#if defined( VK_ENABLE_BETA_EXTENSIONS ) if ( value & BufferUsageFlagBits::eVideoDecodeDstKHR ) result += "VideoDecodeDstKHR | "; #endif /*VK_ENABLE_BETA_EXTENSIONS*/ @@ -9196,8 +9180,6 @@ namespace VULKAN_HPP_NAMESPACE #if defined( VK_ENABLE_BETA_EXTENSIONS ) if ( value & BufferUsageFlagBits::eVideoEncodeDstKHR ) result += "VideoEncodeDstKHR | "; -#endif /*VK_ENABLE_BETA_EXTENSIONS*/ -#if defined( VK_ENABLE_BETA_EXTENSIONS ) if ( value & BufferUsageFlagBits::eVideoEncodeSrcKHR ) result += "VideoEncodeSrcKHR | "; #endif /*VK_ENABLE_BETA_EXTENSIONS*/ @@ -11810,12 +11792,8 @@ namespace VULKAN_HPP_NAMESPACE # if defined( VK_ENABLE_BETA_EXTENSIONS ) if ( value & VideoCodecOperationFlagBitsKHR::eEncodeH264EXT ) result += "EncodeH264EXT | "; -# endif /*VK_ENABLE_BETA_EXTENSIONS*/ -# if defined( VK_ENABLE_BETA_EXTENSIONS ) if ( value & VideoCodecOperationFlagBitsKHR::eDecodeH264EXT ) result += "DecodeH264EXT | "; -# endif /*VK_ENABLE_BETA_EXTENSIONS*/ -# if defined( VK_ENABLE_BETA_EXTENSIONS ) if ( value & VideoCodecOperationFlagBitsKHR::eDecodeH265EXT ) result += "DecodeH265EXT | "; # endif /*VK_ENABLE_BETA_EXTENSIONS*/ @@ -13830,8 +13808,6 @@ namespace VULKAN_HPP_NAMESPACE #if defined( VK_ENABLE_BETA_EXTENSIONS ) if ( value & PipelineStageFlagBits2KHR::eVideoDecode ) result += "VideoDecode | "; -#endif /*VK_ENABLE_BETA_EXTENSIONS*/ -#if defined( VK_ENABLE_BETA_EXTENSIONS ) if ( value & PipelineStageFlagBits2KHR::eVideoEncode ) result += "VideoEncode | "; #endif /*VK_ENABLE_BETA_EXTENSIONS*/ @@ -13967,16 +13943,10 @@ namespace VULKAN_HPP_NAMESPACE #if defined( VK_ENABLE_BETA_EXTENSIONS ) if ( value & AccessFlagBits2KHR::eVideoDecodeRead ) result += "VideoDecodeRead | "; -#endif /*VK_ENABLE_BETA_EXTENSIONS*/ -#if defined( VK_ENABLE_BETA_EXTENSIONS ) if ( value & AccessFlagBits2KHR::eVideoDecodeWrite ) result += "VideoDecodeWrite | "; -#endif /*VK_ENABLE_BETA_EXTENSIONS*/ -#if defined( VK_ENABLE_BETA_EXTENSIONS ) if ( value & AccessFlagBits2KHR::eVideoEncodeRead ) result += "VideoEncodeRead | "; -#endif /*VK_ENABLE_BETA_EXTENSIONS*/ -#if defined( VK_ENABLE_BETA_EXTENSIONS ) if ( value & AccessFlagBits2KHR::eVideoEncodeWrite ) result += "VideoEncodeWrite | "; #endif /*VK_ENABLE_BETA_EXTENSIONS*/