diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index f6c4bf2..e7293da 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -1477,7 +1477,7 @@ void VulkanHppGenerator::appendEnums(std::string & str) const } } -void VulkanHppGenerator::appendEnumInitializer(std::string& str, TypeData const& type, std::vector const& arraySizes, std::vector const& values) const +void VulkanHppGenerator::appendEnumInitializer(std::string& str, TypeData const& type, std::vector const& arraySizes, std::vector const& values, bool argument) const { // enum arguments might need special initialization assert(type.prefix.empty() && !values.empty()); @@ -1491,12 +1491,13 @@ void VulkanHppGenerator::appendEnumInitializer(std::string& str, TypeData const& assert(arraySizes.size() == 1); int count = std::stoi(arraySizes[0]); assert(1 < count); - str += "{ { " + value; + str += argument ? "{ { " : "{ "; // for function arguments, we need two braces, for default initializers just one + str += value; for (int i = 1; i < count; i++) { str += ", " + value; } - str += " } }"; + str += argument ? " } }" : " }"; } } @@ -2938,7 +2939,7 @@ bool VulkanHppGenerator::appendStructConstructorArgument(std::string & str, bool auto enumIt = m_enums.find(memberData.type.type); if (enumIt != m_enums.end() && memberData.type.postfix.empty()) { - appendEnumInitializer(str, memberData.type, memberData.arraySizes, enumIt->second.values); + appendEnumInitializer(str, memberData.type, memberData.arraySizes, enumIt->second.values, true); } else { @@ -3018,7 +3019,7 @@ void VulkanHppGenerator::appendStructMembers(std::string & str, std::pairsecond.values); + appendEnumInitializer(str, member.type, member.arraySizes, enumIt->second.values, false); } else { diff --git a/VulkanHppGenerator.hpp b/VulkanHppGenerator.hpp index 4b99814..9702147 100644 --- a/VulkanHppGenerator.hpp +++ b/VulkanHppGenerator.hpp @@ -227,7 +227,7 @@ class VulkanHppGenerator void appendCall(std::string &str, std::pair const& commandData, size_t returnParamIndex, size_t templateParamIndex, std::map const& vectorParamIndices, bool twoStep, bool firstCall, bool singular) const; void appendCommand(std::string & str, std::string const& indentation, std::string const& name, std::pair const& commandData, bool definition) const; void appendEnum(std::string & str, std::pair const& enumData) const; - void appendEnumInitializer(std::string& str, TypeData const& type, std::vector const& arraySizes, std::vector const& values) const; + void appendEnumInitializer(std::string& str, TypeData const& type, std::vector const& arraySizes, std::vector const& values, bool argument) const; void appendEnumToString(std::string & str, std::pair const& enumData) const; void appendFunction(std::string & str, std::string const& indentation, std::string const& name, std::pair const& commandData, size_t returnParamIndex, size_t templateParamIndex, std::map const& vectorParamIndices, bool twoStep, std::string const& enhancedReturnType, bool definition, bool enhanced, bool singular, bool unique, bool isStructureChain, bool withAllocator) const; void appendFunctionBodyEnhanced(std::string & str, std::string const& indentation, std::string const& commandName, std::pair const& commandData, size_t returnParamIndex, size_t templateParamIndex, std::map const& vectorParamIndices, bool twoStep, std::string const& enhancedReturnType, bool singular, bool unique, bool isStructureChain, bool withAllocator) const;