Merge pull request #539 from asuessenbach/enum

Yet another correction on braces for arrays of enums.
This commit is contained in:
Andreas Süßenbach 2020-03-10 14:36:18 +01:00 committed by GitHub
commit 2a8d8e3ca4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 6 deletions

View File

@ -1477,7 +1477,7 @@ void VulkanHppGenerator::appendEnums(std::string & str) const
}
}
void VulkanHppGenerator::appendEnumInitializer(std::string& str, TypeData const& type, std::vector<std::string> const& arraySizes, std::vector<EnumValueData> const& values) const
void VulkanHppGenerator::appendEnumInitializer(std::string& str, TypeData const& type, std::vector<std::string> const& arraySizes, std::vector<EnumValueData> 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::pair<std::s
auto enumIt = m_enums.find(member.type.type);
if (enumIt != m_enums.end() && member.type.postfix.empty())
{
appendEnumInitializer(str, member.type, member.arraySizes, enumIt->second.values);
appendEnumInitializer(str, member.type, member.arraySizes, enumIt->second.values, false);
}
else
{

View File

@ -227,7 +227,7 @@ class VulkanHppGenerator
void appendCall(std::string &str, std::pair<std::string, CommandData> const& commandData, size_t returnParamIndex, size_t templateParamIndex, std::map<size_t, size_t> const& vectorParamIndices, bool twoStep, bool firstCall, bool singular) const;
void appendCommand(std::string & str, std::string const& indentation, std::string const& name, std::pair<std::string, CommandData> const& commandData, bool definition) const;
void appendEnum(std::string & str, std::pair<std::string, EnumData> const& enumData) const;
void appendEnumInitializer(std::string& str, TypeData const& type, std::vector<std::string> const& arraySizes, std::vector<EnumValueData> const& values) const;
void appendEnumInitializer(std::string& str, TypeData const& type, std::vector<std::string> const& arraySizes, std::vector<EnumValueData> const& values, bool argument) const;
void appendEnumToString(std::string & str, std::pair<std::string, EnumData> const& enumData) const;
void appendFunction(std::string & str, std::string const& indentation, std::string const& name, std::pair<std::string, CommandData> const& commandData, size_t returnParamIndex, size_t templateParamIndex, std::map<size_t, size_t> 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<std::string, CommandData> const& commandData, size_t returnParamIndex, size_t templateParamIndex, std::map<size_t, size_t> const& vectorParamIndices, bool twoStep, std::string const& enhancedReturnType, bool singular, bool unique, bool isStructureChain, bool withAllocator) const;