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