mirror of
https://github.com/KhronosGroup/Vulkan-Hpp.git
synced 2024-10-14 16:32:17 +00:00
Generalize command generation for a specific type of commands
Commands returning some value (not a VkResult), that get no non-const pointers, no input vectors, but zero or more const-pointers of any type are generalized into one function.
This commit is contained in:
parent
ab43775b5b
commit
4ebd8a8b2c
@ -5565,17 +5565,19 @@ std::string VulkanHppGenerator::generateCommandType( std::string const & name,
|
|||||||
assert( ( commandData.returnType != "VkResult" ) && ( commandData.returnType != "void" ) &&
|
assert( ( commandData.returnType != "VkResult" ) && ( commandData.returnType != "void" ) &&
|
||||||
commandData.successCodes.empty() && commandData.errorCodes.empty() );
|
commandData.successCodes.empty() && commandData.errorCodes.empty() );
|
||||||
|
|
||||||
std::set<size_t> skippedParams = determineSkippedParams( commandData.params, initialSkipCount, {}, {}, false );
|
std::set<size_t> skippedParams = determineSkippedParams( commandData.params, initialSkipCount, {}, {}, false );
|
||||||
std::string argumentList =
|
std::set<size_t> templatedParams = determineVoidPointerParams( commandData.params );
|
||||||
generateArgumentListEnhanced( commandData.params, skippedParams, {}, {}, definition, false, false, true );
|
std::string argumentList = generateArgumentListEnhanced(
|
||||||
std::string commandName = generateCommandName( name, commandData.params, initialSkipCount, m_tags );
|
commandData.params, skippedParams, {}, templatedParams, definition, false, false, true );
|
||||||
std::string nodiscard = generateNoDiscard( 1 < commandData.successCodes.size(), 1 < commandData.errorCodes.size() );
|
std::string argumentTemplates = generateArgumentTemplates( commandData.params, templatedParams, false );
|
||||||
std::string returnType = stripPrefix( commandData.returnType, "Vk" );
|
std::string commandName = generateCommandName( name, commandData.params, initialSkipCount, m_tags );
|
||||||
|
std::string nodiscard = generateNoDiscard( 1 < commandData.successCodes.size(), 1 < commandData.errorCodes.size() );
|
||||||
|
std::string returnType = stripPrefix( commandData.returnType, "Vk" );
|
||||||
|
|
||||||
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 VULKAN_HPP_NOEXCEPT
|
${nodiscard}VULKAN_HPP_INLINE ${returnType} ${className}${classSeparator}${commandName}( ${argumentList} ) const VULKAN_HPP_NOEXCEPT
|
||||||
{
|
{
|
||||||
VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION );
|
VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION );
|
||||||
@ -5585,7 +5587,8 @@ std::string VulkanHppGenerator::generateCommandType( std::string const & name,
|
|||||||
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() ? "" : "::" },
|
||||||
@ -5597,11 +5600,12 @@ std::string VulkanHppGenerator::generateCommandType( std::string const & 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 VULKAN_HPP_NOEXCEPT;)";
|
${nodiscard}${returnType} ${commandName}( ${argumentList} ) const VULKAN_HPP_NOEXCEPT;)";
|
||||||
|
|
||||||
return replaceWithMap( functionTemplate,
|
return replaceWithMap( functionTemplate,
|
||||||
{ { "argumentList", argumentList },
|
{ { "argumentList", argumentList },
|
||||||
|
{ "argumentTemplates", argumentTemplates },
|
||||||
{ "commandName", commandName },
|
{ "commandName", commandName },
|
||||||
{ "nodiscard", nodiscard },
|
{ "nodiscard", nodiscard },
|
||||||
{ "returnType", returnType } } );
|
{ "returnType", returnType } } );
|
||||||
@ -5619,22 +5623,16 @@ std::string VulkanHppGenerator::generateCommandValue( std::string const & name,
|
|||||||
std::map<size_t, size_t> vectorParams = determineVectorParams( commandData.params );
|
std::map<size_t, size_t> vectorParams = determineVectorParams( commandData.params );
|
||||||
if ( vectorParams.empty() )
|
if ( vectorParams.empty() )
|
||||||
{
|
{
|
||||||
std::vector<size_t> constPointerParams = determineConstPointerParams( commandData.params );
|
if ( determineConstPointerParams( commandData.params ).empty() )
|
||||||
switch ( constPointerParams.size() )
|
|
||||||
{
|
{
|
||||||
case 0:
|
return generateCommandSetStandard( generateCommandStandard( name, commandData, initialSkipCount, definition ) );
|
||||||
return generateCommandSetStandard(
|
}
|
||||||
generateCommandStandard( name, commandData, initialSkipCount, definition ) );
|
else
|
||||||
break;
|
{
|
||||||
case 1:
|
return generateCommandSetStandardEnhanced(
|
||||||
if ( commandData.params[constPointerParams[0]].type.type != "void" )
|
definition,
|
||||||
{
|
generateCommandStandard( name, commandData, initialSkipCount, definition ),
|
||||||
return generateCommandSetStandardEnhanced(
|
generateCommandType( name, commandData, initialSkipCount, definition ) );
|
||||||
definition,
|
|
||||||
generateCommandStandard( name, commandData, initialSkipCount, definition ),
|
|
||||||
generateCommandType( name, commandData, initialSkipCount, definition ) );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -9643,15 +9641,17 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandValue0Return0VectorType
|
|||||||
{
|
{
|
||||||
std::set<size_t> skippedParams =
|
std::set<size_t> skippedParams =
|
||||||
determineSkippedParams( commandIt->second.params, initialSkipCount, vectorParams, {}, false );
|
determineSkippedParams( commandIt->second.params, initialSkipCount, vectorParams, {}, false );
|
||||||
std::string argumentList =
|
std::set<size_t> templatedParams = determineVoidPointerParams( commandIt->second.params );
|
||||||
generateArgumentListEnhanced( commandIt->second.params, skippedParams, {}, {}, definition, false, false, false );
|
std::string argumentList =
|
||||||
|
generateArgumentListEnhanced( commandIt->second.params, skippedParams, {}, templatedParams, definition, false, false, false );
|
||||||
|
std::string argumentTemplates = generateArgumentTemplates( commandIt->second.params, templatedParams, true );
|
||||||
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 = generateNamespacedType( commandIt->second.returnType );
|
std::string returnType = generateNamespacedType( commandIt->second.returnType );
|
||||||
|
|
||||||
if ( definition )
|
if ( definition )
|
||||||
{
|
{
|
||||||
std::string const definitionTemplate =
|
std::string const definitionTemplate =
|
||||||
R"(
|
R"(${argumentTemplates}
|
||||||
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE ${returnType} ${className}::${commandName}( ${argumentList} ) const VULKAN_HPP_NOEXCEPT
|
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE ${returnType} ${className}::${commandName}( ${argumentList} ) const VULKAN_HPP_NOEXCEPT
|
||||||
{${functionPointerCheck}${vectorSizeCheck}
|
{${functionPointerCheck}${vectorSizeCheck}
|
||||||
return getDispatcher()->${vkCommand}( ${callArguments} );
|
return getDispatcher()->${vkCommand}( ${callArguments} );
|
||||||
@ -9659,7 +9659,7 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandValue0Return0VectorType
|
|||||||
)";
|
)";
|
||||||
|
|
||||||
std::string callArguments =
|
std::string callArguments =
|
||||||
generateCallArgumentsEnhanced( commandIt->second, initialSkipCount, false, {}, {}, true );
|
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
|
vectorSizeCheck.first
|
||||||
@ -9671,6 +9671,7 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandValue0Return0VectorType
|
|||||||
definitionTemplate,
|
definitionTemplate,
|
||||||
{ { "argumentList", argumentList },
|
{ { "argumentList", argumentList },
|
||||||
{ "callArguments", callArguments },
|
{ "callArguments", callArguments },
|
||||||
|
{ "argumentTemplates", argumentTemplates },
|
||||||
{ "className", stripPrefix( commandIt->second.params[initialSkipCount - 1].type.type, "Vk" ) },
|
{ "className", stripPrefix( commandIt->second.params[initialSkipCount - 1].type.type, "Vk" ) },
|
||||||
{ "commandName", commandName },
|
{ "commandName", commandName },
|
||||||
{ "functionPointerCheck", generateFunctionPointerCheck( commandIt->first, commandIt->second.referencedIn ) },
|
{ "functionPointerCheck", generateFunctionPointerCheck( commandIt->first, commandIt->second.referencedIn ) },
|
||||||
@ -9681,13 +9682,14 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandValue0Return0VectorType
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::string const declarationTemplate =
|
std::string const declarationTemplate =
|
||||||
R"(
|
R"(${argumentTemplates}
|
||||||
VULKAN_HPP_NODISCARD ${returnType} ${commandName}( ${argumentList} ) const VULKAN_HPP_NOEXCEPT;
|
VULKAN_HPP_NODISCARD ${returnType} ${commandName}( ${argumentList} ) const VULKAN_HPP_NOEXCEPT;
|
||||||
)";
|
)";
|
||||||
|
|
||||||
return replaceWithMap( declarationTemplate,
|
return replaceWithMap( declarationTemplate,
|
||||||
{
|
{
|
||||||
{ "argumentList", argumentList },
|
{ "argumentList", argumentList },
|
||||||
|
{ "argumentTemplates", argumentTemplates },
|
||||||
{ "commandName", commandName },
|
{ "commandName", commandName },
|
||||||
{ "returnType", returnType },
|
{ "returnType", returnType },
|
||||||
} );
|
} );
|
||||||
@ -13796,7 +13798,7 @@ void VulkanHppGenerator::readExtensionsExtensionRequireCommand( tinyxml2::XMLEle
|
|||||||
{
|
{
|
||||||
int line = element->GetLineNum();
|
int line = element->GetLineNum();
|
||||||
std::map<std::string, std::string> attributes = getAttributes( element );
|
std::map<std::string, std::string> attributes = getAttributes( element );
|
||||||
checkAttributes( line, attributes, { { "name", {} } }, {} );
|
checkAttributes( line, attributes, { { "name", {} } }, { { "comment", {} } } );
|
||||||
checkElements( line, getChildElements( element ), {} );
|
checkElements( line, getChildElements( element ), {} );
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
|
Loading…
Reference in New Issue
Block a user