Simplify determination of returnParameterIndex

Resolves #670.
This commit is contained in:
asuessenbach 2020-07-13 16:04:03 +02:00
parent cf505dda53
commit 178dbd1367
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 and not a vector-size parameter
std::map<size_t, size_t>::const_iterator vpit = vectorParamIndices.find( i );
// 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 ) ||
( commandData.params[vpit->second].type.postfix.find( '*' ) != std::string::npos ) )
( vpit->second == INVALID_INDEX ) )
{
// 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;
}
// 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 =
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*/