aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-01-11 12:05:43 +0100
committerUlf Hermann <ulf.hermann@qt.io>2021-01-20 13:34:01 +0100
commit2506938d829bf146e45e121116f870942c0453e1 (patch)
tree1dcdb0fc2f6513b0d3a57e9043cd9648d02fc324 /src
parent3ae2a6a47c960d159e1110b434795fc69ecf3d80 (diff)
QmlCompiler: Add equality operators and hash functions
We want to be able to use these types in hashes. Change-Id: Iea60bb8dd1ce893a37c4856d153f0f5c77d29fcd Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/qmlcompiler/qqmljsmetatypes_p.h81
1 files changed, 81 insertions, 0 deletions
diff --git a/src/qmlcompiler/qqmljsmetatypes_p.h b/src/qmlcompiler/qqmljsmetatypes_p.h
index 7d00eed199..0ab56e9503 100644
--- a/src/qmlcompiler/qqmljsmetatypes_p.h
+++ b/src/qmlcompiler/qqmljsmetatypes_p.h
@@ -88,6 +88,25 @@ public:
bool hasValues() const { return !m_values.isEmpty(); }
int value(const QString &key) const { return m_values.value(m_keys.indexOf(key)); }
bool hasKey(const QString &key) const { return m_keys.indexOf(key) != -1; }
+
+ friend bool operator==(const QQmlJSMetaEnum &a, const QQmlJSMetaEnum &b)
+ {
+ return a.m_keys == b.m_keys
+ && a.m_values == b.m_values
+ && a.m_name == b.m_name
+ && a.m_alias == b.m_alias
+ && a.m_isFlag == b.m_isFlag;
+ }
+
+ friend bool operator!=(const QQmlJSMetaEnum &a, const QQmlJSMetaEnum &b)
+ {
+ return !(a == b);
+ }
+
+ friend size_t qHash(const QQmlJSMetaEnum &e, size_t seed = 0)
+ {
+ return qHashMulti(seed, e.m_keys, e.m_values, e.m_name, e.m_alias, e.m_isFlag);
+ }
};
class QQmlJSMetaMethod
@@ -158,6 +177,42 @@ public:
bool isValid() const { return !m_name.isEmpty(); }
+ friend bool operator==(const QQmlJSMetaMethod &a, const QQmlJSMetaMethod &b)
+ {
+ return a.m_name == b.m_name
+ && a.m_returnTypeName == b.m_returnTypeName
+ && a.m_returnType == b.m_returnType
+ && a.m_paramNames == b.m_paramNames
+ && a.m_paramTypeNames == b.m_paramTypeNames
+ && a.m_paramTypes == b.m_paramTypes
+ && a.m_methodType == b.m_methodType
+ && a.m_methodAccess == b.m_methodAccess
+ && a.m_revision == b.m_revision;
+ }
+
+ friend bool operator!=(const QQmlJSMetaMethod &a, const QQmlJSMetaMethod &b)
+ {
+ return !(a == b);
+ }
+
+ friend size_t qHash(const QQmlJSMetaMethod &method, size_t seed = 0)
+ {
+ QtPrivate::QHashCombine combine;
+
+ seed = combine(seed, method.m_name);
+ seed = combine(seed, method.m_returnTypeName);
+ seed = combine(seed, method.m_returnType.toStrongRef().data());
+ seed = combine(seed, method.m_paramNames);
+ seed = combine(seed, method.m_methodType);
+ seed = combine(seed, method.m_methodAccess);
+ seed = combine(seed, method.m_revision);
+
+ for (const auto &type : method.m_paramTypes)
+ seed = combine(seed, type.toStrongRef().data());
+
+ return seed;
+ }
+
private:
QString m_name;
QString m_returnTypeName;
@@ -213,6 +268,32 @@ public:
void setRevision(int revision) { m_revision = revision; }
int revision() const { return m_revision; }
+
+ friend bool operator==(const QQmlJSMetaProperty &a, const QQmlJSMetaProperty &b)
+ {
+ return a.m_propertyName == b.m_propertyName
+ && a.m_typeName == b.m_typeName
+ && a.m_bindable == b.m_bindable
+ && a.m_type == b.m_type
+ && a.m_isList == b.m_isList
+ && a.m_isWritable == b.m_isWritable
+ && a.m_isPointer == b.m_isPointer
+ && a.m_isAlias == b.m_isAlias
+ && a.m_revision == b.m_revision;
+ }
+
+ friend bool operator!=(const QQmlJSMetaProperty &a, const QQmlJSMetaProperty &b)
+ {
+ return !(a == b);
+ }
+
+ friend size_t qHash(const QQmlJSMetaProperty &prop, size_t seed = 0)
+ {
+ return qHashMulti(seed, prop.m_propertyName, prop.m_typeName, prop.m_bindable,
+ prop.m_type.toStrongRef().data(),
+ prop.m_isList, prop.m_isWritable, prop.m_isPointer, prop.m_isAlias,
+ prop.m_revision);
+ }
};
QT_END_NAMESPACE