| 2539 | } |
| 2540 | |
| 2541 | Type parseType( tinyxml2::XMLElement const * element ) |
| 2542 | { |
| 2543 | int const line = element->GetLineNum(); |
| 2544 | checkAttributes( "vk.xml", line, getAttributes( element ), {}, {} ); |
| 2545 | checkElements( "vk.xml", line, getChildElements( element ), {}, {} ); |
| 2546 | |
| 2547 | Type type; |
| 2548 | type.name = element->GetText(); |
| 2549 | |
| 2550 | tinyxml2::XMLNode const * preType = element->PreviousSibling(); |
| 2551 | if ( preType && preType->ToText() ) |
| 2552 | { |
| 2553 | std::string prefix = trim( preType->Value() ); |
| 2554 | checkForError( "vk.xml", |
| 2555 | ( prefix == "const" ) || ( prefix == "const struct" ) || ( prefix == "struct" ) || ( prefix == "typedef" ), |
| 2556 | line, |
| 2557 | "unexpected text <" + prefix + "> before type" ); |
| 2558 | // change from west-const to east-const |
| 2559 | if ( prefix.starts_with( "const" ) ) |
| 2560 | { |
| 2561 | type.postfix = "const"; |
| 2562 | } |
| 2563 | if ( prefix.find( "struct" ) != std::string::npos ) |
| 2564 | { |
| 2565 | type.prefix = "struct"; |
| 2566 | } |
| 2567 | } |
| 2568 | |
| 2569 | tinyxml2::XMLNode const * postType = element->NextSibling(); |
| 2570 | if ( postType && postType->ToText() ) |
| 2571 | { |
| 2572 | std::string postfix = trim( postType->Value() ); |
| 2573 | if ( auto pos = postfix.find( "const*" ); pos != std::string::npos ) |
| 2574 | { |
| 2575 | postfix.replace( pos, strlen( "const*" ), "const *" ); |
| 2576 | } |
| 2577 | checkForError( "vk.xml", |
| 2578 | ( postfix == "*" ) || ( postfix == "**" ) || ( postfix == "* const*" ) || ( postfix == "* const *" ) || ( postfix == "(" ), |
| 2579 | line, |
| 2580 | "unexpected text <" + postfix + "> after type" ); |
| 2581 | if ( postfix != "(" ) |
| 2582 | { |
| 2583 | type.postfix += ( type.postfix.empty() ? "" : " " ) + postfix; |
| 2584 | } |
| 2585 | } |
| 2586 | return type; |
| 2587 | } |
| 2588 | |
| 2589 | Types parseTypes( tinyxml2::XMLElement const * element, std::string const & api ) |
| 2590 | { |
no test coverage detected