Minor cleanup work in command generation.

This commit is contained in:
asuessenbach 2022-03-09 09:25:17 +01:00
parent 5f649a999b
commit 4fd8ad4baa
7 changed files with 649 additions and 620 deletions

View File

@ -3131,21 +3131,22 @@ std::string VulkanHppGenerator::generateCommandResult(
std::string argumentList = generateArgumentListEnhanced( commandData.params, skippedParams, {}, templatedParams, definition, false, false, true ); std::string argumentList = generateArgumentListEnhanced( commandData.params, skippedParams, {}, templatedParams, definition, false, false, true );
std::string argumentTemplates = generateArgumentTemplates( commandData.params, templatedParams, false ); std::string argumentTemplates = generateArgumentTemplates( commandData.params, templatedParams, false );
std::string commandName = generateCommandName( name, commandData.params, initialSkipCount, m_tags ); std::string commandName = generateCommandName( name, commandData.params, initialSkipCount, m_tags );
std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( vectorParams );
std::string nodiscard = generateNoDiscard( 1 < commandData.successCodes.size(), 1 < commandData.errorCodes.size() ); std::string nodiscard = generateNoDiscard( 1 < commandData.successCodes.size(), 1 < commandData.errorCodes.size() );
std::string noexceptString = commandData.errorCodes.empty() ? " VULKAN_HPP_NOEXCEPT" : "";
std::string returnType = ( 1 < commandData.successCodes.size() ) ? "Result" : "typename ResultValueType<void>::type"; std::string returnType = ( 1 < commandData.successCodes.size() ) ? "Result" : "typename ResultValueType<void>::type";
if ( definition ) if ( definition )
{ {
std::string const functionTemplate = std::string const functionTemplate =
R"( template <${argumentTemplates}typename Dispatch> R"( template <${argumentTemplates}typename Dispatch>
${nodiscard}VULKAN_HPP_INLINE ${returnType} ${className}${classSeparator}${commandName}( ${argumentList} ) const ${nodiscard}VULKAN_HPP_INLINE ${returnType} ${className}${classSeparator}${commandName}( ${argumentList} )${const}${noexcept}
{ {
VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION );${vectorSizeCheck} VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION );${vectorSizeCheck}
Result result = static_cast<Result>( d.${vkCommand}( ${callArguments} ) ); Result result = static_cast<Result>( d.${vkCommand}( ${callArguments} ) );
return createResultValue( result, VULKAN_HPP_NAMESPACE_STRING "::${className}${classSeparator}${commandName}"${successCodeList} ); return createResultValue( result, VULKAN_HPP_NAMESPACE_STRING "::${className}${classSeparator}${commandName}"${successCodeList} );
})"; })";
std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( vectorParams, {} );
return replaceWithMap( return replaceWithMap(
functionTemplate, functionTemplate,
{ { "argumentList", argumentList }, { { "argumentList", argumentList },
@ -3154,7 +3155,9 @@ std::string VulkanHppGenerator::generateCommandResult(
{ "className", initialSkipCount ? stripPrefix( commandData.params[initialSkipCount - 1].type.type, "Vk" ) : "" }, { "className", initialSkipCount ? stripPrefix( commandData.params[initialSkipCount - 1].type.type, "Vk" ) : "" },
{ "classSeparator", commandData.handle.empty() ? "" : "::" }, { "classSeparator", commandData.handle.empty() ? "" : "::" },
{ "commandName", commandName }, { "commandName", commandName },
{ "const", commandData.handle.empty() ? "" : " const" },
{ "nodiscard", nodiscard }, { "nodiscard", nodiscard },
{ "noexcept", noexceptString },
{ "returnType", returnType }, { "returnType", returnType },
{ "successCodeList", generateSuccessCodeList( commandData.successCodes ) }, { "successCodeList", generateSuccessCodeList( commandData.successCodes ) },
{ "vectorSizeCheck", { "vectorSizeCheck",
@ -3165,13 +3168,15 @@ std::string VulkanHppGenerator::generateCommandResult(
{ {
std::string const functionTemplate = std::string const functionTemplate =
R"( template <${argumentTemplates}typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE> R"( template <${argumentTemplates}typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
${nodiscard}${returnType} ${commandName}( ${argumentList} ) const;)"; ${nodiscard}${returnType} ${commandName}( ${argumentList} )${const}${noexcept};)";
return replaceWithMap( functionTemplate, return replaceWithMap( functionTemplate,
{ { "argumentList", argumentList }, { { "argumentList", argumentList },
{ "argumentTemplates", argumentTemplates }, { "argumentTemplates", argumentTemplates },
{ "commandName", commandName }, { "commandName", commandName },
{ "const", commandData.handle.empty() ? "" : " const" },
{ "nodiscard", nodiscard }, { "nodiscard", nodiscard },
{ "noexcept", noexceptString },
{ "returnType", returnType } } ); { "returnType", returnType } } );
} }
} }
@ -3680,6 +3685,7 @@ std::string VulkanHppGenerator::generateCommandResultGetValue( std::string const
commandName = stripPluralS( commandName ); commandName = stripPluralS( commandName );
} }
std::string nodiscard = generateNoDiscard( 1 < commandData.successCodes.size(), 1 < commandData.errorCodes.size() ); std::string nodiscard = generateNoDiscard( 1 < commandData.successCodes.size(), 1 < commandData.errorCodes.size() );
std::string noexceptString = commandData.errorCodes.empty() ? " VULKAN_HPP_NOEXCEPT" : "";
std::string argumentTemplates = generateArgumentTemplates( commandData.params, templatedParams, false ); std::string argumentTemplates = generateArgumentTemplates( commandData.params, templatedParams, false );
std::string dataType = ( templatedParams.find( returnParam ) != templatedParams.end() ) std::string dataType = ( templatedParams.find( returnParam ) != templatedParams.end() )
? ( stripPrefix( commandData.params[returnParam].name, "p" ) + "Type" ) ? ( stripPrefix( commandData.params[returnParam].name, "p" ) + "Type" )
@ -3690,9 +3696,9 @@ std::string VulkanHppGenerator::generateCommandResultGetValue( std::string const
{ {
std::string const functionTemplate = std::string const functionTemplate =
R"( template <${argumentTemplates}typename Dispatch> R"( template <${argumentTemplates}typename Dispatch>
${nodiscard}VULKAN_HPP_INLINE ${returnType} ${className}${classSeparator}${commandName}( ${argumentList} )${const} ${nodiscard}VULKAN_HPP_INLINE ${returnType} ${className}${classSeparator}${commandName}( ${argumentList} )${const}${noexcept}
{ {
VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION ); VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION );${vectorSizeCheck}
${dataType} ${dataVariable}; ${dataType} ${dataVariable};
Result result = static_cast<Result>( d.${vkCommand}( ${callArguments} ) ); Result result = static_cast<Result>( d.${vkCommand}( ${callArguments} ) );
return createResultValue( result, ${dataVariable}, VULKAN_HPP_NAMESPACE_STRING "::${className}${classSeparator}${commandName}"${successCodeList} ); return createResultValue( result, ${dataVariable}, VULKAN_HPP_NAMESPACE_STRING "::${className}${classSeparator}${commandName}"${successCodeList} );
@ -3703,8 +3709,10 @@ std::string VulkanHppGenerator::generateCommandResultGetValue( std::string const
{ {
dataVariable = stripPluralS( dataVariable ); dataVariable = stripPluralS( dataVariable );
} }
std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( vectorParams, singularParams );
return replaceWithMap( functionTemplate, return replaceWithMap(
functionTemplate,
{ { "argumentList", argumentList }, { { "argumentList", argumentList },
{ "argumentTemplates", argumentTemplates }, { "argumentTemplates", argumentTemplates },
{ "callArguments", generateCallArgumentsEnhanced( commandData, initialSkipCount, false, singularParams, templatedParams, false ) }, { "callArguments", generateCallArgumentsEnhanced( commandData, initialSkipCount, false, singularParams, templatedParams, false ) },
@ -3715,15 +3723,18 @@ std::string VulkanHppGenerator::generateCommandResultGetValue( std::string const
{ "dataType", dataType }, { "dataType", dataType },
{ "dataVariable", dataVariable }, { "dataVariable", dataVariable },
{ "nodiscard", nodiscard }, { "nodiscard", nodiscard },
{ "noexcept", noexceptString },
{ "returnType", returnType }, { "returnType", returnType },
{ "successCodeList", generateSuccessCodeList( commandData.successCodes ) }, { "successCodeList", generateSuccessCodeList( commandData.successCodes ) },
{ "vectorSizeCheck",
vectorSizeCheck.first ? generateVectorSizeCheck( name, commandData, initialSkipCount, vectorSizeCheck.second, skippedParams ) : "" },
{ "vkCommand", name } } ); { "vkCommand", name } } );
} }
else else
{ {
std::string const functionTemplate = std::string const functionTemplate =
R"( template <${argumentTemplates}typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE> R"( template <${argumentTemplates}typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
${nodiscard}${returnType} ${commandName}( ${argumentList} )${const};)"; ${nodiscard}${returnType} ${commandName}( ${argumentList} )${const}${noexcept};)";
return replaceWithMap( functionTemplate, return replaceWithMap( functionTemplate,
{ { "argumentList", argumentList }, { { "argumentList", argumentList },
@ -3731,6 +3742,7 @@ std::string VulkanHppGenerator::generateCommandResultGetValue( std::string const
{ "commandName", commandName }, { "commandName", commandName },
{ "const", commandData.handle.empty() ? "" : " const" }, { "const", commandData.handle.empty() ? "" : " const" },
{ "nodiscard", nodiscard }, { "nodiscard", nodiscard },
{ "noexcept", noexceptString },
{ "returnType", returnType } } ); { "returnType", returnType } } );
} }
} }
@ -4864,8 +4876,8 @@ std::string VulkanHppGenerator::generateCommandSingle(
std::string argumentTemplates = generateArgumentTemplates( commandData.params, templatedParams, false ); std::string argumentTemplates = generateArgumentTemplates( commandData.params, templatedParams, false );
std::string commandName = generateCommandName( name, commandData.params, initialSkipCount, m_tags ); std::string commandName = generateCommandName( name, commandData.params, initialSkipCount, m_tags );
std::string nodiscard = generateNoDiscard( 1 < commandData.successCodes.size(), 1 < commandData.errorCodes.size() ); std::string nodiscard = generateNoDiscard( 1 < commandData.successCodes.size(), 1 < commandData.errorCodes.size() );
std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( vectorParams ); std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( vectorParams, {} );
std::string noexceptString = vectorSizeCheck.first ? "VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS" : "VULKAN_HPP_NOEXCEPT"; std::string noexceptString = vectorSizeCheck.first ? " VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS" : " VULKAN_HPP_NOEXCEPT";
std::string returnType = ( commandData.returnType == "void" ) ? "void" : stripPrefix( commandData.returnType, "Vk" ); std::string returnType = ( commandData.returnType == "void" ) ? "void" : stripPrefix( commandData.returnType, "Vk" );
std::string returnCall = ( returnType == "void" ) ? "" : "return "; std::string returnCall = ( returnType == "void" ) ? "" : "return ";
@ -4873,7 +4885,7 @@ std::string VulkanHppGenerator::generateCommandSingle(
{ {
std::string const functionTemplate = std::string const functionTemplate =
R"( template <${argumentTemplates}typename Dispatch> R"( template <${argumentTemplates}typename Dispatch>
${nodiscard}VULKAN_HPP_INLINE ${returnType} ${className}${classSeparator}${commandName}( ${argumentList} ) const ${noexcept} ${nodiscard}VULKAN_HPP_INLINE ${returnType} ${className}${classSeparator}${commandName}( ${argumentList} )${const}${noexcept}
{ {
VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION );${vectorSizeCheck} VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION );${vectorSizeCheck}
${return}d.${vkCommand}( ${callArguments} ); ${return}d.${vkCommand}( ${callArguments} );
@ -4887,6 +4899,7 @@ std::string VulkanHppGenerator::generateCommandSingle(
{ "className", initialSkipCount ? stripPrefix( commandData.params[initialSkipCount - 1].type.type, "Vk" ) : "" }, { "className", initialSkipCount ? stripPrefix( commandData.params[initialSkipCount - 1].type.type, "Vk" ) : "" },
{ "classSeparator", commandData.handle.empty() ? "" : "::" }, { "classSeparator", commandData.handle.empty() ? "" : "::" },
{ "commandName", commandName }, { "commandName", commandName },
{ "const", commandData.handle.empty() ? "" : " const" },
{ "nodiscard", nodiscard }, { "nodiscard", nodiscard },
{ "noexcept", noexceptString }, { "noexcept", noexceptString },
{ "return", returnCall }, { "return", returnCall },
@ -4899,12 +4912,13 @@ std::string VulkanHppGenerator::generateCommandSingle(
{ {
std::string const functionTemplate = std::string const functionTemplate =
R"( template <${argumentTemplates}typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE> R"( template <${argumentTemplates}typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
${nodiscard}${returnType} ${commandName}( ${argumentList} ) const ${noexcept};)"; ${nodiscard}${returnType} ${commandName}( ${argumentList} )${const}${noexcept};)";
return replaceWithMap( functionTemplate, return replaceWithMap( functionTemplate,
{ { "argumentList", argumentList }, { { "argumentList", argumentList },
{ "argumentTemplates", argumentTemplates }, { "argumentTemplates", argumentTemplates },
{ "commandName", commandName }, { "commandName", commandName },
{ "const", commandData.handle.empty() ? "" : " const" },
{ "nodiscard", nodiscard }, { "nodiscard", nodiscard },
{ "noexcept", noexceptString }, { "noexcept", noexceptString },
{ "returnType", returnType } } ); { "returnType", returnType } } );
@ -5345,7 +5359,7 @@ std::string VulkanHppGenerator::generateCommandVoidGetValue( std::string const &
std::string returnType = stripPostfix( commandData.params[returnParam].type.compose( "VULKAN_HPP_NAMESPACE" ), "*" ); std::string returnType = stripPostfix( commandData.params[returnParam].type.compose( "VULKAN_HPP_NAMESPACE" ), "*" );
bool needsVectorSizeCheck = bool needsVectorSizeCheck =
!vectorParams.empty() && isLenByStructMember( commandData.params[vectorParams.begin()->first].len, commandData.params[vectorParams.begin()->second] ); !vectorParams.empty() && isLenByStructMember( commandData.params[vectorParams.begin()->first].len, commandData.params[vectorParams.begin()->second] );
std::string noexceptString = needsVectorSizeCheck ? "VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS" : "VULKAN_HPP_NOEXCEPT"; std::string noexceptString = needsVectorSizeCheck ? " VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS" : " VULKAN_HPP_NOEXCEPT";
if ( definition ) if ( definition )
{ {
@ -5379,7 +5393,7 @@ std::string VulkanHppGenerator::generateCommandVoidGetValue( std::string const &
std::string const functionTemplate = std::string const functionTemplate =
R"( template <${argumentTemplates}typename Dispatch> R"( template <${argumentTemplates}typename Dispatch>
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE ${returnType} ${className}${classSeparator}${commandName}( ${argumentList} ) const ${noexcept} ${nodiscard}VULKAN_HPP_INLINE ${returnType} ${className}${classSeparator}${commandName}( ${argumentList} )${const}${noexcept}
{ {
VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION );${vectorSizeCheck} VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION );${vectorSizeCheck}
${returnType} ${returnVariable}; ${returnType} ${returnVariable};
@ -5394,6 +5408,8 @@ std::string VulkanHppGenerator::generateCommandVoidGetValue( std::string const &
{ "className", className }, { "className", className },
{ "classSeparator", classSeparator }, { "classSeparator", classSeparator },
{ "commandName", commandName }, { "commandName", commandName },
{ "const", commandData.handle.empty() ? "" : " const" },
{ "nodiscard", "VULKAN_HPP_NODISCARD " },
{ "noexcept", noexceptString }, { "noexcept", noexceptString },
{ "returnType", returnType }, { "returnType", returnType },
{ "returnVariable", startLowerCase( stripPrefix( commandData.params[returnParam].name, "p" ) ) }, { "returnVariable", startLowerCase( stripPrefix( commandData.params[returnParam].name, "p" ) ) },
@ -5404,12 +5420,14 @@ std::string VulkanHppGenerator::generateCommandVoidGetValue( std::string const &
{ {
std::string const functionTemplate = std::string const functionTemplate =
R"( template <${argumentTemplates}typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE> R"( template <${argumentTemplates}typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
VULKAN_HPP_NODISCARD ${returnType} ${commandName}( ${argumentList} ) const ${noexcept};)"; ${nodiscard}${returnType} ${commandName}( ${argumentList} )${const}${noexcept};)";
return replaceWithMap( functionTemplate, return replaceWithMap( functionTemplate,
{ { "argumentList", argumentList }, { { "argumentList", argumentList },
{ "argumentTemplates", argumentTemplates }, { "argumentTemplates", argumentTemplates },
{ "commandName", commandName }, { "commandName", commandName },
{ "const", commandData.handle.empty() ? "" : " const" },
{ "nodiscard", "VULKAN_HPP_NODISCARD " },
{ "noexcept", noexceptString }, { "noexcept", noexceptString },
{ "returnType", returnType } } ); { "returnType", returnType } } );
} }
@ -6703,7 +6721,7 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandResultMultiSuccessNoErr
)"; )";
std::string callArguments = generateCallArgumentsEnhanced( commandIt->second, initialSkipCount, false, {}, {}, true ); std::string callArguments = generateCallArgumentsEnhanced( commandIt->second, initialSkipCount, false, {}, {}, true );
std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( vectorParams ); std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( vectorParams, {} );
std::string vectorSizeCheckString = std::string vectorSizeCheckString =
vectorSizeCheck.first ? generateRAIIHandleVectorSizeCheck( commandIt->first, commandIt->second, initialSkipCount, vectorSizeCheck.second, skippedParams ) vectorSizeCheck.first ? generateRAIIHandleVectorSizeCheck( commandIt->first, commandIt->second, initialSkipCount, vectorSizeCheck.second, skippedParams )
: ""; : "";
@ -6777,7 +6795,7 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandResultMultiSuccessWithE
)"; )";
std::string callArguments = generateCallArgumentsEnhanced( commandIt->second, initialSkipCount, false, {}, templatedParams, true ); std::string callArguments = generateCallArgumentsEnhanced( commandIt->second, initialSkipCount, false, {}, templatedParams, true );
std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( vectorParams ); std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( vectorParams, {} );
std::string vectorSizeCheckString = std::string vectorSizeCheckString =
vectorSizeCheck.first ? generateRAIIHandleVectorSizeCheck( commandIt->first, commandIt->second, initialSkipCount, vectorSizeCheck.second, skippedParams ) vectorSizeCheck.first ? generateRAIIHandleVectorSizeCheck( commandIt->first, commandIt->second, initialSkipCount, vectorSizeCheck.second, skippedParams )
: ""; : "";
@ -7433,7 +7451,7 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandResultSingleSuccessNoEr
)"; )";
std::string callArguments = generateCallArgumentsEnhanced( commandIt->second, initialSkipCount, false, {}, {}, true ); std::string callArguments = generateCallArgumentsEnhanced( commandIt->second, initialSkipCount, false, {}, {}, true );
std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( vectorParams ); std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( vectorParams, {} );
std::string vectorSizeCheckString = std::string vectorSizeCheckString =
vectorSizeCheck.first ? generateRAIIHandleVectorSizeCheck( commandIt->first, commandIt->second, initialSkipCount, vectorSizeCheck.second, skippedParams ) vectorSizeCheck.first ? generateRAIIHandleVectorSizeCheck( commandIt->first, commandIt->second, initialSkipCount, vectorSizeCheck.second, skippedParams )
: ""; : "";
@ -7506,7 +7524,7 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandResultSingleSuccessWith
)"; )";
std::string callArguments = generateCallArgumentsEnhanced( commandIt->second, initialSkipCount, false, {}, templatedParams, true ); std::string callArguments = generateCallArgumentsEnhanced( commandIt->second, initialSkipCount, false, {}, templatedParams, true );
std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( vectorParams ); std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( vectorParams, {} );
std::string vectorSizeCheckString = std::string vectorSizeCheckString =
vectorSizeCheck.first ? generateRAIIHandleVectorSizeCheck( commandIt->first, commandIt->second, initialSkipCount, vectorSizeCheck.second, skippedParams ) vectorSizeCheck.first ? generateRAIIHandleVectorSizeCheck( commandIt->first, commandIt->second, initialSkipCount, vectorSizeCheck.second, skippedParams )
: ""; : "";
@ -8227,7 +8245,7 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandValue0Return0VectorType
)"; )";
std::string callArguments = generateCallArgumentsEnhanced( commandIt->second, initialSkipCount, false, {}, templatedParams, true ); std::string callArguments = generateCallArgumentsEnhanced( commandIt->second, initialSkipCount, false, {}, templatedParams, true );
std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( vectorParams ); std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( vectorParams, {} );
std::string vectorSizeCheckString = std::string vectorSizeCheckString =
vectorSizeCheck.first ? generateVectorSizeCheck( commandIt->first, commandIt->second, initialSkipCount, vectorSizeCheck.second, skippedParams ) : ""; vectorSizeCheck.first ? generateVectorSizeCheck( commandIt->first, commandIt->second, initialSkipCount, vectorSizeCheck.second, skippedParams ) : "";
@ -8280,7 +8298,7 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandValue0Return0VectorVkTy
)"; )";
std::string callArguments = generateCallArgumentsEnhanced( commandIt->second, initialSkipCount, false, {}, {}, true ); std::string callArguments = generateCallArgumentsEnhanced( commandIt->second, initialSkipCount, false, {}, {}, true );
std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( vectorParams ); std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( vectorParams, {} );
std::string vectorSizeCheckString = std::string vectorSizeCheckString =
vectorSizeCheck.first ? generateRAIIHandleVectorSizeCheck( commandIt->first, commandIt->second, initialSkipCount, vectorSizeCheck.second, skippedParams ) vectorSizeCheck.first ? generateRAIIHandleVectorSizeCheck( commandIt->first, commandIt->second, initialSkipCount, vectorSizeCheck.second, skippedParams )
: ""; : "";
@ -8388,7 +8406,7 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandVoid0Return( std::map<s
std::set<size_t> templatedParams = determineVoidPointerParams( commandIt->second.params ); std::set<size_t> templatedParams = determineVoidPointerParams( commandIt->second.params );
std::string argumentList = generateArgumentListEnhanced( commandIt->second.params, skippedParams, {}, templatedParams, definition, false, false, false ); std::string argumentList = generateArgumentListEnhanced( commandIt->second.params, skippedParams, {}, templatedParams, definition, false, false, false );
std::string commandName = generateCommandName( commandIt->first, commandIt->second.params, initialSkipCount, m_tags ); std::string commandName = generateCommandName( commandIt->first, commandIt->second.params, initialSkipCount, m_tags );
std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( vectorParams ); std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( vectorParams, {} );
std::string noexceptString = vectorSizeCheck.first ? "VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS" : "VULKAN_HPP_NOEXCEPT"; std::string noexceptString = vectorSizeCheck.first ? "VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS" : "VULKAN_HPP_NOEXCEPT";
std::string argumentTemplates = generateArgumentTemplates( commandIt->second.params, templatedParams, true ); std::string argumentTemplates = generateArgumentTemplates( commandIt->second.params, templatedParams, true );
@ -8494,7 +8512,7 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandVoid1ReturnValue( std::
std::string argumentList = generateArgumentListEnhanced( commandIt->second.params, skippedParams, {}, {}, definition, false, false, false ); std::string argumentList = generateArgumentListEnhanced( commandIt->second.params, skippedParams, {}, {}, definition, false, false, false );
std::string commandName = generateCommandName( commandIt->first, commandIt->second.params, initialSkipCount, m_tags ); std::string commandName = generateCommandName( commandIt->first, commandIt->second.params, initialSkipCount, m_tags );
std::string returnType = stripPostfix( commandIt->second.params[returnParam].type.compose( "VULKAN_HPP_NAMESPACE" ), "*" ); std::string returnType = stripPostfix( commandIt->second.params[returnParam].type.compose( "VULKAN_HPP_NAMESPACE" ), "*" );
std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( vectorParams ); std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( vectorParams, {} );
std::string noexceptString = vectorSizeCheck.first ? "VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS" : "VULKAN_HPP_NOEXCEPT"; std::string noexceptString = vectorSizeCheck.first ? "VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS" : "VULKAN_HPP_NOEXCEPT";
if ( definition ) if ( definition )
@ -11419,12 +11437,13 @@ bool VulkanHppGenerator::isStructureChainAnchor( std::string const & type ) cons
return false; return false;
} }
std::pair<bool, std::map<size_t, std::vector<size_t>>> VulkanHppGenerator::needsVectorSizeCheck( std::map<size_t, size_t> const & vectorParams ) const std::pair<bool, std::map<size_t, std::vector<size_t>>> VulkanHppGenerator::needsVectorSizeCheck( std::map<size_t, size_t> const & vectorParams,
std::set<size_t> const & singularParams ) const
{ {
std::map<size_t, std::vector<size_t>> countToVectorMap; std::map<size_t, std::vector<size_t>> countToVectorMap;
for ( auto const & vpi : vectorParams ) for ( auto const & vpi : vectorParams )
{ {
if ( vpi.second != INVALID_INDEX ) if ( vpi.second != INVALID_INDEX && ( singularParams.find( vpi.second ) == singularParams.end() ) )
{ {
countToVectorMap[vpi.second].push_back( vpi.first ); countToVectorMap[vpi.second].push_back( vpi.first );
} }
@ -12813,7 +12832,8 @@ void VulkanHppGenerator::readSPIRVCapabilitiesSPIRVCapabilityEnableProperty( int
} }
if ( attribute.first == "requires" ) if ( attribute.first == "requires" )
{ {
std::vector<std::string> requires = tokenize( attribute.second, "," ); std::vector<std::string>
requires = tokenize( attribute.second, "," );
for ( auto const & r : requires ) for ( auto const & r : requires )
{ {
check( ( m_features.find( r ) != m_features.end() ) || ( m_extensions.find( r ) != m_extensions.end() ), check( ( m_features.find( r ) != m_features.end() ) || ( m_extensions.find( r ) != m_extensions.end() ),
@ -12861,7 +12881,8 @@ void VulkanHppGenerator::readSPIRVCapabilitiesSPIRVCapabilityEnableStruct( int x
{ {
if ( attribute.first == "requires" ) if ( attribute.first == "requires" )
{ {
std::vector<std::string> requires = tokenize( attribute.second, "," ); std::vector<std::string>
requires = tokenize( attribute.second, "," );
for ( auto const & r : requires ) for ( auto const & r : requires )
{ {
check( ( m_features.find( r ) != m_features.end() ) || ( m_extensions.find( r ) != m_extensions.end() ), check( ( m_features.find( r ) != m_features.end() ) || ( m_extensions.find( r ) != m_extensions.end() ),
@ -16492,6 +16513,12 @@ extern "C" __declspec( dllimport ) FARPROC __stdcall GetProcAddress( HINSTANCE h
return -1; return -1;
} }
#if defined( CLANG_FORMAT_EXECUTABLE )
std::cout << "VulkanHppGenerator: Formatting using ";
std::string commandString = "\"" CLANG_FORMAT_EXECUTABLE "\" --version ";
std::system( commandString.c_str() );
#endif
std::cout << "VulkanHppGenerator: Parsing " << filename << std::endl; std::cout << "VulkanHppGenerator: Parsing " << filename << std::endl;
VulkanHppGenerator generator( doc ); VulkanHppGenerator generator( doc );

View File

@ -970,7 +970,8 @@ private:
bool isParam( std::string const & name, std::vector<ParamData> const & params ) const; bool isParam( std::string const & name, std::vector<ParamData> const & params ) const;
bool isStructMember( std::string const & name, std::vector<MemberData> const & memberData ) const; bool isStructMember( std::string const & name, std::vector<MemberData> const & memberData ) const;
bool isStructureChainAnchor( std::string const & type ) const; bool isStructureChainAnchor( std::string const & type ) const;
std::pair<bool, std::map<size_t, std::vector<size_t>>> needsVectorSizeCheck( std::map<size_t, size_t> const & vectorParamIndices ) const; std::pair<bool, std::map<size_t, std::vector<size_t>>> needsVectorSizeCheck( std::map<size_t, size_t> const & vectorParamIndices,
std::set<size_t> const & singularParams ) const;
void readCommands( tinyxml2::XMLElement const * element ); void readCommands( tinyxml2::XMLElement const * element );
void readCommandsCommand( tinyxml2::XMLElement const * element ); void readCommandsCommand( tinyxml2::XMLElement const * element );
ParamData readCommandsCommandParam( tinyxml2::XMLElement const * element, std::vector<ParamData> const & params ); ParamData readCommandsCommandParam( tinyxml2::XMLElement const * element, std::vector<ParamData> const & params );

View File

@ -3304,7 +3304,7 @@ namespace VULKAN_HPP_NAMESPACE
template <typename Dispatch> template <typename Dispatch>
VULKAN_HPP_INLINE typename ResultValueType<void>::type Device::resetDescriptorPool( VULKAN_HPP_NAMESPACE::DescriptorPool descriptorPool, VULKAN_HPP_INLINE typename ResultValueType<void>::type Device::resetDescriptorPool( VULKAN_HPP_NAMESPACE::DescriptorPool descriptorPool,
VULKAN_HPP_NAMESPACE::DescriptorPoolResetFlags flags, VULKAN_HPP_NAMESPACE::DescriptorPoolResetFlags flags,
Dispatch const & d ) const Dispatch const & d ) const VULKAN_HPP_NOEXCEPT
{ {
VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION ); VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION );
Result result = static_cast<Result>( Result result = static_cast<Result>(
@ -3421,7 +3421,7 @@ namespace VULKAN_HPP_NAMESPACE
VULKAN_HPP_INLINE typename ResultValueType<void>::type VULKAN_HPP_INLINE typename ResultValueType<void>::type
Device::freeDescriptorSets( VULKAN_HPP_NAMESPACE::DescriptorPool descriptorPool, Device::freeDescriptorSets( VULKAN_HPP_NAMESPACE::DescriptorPool descriptorPool,
ArrayProxy<const VULKAN_HPP_NAMESPACE::DescriptorSet> const & descriptorSets, ArrayProxy<const VULKAN_HPP_NAMESPACE::DescriptorSet> const & descriptorSets,
Dispatch const & d ) const Dispatch const & d ) const VULKAN_HPP_NOEXCEPT
{ {
VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION ); VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION );
Result result = static_cast<Result>( d.vkFreeDescriptorSets( Result result = static_cast<Result>( d.vkFreeDescriptorSets(
@ -3445,7 +3445,7 @@ namespace VULKAN_HPP_NAMESPACE
template <typename Dispatch> template <typename Dispatch>
VULKAN_HPP_INLINE typename ResultValueType<void>::type( Device::free )( VULKAN_HPP_NAMESPACE::DescriptorPool descriptorPool, VULKAN_HPP_INLINE typename ResultValueType<void>::type( Device::free )( VULKAN_HPP_NAMESPACE::DescriptorPool descriptorPool,
ArrayProxy<const VULKAN_HPP_NAMESPACE::DescriptorSet> const & descriptorSets, ArrayProxy<const VULKAN_HPP_NAMESPACE::DescriptorSet> const & descriptorSets,
Dispatch const & d ) const Dispatch const & d ) const VULKAN_HPP_NOEXCEPT
{ {
VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION ); VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION );
Result result = static_cast<Result>( d.vkFreeDescriptorSets( Result result = static_cast<Result>( d.vkFreeDescriptorSets(
@ -10972,7 +10972,8 @@ namespace VULKAN_HPP_NAMESPACE
} }
#else #else
template <typename Dispatch> template <typename Dispatch>
VULKAN_HPP_INLINE typename ResultValueType<void>::type PhysicalDevice::releaseDisplayEXT( VULKAN_HPP_NAMESPACE::DisplayKHR display, Dispatch const & d ) const VULKAN_HPP_INLINE typename ResultValueType<void>::type PhysicalDevice::releaseDisplayEXT( VULKAN_HPP_NAMESPACE::DisplayKHR display,
Dispatch const & d ) const VULKAN_HPP_NOEXCEPT
{ {
VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION ); VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION );
Result result = static_cast<Result>( d.vkReleaseDisplayEXT( m_physicalDevice, static_cast<VkDisplayKHR>( display ) ) ); Result result = static_cast<Result>( d.vkReleaseDisplayEXT( m_physicalDevice, static_cast<VkDisplayKHR>( display ) ) );
@ -16060,7 +16061,7 @@ namespace VULKAN_HPP_NAMESPACE
#else #else
template <typename Dispatch> template <typename Dispatch>
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE Result Device::getDeferredOperationResultKHR( VULKAN_HPP_NAMESPACE::DeferredOperationKHR operation, VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE Result Device::getDeferredOperationResultKHR( VULKAN_HPP_NAMESPACE::DeferredOperationKHR operation,
Dispatch const & d ) const Dispatch const & d ) const VULKAN_HPP_NOEXCEPT
{ {
VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION ); VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION );
Result result = static_cast<Result>( d.vkGetDeferredOperationResultKHR( m_device, static_cast<VkDeferredOperationKHR>( operation ) ) ); Result result = static_cast<Result>( d.vkGetDeferredOperationResultKHR( m_device, static_cast<VkDeferredOperationKHR>( operation ) ) );

View File

@ -8443,7 +8443,7 @@ namespace VULKAN_HPP_NAMESPACE
template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE> template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
typename ResultValueType<void>::type resetDescriptorPool( VULKAN_HPP_NAMESPACE::DescriptorPool descriptorPool, typename ResultValueType<void>::type resetDescriptorPool( VULKAN_HPP_NAMESPACE::DescriptorPool descriptorPool,
VULKAN_HPP_NAMESPACE::DescriptorPoolResetFlags flags VULKAN_HPP_DEFAULT_ARGUMENT_ASSIGNMENT, VULKAN_HPP_NAMESPACE::DescriptorPoolResetFlags flags VULKAN_HPP_DEFAULT_ARGUMENT_ASSIGNMENT,
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const; Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT;
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE> template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
@ -8488,7 +8488,7 @@ namespace VULKAN_HPP_NAMESPACE
template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE> template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
typename ResultValueType<void>::type freeDescriptorSets( VULKAN_HPP_NAMESPACE::DescriptorPool descriptorPool, typename ResultValueType<void>::type freeDescriptorSets( VULKAN_HPP_NAMESPACE::DescriptorPool descriptorPool,
ArrayProxy<const VULKAN_HPP_NAMESPACE::DescriptorSet> const & descriptorSets, ArrayProxy<const VULKAN_HPP_NAMESPACE::DescriptorSet> const & descriptorSets,
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const; Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT;
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE> template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
@ -8500,7 +8500,7 @@ namespace VULKAN_HPP_NAMESPACE
template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE> template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
typename ResultValueType<void>::type( free )( VULKAN_HPP_NAMESPACE::DescriptorPool descriptorPool, typename ResultValueType<void>::type( free )( VULKAN_HPP_NAMESPACE::DescriptorPool descriptorPool,
ArrayProxy<const VULKAN_HPP_NAMESPACE::DescriptorSet> const & descriptorSets, ArrayProxy<const VULKAN_HPP_NAMESPACE::DescriptorSet> const & descriptorSets,
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const; Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT;
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE> template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
@ -10887,7 +10887,7 @@ namespace VULKAN_HPP_NAMESPACE
#else #else
template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE> template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
VULKAN_HPP_NODISCARD Result getDeferredOperationResultKHR( VULKAN_HPP_NAMESPACE::DeferredOperationKHR operation, VULKAN_HPP_NODISCARD Result getDeferredOperationResultKHR( VULKAN_HPP_NAMESPACE::DeferredOperationKHR operation,
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const; Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT;
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
#ifdef VULKAN_HPP_DISABLE_ENHANCED_MODE #ifdef VULKAN_HPP_DISABLE_ENHANCED_MODE
@ -12409,7 +12409,7 @@ namespace VULKAN_HPP_NAMESPACE
#else #else
template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE> template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
typename ResultValueType<void>::type releaseDisplayEXT( VULKAN_HPP_NAMESPACE::DisplayKHR display, typename ResultValueType<void>::type releaseDisplayEXT( VULKAN_HPP_NAMESPACE::DisplayKHR display,
Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const; Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT;
#endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
#if defined( VK_USE_PLATFORM_XLIB_XRANDR_EXT ) #if defined( VK_USE_PLATFORM_XLIB_XRANDR_EXT )