From 76bf85b50edf85b9204f4fbd97f36760de755577 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20S=C3=BC=C3=9Fenbach?= Date: Wed, 11 Jul 2018 08:50:20 +0200 Subject: [PATCH] Slightly improved vector-size determination on functions returning a vector and detection if a singular version of a function should be generated. (#229) --- VulkanHppGenerator.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index a8a63de..30d72f2 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -3434,16 +3434,21 @@ std::string VulkanHppGenerator::writeFunctionBodyEnhancedLocalReturnVariable(std else { // the size of the vector is given by an other parameter - // that means (as this is not a two-step algorithm) it's size is determined by some other vector parameter! + // first check, if that size has become the size of some other vector parameter // -> look for it and get it's actual size for (auto const& vectorParam : commandData.vectorParams) { - if ((vectorParam.first != commandData.returnParam) && (vectorParam.second == it->second)) + if ((vectorParam.first != it->first) && (vectorParam.second == it->second)) { size = startLowerCase(strip(commandData.params[vectorParam.first].name, "p")) + ".size()"; break; } } + if (size.empty()) + { + // otherwise, just use that parameter + size = commandData.params[it->second].name; + } } assert(!size.empty()); os << "( " << size << " )"; @@ -4388,7 +4393,10 @@ void VulkanHppGenerator::writeTypeCommand(std::ostream & os, std::string const& // then a singular version, if a sized vector would be returned std::map::const_iterator returnVector = commandData.vectorParams.find(commandData.returnParam); - bool singular = (returnVector != commandData.vectorParams.end()) && (returnVector->second != ~0) && (commandData.params[returnVector->second].type.back() != '*'); + bool singular = (returnVector != commandData.vectorParams.end()) && + (returnVector->second != ~0) && + (commandData.params[returnVector->first].pureType != "void") && + (commandData.params[returnVector->second].type.back() != '*'); if (singular) { writeFunction(enhanced, indentation, commandData, definition, true, true, false, false);