From 178dbd13673f41928df2fea8ccc2ecd8f65c4b2e Mon Sep 17 00:00:00 2001 From: asuessenbach Date: Mon, 13 Jul 2020 16:04:03 +0200 Subject: [PATCH] Simplify determination of returnParameterIndex Resolves #670. --- VulkanHppGenerator.cpp | 48 ++++++++++++++++++------------------------ vulkan/vulkan.hpp | 14 ++++++------ 2 files changed, 27 insertions(+), 35 deletions(-) diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index 1fb8575..c83af51 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -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 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 const & vpi ) { + return vpi.second == index; + } ) == vectorParamIndices.end() ); + + std::map::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::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; } diff --git a/vulkan/vulkan.hpp b/vulkan/vulkan.hpp index ad8f2bc..981ef73 100644 --- a/vulkan/vulkan.hpp +++ b/vulkan/vulkan.hpp @@ -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 ResultValueType::type - acquireXlibDisplayEXT( VULKAN_HPP_NAMESPACE::DisplayKHR display, + typename ResultValueType::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 - VULKAN_HPP_INLINE typename ResultValueType::type - PhysicalDevice::acquireXlibDisplayEXT( VULKAN_HPP_NAMESPACE::DisplayKHR display, Dispatch const & d ) const + VULKAN_HPP_INLINE typename ResultValueType::type PhysicalDevice::acquireXlibDisplayEXT( + Display & dpy, VULKAN_HPP_NAMESPACE::DisplayKHR display, Dispatch const & d ) const { - Display dpy; - Result result = + Result result = static_cast( d.vkAcquireXlibDisplayEXT( m_physicalDevice, &dpy, static_cast( 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*/