Merge pull request #671 from asuessenbach/returnParameterIndex

Simplify determination of returnParameterIndex
This commit is contained in:
Andreas Süßenbach 2020-07-13 17:18:37 +02:00 committed by GitHub
commit 39f03c4e99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 35 deletions

View File

@ -4749,39 +4749,31 @@ size_t VulkanHppGenerator::determineReturnParamIndex( CommandData const &
// for return types of type VkResult or void, we can determine a parameter to return
if ( ( commandData.returnType == "VkResult" ) || ( commandData.returnType == "void" ) )
{
for ( size_t i = 0; i < commandData.params.size(); i++ )
size_t index = commandData.params.size() - 1;
if ( ( commandData.params[index].type.postfix.find( '*' ) != std::string::npos ) &&
( ( commandData.params[index].type.type != "void" ) || twoStep ||
( commandData.params[index].type.postfix.find( "**" ) != std::string::npos ) ) &&
( commandData.params[index].type.prefix.find( "const" ) == std::string::npos ) )
{
if ( ( commandData.params[i].type.postfix.find( '*' ) != std::string::npos ) &&
( ( commandData.params[i].type.type != "void" ) || twoStep ||
( commandData.params[i].type.postfix.find( "**" ) != std::string::npos ) ) &&
( commandData.params[i].type.prefix.find( "const" ) == std::string::npos ) &&
std::find_if(
vectorParamIndices.begin(), vectorParamIndices.end(), [i]( std::pair<size_t, size_t> const & vpi ) {
return vpi.second == i;
} ) == vectorParamIndices.end() )
// it's a non-const pointer
// assert that it's not a vector-size parameter
assert( std::find_if(
vectorParamIndices.begin(), vectorParamIndices.end(), [index]( std::pair<size_t, size_t> const & vpi ) {
return vpi.second == index;
} ) == vectorParamIndices.end() );
std::map<size_t, size_t>::const_iterator vpit = vectorParamIndices.find( index );
if ( ( vpit == vectorParamIndices.end() ) || twoStep || ( vectorParamIndices.size() > 1 ) ||
( vpit->second == INVALID_INDEX ) )
{
// it's a non-const pointer and not a vector-size parameter
std::map<size_t, size_t>::const_iterator vpit = vectorParamIndices.find( i );
if ( ( vpit == vectorParamIndices.end() ) || twoStep || ( vectorParamIndices.size() > 1 ) ||
( vpit->second == INVALID_INDEX ) ||
( commandData.params[vpit->second].type.postfix.find( '*' ) != std::string::npos ) )
{
// it's not a vector parameter, or a two-step process, or there is at least one more vector parameter, or
// the size argument of this vector parameter is not an argument, or the size argument of this vector
// parameter is provided by a pointer
// -> look for another non-cost pointer argument
auto paramIt =
std::find_if( commandData.params.begin() + i + 1, commandData.params.end(), []( ParamData const & pd ) {
return ( pd.type.postfix.find( '*' ) != std::string::npos ) &&
( pd.type.postfix.find( "const" ) == std::string::npos );
} );
// if there is another such argument, we can't decide which one to return -> return INVALID_INDEX
// otherwise return the index of the selcted parameter
returnParamIndex = paramIt != commandData.params.end() ? INVALID_INDEX : i;
}
// it's not a vector parameter, or a two-step process, or there is at least one more vector parameter, or
// the size argument of this vector parameter is not an argument
// -> return the index of the selcted parameter
returnParamIndex = index;
}
}
}
return returnParamIndex;
}

View File

@ -25242,8 +25242,9 @@ namespace VULKAN_HPP_NAMESPACE
Dispatch const & d = VULKAN_HPP_DEFAULT_DISPATCHER ) const VULKAN_HPP_NOEXCEPT;
# ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
typename ResultValueType<Display>::type
acquireXlibDisplayEXT( VULKAN_HPP_NAMESPACE::DisplayKHR display,
typename ResultValueType<void>::type
acquireXlibDisplayEXT( Display & dpy,
VULKAN_HPP_NAMESPACE::DisplayKHR display,
Dispatch const & d = VULKAN_HPP_DEFAULT_DISPATCHER ) const;
# endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
#endif /*VK_USE_PLATFORM_XLIB_XRANDR_EXT*/
@ -98110,13 +98111,12 @@ namespace VULKAN_HPP_NAMESPACE
}
# ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
template <typename Dispatch>
VULKAN_HPP_INLINE typename ResultValueType<Display>::type
PhysicalDevice::acquireXlibDisplayEXT( VULKAN_HPP_NAMESPACE::DisplayKHR display, Dispatch const & d ) const
VULKAN_HPP_INLINE typename ResultValueType<void>::type PhysicalDevice::acquireXlibDisplayEXT(
Display & dpy, VULKAN_HPP_NAMESPACE::DisplayKHR display, Dispatch const & d ) const
{
Display dpy;
Result result =
Result result =
static_cast<Result>( d.vkAcquireXlibDisplayEXT( m_physicalDevice, &dpy, static_cast<VkDisplayKHR>( display ) ) );
return createResultValue( result, dpy, VULKAN_HPP_NAMESPACE_STRING "::PhysicalDevice::acquireXlibDisplayEXT" );
return createResultValue( result, VULKAN_HPP_NAMESPACE_STRING "::PhysicalDevice::acquireXlibDisplayEXT" );
}
# endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
#endif /*VK_USE_PLATFORM_XLIB_XRANDR_EXT*/