mirror of
https://github.com/KhronosGroup/Vulkan-Hpp.git
synced 2024-10-14 16:32:17 +00:00
Support arrays of enums in structures.
This commit is contained in:
parent
87cecae683
commit
434c0326f4
@ -1477,6 +1477,29 @@ 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
|
||||
{
|
||||
// enum arguments might need special initialization
|
||||
assert(type.prefix.empty() && !values.empty());
|
||||
std::string value = "VULKAN_HPP_NAMESPACE::" + stripPrefix(type.type, "Vk") + "::" + values.front().vkValue;
|
||||
if (arraySizes.empty())
|
||||
{
|
||||
str += value;
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(arraySizes.size() == 1);
|
||||
int count = std::stoi(arraySizes[0]);
|
||||
assert(1 < count);
|
||||
str += "{ " + value;
|
||||
for (int i = 1; i < count; i++)
|
||||
{
|
||||
str += ", " + value;
|
||||
}
|
||||
str += " }";
|
||||
}
|
||||
}
|
||||
|
||||
void VulkanHppGenerator::appendEnumToString(std::string & str, std::pair<std::string, EnumData> const& enumData) const
|
||||
{
|
||||
std::string enumName = stripPrefix(enumData.first, "Vk");
|
||||
@ -2915,9 +2938,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())
|
||||
{
|
||||
// enum arguments might need special initialization
|
||||
assert(memberData.type.prefix.empty() && memberData.arraySizes.empty() && !enumIt->second.values.empty());
|
||||
str += "VULKAN_HPP_NAMESPACE::" + stripPrefix(memberData.type.type, "Vk") + "::" + enumIt->second.values.front().vkValue;
|
||||
appendEnumInitializer(str, memberData.type, memberData.arraySizes, enumIt->second.values);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2993,16 +3014,15 @@ void VulkanHppGenerator::appendStructMembers(std::string & str, std::pair<std::s
|
||||
}
|
||||
else
|
||||
{
|
||||
str += constructCArraySizes(member.arraySizes) + " = ";
|
||||
auto enumIt = m_enums.find(member.type.type);
|
||||
if (enumIt != m_enums.end() && member.type.postfix.empty())
|
||||
{
|
||||
// enum arguments might need special initialization
|
||||
assert(member.type.prefix.empty() && member.arraySizes.empty() && !enumIt->second.values.empty());
|
||||
str += " = VULKAN_HPP_NAMESPACE::" + stripPrefix(member.type.type, "Vk") + "::" + enumIt->second.values.front().vkValue;
|
||||
appendEnumInitializer(str, member.type, member.arraySizes, enumIt->second.values);
|
||||
}
|
||||
else
|
||||
{
|
||||
str += constructCArraySizes(member.arraySizes) + " = {}";
|
||||
str += "{}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -227,6 +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 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;
|
||||
|
Loading…
Reference in New Issue
Block a user