Introduce helper function check() to ease throwing on spec error detection. (#502)

* Introduce helper function check() to ease throwing on spec error detection.

* Use some more checks

* Some more checks
This commit is contained in:
Andreas Süßenbach
2020-02-04 10:35:33 +01:00
committed by GitHub
parent 4d53dac22b
commit cf39cd4f0c
2 changed files with 228 additions and 162 deletions

View File

@@ -52,15 +52,28 @@ class VulkanHppGenerator
void readTypes(tinyxml2::XMLElement const* element);
private:
struct BaseTypeData
{
BaseTypeData(std::string const& type_, int line)
: type(type_)
, xmlLine(line)
{}
std::string type;
int xmlLine;
};
struct BitmaskData
{
BitmaskData(std::string const& r)
BitmaskData(std::string const& r, int line)
: requirement(r)
, xmlLine(line)
{}
std::string requirement; // original vulkan name: VK*FlagBits
std::string platform;
std::string alias; // original vulkan name
int xmlLine;
};
struct TypeData
@@ -92,8 +105,9 @@ class VulkanHppGenerator
struct CommandData
{
CommandData()
CommandData(int line)
: isAlias(false)
, xmlLine(line)
{}
std::vector<ParamData> params;
@@ -101,6 +115,7 @@ class VulkanHppGenerator
std::string returnType;
std::vector<std::string> successCodes;
bool isAlias;
int xmlLine;
};
struct EnumValueData
@@ -147,9 +162,10 @@ class VulkanHppGenerator
struct StructureData
{
StructureData()
StructureData(int line)
: returnedOnly(false)
, isUnion(false)
, xmlLine(line)
{}
bool returnedOnly;
@@ -159,6 +175,7 @@ class VulkanHppGenerator
std::vector<std::string> structExtends;
std::vector<std::string> aliases;
std::string subStruct;
int xmlLine;
};
private:
@@ -237,6 +254,7 @@ class VulkanHppGenerator
void readHandle(tinyxml2::XMLElement const* element, std::map<std::string, std::string> const& attributes);
void readPlatform(tinyxml2::XMLElement const* element);
void readRequireEnum(tinyxml2::XMLElement const* element, std::string const& tag);
void readRequires(tinyxml2::XMLElement const* element, std::map<std::string, std::string> const& attributes);
void readStruct(tinyxml2::XMLElement const* element, bool isUnion, std::map<std::string, std::string> const& attributes);
void readStructAlias(int lineNum, std::string const& name, std::string const& alias, std::map<std::string, std::string> const& attributes);
MemberData readStructMember(tinyxml2::XMLElement const* element);
@@ -244,29 +262,26 @@ class VulkanHppGenerator
void readTag(tinyxml2::XMLElement const* element);
void readType(tinyxml2::XMLElement const* element);
void readTypeEnum(tinyxml2::XMLElement const* element, std::map<std::string, std::string> const& attributes);
void readTypeInclude(tinyxml2::XMLElement const* element, std::map<std::string, std::string> const& attributes);
void registerDeleter(std::string const& name, std::pair<std::string, CommandData> const& commandData);
void unlinkCommandFromHandle(std::string const& name);
#if !defined(NDEBUG)
void readRequires(tinyxml2::XMLElement const* element, std::map<std::string, std::string> const& attributes);
#endif
private:
std::map<std::string, std::string> m_baseTypes;
std::map<std::string, BaseTypeData> m_baseTypes;
std::map<std::string, BitmaskData> m_bitmasks;
std::map<std::string, std::string> m_commandToHandle;
std::map<std::string, EnumData> m_enums;
std::set<std::string> m_extendedStructs; // structs which are referenced by the structextends tag
std::map<std::string, HandleData> m_handles;
std::set<std::string> m_includes;
std::map<std::string, std::string> m_platforms;
std::map<std::string, std::string> m_structureAliases;
std::map<std::string, StructureData> m_structures;
std::set<std::string> m_tags;
std::set<std::string> m_types;
std::string m_typesafeCheck;
std::string m_version;
std::string m_vulkanLicenseHeader;
#if !defined(NDEBUG)
std::set<std::string> m_defines; // just used for verfication in readExtensionType
#endif
};
const size_t INVALID_INDEX = (size_t)~0;