| 660 | } |
| 661 | |
| 662 | Enums parseEnums( tinyxml2::XMLElement const * element ) |
| 663 | { |
| 664 | int const line = element->GetLineNum(); |
| 665 | std::map<std::string, std::string> attributes = getAttributes( element ); |
| 666 | checkAttributes( |
| 667 | "vk.xml", line, attributes, { { "name", {} } }, { { "bitwidth", { "64" } }, { "comment", {} }, { "type", { "bitmask", "constants", "enum" } } } ); |
| 668 | std::vector<tinyxml2::XMLElement const *> children = getChildElements( element ); |
| 669 | |
| 670 | std::string bitwidth, name, type; |
| 671 | for ( auto const & attribute : attributes ) |
| 672 | { |
| 673 | if ( attribute.first == "bitwidth" ) |
| 674 | { |
| 675 | checkNoList( attribute.second, line ); |
| 676 | bitwidth = attribute.second; |
| 677 | } |
| 678 | else if ( attribute.first == "name" ) |
| 679 | { |
| 680 | checkNoList( attribute.second, line ); |
| 681 | name = attribute.second; |
| 682 | } |
| 683 | else if ( attribute.first == "type" ) |
| 684 | { |
| 685 | checkNoList( attribute.second, line ); |
| 686 | type = attribute.second; |
| 687 | } |
| 688 | } |
| 689 | assert( !name.empty() ); |
| 690 | |
| 691 | Enums enums{ .xmlLine = line }; |
| 692 | if ( type == "constants" ) |
| 693 | { |
| 694 | assert( bitwidth.empty() && ( name == "API Constants" ) ); |
| 695 | checkElements( "vk.xml", line, children, { { "enum", MultipleAllowed::Yes } } ); |
| 696 | for ( auto const & child : children ) |
| 697 | { |
| 698 | auto constant = parseConstant( child ); |
| 699 | checkForError( "vk.xml", enums.constants.insert( constant ).second, constant.second.xmlLine, "enum constant <" + constant.first + "> already specified" ); |
| 700 | } |
| 701 | } |
| 702 | else |
| 703 | { |
| 704 | checkForError( "vk.xml", ( type == "bitmask" ) || ( type == "enum" ), line, "unexpected enum type <" + type + ">" ); |
| 705 | checkElements( |
| 706 | "vk.xml", line, children, {}, { { "comment", MultipleAllowed::Yes }, { "enum", MultipleAllowed::Yes }, { "unused", MultipleAllowed::Yes } } ); |
| 707 | |
| 708 | auto [enumIt, inserted] = enums.enumValues.insert( { name, { .bitwidth = bitwidth, .type = type, .xmlLine = line } } ); |
| 709 | checkForError( "vk.xml", inserted, line, "enum <" + name + "> already specified on line " + std::to_string( enumIt->second.xmlLine ) ); |
| 710 | for ( auto const & child : children ) |
| 711 | { |
| 712 | std::string value = child->Value(); |
| 713 | if ( value == "enum" ) |
| 714 | { |
| 715 | parseEnum( child, *enumIt ); |
| 716 | } |
| 717 | } |
| 718 | } |
| 719 | return enums; |
no test coverage detected