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 // for return types of type VkResult or void, we can determine a parameter to return
if ( ( commandData.returnType == "VkResult" ) || ( commandData.returnType == "void" ) ) 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 ) && // it's a non-const pointer
( ( commandData.params[i].type.type != "void" ) || twoStep || // assert that it's not a vector-size parameter
( commandData.params[i].type.postfix.find( "**" ) != std::string::npos ) ) && assert( std::find_if(
( commandData.params[i].type.prefix.find( "const" ) == std::string::npos ) && vectorParamIndices.begin(), vectorParamIndices.end(), [index]( std::pair<size_t, size_t> const & vpi ) {
std::find_if( return vpi.second == index;
vectorParamIndices.begin(), vectorParamIndices.end(), [i]( std::pair<size_t, size_t> const & vpi ) { } ) == vectorParamIndices.end() );
return vpi.second == i;
} ) == vectorParamIndices.end() ) std::map<size_t, size_t>::const_iterator vpit = vectorParamIndices.find( 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 ) || if ( ( vpit == vectorParamIndices.end() ) || twoStep || ( vectorParamIndices.size() > 1 ) ||
( vpit->second == INVALID_INDEX ) || ( 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 // 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 // the size argument of this vector parameter is not an argument
// parameter is provided by a pointer // -> return the index of the selcted parameter
// -> look for another non-cost pointer argument returnParamIndex = index;
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;
}
} }
} }
} }
return returnParamIndex; return returnParamIndex;
} }

View File

@ -25242,8 +25242,9 @@ namespace VULKAN_HPP_NAMESPACE
Dispatch const & d = VULKAN_HPP_DEFAULT_DISPATCHER ) const VULKAN_HPP_NOEXCEPT; Dispatch const & d = VULKAN_HPP_DEFAULT_DISPATCHER ) const VULKAN_HPP_NOEXCEPT;
# ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE # ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE> template <typename Dispatch = VULKAN_HPP_DEFAULT_DISPATCHER_TYPE>
typename ResultValueType<Display>::type typename ResultValueType<void>::type
acquireXlibDisplayEXT( VULKAN_HPP_NAMESPACE::DisplayKHR display, acquireXlibDisplayEXT( Display & dpy,
VULKAN_HPP_NAMESPACE::DisplayKHR display,
Dispatch const & d = VULKAN_HPP_DEFAULT_DISPATCHER ) const; Dispatch const & d = VULKAN_HPP_DEFAULT_DISPATCHER ) const;
# endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ # endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
#endif /*VK_USE_PLATFORM_XLIB_XRANDR_EXT*/ #endif /*VK_USE_PLATFORM_XLIB_XRANDR_EXT*/
@ -98110,13 +98111,12 @@ namespace VULKAN_HPP_NAMESPACE
} }
# ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE # ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE
template <typename Dispatch> template <typename Dispatch>
VULKAN_HPP_INLINE typename ResultValueType<Display>::type VULKAN_HPP_INLINE typename ResultValueType<void>::type PhysicalDevice::acquireXlibDisplayEXT(
PhysicalDevice::acquireXlibDisplayEXT( VULKAN_HPP_NAMESPACE::DisplayKHR display, Dispatch const & d ) const 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 ) ) ); 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 /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/
#endif /*VK_USE_PLATFORM_XLIB_XRANDR_EXT*/ #endif /*VK_USE_PLATFORM_XLIB_XRANDR_EXT*/