mirror of
https://github.com/KhronosGroup/Vulkan-Hpp.git
synced 2024-10-14 16:32:17 +00:00
Merge pull request #1214 from asuessenbach/cleanup
Combine two types of commands into one generation function.
This commit is contained in:
commit
96b367bad3
@ -3286,23 +3286,24 @@ std::string VulkanHppGenerator::generateCommandResult( std::string const &
|
|||||||
bool definition,
|
bool definition,
|
||||||
std::map<size_t, size_t> const & vectorParams ) const
|
std::map<size_t, size_t> const & vectorParams ) const
|
||||||
{
|
{
|
||||||
assert( commandData.returnType == "VkResult" );
|
|
||||||
|
|
||||||
std::set<size_t> skippedParams =
|
std::set<size_t> skippedParams =
|
||||||
determineSkippedParams( commandData.params, initialSkipCount, vectorParams, {}, false );
|
determineSkippedParams( commandData.params, initialSkipCount, vectorParams, {}, false );
|
||||||
std::string argumentList =
|
std::set<size_t> templatedParams = determineVoidPointerParams( commandData.params );
|
||||||
generateArgumentListEnhanced( commandData.params, skippedParams, {}, {}, 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 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 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 <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
|
||||||
{
|
{
|
||||||
VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION );
|
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} );
|
||||||
})";
|
})";
|
||||||
@ -3310,7 +3311,9 @@ std::string VulkanHppGenerator::generateCommandResult( std::string const &
|
|||||||
return replaceWithMap(
|
return replaceWithMap(
|
||||||
functionTemplate,
|
functionTemplate,
|
||||||
{ { "argumentList", argumentList },
|
{ { "argumentList", argumentList },
|
||||||
{ "callArguments", generateCallArgumentsEnhanced( commandData, initialSkipCount, false, {}, {}, false ) },
|
{ "argumentTemplates", argumentTemplates },
|
||||||
|
{ "callArguments",
|
||||||
|
generateCallArgumentsEnhanced( commandData, initialSkipCount, false, {}, templatedParams, false ) },
|
||||||
{ "className",
|
{ "className",
|
||||||
initialSkipCount ? stripPrefix( commandData.params[initialSkipCount - 1].type.type, "Vk" ) : "" },
|
initialSkipCount ? stripPrefix( commandData.params[initialSkipCount - 1].type.type, "Vk" ) : "" },
|
||||||
{ "classSeparator", commandData.handle.empty() ? "" : "::" },
|
{ "classSeparator", commandData.handle.empty() ? "" : "::" },
|
||||||
@ -3318,16 +3321,21 @@ std::string VulkanHppGenerator::generateCommandResult( std::string const &
|
|||||||
{ "nodiscard", nodiscard },
|
{ "nodiscard", nodiscard },
|
||||||
{ "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 <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;)";
|
||||||
|
|
||||||
return replaceWithMap( functionTemplate,
|
return replaceWithMap( functionTemplate,
|
||||||
{ { "argumentList", argumentList },
|
{ { "argumentList", argumentList },
|
||||||
|
{ "argumentTemplates", argumentTemplates },
|
||||||
{ "commandName", commandName },
|
{ "commandName", commandName },
|
||||||
{ "nodiscard", nodiscard },
|
{ "nodiscard", nodiscard },
|
||||||
{ "returnType", returnType } } );
|
{ "returnType", returnType } } );
|
||||||
@ -5096,81 +5104,18 @@ std::string VulkanHppGenerator::generateCommandResultWithErrors0Return( std::str
|
|||||||
{
|
{
|
||||||
return generateCommandSetStandardOrEnhanced(
|
return generateCommandSetStandardOrEnhanced(
|
||||||
generateCommandStandard( name, commandData, initialSkipCount, definition ),
|
generateCommandStandard( name, commandData, initialSkipCount, definition ),
|
||||||
generateCommandResultWithErrors0ReturnNVector( name, commandData, initialSkipCount, definition, vectorParams ) );
|
generateCommandResult( name, commandData, initialSkipCount, definition, vectorParams ) );
|
||||||
}
|
}
|
||||||
else if ( allVectorSizesSupported( commandData.params, vectorParams ) )
|
else if ( allVectorSizesSupported( commandData.params, vectorParams ) )
|
||||||
{
|
{
|
||||||
return generateCommandSetStandardEnhanced(
|
return generateCommandSetStandardEnhanced(
|
||||||
definition,
|
definition,
|
||||||
generateCommandStandard( name, commandData, initialSkipCount, definition ),
|
generateCommandStandard( name, commandData, initialSkipCount, definition ),
|
||||||
generateCommandResultWithErrors0ReturnNVector( name, commandData, initialSkipCount, definition, vectorParams ) );
|
generateCommandResult( name, commandData, initialSkipCount, definition, vectorParams ) );
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string VulkanHppGenerator::generateCommandResultWithErrors0ReturnNVector(
|
|
||||||
std::string const & name,
|
|
||||||
CommandData const & commandData,
|
|
||||||
size_t initialSkipCount,
|
|
||||||
bool definition,
|
|
||||||
std::map<size_t, size_t> const & vectorParams ) const
|
|
||||||
{
|
|
||||||
std::set<size_t> skippedParams =
|
|
||||||
determineSkippedParams( commandData.params, initialSkipCount, vectorParams, {}, false );
|
|
||||||
std::set<size_t> templatedParams = determineVoidPointerParams( commandData.params );
|
|
||||||
std::string argumentList = generateArgumentListEnhanced(
|
|
||||||
commandData.params, skippedParams, {}, templatedParams, definition, false, false, true );
|
|
||||||
std::string argumentTemplates = generateArgumentTemplates( commandData.params, templatedParams, false );
|
|
||||||
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 returnType = ( 1 < commandData.successCodes.size() ) ? "Result" : "typename ResultValueType<void>::type";
|
|
||||||
|
|
||||||
if ( definition )
|
|
||||||
{
|
|
||||||
std::string const functionTemplate =
|
|
||||||
R"( template <${argumentTemplates}typename Dispatch>
|
|
||||||
${nodiscard}VULKAN_HPP_INLINE ${returnType} ${className}${classSeparator}${commandName}( ${argumentList} ) const
|
|
||||||
{
|
|
||||||
VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION );${vectorSizeCheck}
|
|
||||||
Result result = static_cast<Result>( d.${vkCommand}( ${callArguments} ) );
|
|
||||||
return createResultValue( result, VULKAN_HPP_NAMESPACE_STRING "::${className}${classSeparator}${commandName}"${successCodeList} );
|
|
||||||
})";
|
|
||||||
|
|
||||||
return replaceWithMap(
|
|
||||||
functionTemplate,
|
|
||||||
{ { "argumentList", argumentList },
|
|
||||||
{ "argumentTemplates", argumentTemplates },
|
|
||||||
{ "callArguments",
|
|
||||||
generateCallArgumentsEnhanced( commandData, initialSkipCount, false, {}, templatedParams, false ) },
|
|
||||||
{ "className",
|
|
||||||
initialSkipCount ? stripPrefix( commandData.params[initialSkipCount - 1].type.type, "Vk" ) : "" },
|
|
||||||
{ "classSeparator", commandData.handle.empty() ? "" : "::" },
|
|
||||||
{ "commandName", commandName },
|
|
||||||
{ "nodiscard", nodiscard },
|
|
||||||
{ "returnType", returnType },
|
|
||||||
{ "successCodeList", generateSuccessCodeList( commandData.successCodes ) },
|
|
||||||
{ "vectorSizeCheck",
|
|
||||||
vectorSizeCheck.first
|
|
||||||
? generateVectorSizeCheck( name, commandData, initialSkipCount, vectorSizeCheck.second, skippedParams )
|
|
||||||
: "" },
|
|
||||||
{ "vkCommand", name } } );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::string const functionTemplate =
|
|
||||||
R"( template <${argumentTemplates}typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
|
|
||||||
${nodiscard}${returnType} ${commandName}( ${argumentList} ) const;)";
|
|
||||||
|
|
||||||
return replaceWithMap( functionTemplate,
|
|
||||||
{ { "argumentList", argumentList },
|
|
||||||
{ "argumentTemplates", argumentTemplates },
|
|
||||||
{ "commandName", commandName },
|
|
||||||
{ "nodiscard", nodiscard },
|
|
||||||
{ "returnType", returnType } } );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string VulkanHppGenerator::generateCommandSetStandard( std::string const & standard ) const
|
std::string VulkanHppGenerator::generateCommandSetStandard( std::string const & standard ) const
|
||||||
{
|
{
|
||||||
const std::string commandTemplate = R"(
|
const std::string commandTemplate = R"(
|
||||||
|
@ -683,11 +683,6 @@ private:
|
|||||||
CommandData const & commandData,
|
CommandData const & commandData,
|
||||||
size_t initialSkipCount,
|
size_t initialSkipCount,
|
||||||
bool definition ) const;
|
bool definition ) const;
|
||||||
std::string generateCommandResultWithErrors0ReturnNVector( std::string const & name,
|
|
||||||
CommandData const & commandData,
|
|
||||||
size_t initialSkipCount,
|
|
||||||
bool definition,
|
|
||||||
std::map<size_t, size_t> const & vectorParams ) const;
|
|
||||||
std::string generateCommandSetStandard( std::string const & standard ) const;
|
std::string generateCommandSetStandard( std::string const & standard ) const;
|
||||||
std::string generateCommandSetStandardEnhanced( bool definition,
|
std::string generateCommandSetStandardEnhanced( bool definition,
|
||||||
std::string const & standard,
|
std::string const & standard,
|
||||||
|
Loading…
Reference in New Issue
Block a user