From 33071cd7a39c26b1dbeda6189954913af305024d Mon Sep 17 00:00:00 2001 From: Markus Tavenrath Date: Mon, 29 Aug 2016 10:03:04 +0200 Subject: [PATCH] issue #25: Change error checking asserts to std::runtime_error exceptions for invalid enums tags. (#26) --- VulkanHppGenerator.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index cb1ff37..e913964 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -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" ) { @@ -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)