From 8c6ac21d2702149abb1f90a51d1b2e736bb2a414 Mon Sep 17 00:00:00 2001 From: asuessenbach Date: Tue, 24 Mar 2020 09:43:50 +0100 Subject: [PATCH] Relax criterion on determining enhanced return type. --- VulkanHppGenerator.cpp | 19 +++++++------------ VulkanHppGenerator.hpp | 2 +- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index 5c22f52..d7084b8 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -996,7 +996,7 @@ void VulkanHppGenerator::appendCommand(std::string & str, std::string const& ind size_t returnParamIndex = determineReturnParamIndex(commandData.second, vectorParamIndices, twoStep); bool isStructureChain = (returnParamIndex != INVALID_INDEX) && determineStructureChaining(commandData.second.params[returnParamIndex].type.type, m_extendedStructs, m_structureAliases); - std::string enhancedReturnType = determineEnhancedReturnType(commandData.second, returnParamIndex, vectorParamIndices, twoStep, false); // get the enhanced return type without structureChain + std::string enhancedReturnType = determineEnhancedReturnType(commandData.second, returnParamIndex, vectorParamIndices, false); // get the enhanced return type without structureChain size_t templateParamIndex = determineTemplateParamIndex(commandData.second.params, vectorParamIndices); @@ -1015,7 +1015,7 @@ void VulkanHppGenerator::appendCommand(std::string & str, std::string const& ind if (isStructureChain) { - std::string enhancedReturnTypeWithStructureChain = determineEnhancedReturnType(commandData.second, returnParamIndex, vectorParamIndices, twoStep, true); + std::string enhancedReturnTypeWithStructureChain = determineEnhancedReturnType(commandData.second, returnParamIndex, vectorParamIndices, true); appendFunction(enhanced, indentation, name, commandData, returnParamIndex, templateParamIndex, vectorParamIndices, twoStep, enhancedReturnTypeWithStructureChain, definition, true, false, false, true, false); if (enhancedReturnTypeWithStructureChain.find("Allocator") != std::string::npos) @@ -3568,7 +3568,7 @@ bool VulkanHppGenerator::containsUnion(std::string const& type) const return found; } -std::string VulkanHppGenerator::determineEnhancedReturnType(CommandData const& commandData, size_t returnParamIndex, std::map const& vectorParamIndices, bool twoStep, bool isStructureChain) const +std::string VulkanHppGenerator::determineEnhancedReturnType(CommandData const& commandData, size_t returnParamIndex, std::map const& vectorParamIndices, bool isStructureChain) const { assert((returnParamIndex == INVALID_INDEX) || (returnParamIndex < commandData.params.size())); for (auto vpi : vectorParamIndices) @@ -3577,16 +3577,11 @@ std::string VulkanHppGenerator::determineEnhancedReturnType(CommandData const& c } std::string enhancedReturnType; - // if there is a return parameter of type void or Result, and if it's of type Result it either has just one success code - // or two success codes, where the second one is of type VK_INCOMPLETE and it's a two-step process - // -> we can return that parameter - if ((returnParamIndex != INVALID_INDEX) - && ((commandData.returnType == "void") - || ((commandData.returnType == "VkResult") - && ((commandData.successCodes.size() == 1) - || ((commandData.successCodes.size() == 2) && (commandData.successCodes[1] == "VK_INCOMPLETE") && twoStep) - || ((commandData.successCodes.size() == 3) && (commandData.successCodes[1] == "VK_OPERATION_DEFERRED_KHR") && (commandData.successCodes[2] == "VK_OPERATION_NOT_DEFERRED_KHR")))))) + if (returnParamIndex != INVALID_INDEX) { + // if there is a return parameter, we think returnType is always "void" or "VkResult" + // -> we can return that parameter + assert((commandData.returnType == "void") || (commandData.returnType == "VkResult")); assert(commandData.successCodes.empty() || (commandData.successCodes[0] == "VK_SUCCESS")); if (vectorParamIndices.find(returnParamIndex) != vectorParamIndices.end()) { diff --git a/VulkanHppGenerator.hpp b/VulkanHppGenerator.hpp index d335967..ac6e84e 100644 --- a/VulkanHppGenerator.hpp +++ b/VulkanHppGenerator.hpp @@ -288,7 +288,7 @@ class VulkanHppGenerator bool checkLenAttribute(std::string const& len, std::vector const& params); bool containsArray(std::string const& type) const; bool containsUnion(std::string const& type) const; - std::string determineEnhancedReturnType(CommandData const& commandData, size_t returnParamIndex, std::map const& vectorParamIndices, bool twoStep, bool isStructureChain) const; + std::string determineEnhancedReturnType(CommandData const& commandData, size_t returnParamIndex, std::map const& vectorParamIndices, bool isStructureChain) const; size_t determineReturnParamIndex(CommandData const& commandData, std::map const& vectorParamIndices, bool twoStep) const; std::string determineSubStruct(std::pair const& structure) const; size_t determineTemplateParamIndex(std::vector const& params, std::map const& vectorParamIndices) const;