diff --git a/Vulkan-Docs b/Vulkan-Docs index 4ad4fd1..8cc971f 160000 --- a/Vulkan-Docs +++ b/Vulkan-Docs @@ -1 +1 @@ -Subproject commit 4ad4fd17161efd9bfd1125c0c9d17db6fb276216 +Subproject commit 8cc971fb3e1c25afb949cdc49d6a6de63f19c5c6 diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index de14a2f..28799d3 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -758,6 +758,13 @@ std::pair writeFunctionBodyStandardReturn(std::string const& return std::make_pair(castReturn, ret); } +VulkanHppGenerator::VulkanHppGenerator() +{ + m_handles.insert(std::make_pair("", HandleData())); // insert the default "handle" without class (for createInstance, and such) +#if !defined(NDEBUG) +#endif +} + bool VulkanHppGenerator::containsUnion(std::string const& type) const { // a simple recursive check if a type is or contains a union @@ -826,13 +833,7 @@ std::string VulkanHppGenerator::defaultValue(std::string const& type) const } else { -#if !defined(NDEBUG) - static const std::set otherTypes = - { - "DWORD", "float", "HANDLE", "HINSTANCE", "HWND", "int", "int32_t", "size_t", "uint32_t", "uint64_t", "uint8_t", "Window", "xcb_window_t", "zx_handle_t" - }; - assert(otherTypes.find(type) != otherTypes.end()); -#endif + assert(m_defaultZeroTypes.find(type) != m_defaultZeroTypes.end()); return "0"; } } @@ -1817,6 +1818,19 @@ void VulkanHppGenerator::readRequireEnum(tinyxml2::XMLElement const* element, st } } +#if !defined(NDEBUG) +void VulkanHppGenerator::readRequires(tinyxml2::XMLElement const* element, std::map const& attributes) +{ + checkAttributes(attributes, element->GetLineNum(), { {"name", {}}, { "requires", {}} }, {}); + checkElements(getChildElements(element), {}); + + auto nameIt = attributes.find("name"); + assert(nameIt != attributes.end()); + assert(m_defaultZeroTypes.find(nameIt->second) == m_defaultZeroTypes.end()); + m_defaultZeroTypes.insert(nameIt->second); +} +#endif + void VulkanHppGenerator::readStruct(tinyxml2::XMLElement const* element, bool isUnion, std::map const& attributes) { checkAttributes(attributes, element->GetLineNum(), @@ -2016,10 +2030,21 @@ void VulkanHppGenerator::readType(tinyxml2::XMLElement const* element) throw std::runtime_error("Spec error on line " + lineNumber + ": unknown category <" + categoryIt->second + ">"); } } +#if !defined(NDEBUG) else { - assert(attributes.find("name") != attributes.end()); + auto requiresIt = attributes.find("requires"); + if (requiresIt != attributes.end()) + { + readRequires(element, attributes); + } + else + { + assert((attributes.size() == 1) && (attributes.begin()->first == "name") && (attributes.begin()->second == "int")); + m_defaultZeroTypes.insert("int"); + } } +#endif } void VulkanHppGenerator::readTypes(tinyxml2::XMLElement const* element) diff --git a/VulkanHppGenerator.hpp b/VulkanHppGenerator.hpp index 616cb98..430b667 100644 --- a/VulkanHppGenerator.hpp +++ b/VulkanHppGenerator.hpp @@ -23,10 +23,7 @@ class VulkanHppGenerator { public: - VulkanHppGenerator() - { - m_handles.insert(std::make_pair("", HandleData())); // insert the default "handle" without class (for createInstance, and such) - } + VulkanHppGenerator(); void checkCorrectness(); std::string const& getTypesafeCheck() const; @@ -222,6 +219,9 @@ class VulkanHppGenerator void writeStructure(std::ostream & os, std::pair const& structure) const; void writeUnion(std::ostream & os, std::pair const& structure) const; void writeUniqueTypes(std::ostream &os, std::string const& parentType, std::set const& childrenTypes) const; +#if !defined(NDEBUG) + void readRequires(tinyxml2::XMLElement const* element, std::map const& attributes); +#endif private: std::map m_baseTypes; @@ -239,6 +239,7 @@ class VulkanHppGenerator std::string m_version; std::string m_vulkanLicenseHeader; #if !defined(NDEBUG) + std::set m_defaultZeroTypes; std::set m_defines; // just used for verfication in readExtensionType #endif };