diff options
author | David Morgan <david.morgan@kdab.com> | 2014-07-02 17:43:16 +0100 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2014-08-29 12:41:21 +0200 |
commit | d444bbf110e83c72d0657203896ad3c8a4cb5107 (patch) | |
tree | ac9e57627a3d19cfb0902115386110e1cbc0fef2 /util/glgen/specparser.h | |
parent | 036cc9cb047c4ceffb545c8cbeedb315691fc6ce (diff) |
glgen: Added support for parsing the new xml spec.
The .spec file is no longer updated thus support for gl 4.4 is impossible without an update to parse the new xml spec. The legacy parser can be used with the -l (--legacy) switch.
Task-number: QTBUG-33671
Task-number: QTBUG-40090
Change-Id: I83d9380842a16e925f6c07331ee35fe035f6baa9
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'util/glgen/specparser.h')
-rw-r--r-- | util/glgen/specparser.h | 90 |
1 files changed, 71 insertions, 19 deletions
diff --git a/util/glgen/specparser.h b/util/glgen/specparser.h index 19357841ca..0ba36ef8d8 100644 --- a/util/glgen/specparser.h +++ b/util/glgen/specparser.h @@ -46,6 +46,7 @@ #include <QVariant> class QTextStream; +class QXmlStreamReader; struct Version { int major; @@ -57,6 +58,11 @@ inline bool operator == (const Version &lhs, const Version &rhs) return (lhs.major == rhs.major && lhs.minor == rhs.minor); } +inline bool operator != (const Version &lhs, const Version &rhs) +{ + return !(lhs == rhs); +} + inline bool operator < (const Version &lhs, const Version &rhs) { if (lhs.major != rhs.major) @@ -73,6 +79,17 @@ inline bool operator > (const Version &lhs, const Version &rhs) return (lhs.minor > rhs.minor); } +inline bool operator >= (const Version &lhs, const Version &rhs) +{ + return !(lhs < rhs); +} + + +inline bool operator <= (const Version &lhs, const Version &rhs) +{ + return !(lhs > rhs); +} + inline uint qHash(const Version &v) { return qHash(v.major * 100 + v.minor * 10); @@ -102,6 +119,11 @@ inline bool operator == (const VersionProfile &lhs, const VersionProfile &rhs) return lhs.version == rhs.version; } +inline bool operator != (const VersionProfile &lhs, const VersionProfile &rhs) +{ + return !(lhs == rhs); +} + inline bool operator < (const VersionProfile &lhs, const VersionProfile &rhs) { if (lhs.profile != rhs.profile) @@ -140,13 +162,47 @@ struct Function QList<Argument> arguments; }; +inline bool operator== (const Argument &lhs, const Argument &rhs) +{ + if ((lhs.type != rhs.type) || (lhs.name != rhs.name) || (lhs.direction != rhs.direction)) { + return false; + } + + return (lhs.mode != rhs.mode); +} + +inline bool operator!= (const Argument &lhs, const Argument &rhs) +{ + return !(lhs == rhs); +} + +inline bool operator== (const Function &lhs, const Function &rhs) +{ + if ((lhs.returnType != rhs.returnType) || (lhs.name != rhs.name)) { + return false; + } + + return (lhs.arguments == rhs.arguments); +} + +inline bool operator!= (const Function &lhs, const Function &rhs) +{ + return !(lhs == rhs); +} + typedef QList<Function> FunctionList; typedef QMap<VersionProfile, FunctionList> FunctionCollection; +struct FunctionProfile +{ + VersionProfile::OpenGLProfile profile; + Function function; +}; + class SpecParser { public: - explicit SpecParser(); + virtual ~SpecParser() {} QString specFileName() const { @@ -158,22 +214,28 @@ public: return m_typeMapFileName; } - QList<Version> versions() const {return m_versions;} - QList<VersionProfile> versionProfiles() const {return m_functions.uniqueKeys();} + virtual QList<Version> versions() const = 0; + + QList<VersionProfile> versionProfiles() const {return versionFunctions().uniqueKeys();} QList<Function> functionsForVersion(const VersionProfile &v) const { - return m_functions.values(v); + return versionFunctions().values(v); } QStringList extensions() const { - return QStringList(m_extensionFunctions.uniqueKeys()); + return QStringList(extensionFunctions().uniqueKeys()); } QList<Function> functionsForExtension(const QString &extension) { - return m_extensionFunctions.values(extension); + QList<Function> func; + + Q_FOREACH (const FunctionProfile &f, extensionFunctions().values(extension)) + func.append(f.function); + + return func; } void setSpecFileName(QString arg) @@ -186,25 +248,15 @@ public: m_typeMapFileName = arg; } - void parse(); + virtual bool parse() = 0; protected: - bool parseTypeMap(); - void parseEnums(); - void parseFunctions(QTextStream &stream); - bool inDeprecationException(const QString &functionName) const; + virtual const QMultiHash<VersionProfile, Function> &versionFunctions() const = 0; + virtual const QMultiMap<QString, FunctionProfile> &extensionFunctions() const = 0; private: QString m_specFileName; QString m_typeMapFileName; - - QMap<QString, QString> m_typeMap; - QMultiMap<VersionProfile, Function> m_functions; - - QList<Version> m_versions; - - // Extension support - QMultiMap<QString, Function> m_extensionFunctions; }; #endif // SPECPARSER_H |