MCPcopy Create free account
hub / github.com/KhronosGroup/Vulkan-Hpp / parseType

Function parseType

generator/VkXMLParser.cpp:2541–2587  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2539}
2540
2541Type 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
2589Types parseTypes( tinyxml2::XMLElement const * element, std::string const & api )
2590{

Callers 2

parseNameAndTypeModifiedFunction · 0.85
parseStructMemberFunction · 0.85

Calls 6

checkAttributesFunction · 0.85
getAttributesFunction · 0.85
checkElementsFunction · 0.85
getChildElementsFunction · 0.85
trimFunction · 0.85
checkForErrorFunction · 0.85

Tested by

no test coverage detected