Skip to content

Commit

Permalink
issue KhronosGroup#25: Change error checking asserts to std::runtime_…
Browse files Browse the repository at this point in the history
…error exceptions for invalid enums tags.
  • Loading branch information
mtavenrath committed Aug 29, 2016
1 parent f1ade1b commit 7685c53
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions VulkanHppGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,11 @@ void readComment(tinyxml2::XMLElement * element, std::string & header)

void readEnums( tinyxml2::XMLElement * element, VkData & vkData )
{
assert( element->Attribute( "name" ) );
if (!element->Attribute("name"))
{
throw std::runtime_error(std::string("spec error: enums element is missing the name attribute"));
}

std::string name = getEnumName(element->Attribute("name"));
if ( name != "API Constants" )
{
Expand All @@ -1090,9 +1094,18 @@ void readEnums( tinyxml2::XMLElement * element, VkData & vkData )
}
else
{
assert(element->Attribute("type"));
if (!element->Attribute("type"))
{
throw std::runtime_error(std::string("spec error: <enums name=\"" + name + "\" is missing the type attribute"));
}

std::string type = element->Attribute("type");
assert((type == "bitmask") || (type == "enum"));

if (type != "bitmask" && type != "enum")
{
throw std::runtime_error(std::string("spec error: <enums name=\"" + name + "\" has unknown type " + type));
}

it->second.bitmask = (type == "bitmask");
std::string prefix, postfix;
if (it->second.bitmask)
Expand Down

0 comments on commit 7685c53

Please sign in to comment.