Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve IndexTypeTraits determination. #1911

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading