mirror of
https://github.com/KhronosGroup/Vulkan-Hpp.git
synced 2025-09-09 20:09:49 -04:00
Combine two types of commands into one generation function
This commit is contained in:
parent
a914d02f89
commit
5c571c1b9a
@ -3436,7 +3436,7 @@ std::string VulkanHppGenerator::generateCommandEnhanced( std::string const &
|
|||||||
generateAllocatorTemplates( returnParams, dataTypes, vectorParams, definition, singular, unique, chained );
|
generateAllocatorTemplates( returnParams, dataTypes, vectorParams, definition, singular, unique, chained );
|
||||||
std::string typenameCheck = generateTypenameCheck( returnParams, vectorParams, definition, dataTypes, singular, withAllocator, unique, chained );
|
std::string typenameCheck = generateTypenameCheck( returnParams, vectorParams, definition, dataTypes, singular, withAllocator, unique, chained );
|
||||||
std::string nodiscard = generateNoDiscard( !returnParams.empty(), 1 < commandData.successCodes.size(), 1 < commandData.errorCodes.size() );
|
std::string nodiscard = generateNoDiscard( !returnParams.empty(), 1 < commandData.successCodes.size(), 1 < commandData.errorCodes.size() );
|
||||||
std::string returnType = generateReturnType( commandData, returnParams, unique, chained, dataType );
|
std::string returnType = generateReturnType( commandData, returnParams, unique, chained, false, dataType );
|
||||||
std::string className = initialSkipCount ? stripPrefix( commandData.params[initialSkipCount - 1].type.type, "Vk" ) : "";
|
std::string className = initialSkipCount ? stripPrefix( commandData.params[initialSkipCount - 1].type.type, "Vk" ) : "";
|
||||||
std::string classSeparator = commandData.handle.empty() ? "" : "::";
|
std::string classSeparator = commandData.handle.empty() ? "" : "::";
|
||||||
std::string commandName = generateCommandName( name, commandData.params, initialSkipCount, m_tags, singular, unique );
|
std::string commandName = generateCommandName( name, commandData.params, initialSkipCount, m_tags, singular, unique );
|
||||||
@ -3466,8 +3466,16 @@ std::string VulkanHppGenerator::generateCommandEnhanced( std::string const &
|
|||||||
std::string callSequence =
|
std::string callSequence =
|
||||||
generateCallSequence( name, commandData, returnParams, vectorParams, initialSkipCount, singularParams, templatedParams, chained, false );
|
generateCallSequence( name, commandData, returnParams, vectorParams, initialSkipCount, singularParams, templatedParams, chained, false );
|
||||||
std::string resultCheck = generateResultCheck( commandData, className, classSeparator, commandName, enumerating );
|
std::string resultCheck = generateResultCheck( commandData, className, classSeparator, commandName, enumerating );
|
||||||
std::string returnStatement = generateReturnStatement(
|
std::string returnStatement = generateReturnStatement( name,
|
||||||
name, commandData, returnVariable, returnType, dataType, initialSkipCount, returnParams.empty() ? INVALID_INDEX : returnParams[0], unique, enumerating );
|
commandData,
|
||||||
|
returnVariable,
|
||||||
|
returnType,
|
||||||
|
dataType,
|
||||||
|
initialSkipCount,
|
||||||
|
returnParams.empty() ? INVALID_INDEX : returnParams[0],
|
||||||
|
unique,
|
||||||
|
enumerating,
|
||||||
|
false );
|
||||||
|
|
||||||
std::string const functionTemplate =
|
std::string const functionTemplate =
|
||||||
R"( template <${argumentTemplates}${chainTemplates}${allocatorTemplates}typename Dispatch${uniqueHandleAllocatorTemplates}${typenameCheck}>
|
R"( template <${argumentTemplates}${chainTemplates}${allocatorTemplates}typename Dispatch${uniqueHandleAllocatorTemplates}${typenameCheck}>
|
||||||
@ -6126,10 +6134,11 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandEnhanced( std::map<std:
|
|||||||
std::string nodiscard =
|
std::string nodiscard =
|
||||||
generateNoDiscard( !returnParams.empty() || ( ( commandIt->second.returnType != "VkResult" ) && ( commandIt->second.returnType != "void" ) ),
|
generateNoDiscard( !returnParams.empty() || ( ( commandIt->second.returnType != "VkResult" ) && ( commandIt->second.returnType != "void" ) ),
|
||||||
1 < commandIt->second.successCodes.size(),
|
1 < commandIt->second.successCodes.size(),
|
||||||
1 < commandIt->second.errorCodes.size() );
|
false );
|
||||||
std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( commandIt->second.params, vectorParams, returnParams, {} );
|
std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck =
|
||||||
std::string noexceptString = vectorSizeCheck.first ? "" : "VULKAN_HPP_NOEXCEPT";
|
needsVectorSizeCheck( commandIt->second.params, vectorParams, returnParams, singularParams );
|
||||||
std::string returnType = generateReturnType( commandIt->second, returnParams, false, false, dataType );
|
std::string noexceptString = ( vectorSizeCheck.first || !commandIt->second.errorCodes.empty() ) ? "" : " VULKAN_HPP_NOEXCEPT";
|
||||||
|
std::string returnType = generateReturnType( commandIt->second, returnParams, false, false, true, dataType );
|
||||||
|
|
||||||
if ( definition )
|
if ( definition )
|
||||||
{
|
{
|
||||||
@ -6142,15 +6151,18 @@ ${functionPointerCheck}
|
|||||||
${vectorSizeCheck}
|
${vectorSizeCheck}
|
||||||
${dataDeclarations}
|
${dataDeclarations}
|
||||||
${callSequence}
|
${callSequence}
|
||||||
|
${resultCheck}
|
||||||
${returnStatement}
|
${returnStatement}
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
std::string callSequence =
|
std::string callSequence =
|
||||||
generateCallSequence( commandIt->first, commandIt->second, returnParams, vectorParams, initialSkipCount, singularParams, templatedParams, false, true );
|
generateCallSequence( commandIt->first, commandIt->second, returnParams, vectorParams, initialSkipCount, singularParams, templatedParams, false, true );
|
||||||
|
std::string className = stripPrefix( commandIt->second.params[initialSkipCount - 1].type.type, "Vk" );
|
||||||
std::string returnVariable = generateReturnVariable( commandIt->second, returnParams, vectorParams, false, false );
|
std::string returnVariable = generateReturnVariable( commandIt->second, returnParams, vectorParams, false, false );
|
||||||
std::string dataDeclarations = generateDataDeclarations(
|
std::string dataDeclarations = generateDataDeclarations(
|
||||||
commandIt->second, returnParams, vectorParams, templatedParams, false, false, false, false, dataTypes, dataType, returnType, returnVariable );
|
commandIt->second, returnParams, vectorParams, templatedParams, false, false, false, false, dataTypes, dataType, returnType, returnVariable );
|
||||||
|
std::string resultCheck = generateResultCheck( commandIt->second, className, "::", commandName, enumerating );
|
||||||
std::string returnStatement = generateReturnStatement( commandIt->first,
|
std::string returnStatement = generateReturnStatement( commandIt->first,
|
||||||
commandIt->second,
|
commandIt->second,
|
||||||
returnVariable,
|
returnVariable,
|
||||||
@ -6159,7 +6171,8 @@ ${vectorSizeCheck}
|
|||||||
initialSkipCount,
|
initialSkipCount,
|
||||||
returnParams.empty() ? INVALID_INDEX : returnParams[0],
|
returnParams.empty() ? INVALID_INDEX : returnParams[0],
|
||||||
false,
|
false,
|
||||||
enumerating );
|
enumerating,
|
||||||
|
true );
|
||||||
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 )
|
||||||
: "";
|
: "";
|
||||||
@ -6168,12 +6181,13 @@ ${vectorSizeCheck}
|
|||||||
{ { "argumentList", argumentList },
|
{ { "argumentList", argumentList },
|
||||||
{ "argumentTemplates", argumentTemplates },
|
{ "argumentTemplates", argumentTemplates },
|
||||||
{ "callSequence", callSequence },
|
{ "callSequence", callSequence },
|
||||||
{ "className", stripPrefix( commandIt->second.params[initialSkipCount - 1].type.type, "Vk" ) },
|
{ "className", className },
|
||||||
{ "commandName", commandName },
|
{ "commandName", commandName },
|
||||||
{ "dataDeclarations", dataDeclarations },
|
{ "dataDeclarations", dataDeclarations },
|
||||||
{ "functionPointerCheck", generateFunctionPointerCheck( commandIt->first, commandIt->second.referencedIn ) },
|
{ "functionPointerCheck", generateFunctionPointerCheck( commandIt->first, commandIt->second.referencedIn ) },
|
||||||
{ "nodiscard", nodiscard },
|
{ "nodiscard", nodiscard },
|
||||||
{ "noexcept", noexceptString },
|
{ "noexcept", noexceptString },
|
||||||
|
{ "resultCheck", resultCheck },
|
||||||
{ "returnStatement", returnStatement },
|
{ "returnStatement", returnStatement },
|
||||||
{ "returnType", returnType },
|
{ "returnType", returnType },
|
||||||
{ "vectorSizeCheck", vectorSizeCheckString } } );
|
{ "vectorSizeCheck", vectorSizeCheckString } } );
|
||||||
@ -7196,8 +7210,7 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandResultSingleSuccessWith
|
|||||||
switch ( returnParams.size() )
|
switch ( returnParams.size() )
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
return generateRAIIHandleCommandResultSingleSuccessWithErrors0Return(
|
return generateRAIIHandleCommandEnhanced( commandIt, initialSkipCount, returnParams, determineVectorParams( commandIt->second.params ), definition );
|
||||||
commandIt, initialSkipCount, determineVectorParams( commandIt->second.params ), definition );
|
|
||||||
break;
|
break;
|
||||||
case 1: return generateRAIIHandleCommandResultSingleSuccessWithErrors1Return( commandIt, initialSkipCount, definition, returnParams[0] ); break;
|
case 1: return generateRAIIHandleCommandResultSingleSuccessWithErrors1Return( commandIt, initialSkipCount, definition, returnParams[0] ); break;
|
||||||
case 2: return generateRAIIHandleCommandResultSingleSuccessWithErrors2Return( commandIt, initialSkipCount, definition, returnParams ); break;
|
case 2: return generateRAIIHandleCommandResultSingleSuccessWithErrors2Return( commandIt, initialSkipCount, definition, returnParams ); break;
|
||||||
@ -7205,69 +7218,6 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandResultSingleSuccessWith
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string VulkanHppGenerator::generateRAIIHandleCommandResultSingleSuccessWithErrors0Return( std::map<std::string, CommandData>::const_iterator commandIt,
|
|
||||||
size_t initialSkipCount,
|
|
||||||
std::map<size_t, size_t> const & vectorParams,
|
|
||||||
bool definition ) const
|
|
||||||
{
|
|
||||||
std::set<size_t> skippedParams = determineSkippedParams( commandIt->second.params, initialSkipCount, vectorParams, {}, false );
|
|
||||||
std::set<size_t> templatedParams = determineVoidPointerParams( commandIt->second.params );
|
|
||||||
assert( areDisjoint( skippedParams, templatedParams ) );
|
|
||||||
std::string argumentList =
|
|
||||||
generateArgumentListEnhanced( commandIt->second.params, {}, vectorParams, skippedParams, {}, templatedParams, definition, false, false, false );
|
|
||||||
std::string commandName = generateCommandName( commandIt->first, commandIt->second.params, initialSkipCount, m_tags, false, false );
|
|
||||||
std::string argumentTemplates = generateArgumentTemplates( commandIt->second.params, {}, vectorParams, templatedParams, true );
|
|
||||||
|
|
||||||
if ( definition )
|
|
||||||
{
|
|
||||||
std::string const definitionTemplate =
|
|
||||||
R"(
|
|
||||||
${argumentTemplates}
|
|
||||||
VULKAN_HPP_INLINE void ${className}::${commandName}( ${argumentList} ) const
|
|
||||||
{${functionPointerCheck}
|
|
||||||
${vectorSizeCheck}
|
|
||||||
VULKAN_HPP_NAMESPACE::Result result = static_cast<VULKAN_HPP_NAMESPACE::Result>( getDispatcher()->${vkCommand}( ${callArguments} ) );
|
|
||||||
if ( ${failureCheck} )
|
|
||||||
{
|
|
||||||
throwResultException( result, VULKAN_HPP_NAMESPACE_STRING"::${className}::${commandName}" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)";
|
|
||||||
|
|
||||||
std::string callArguments = generateCallArgumentsEnhanced( commandIt->second, initialSkipCount, false, {}, templatedParams, true );
|
|
||||||
std::pair<bool, std::map<size_t, std::vector<size_t>>> vectorSizeCheck = needsVectorSizeCheck( commandIt->second.params, vectorParams, {}, {} );
|
|
||||||
std::string vectorSizeCheckString =
|
|
||||||
vectorSizeCheck.first ? generateRAIIHandleVectorSizeCheck( commandIt->first, commandIt->second, initialSkipCount, vectorSizeCheck.second, skippedParams )
|
|
||||||
: "";
|
|
||||||
|
|
||||||
return replaceWithMap( definitionTemplate,
|
|
||||||
{ { "argumentList", argumentList },
|
|
||||||
{ "argumentTemplates", argumentTemplates },
|
|
||||||
{ "callArguments", callArguments },
|
|
||||||
{ "className", stripPrefix( commandIt->second.params[initialSkipCount - 1].type.type, "Vk" ) },
|
|
||||||
{ "commandName", commandName },
|
|
||||||
{ "failureCheck", generateFailureCheck( commandIt->second.successCodes ) },
|
|
||||||
{ "functionPointerCheck", generateFunctionPointerCheck( commandIt->first, commandIt->second.referencedIn ) },
|
|
||||||
{ "vectorSizeCheck", vectorSizeCheckString },
|
|
||||||
{ "vkCommand", commandIt->first } } );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::string const declarationTemplate =
|
|
||||||
R"(
|
|
||||||
${argumentTemplates}
|
|
||||||
void ${commandName}( ${argumentList} ) const;
|
|
||||||
)";
|
|
||||||
|
|
||||||
return replaceWithMap( declarationTemplate,
|
|
||||||
{
|
|
||||||
{ "argumentList", argumentList },
|
|
||||||
{ "argumentTemplates", argumentTemplates },
|
|
||||||
{ "commandName", commandName },
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
VulkanHppGenerator::generateRAIIHandleCommandResultSingleSuccessWithErrors1ReturnChain( std::map<std::string, CommandData>::const_iterator commandIt,
|
VulkanHppGenerator::generateRAIIHandleCommandResultSingleSuccessWithErrors1ReturnChain( std::map<std::string, CommandData>::const_iterator commandIt,
|
||||||
size_t initialSkipCount,
|
size_t initialSkipCount,
|
||||||
@ -9661,7 +9611,8 @@ std::string VulkanHppGenerator::generateReturnStatement( std::string const & com
|
|||||||
size_t initialSkipCount,
|
size_t initialSkipCount,
|
||||||
size_t returnParam,
|
size_t returnParam,
|
||||||
bool unique,
|
bool unique,
|
||||||
bool enumerating ) const
|
bool enumerating,
|
||||||
|
bool raii ) const
|
||||||
{
|
{
|
||||||
std::string returnStatement;
|
std::string returnStatement;
|
||||||
if ( beginsWith( commandData.returnType, "Vk" ) )
|
if ( beginsWith( commandData.returnType, "Vk" ) )
|
||||||
@ -9669,7 +9620,7 @@ std::string VulkanHppGenerator::generateReturnStatement( std::string const & com
|
|||||||
if ( ( commandData.successCodes.size() == 1 ) || enumerating )
|
if ( ( commandData.successCodes.size() == 1 ) || enumerating )
|
||||||
{
|
{
|
||||||
assert( commandData.successCodes[0] == "VK_SUCCESS" );
|
assert( commandData.successCodes[0] == "VK_SUCCESS" );
|
||||||
if ( !commandData.errorCodes.empty() )
|
if ( !commandData.errorCodes.empty() && !raii )
|
||||||
{
|
{
|
||||||
if ( returnVariable.empty() )
|
if ( returnVariable.empty() )
|
||||||
{
|
{
|
||||||
@ -9746,7 +9697,7 @@ std::string VulkanHppGenerator::generateReturnStatement( std::string const & com
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string VulkanHppGenerator::generateReturnType(
|
std::string VulkanHppGenerator::generateReturnType(
|
||||||
CommandData const & commandData, std::vector<size_t> const & returnParams, bool unique, bool chained, std::string const & dataType ) const
|
CommandData const & commandData, std::vector<size_t> const & returnParams, bool unique, bool chained, bool raii, std::string const & dataType ) const
|
||||||
{
|
{
|
||||||
std::string modifiedDataType = dataType;
|
std::string modifiedDataType = dataType;
|
||||||
if ( chained )
|
if ( chained )
|
||||||
@ -9793,7 +9744,7 @@ std::string VulkanHppGenerator::generateReturnType(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( ( commandData.returnType == "void" ) ||
|
else if ( ( commandData.returnType == "void" ) ||
|
||||||
( ( commandData.returnType == "VkResult" ) && ( commandData.successCodes.size() == 1 ) && commandData.errorCodes.empty() ) )
|
( ( commandData.returnType == "VkResult" ) && ( commandData.successCodes.size() == 1 ) && ( commandData.errorCodes.empty() || raii ) ) )
|
||||||
{
|
{
|
||||||
assert( !unique );
|
assert( !unique );
|
||||||
assert( ( commandData.returnType != "void" ) || ( returnParams.size() <= 2 ) );
|
assert( ( commandData.returnType != "void" ) || ( returnParams.size() <= 2 ) );
|
||||||
|
@ -762,10 +762,6 @@ private:
|
|||||||
std::string generateRAIIHandleCommandResultSingleSuccessWithErrors( std::map<std::string, CommandData>::const_iterator commandIt,
|
std::string generateRAIIHandleCommandResultSingleSuccessWithErrors( std::map<std::string, CommandData>::const_iterator commandIt,
|
||||||
size_t initialSkipCount,
|
size_t initialSkipCount,
|
||||||
bool definition ) const;
|
bool definition ) const;
|
||||||
std::string generateRAIIHandleCommandResultSingleSuccessWithErrors0Return( std::map<std::string, CommandData>::const_iterator commandIt,
|
|
||||||
size_t initialSkipCount,
|
|
||||||
std::map<size_t, size_t> const & vectorParamIndices,
|
|
||||||
bool definition ) const;
|
|
||||||
std::string generateRAIIHandleCommandResultSingleSuccessWithErrors1ReturnChain( std::map<std::string, CommandData>::const_iterator commandIt,
|
std::string generateRAIIHandleCommandResultSingleSuccessWithErrors1ReturnChain( std::map<std::string, CommandData>::const_iterator commandIt,
|
||||||
size_t initialSkipCount,
|
size_t initialSkipCount,
|
||||||
std::map<size_t, size_t> const & vectorParamIndices,
|
std::map<size_t, size_t> const & vectorParamIndices,
|
||||||
@ -924,9 +920,10 @@ private:
|
|||||||
size_t initialSkipCount,
|
size_t initialSkipCount,
|
||||||
size_t returnParam,
|
size_t returnParam,
|
||||||
bool unique,
|
bool unique,
|
||||||
bool enumerating ) const;
|
bool enumerating,
|
||||||
|
bool raii ) const;
|
||||||
std::string generateReturnType(
|
std::string generateReturnType(
|
||||||
CommandData const & commandData, std::vector<size_t> const & returnParams, bool unique, bool chained, std::string const & dataType ) const;
|
CommandData const & commandData, std::vector<size_t> const & returnParams, bool unique, bool chained, bool raii, std::string const & dataType ) const;
|
||||||
std::string generateReturnVariable( CommandData const & commandData,
|
std::string generateReturnVariable( CommandData const & commandData,
|
||||||
std::vector<size_t> const & returnParams,
|
std::vector<size_t> const & returnParams,
|
||||||
std::map<size_t, size_t> const & vectorParams,
|
std::map<size_t, size_t> const & vectorParams,
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user