QQmlJSScope: Avoid nested structs
Nested structs cannot be forward declared, and some of them are only loosely related to QQmlJSScope. To avoid changing usage sites, keep the name accessible via typedefs. Change-Id: I65d51695f3b14b7d25fc4fb1560090e992568377 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Semih Yavuz <semih.yavuz@qt.io> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
This commit is contained in:
parent
07b361db82
commit
4bf10f9f9c
|
@ -92,6 +92,71 @@ private:
|
|||
ConstPtr m_pointer;
|
||||
};
|
||||
|
||||
class Import
|
||||
{
|
||||
public:
|
||||
Import() = default;
|
||||
Import(QString prefix, QString name, QTypeRevision version, bool isFile, bool isDependency);
|
||||
|
||||
bool isValid() const;
|
||||
|
||||
QString prefix() const { return m_prefix; }
|
||||
QString name() const { return m_name; }
|
||||
QTypeRevision version() const { return m_version; }
|
||||
bool isFile() const { return m_isFile; }
|
||||
bool isDependency() const { return m_isDependency; }
|
||||
|
||||
private:
|
||||
QString m_prefix;
|
||||
QString m_name;
|
||||
QTypeRevision m_version;
|
||||
bool m_isFile = false;
|
||||
bool m_isDependency = false;
|
||||
|
||||
friend inline size_t qHash(const Import &key, size_t seed = 0) noexcept
|
||||
{
|
||||
return qHashMulti(seed, key.m_prefix, key.m_name, key.m_version,
|
||||
key.m_isFile, key.m_isDependency);
|
||||
}
|
||||
|
||||
friend inline bool operator==(const Import &a, const Import &b)
|
||||
{
|
||||
return a.m_prefix == b.m_prefix && a.m_name == b.m_name && a.m_version == b.m_version
|
||||
&& a.m_isFile == b.m_isFile && a.m_isDependency == b.m_isDependency;
|
||||
}
|
||||
};
|
||||
|
||||
class Export {
|
||||
public:
|
||||
Export() = default;
|
||||
Export(QString package, QString type, QTypeRevision version, QTypeRevision revision);
|
||||
|
||||
bool isValid() const;
|
||||
|
||||
QString package() const { return m_package; }
|
||||
QString type() const { return m_type; }
|
||||
QTypeRevision version() const { return m_version; }
|
||||
QTypeRevision revision() const { return m_revision; }
|
||||
|
||||
private:
|
||||
QString m_package;
|
||||
QString m_type;
|
||||
QTypeRevision m_version;
|
||||
QTypeRevision m_revision;
|
||||
};
|
||||
|
||||
template<typename Pointer>
|
||||
struct ExportedScope {
|
||||
Pointer scope;
|
||||
QList<Export> exports;
|
||||
};
|
||||
|
||||
template<typename Pointer>
|
||||
struct ImportedScope {
|
||||
Pointer scope;
|
||||
QTypeRevision revision;
|
||||
};
|
||||
|
||||
} // namespace QQmlJS
|
||||
|
||||
class Q_QMLCOMPILER_PRIVATE_EXPORT QQmlJSScope
|
||||
|
@ -136,70 +201,12 @@ public:
|
|||
Q_DECLARE_FLAGS(Flags, Flag)
|
||||
Q_FLAGS(Flags);
|
||||
|
||||
class Import
|
||||
{
|
||||
public:
|
||||
Import() = default;
|
||||
Import(QString prefix, QString name, QTypeRevision version, bool isFile, bool isDependency);
|
||||
|
||||
bool isValid() const;
|
||||
|
||||
QString prefix() const { return m_prefix; }
|
||||
QString name() const { return m_name; }
|
||||
QTypeRevision version() const { return m_version; }
|
||||
bool isFile() const { return m_isFile; }
|
||||
bool isDependency() const { return m_isDependency; }
|
||||
|
||||
private:
|
||||
QString m_prefix;
|
||||
QString m_name;
|
||||
QTypeRevision m_version;
|
||||
bool m_isFile = false;
|
||||
bool m_isDependency = false;
|
||||
|
||||
friend inline size_t qHash(const Import &key, size_t seed = 0) noexcept
|
||||
{
|
||||
return qHashMulti(seed, key.m_prefix, key.m_name, key.m_version,
|
||||
key.m_isFile, key.m_isDependency);
|
||||
}
|
||||
|
||||
friend inline bool operator==(const Import &a, const Import &b)
|
||||
{
|
||||
return a.m_prefix == b.m_prefix && a.m_name == b.m_name && a.m_version == b.m_version
|
||||
&& a.m_isFile == b.m_isFile && a.m_isDependency == b.m_isDependency;
|
||||
}
|
||||
};
|
||||
|
||||
class Export {
|
||||
public:
|
||||
Export() = default;
|
||||
Export(QString package, QString type, QTypeRevision version, QTypeRevision revision);
|
||||
|
||||
bool isValid() const;
|
||||
|
||||
QString package() const { return m_package; }
|
||||
QString type() const { return m_type; }
|
||||
QTypeRevision version() const { return m_version; }
|
||||
QTypeRevision revision() const { return m_revision; }
|
||||
|
||||
private:
|
||||
QString m_package;
|
||||
QString m_type;
|
||||
QTypeRevision m_version;
|
||||
QTypeRevision m_revision;
|
||||
};
|
||||
|
||||
template<typename Pointer>
|
||||
struct ExportedScope {
|
||||
Pointer scope;
|
||||
QList<QQmlJSScope::Export> exports;
|
||||
};
|
||||
|
||||
template<typename Pointer>
|
||||
struct ImportedScope {
|
||||
Pointer scope;
|
||||
QTypeRevision revision;
|
||||
};
|
||||
using Import = QQmlJS::Import;
|
||||
using Export = QQmlJS::Export;
|
||||
template <typename Pointer>
|
||||
using ImportedScope = QQmlJS::ImportedScope<Pointer>;
|
||||
template <typename Pointer>
|
||||
using ExportedScope = QQmlJS::ExportedScope<Pointer>;
|
||||
|
||||
/*! \internal
|
||||
* Maps type names to types and the compile context of the types. The context can be
|
||||
|
|
Loading…
Reference in New Issue