mirror of
https://github.com/KhronosGroup/Vulkan-Hpp.git
synced 2024-10-14 16:32:17 +00:00
Fix enum array initializer using enum constant
This commit is contained in:
parent
2e66b9101a
commit
238093f1c6
@ -2505,7 +2505,8 @@ void VulkanHppGenerator::appendEnumInitializer( std::string &
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
assert( arraySizes.size() == 1 );
|
assert( arraySizes.size() == 1 );
|
||||||
int count = std::stoi( arraySizes[0] );
|
auto constIt = m_constants.find( arraySizes[0] );
|
||||||
|
int count = std::stoi( ( constIt == m_constants.end() ) ? arraySizes[0] : constIt->second );
|
||||||
assert( 1 < count );
|
assert( 1 < count );
|
||||||
str += "{ { " + value;
|
str += "{ { " + value;
|
||||||
for ( int i = 1; i < count; i++ )
|
for ( int i = 1; i < count; i++ )
|
||||||
@ -11713,6 +11714,7 @@ void VulkanHppGenerator::readEnumConstant( tinyxml2::XMLElement const * element
|
|||||||
checkAttributes( line, attributes, { { "name", {} } }, { { "alias", {} }, { "comment", {} }, { "value", {} } } );
|
checkAttributes( line, attributes, { { "name", {} } }, { { "alias", {} }, { "comment", {} }, { "value", {} } } );
|
||||||
checkElements( line, getChildElements( element ), {} );
|
checkElements( line, getChildElements( element ), {} );
|
||||||
|
|
||||||
|
std::string alias, name, value;
|
||||||
for ( auto const & attribute : attributes )
|
for ( auto const & attribute : attributes )
|
||||||
{
|
{
|
||||||
if ( attribute.first == "alias" )
|
if ( attribute.first == "alias" )
|
||||||
@ -11720,14 +11722,25 @@ void VulkanHppGenerator::readEnumConstant( tinyxml2::XMLElement const * element
|
|||||||
check( m_constants.find( attribute.second ) != m_constants.end(),
|
check( m_constants.find( attribute.second ) != m_constants.end(),
|
||||||
line,
|
line,
|
||||||
"unknown enum constant alias <" + attribute.second + ">" );
|
"unknown enum constant alias <" + attribute.second + ">" );
|
||||||
|
alias = attribute.second;
|
||||||
}
|
}
|
||||||
else if ( attribute.first == "name" )
|
else if ( attribute.first == "name" )
|
||||||
{
|
{
|
||||||
check( m_constants.insert( attribute.second ).second,
|
check( m_constants.find( attribute.second ) == m_constants.end(),
|
||||||
line,
|
line,
|
||||||
"already specified enum constant <" + attribute.second + ">" );
|
"already specified enum constant <" + attribute.second + ">" );
|
||||||
|
name = attribute.second;
|
||||||
|
}
|
||||||
|
else if ( attribute.first == "value" )
|
||||||
|
{
|
||||||
|
check( !attribute.second.empty(),
|
||||||
|
line,
|
||||||
|
"value of enum constant is empty");
|
||||||
|
value = attribute.second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
check( alias.empty() != value.empty(), line, "for enum <" + name + "> either alias or value need to be specified" );
|
||||||
|
m_constants[name] = alias.empty() ? value : m_constants[alias];
|
||||||
}
|
}
|
||||||
|
|
||||||
void VulkanHppGenerator::readEnums( tinyxml2::XMLElement const * element )
|
void VulkanHppGenerator::readEnums( tinyxml2::XMLElement const * element )
|
||||||
|
@ -1047,7 +1047,7 @@ private:
|
|||||||
std::map<std::string, BaseTypeData> m_baseTypes;
|
std::map<std::string, BaseTypeData> m_baseTypes;
|
||||||
std::map<std::string, BitmaskData> m_bitmasks;
|
std::map<std::string, BitmaskData> m_bitmasks;
|
||||||
std::map<std::string, CommandData> m_commands;
|
std::map<std::string, CommandData> m_commands;
|
||||||
std::set<std::string> m_constants;
|
std::map<std::string, std::string> m_constants;
|
||||||
std::set<std::string> m_defines;
|
std::set<std::string> m_defines;
|
||||||
std::map<std::string, EnumData> m_enums;
|
std::map<std::string, EnumData> m_enums;
|
||||||
std::set<std::string> m_extendedStructs; // structs which are referenced by the structextends tag
|
std::set<std::string> m_extendedStructs; // structs which are referenced by the structextends tag
|
||||||
|
Loading…
Reference in New Issue
Block a user