mirror of
https://github.com/KhronosGroup/Vulkan-Hpp
synced 2024-11-24 04:50:13 +00:00
Merge pull request #1006 from asuessenbach/protect
Add support of attribute "protect" for enum values.
This commit is contained in:
commit
4dcc1f06b4
@ -1023,7 +1023,16 @@ void VulkanHppGenerator::appendEnum( std::string & str, std::pair<std::string, E
|
||||
for ( auto const & value : enumData.second.values )
|
||||
{
|
||||
std::string enter, leave;
|
||||
std::tie( enter, leave ) = generateProtection( value.extension );
|
||||
if ( !value.extension.empty() )
|
||||
{
|
||||
assert( value.protect.empty() );
|
||||
std::tie( enter, leave ) = generateProtection( value.extension );
|
||||
}
|
||||
else if ( !value.protect.empty() )
|
||||
{
|
||||
enter = "#if defined( " + value.protect + " )\n";
|
||||
leave = "#endif /*" + value.protect + "*/\n";
|
||||
}
|
||||
if ( previousEnter != enter )
|
||||
{
|
||||
enumList += previousLeave + enter;
|
||||
@ -9580,16 +9589,14 @@ void VulkanHppGenerator::EnumData::addEnumAlias( int line, std::string const & n
|
||||
aliases.insert( std::make_pair( name, EnumAliasData( aliasName, line ) ) );
|
||||
}
|
||||
|
||||
void VulkanHppGenerator::EnumData::addEnumValue( int line,
|
||||
std::string const & valueName,
|
||||
bool bitpos,
|
||||
std::string const & extension )
|
||||
void VulkanHppGenerator::EnumData::addEnumValue(
|
||||
int line, std::string const & valueName, std::string const & protect, bool bitpos, std::string const & extension )
|
||||
{
|
||||
auto valueIt = std::find_if(
|
||||
values.begin(), values.end(), [&valueName]( EnumValueData const & evd ) { return evd.name == valueName; } );
|
||||
if ( valueIt == values.end() )
|
||||
{
|
||||
values.emplace_back( line, valueName, extension, bitpos );
|
||||
values.emplace_back( line, valueName, protect, extension, bitpos );
|
||||
}
|
||||
}
|
||||
|
||||
@ -12718,10 +12725,14 @@ void VulkanHppGenerator::readEnum( tinyxml2::XMLElement const * el
|
||||
std::map<std::string, EnumData>::iterator enumIt )
|
||||
{
|
||||
int line = element->GetLineNum();
|
||||
checkAttributes( line, attributes, { { "name", {} } }, { { "bitpos", {} }, { "comment", {} }, { "value", {} } } );
|
||||
checkAttributes(
|
||||
line,
|
||||
attributes,
|
||||
{ { "name", {} } },
|
||||
{ { "bitpos", {} }, { "comment", {} }, { "protect", { "VK_ENABLE_BETA_EXTENSIONS" } }, { "value", {} } } );
|
||||
checkElements( line, getChildElements( element ), {} );
|
||||
|
||||
std::string alias, bitpos, name, value;
|
||||
std::string alias, bitpos, name, protect, value;
|
||||
for ( auto const & attribute : attributes )
|
||||
{
|
||||
if ( attribute.first == "bitpos" )
|
||||
@ -12732,6 +12743,10 @@ void VulkanHppGenerator::readEnum( tinyxml2::XMLElement const * el
|
||||
{
|
||||
name = attribute.second;
|
||||
}
|
||||
else if ( attribute.first == "protect" )
|
||||
{
|
||||
protect = attribute.second;
|
||||
}
|
||||
else if ( attribute.first == "value" )
|
||||
{
|
||||
value = attribute.second;
|
||||
@ -12744,7 +12759,7 @@ void VulkanHppGenerator::readEnum( tinyxml2::XMLElement const * el
|
||||
"encountered enum value <" + name + "> that does not begin with expected prefix <" + prefix + ">" );
|
||||
|
||||
check( bitpos.empty() ^ value.empty(), line, "invalid set of attributes for enum <" + name + ">" );
|
||||
enumIt->second.addEnumValue( line, name, !bitpos.empty(), "" );
|
||||
enumIt->second.addEnumValue( line, name, protect, !bitpos.empty(), "" );
|
||||
}
|
||||
|
||||
void VulkanHppGenerator::readEnumAlias( tinyxml2::XMLElement const * element,
|
||||
@ -13688,7 +13703,7 @@ void VulkanHppGenerator::readRequireEnum( tinyxml2::XMLElement const *
|
||||
line,
|
||||
"exactly one out of bitpos = <" + bitpos + ">, offset = <" + offset + ">, and value = <" + value +
|
||||
"> are supposed to be empty" );
|
||||
enumIt->second.addEnumValue( element->GetLineNum(), name, !bitpos.empty(), extension );
|
||||
enumIt->second.addEnumValue( element->GetLineNum(), name, "", !bitpos.empty(), extension );
|
||||
}
|
||||
else if ( value.empty() )
|
||||
{
|
||||
|
@ -138,12 +138,17 @@ private:
|
||||
|
||||
struct EnumValueData
|
||||
{
|
||||
EnumValueData( int line, std::string const & name_, std::string const & extension_, bool singleBit_ )
|
||||
: name( name_ ), extension( extension_ ), singleBit( singleBit_ ), xmlLine( line )
|
||||
EnumValueData( int line,
|
||||
std::string const & name_,
|
||||
std::string const & protect_,
|
||||
std::string const & extension_,
|
||||
bool singleBit_ )
|
||||
: name( name_ ), extension( extension_ ), protect( protect_ ), singleBit( singleBit_ ), xmlLine( line )
|
||||
{}
|
||||
|
||||
std::string name;
|
||||
std::string extension;
|
||||
std::string protect;
|
||||
bool singleBit;
|
||||
int xmlLine;
|
||||
};
|
||||
@ -152,7 +157,11 @@ private:
|
||||
{
|
||||
EnumData( int line ) : xmlLine( line ) {}
|
||||
void addEnumAlias( int line, std::string const & name, std::string const & alias );
|
||||
void addEnumValue( int line, std::string const & valueName, bool bitpos, std::string const & extension );
|
||||
void addEnumValue( int line,
|
||||
std::string const & valueName,
|
||||
std::string const & protect,
|
||||
bool bitpos,
|
||||
std::string const & extension );
|
||||
|
||||
std::string alias; // alias for this enum
|
||||
std::map<std::string, EnumAliasData> aliases; // aliases for the values
|
||||
|
Loading…
Reference in New Issue
Block a user