mirror of
https://github.com/KhronosGroup/Vulkan-Hpp
synced 2024-11-29 23:21:05 +00:00
Merge pull request #627 from asuessenbach/protect
Extend check against protect attribute for types that are required by multiple extensions.
This commit is contained in:
commit
a688d5a579
@ -3296,8 +3296,8 @@ void VulkanHppGenerator::appendHandlesCommandDefintions( std::string & str ) con
|
||||
// special handling for destroy functions
|
||||
std::string commandName = determineCommandName( commandIt->first, commandIt->second.params[0].type.type );
|
||||
if ( commandIt->second.alias.empty() &&
|
||||
( ( commandIt->first.substr( 2, 7 ) == "Destroy" ) && ( commandName != "destroy" ) ) ||
|
||||
( commandIt->first.substr( 2, 4 ) == "Free" ) )
|
||||
( ( ( commandIt->first.substr( 2, 7 ) == "Destroy" ) && ( commandName != "destroy" ) ) ||
|
||||
( commandIt->first.substr( 2, 4 ) == "Free" ) ) )
|
||||
{
|
||||
std::string destroyCommandString;
|
||||
appendCommand( destroyCommandString, " ", commandIt->first, commandIt->second, true );
|
||||
@ -4650,28 +4650,20 @@ std::string const & VulkanHppGenerator::getVulkanLicenseHeader() const
|
||||
std::pair<std::string, std::string>
|
||||
VulkanHppGenerator::generateProtection( std::string const & feature, std::set<std::string> const & extensions ) const
|
||||
{
|
||||
if ( feature.empty() )
|
||||
if ( feature.empty() && !extensions.empty() )
|
||||
{
|
||||
std::string protect;
|
||||
for ( auto const & extension : extensions )
|
||||
assert( getPlatforms( extensions ).size() == 1 );
|
||||
std::string platform = *getPlatforms( extensions ).begin();
|
||||
if ( !platform.empty() )
|
||||
{
|
||||
auto extensionIt = m_extensions.find( extension );
|
||||
assert( extensionIt != m_extensions.end() );
|
||||
if ( !extensionIt->second.platform.empty() )
|
||||
auto platformIt = m_platforms.find( platform );
|
||||
assert( platformIt != m_platforms.end() );
|
||||
std::string const & protect = platformIt->second.protect;
|
||||
if ( !protect.empty() )
|
||||
{
|
||||
auto platformIt = m_platforms.find( extensionIt->second.platform );
|
||||
assert( platformIt != m_platforms.end() );
|
||||
if ( !platformIt->second.protect.empty() )
|
||||
{
|
||||
assert( protect.empty() );
|
||||
protect = platformIt->second.protect;
|
||||
}
|
||||
return std::make_pair( "#ifdef " + protect + "\n", "#endif /*" + protect + "*/\n" );
|
||||
}
|
||||
}
|
||||
if ( !protect.empty() )
|
||||
{
|
||||
return std::make_pair( "#ifdef " + protect + "\n", "#endif /*" + protect + "*/\n" );
|
||||
}
|
||||
}
|
||||
return std::make_pair( "", "" );
|
||||
}
|
||||
@ -4691,6 +4683,18 @@ std::pair<std::string, std::string> VulkanHppGenerator::generateProtection( std:
|
||||
}
|
||||
}
|
||||
|
||||
std::set<std::string> VulkanHppGenerator::getPlatforms( std::set<std::string> const & extensions ) const
|
||||
{
|
||||
std::set<std::string> platforms;
|
||||
for ( auto const & e : extensions )
|
||||
{
|
||||
auto extensionIt = m_extensions.find( e );
|
||||
assert( extensionIt != m_extensions.end() );
|
||||
platforms.insert( extensionIt->second.platform );
|
||||
}
|
||||
return platforms;
|
||||
}
|
||||
|
||||
bool VulkanHppGenerator::holdsSType( std::string const & type ) const
|
||||
{
|
||||
auto it = m_structures.find( type );
|
||||
@ -5714,6 +5718,9 @@ void VulkanHppGenerator::readExtensionRequireType( tinyxml2::XMLElement const *
|
||||
auto typeIt = m_types.find( name );
|
||||
check( typeIt != m_types.end(), line, "failed to find required type <" + name + ">" );
|
||||
typeIt->second.extensions.insert( extension );
|
||||
check( getPlatforms( typeIt->second.extensions ).size() == 1,
|
||||
line,
|
||||
"type <" + name + "> is protected by more than one platform" );
|
||||
}
|
||||
|
||||
void VulkanHppGenerator::readExtensions( tinyxml2::XMLElement const * element )
|
||||
|
@ -515,10 +515,11 @@ private:
|
||||
std::pair<std::string, std::string> generateProtection( std::string const & feature,
|
||||
std::set<std::string> const & extension ) const;
|
||||
std::pair<std::string, std::string> generateProtection( std::string const & type, bool isAliased ) const;
|
||||
std::set<std::string> getPlatforms( std::set<std::string> const & extensions ) const;
|
||||
bool holdsSType( std::string const & type ) const;
|
||||
bool isParam( std::string const & name, std::vector<ParamData> const & params ) const;
|
||||
bool isParamIndirect( std::string const & name, std::vector<ParamData> const & params ) const;
|
||||
bool isTwoStepAlgorithm( std::vector<ParamData> const & params ) const;
|
||||
bool isParamIndirect( std::string const & name, std::vector<ParamData> const & params ) const;
|
||||
bool isTwoStepAlgorithm( std::vector<ParamData> const & params ) const;
|
||||
void readBaseType( tinyxml2::XMLElement const * element, std::map<std::string, std::string> const & attributes );
|
||||
void readBitmask( tinyxml2::XMLElement const * element, std::map<std::string, std::string> const & attributes );
|
||||
void readBitmaskAlias( tinyxml2::XMLElement const * element, std::map<std::string, std::string> const & attributes );
|
||||
|
Loading…
Reference in New Issue
Block a user