Skip to content

Commit

Permalink
Improve IndexTypeTraits determination. (#1911)
Browse files Browse the repository at this point in the history
  • Loading branch information
asuessenbach authored Jun 28, 2024
1 parent 3b0d995 commit 620cf05
Showing 1 changed file with 12 additions and 21 deletions.
33 changes: 12 additions & 21 deletions VulkanHppGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8134,29 +8134,20 @@ std::string VulkanHppGenerator::generateIndexTypeTraits( std::pair<std::string,
std::string typeTraits;
for ( auto const & value : enumData.second.values )
{
std::string cppType, valueName;
if ( value.name == "VK_INDEX_TYPE_UINT8_KHR" )
{
valueName = "eUint8KHR";
cppType = "uint8_t";
}
else if ( value.name == "VK_INDEX_TYPE_UINT16" )
{
valueName = "eUint16";
cppType = "uint16_t";
}
else if ( value.name == "VK_INDEX_TYPE_UINT32" )
{
valueName = "eUint32";
cppType = "uint32_t";
}
else
{
checkForError( value.name == "VK_INDEX_TYPE_NONE_KHR", value.xmlLine, "unknown IndexType <" + value.name + "> encountered" );
}
assert( value.name.starts_with( "VK_INDEX_TYPE_" ) );
std::string type = stripPrefix( value.name, "VK_INDEX_TYPE_" );

if ( !valueName.empty() )
if ( !type.starts_with( "NONE" ) )
{
checkForError( type.starts_with( "UINT" ), value.xmlLine, "unknown VkIndexType <" + value.name + "> encountered" );
std::string::size_type pos = type.find_first_of( "0123456789" );
assert( pos != std::string::npos );
std::string::size_type end = type.find_first_not_of( "0123456789", pos );
std::string::size_type count = ( end != std::string::npos ) ? ( end - pos ) : end;

std::string valueName = generateEnumValueName( "VkIndexType", value.name, false );
std::string cppType = "uint" + type.substr( pos, count ) + "_t";

const std::string typeTraitTemplate = R"( template <>
struct IndexTypeValue<${cppType}>
{
Expand Down

0 comments on commit 620cf05

Please sign in to comment.