Port qmake from QStringRef to QStringView

Change-Id: Ie07a976cd3c634e04c8b9b1e0a6cacd4c2d94939
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Lars Knoll 2020-05-30 23:29:21 +02:00
parent 690abaac0e
commit c49728eb27
20 changed files with 109 additions and 113 deletions

View File

@ -857,29 +857,29 @@ MakefileGenerator::processPrlFile(QString &file, bool baseOnly)
QString f = fileFixify(file, FileFixifyBackwards); QString f = fileFixify(file, FileFixifyBackwards);
// Explicitly given full .prl name // Explicitly given full .prl name
if (!baseOnly && f.endsWith(Option::prl_ext)) if (!baseOnly && f.endsWith(Option::prl_ext))
return processPrlFileCore(file, QStringRef(), f); return processPrlFileCore(file, QStringView(), f);
// Explicitly given or derived (from -l) base name // Explicitly given or derived (from -l) base name
if (processPrlFileCore(file, QStringRef(), f + Option::prl_ext)) if (processPrlFileCore(file, QStringView(), f + Option::prl_ext))
return true; return true;
if (!baseOnly) { if (!baseOnly) {
// Explicitly given full library name // Explicitly given full library name
int off = qMax(f.lastIndexOf('/'), f.lastIndexOf('\\')) + 1; int off = qMax(f.lastIndexOf('/'), f.lastIndexOf('\\')) + 1;
int ext = f.midRef(off).lastIndexOf('.'); int ext = QStringView(f).mid(off).lastIndexOf('.');
if (ext != -1) if (ext != -1)
return processPrlFileBase(file, f.midRef(off), f.leftRef(off + ext), off); return processPrlFileBase(file, QStringView(f).mid(off), QStringView{f}.left(off + ext), off);
} }
return false; return false;
} }
bool bool
MakefileGenerator::processPrlFileBase(QString &origFile, const QStringRef &origName, MakefileGenerator::processPrlFileBase(QString &origFile, QStringView origName,
const QStringRef &fixedBase, int /*slashOff*/) QStringView fixedBase, int /*slashOff*/)
{ {
return processPrlFileCore(origFile, origName, fixedBase + Option::prl_ext); return processPrlFileCore(origFile, origName, fixedBase + Option::prl_ext);
} }
bool bool
MakefileGenerator::processPrlFileCore(QString &origFile, const QStringRef &origName, MakefileGenerator::processPrlFileCore(QString &origFile, QStringView origName,
const QString &fixedFile) const QString &fixedFile)
{ {
const QString meta_file = QMakeMetaInfo::checkLib(fixedFile); const QString meta_file = QMakeMetaInfo::checkLib(fixedFile);
@ -1516,7 +1516,7 @@ MakefileGenerator::createObjectList(const ProStringList &sources)
int lastDirSepPosition = sourceRelativePath.lastIndexOf(Option::dir_sep); int lastDirSepPosition = sourceRelativePath.lastIndexOf(Option::dir_sep);
if (lastDirSepPosition != -1) if (lastDirSepPosition != -1)
dir += sourceRelativePath.leftRef(lastDirSepPosition + 1); dir += QStringView{sourceRelativePath}.left(lastDirSepPosition + 1);
if (!noIO()) { if (!noIO()) {
// Ensure that the final output directory of each object exists // Ensure that the final output directory of each object exists
@ -1840,8 +1840,8 @@ QString MakefileGenerator::resolveDependency(const QDir &outDir, const QString &
int cut = file.indexOf('/'); int cut = file.indexOf('/');
if (cut < 0 || cut + 1 >= file.size()) if (cut < 0 || cut + 1 >= file.size())
continue; continue;
QStringRef framework = file.leftRef(cut); QStringView framework = QStringView{file}.left(cut);
QStringRef include = file.midRef(cut + 1); QStringView include = QStringView(file).mid(cut + 1);
if (local.endsWith('/' + framework + ".framework/Headers")) { if (local.endsWith('/' + framework + ".framework/Headers")) {
lf = outDir.absoluteFilePath(local + '/' + include); lf = outDir.absoluteFilePath(local + '/' + include);
if (exists(lf)) if (exists(lf))

View File

@ -260,9 +260,9 @@ protected:
QString installMetaFile(const ProKey &replace_rule, const QString &src, const QString &dst); QString installMetaFile(const ProKey &replace_rule, const QString &src, const QString &dst);
virtual bool processPrlFileBase(QString &origFile, const QStringRef &origName, virtual bool processPrlFileBase(QString &origFile, QStringView origName,
const QStringRef &fixedBase, int slashOff); QStringView fixedBase, int slashOff);
bool processPrlFileCore(QString &origFile, const QStringRef &origName, bool processPrlFileCore(QString &origFile, QStringView origName,
const QString &fixedFile); const QString &fixedFile);
void createResponseFile(const QString &fileName, const ProStringList &objList); void createResponseFile(const QString &fileName, const ProStringList &objList);

View File

@ -64,13 +64,13 @@ MingwMakefileGenerator::parseLibFlag(const ProString &flag, ProString *arg)
return MakefileGenerator::parseLibFlag(flag, arg); return MakefileGenerator::parseLibFlag(flag, arg);
} }
bool MingwMakefileGenerator::processPrlFileBase(QString &origFile, const QStringRef &origName, bool MingwMakefileGenerator::processPrlFileBase(QString &origFile, QStringView origName,
const QStringRef &fixedBase, int slashOff) QStringView fixedBase, int slashOff)
{ {
if (origName.startsWith("lib")) { if (origName.startsWith(u"lib")) {
QString newFixedBase = fixedBase.left(slashOff) + fixedBase.mid(slashOff + 3); QString newFixedBase = fixedBase.left(slashOff) + fixedBase.mid(slashOff + 3);
if (Win32MakefileGenerator::processPrlFileBase(origFile, origName, if (Win32MakefileGenerator::processPrlFileBase(origFile, origName,
QStringRef(&newFixedBase), slashOff)) { QStringView(newFixedBase), slashOff)) {
return true; return true;
} }
} }

View File

@ -39,8 +39,8 @@ protected:
using MakefileGenerator::escapeDependencyPath; using MakefileGenerator::escapeDependencyPath;
QString escapeDependencyPath(const QString &path) const override; QString escapeDependencyPath(const QString &path) const override;
ProString fixLibFlag(const ProString &lib) override; ProString fixLibFlag(const ProString &lib) override;
bool processPrlFileBase(QString &origFile, const QStringRef &origName, bool processPrlFileBase(QString &origFile, QStringView origName,
const QStringRef &fixedBase, int slashOff) override; QStringView fixedBase, int slashOff) override;
bool writeMakefile(QTextStream &) override; bool writeMakefile(QTextStream &) override;
void init() override; void init() override;
QString installRoot() const override; QString installRoot() const override;

View File

@ -194,8 +194,8 @@ Win32MakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags)
return true; return true;
} }
bool Win32MakefileGenerator::processPrlFileBase(QString &origFile, const QStringRef &origName, bool Win32MakefileGenerator::processPrlFileBase(QString &origFile, QStringView origName,
const QStringRef &fixedBase, int slashOff) QStringView fixedBase, int slashOff)
{ {
if (MakefileGenerator::processPrlFileBase(origFile, origName, fixedBase, slashOff)) if (MakefileGenerator::processPrlFileBase(origFile, origName, fixedBase, slashOff))
return true; return true;

View File

@ -56,8 +56,8 @@ protected:
LibFlagType parseLibFlag(const ProString &flag, ProString *arg) override; LibFlagType parseLibFlag(const ProString &flag, ProString *arg) override;
ProString fixLibFlag(const ProString &lib) override; ProString fixLibFlag(const ProString &lib) override;
bool processPrlFileBase(QString &origFile, const QStringRef &origName, bool processPrlFileBase(QString &origFile, QStringView origName,
const QStringRef &fixedBase, int slashOff) override; QStringView fixedBase, int slashOff) override;
void processVars(); void processVars();
void fixTargetExt(); void fixTargetExt();

View File

@ -91,14 +91,14 @@ bool IoUtils::isRelativePath(const QString &path)
return true; return true;
} }
QStringRef IoUtils::pathName(const QString &fileName) QStringView IoUtils::pathName(const QString &fileName)
{ {
return fileName.leftRef(fileName.lastIndexOf(QLatin1Char('/')) + 1); return QStringView{fileName}.left(fileName.lastIndexOf(QLatin1Char('/')) + 1);
} }
QStringRef IoUtils::fileName(const QString &fileName) QStringView IoUtils::fileName(const QString &fileName)
{ {
return fileName.midRef(fileName.lastIndexOf(QLatin1Char('/')) + 1); return QStringView(fileName).mid(fileName.lastIndexOf(QLatin1Char('/')) + 1);
} }
QString IoUtils::resolvePath(const QString &baseDir, const QString &fileName) QString IoUtils::resolvePath(const QString &baseDir, const QString &fileName)

View File

@ -53,8 +53,8 @@ public:
static bool exists(const QString &fileName) { return fileType(fileName) != FileNotFound; } static bool exists(const QString &fileName) { return fileType(fileName) != FileNotFound; }
static bool isRelativePath(const QString &fileName); static bool isRelativePath(const QString &fileName);
static bool isAbsolutePath(const QString &fileName) { return !isRelativePath(fileName); } static bool isAbsolutePath(const QString &fileName) { return !isRelativePath(fileName); }
static QStringRef pathName(const QString &fileName); // Requires normalized path static QStringView pathName(const QString &fileName); // Requires normalized path
static QStringRef fileName(const QString &fileName); // Requires normalized path static QStringView fileName(const QString &fileName); // Requires normalized path
static QString resolvePath(const QString &baseDir, const QString &fileName); static QString resolvePath(const QString &baseDir, const QString &fileName);
static QString shellQuoteUnix(const QString &arg); static QString shellQuoteUnix(const QString &arg);
static QString shellQuoteWin(const QString &arg); static QString shellQuoteWin(const QString &arg);

View File

@ -74,8 +74,8 @@ ProString::ProString(const QString &str) :
{ {
} }
ProString::ProString(const QStringRef &str) : ProString::ProString(QStringView str) :
m_string(*str.string()), m_offset(str.position()), m_length(str.size()), m_file(0), m_hash(0x80000000) m_string(str.toString()), m_offset(0), m_length(str.size()), m_file(0), m_hash(0x80000000)
{ {
} }
@ -341,7 +341,7 @@ ProString ProString::trimmed() const
QTextStream &operator<<(QTextStream &t, const ProString &str) QTextStream &operator<<(QTextStream &t, const ProString &str)
{ {
t << str.toQStringRef(); t << str.toQStringView();
return t; return t;
} }
@ -466,10 +466,10 @@ bool ProStringList::contains(const ProString &str, Qt::CaseSensitivity cs) const
return false; return false;
} }
bool ProStringList::contains(const QStringRef &str, Qt::CaseSensitivity cs) const bool ProStringList::contains(QStringView str, Qt::CaseSensitivity cs) const
{ {
for (int i = 0; i < size(); i++) for (int i = 0; i < size(); i++)
if (!at(i).toQStringRef().compare(str, cs)) if (!at(i).toQStringView().compare(str, cs))
return true; return true;
return false; return false;
} }

View File

@ -74,7 +74,7 @@ public:
ProString &operator=(const QStringBuilder<A, B> &str) ProString &operator=(const QStringBuilder<A, B> &str)
{ return *this = QString(str); } { return *this = QString(str); }
ProString(const QString &str); ProString(const QString &str);
PROITEM_EXPLICIT ProString(const QStringRef &str); PROITEM_EXPLICIT ProString(QStringView str);
PROITEM_EXPLICIT ProString(const char *str); PROITEM_EXPLICIT ProString(const char *str);
template<typename A, typename B> template<typename A, typename B>
ProString(const QStringBuilder<A, B> &str) ProString(const QStringBuilder<A, B> &str)
@ -107,16 +107,16 @@ public:
void chop(int n) { Q_ASSERT(n <= m_length); m_length -= n; } void chop(int n) { Q_ASSERT(n <= m_length); m_length -= n; }
void chopFront(int n) { Q_ASSERT(n <= m_length); m_offset += n; m_length -= n; } void chopFront(int n) { Q_ASSERT(n <= m_length); m_offset += n; m_length -= n; }
bool operator==(const ProString &other) const { return toQStringRef() == other.toQStringRef(); } bool operator==(const ProString &other) const { return toQStringView() == other.toQStringView(); }
bool operator==(const QString &other) const { return toQStringRef() == other; } bool operator==(const QString &other) const { return toQStringView() == other; }
bool operator==(const QStringRef &other) const { return toQStringRef() == other; } bool operator==(QStringView other) const { return toQStringView() == other; }
bool operator==(QLatin1String other) const { return toQStringRef() == other; } bool operator==(QLatin1String other) const { return toQStringView() == other; }
bool operator==(const char *other) const { return toQStringRef() == QLatin1String(other); } bool operator==(const char *other) const { return toQStringView() == QLatin1String(other); }
bool operator!=(const ProString &other) const { return !(*this == other); } bool operator!=(const ProString &other) const { return !(*this == other); }
bool operator!=(const QString &other) const { return !(*this == other); } bool operator!=(const QString &other) const { return !(*this == other); }
bool operator!=(QLatin1String other) const { return !(*this == other); } bool operator!=(QLatin1String other) const { return !(*this == other); }
bool operator!=(const char *other) const { return !(*this == other); } bool operator!=(const char *other) const { return !(*this == other); }
bool operator<(const ProString &other) const { return toQStringRef() < other.toQStringRef(); } bool operator<(const ProString &other) const { return toQStringView() < other.toQStringView(); }
bool isNull() const { return m_string.isNull(); } bool isNull() const { return m_string.isNull(); }
bool isEmpty() const { return !m_length; } bool isEmpty() const { return !m_length; }
int length() const { return m_length; } int length() const { return m_length; }
@ -127,38 +127,37 @@ public:
ProString left(int len) const { return mid(0, len); } ProString left(int len) const { return mid(0, len); }
ProString right(int len) const { return mid(qMax(0, size() - len)); } ProString right(int len) const { return mid(qMax(0, size() - len)); }
ProString trimmed() const; ProString trimmed() const;
int compare(const ProString &sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().compare(sub.toQStringRef(), cs); } int compare(const ProString &sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringView().compare(sub.toQStringView(), cs); }
int compare(const QString &sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().compare(sub, cs); } int compare(const QString &sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringView().compare(sub, cs); }
int compare(const char *sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().compare(QLatin1String(sub), cs); } int compare(const char *sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringView().compare(QLatin1String(sub), cs); }
bool startsWith(const ProString &sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().startsWith(sub.toQStringRef(), cs); } bool startsWith(const ProString &sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringView().startsWith(sub.toQStringView(), cs); }
bool startsWith(const QString &sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().startsWith(sub, cs); } bool startsWith(const QString &sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringView().startsWith(sub, cs); }
bool startsWith(const char *sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().startsWith(QLatin1String(sub), cs); } bool startsWith(const char *sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringView().startsWith(QLatin1String(sub), cs); }
bool startsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().startsWith(c, cs); } bool startsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringView().startsWith(c, cs); }
template<typename A, typename B> template<typename A, typename B>
bool startsWith(const QStringBuilder<A, B> &str) { return startsWith(QString(str)); } bool startsWith(const QStringBuilder<A, B> &str) { return startsWith(QString(str)); }
bool endsWith(const ProString &sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().endsWith(sub.toQStringRef(), cs); } bool endsWith(const ProString &sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringView().endsWith(sub.toQStringView(), cs); }
bool endsWith(const QString &sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().endsWith(sub, cs); } bool endsWith(const QString &sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringView().endsWith(sub, cs); }
bool endsWith(const char *sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().endsWith(QLatin1String(sub), cs); } bool endsWith(const char *sub, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringView().endsWith(QLatin1String(sub), cs); }
template<typename A, typename B> template<typename A, typename B>
bool endsWith(const QStringBuilder<A, B> &str) { return endsWith(QString(str)); } bool endsWith(const QStringBuilder<A, B> &str) { return endsWith(QString(str)); }
bool endsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().endsWith(c, cs); } bool endsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringView().endsWith(c, cs); }
int indexOf(const QString &s, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().indexOf(s, from, cs); } int indexOf(const QString &s, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringView().indexOf(s, from, cs); }
int indexOf(const char *s, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().indexOf(QLatin1String(s), from, cs); } int indexOf(const char *s, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringView().indexOf(QLatin1String(s), from, cs); }
int indexOf(QChar c, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().indexOf(c, from, cs); } int indexOf(QChar c, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringView().indexOf(c, from, cs); }
int lastIndexOf(const QString &s, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().lastIndexOf(s, from, cs); } int lastIndexOf(const QString &s, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringView().lastIndexOf(s, from, cs); }
int lastIndexOf(const char *s, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().lastIndexOf(QLatin1String(s), from, cs); } int lastIndexOf(const char *s, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringView().lastIndexOf(QLatin1String(s), from, cs); }
int lastIndexOf(QChar c, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringRef().lastIndexOf(c, from, cs); } int lastIndexOf(QChar c, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return toQStringView().lastIndexOf(c, from, cs); }
bool contains(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return indexOf(s, 0, cs) >= 0; } bool contains(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return indexOf(s, 0, cs) >= 0; }
bool contains(const char *s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return indexOf(QLatin1String(s), 0, cs) >= 0; } bool contains(const char *s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return indexOf(QLatin1String(s), 0, cs) >= 0; }
bool contains(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return indexOf(c, 0, cs) >= 0; } bool contains(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return indexOf(c, 0, cs) >= 0; }
qlonglong toLongLong(bool *ok = nullptr, int base = 10) const { return toQStringRef().toLongLong(ok, base); } qlonglong toLongLong(bool *ok = nullptr, int base = 10) const { return toQStringView().toLongLong(ok, base); }
int toInt(bool *ok = nullptr, int base = 10) const { return toQStringRef().toInt(ok, base); } int toInt(bool *ok = nullptr, int base = 10) const { return toQStringView().toInt(ok, base); }
short toShort(bool *ok = nullptr, int base = 10) const { return toQStringRef().toShort(ok, base); } short toShort(bool *ok = nullptr, int base = 10) const { return toQStringView().toShort(ok, base); }
uint hash() const { return m_hash; } uint hash() const { return m_hash; }
static uint hash(const QChar *p, int n); static uint hash(const QChar *p, int n);
ALWAYS_INLINE QStringRef toQStringRef() const { return QStringRef(&m_string, m_offset, m_length); }
ALWAYS_INLINE QStringView toQStringView() const { return QStringView(m_string).mid(m_offset, m_length); } ALWAYS_INLINE QStringView toQStringView() const { return QStringView(m_string).mid(m_offset, m_length); }
ALWAYS_INLINE ProKey &toKey() { return *(ProKey *)this; } ALWAYS_INLINE ProKey &toKey() { return *(ProKey *)this; }
@ -167,7 +166,7 @@ public:
QString toQString() const; QString toQString() const;
QString &toQString(QString &tmp) const; QString &toQString(QString &tmp) const;
QByteArray toLatin1() const { return toQStringRef().toLatin1(); } QByteArray toLatin1() const { return toQStringView().toLatin1(); }
private: private:
ProString(const ProKey &other); ProString(const ProKey &other);
@ -258,7 +257,7 @@ template <> struct QConcatenable<ProKey> : private QAbstractConcatenable
size_t qHash(const ProString &str); size_t qHash(const ProString &str);
inline QString &operator+=(QString &that, const ProString &other) inline QString &operator+=(QString &that, const ProString &other)
{ return that += other.toQStringRef(); } { return that += other.toQStringView(); }
QTextStream &operator<<(QTextStream &t, const ProString &str); QTextStream &operator<<(QTextStream &t, const ProString &str);
template<typename A, typename B> template<typename A, typename B>
@ -341,7 +340,7 @@ public:
void removeDuplicates(); void removeDuplicates();
bool contains(const ProString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; bool contains(const ProString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
bool contains(const QStringRef &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; bool contains(QStringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
bool contains(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const bool contains(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
{ return contains(ProString(str), cs); } { return contains(ProString(str), cs); }
bool contains(const char *str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; bool contains(const char *str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;

View File

@ -673,7 +673,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
bool leftalign = false; bool leftalign = false;
enum { DefaultSign, PadSign, AlwaysSign } sign = DefaultSign; enum { DefaultSign, PadSign, AlwaysSign } sign = DefaultSign;
if (args.count() >= 2) { if (args.count() >= 2) {
const auto opts = split_value_list(args.at(1).toQStringRef()); const auto opts = split_value_list(args.at(1).toQStringView());
for (const ProString &opt : opts) { for (const ProString &opt : opts) {
if (opt.startsWith(QLatin1String("ibase="))) { if (opt.startsWith(QLatin1String("ibase="))) {
ibase = opt.mid(6).toInt(); ibase = opt.mid(6).toInt();
@ -776,7 +776,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
const auto vars = values(map(args.at(0))); const auto vars = values(map(args.at(0)));
for (const ProString &var : vars) { for (const ProString &var : vars) {
// FIXME: this is inconsistent with the "there are no empty strings" dogma. // FIXME: this is inconsistent with the "there are no empty strings" dogma.
const auto splits = var.toQStringRef().split(sep, Qt::KeepEmptyParts); const auto splits = var.toQStringView().split(sep, Qt::KeepEmptyParts);
for (const auto &splt : splits) for (const auto &splt : splits)
ret << ProString(splt).setSource(var); ret << ProString(splt).setSource(var);
} }
@ -866,7 +866,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
ret += ProString(stream.readLine()); ret += ProString(stream.readLine());
} else { } else {
const QString &line = stream.readLine(); const QString &line = stream.readLine();
ret += split_value_list(QStringRef(&line).trimmed()); ret += split_value_list(QStringView(line).trimmed());
if (!singleLine) if (!singleLine)
ret += ProString("\n"); ret += ProString("\n");
} }
@ -890,7 +890,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
ret = ProStringList(ProString(tmp)); ret = ProStringList(ProString(tmp));
ProStringList lst; ProStringList lst;
for (const ProString &arg : args) for (const ProString &arg : args)
lst += split_value_list(arg.toQStringRef(), arg.sourceFile()); // Relies on deep copy lst += split_value_list(arg.toQStringView(), arg.sourceFile()); // Relies on deep copy
m_valuemapStack.top()[ret.at(0).toKey()] = lst; m_valuemapStack.top()[ret.at(0).toKey()] = lst;
break; } break; }
case E_FIND: { case E_FIND: {
@ -939,7 +939,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
output.replace(QLatin1Char('\t'), QLatin1Char(' ')); output.replace(QLatin1Char('\t'), QLatin1Char(' '));
if (singleLine) if (singleLine)
output.replace(QLatin1Char('\n'), QLatin1Char(' ')); output.replace(QLatin1Char('\n'), QLatin1Char(' '));
ret += split_value_list(QStringRef(&output)); ret += split_value_list(QStringView(output));
} }
} }
break; break;
@ -1092,7 +1092,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
evalError(fL1S("Unexpected EOF.")); evalError(fL1S("Unexpected EOF."));
return ReturnError; return ReturnError;
} }
ret = split_value_list(QStringRef(&line)); ret = split_value_list(QStringView(line));
} }
break; break;
} }
@ -1125,7 +1125,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
ProString priosfx = args.count() < 4 ? ProString(".priority") : args.at(3); ProString priosfx = args.count() < 4 ? ProString(".priority") : args.at(3);
populateDeps(orgList, prefix, populateDeps(orgList, prefix,
args.count() < 3 ? ProStringList(ProString(".depends")) args.count() < 3 ? ProStringList(ProString(".depends"))
: split_value_list(args.at(2).toQStringRef()), : split_value_list(args.at(2).toQStringView()),
priosfx, dependencies, dependees, rootSet); priosfx, dependencies, dependees, rootSet);
while (!rootSet.isEmpty()) { while (!rootSet.isEmpty()) {
QMultiMap<int, ProString>::iterator it = rootSet.begin(); QMultiMap<int, ProString>::iterator it = rootSet.begin();
@ -1283,7 +1283,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::testFunc_cache(const ProStringList &
enum { CacheSet, CacheAdd, CacheSub } mode = CacheSet; enum { CacheSet, CacheAdd, CacheSub } mode = CacheSet;
ProKey srcvar; ProKey srcvar;
if (args.count() >= 2) { if (args.count() >= 2) {
const auto opts = split_value_list(args.at(1).toQStringRef()); const auto opts = split_value_list(args.at(1).toQStringView());
for (const ProString &opt : opts) { for (const ProString &opt : opts) {
if (opt == QLatin1String("transient")) { if (opt == QLatin1String("transient")) {
persist = false; persist = false;
@ -1576,7 +1576,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
case T_EVAL: { case T_EVAL: {
VisitReturn ret = ReturnFalse; VisitReturn ret = ReturnFalse;
QString contents = args.join(statics.field_sep); QString contents = args.join(statics.field_sep);
ProFile *pro = m_parser->parsedProBlock(QStringRef(&contents), ProFile *pro = m_parser->parsedProBlock(QStringView(contents),
0, m_current.pro->fileName(), m_current.line); 0, m_current.pro->fileName(), m_current.line);
if (m_cumulative || pro->isOk()) { if (m_cumulative || pro->isOk()) {
m_locationStack.push(m_current); m_locationStack.push(m_current);
@ -1588,19 +1588,19 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
return ret; return ret;
} }
case T_IF: { case T_IF: {
return evaluateConditional(args.at(0).toQStringRef(), return evaluateConditional(args.at(0).toQStringView(),
m_current.pro->fileName(), m_current.line); m_current.pro->fileName(), m_current.line);
} }
case T_CONFIG: { case T_CONFIG: {
if (args.count() == 1) if (args.count() == 1)
return returnBool(isActiveConfig(args.at(0).toQStringRef())); return returnBool(isActiveConfig(args.at(0).toQStringView()));
const auto mutuals = args.at(1).toQStringRef().split(QLatin1Char('|'), const auto mutuals = args.at(1).toQStringView().split(QLatin1Char('|'),
Qt::SkipEmptyParts); Qt::SkipEmptyParts);
const ProStringList &configs = values(statics.strCONFIG); const ProStringList &configs = values(statics.strCONFIG);
for (int i = configs.size() - 1; i >= 0; i--) { for (int i = configs.size() - 1; i >= 0; i--) {
for (int mut = 0; mut < mutuals.count(); mut++) { for (int mut = 0; mut < mutuals.count(); mut++) {
if (configs[i].toQStringRef() == mutuals[mut].trimmed()) if (configs[i].toQStringView() == mutuals[mut].trimmed())
return returnBool(configs[i] == args[0]); return returnBool(configs[i] == args[0]);
} }
} }
@ -1631,12 +1631,12 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
} }
} }
} else { } else {
const auto mutuals = args.at(2).toQStringRef().split(QLatin1Char('|'), const auto mutuals = args.at(2).toQStringView().split(QLatin1Char('|'),
Qt::SkipEmptyParts); Qt::SkipEmptyParts);
for (int i = l.size() - 1; i >= 0; i--) { for (int i = l.size() - 1; i >= 0; i--) {
const ProString &val = l[i]; const ProString &val = l[i];
for (int mut = 0; mut < mutuals.count(); mut++) { for (int mut = 0; mut < mutuals.count(); mut++) {
if (val.toQStringRef() == mutuals[mut].trimmed()) { if (val.toQStringView() == mutuals[mut].trimmed()) {
if (val == qry) if (val == qry)
return ReturnTrue; return ReturnTrue;
if (!regx.pattern().isEmpty()) { if (!regx.pattern().isEmpty()) {
@ -1689,8 +1689,8 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
} }
} }
if (func_t == T_GREATERTHAN) if (func_t == T_GREATERTHAN)
return returnBool(lhs > rhs.toQStringRef()); return returnBool(lhs > rhs.toQStringView());
return returnBool(lhs < rhs.toQStringRef()); return returnBool(lhs < rhs.toQStringView());
} }
case T_EQUALS: case T_EQUALS:
return returnBool(values(map(args.at(0))).join(statics.field_sep) return returnBool(values(map(args.at(0))).join(statics.field_sep)
@ -1881,7 +1881,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
if (!vals.isEmpty()) if (!vals.isEmpty())
contents = vals.join(QLatin1Char('\n')) + QLatin1Char('\n'); contents = vals.join(QLatin1Char('\n')) + QLatin1Char('\n');
if (args.count() >= 3) { if (args.count() >= 3) {
const auto opts = split_value_list(args.at(2).toQStringRef()); const auto opts = split_value_list(args.at(2).toQStringView());
for (const ProString &opt : opts) { for (const ProString &opt : opts) {
if (opt == QLatin1String("append")) { if (opt == QLatin1String("append")) {
mode = QIODevice::Append; mode = QIODevice::Append;

View File

@ -272,7 +272,7 @@ void QMakeEvaluator::skipHashStr(const ushort *&tokPtr)
// FIXME: this should not build new strings for direct sections. // FIXME: this should not build new strings for direct sections.
// Note that the E_SPRINTF and E_LIST implementations rely on the deep copy. // Note that the E_SPRINTF and E_LIST implementations rely on the deep copy.
ProStringList QMakeEvaluator::split_value_list(const QStringRef &vals, int source) ProStringList QMakeEvaluator::split_value_list(QStringView vals, int source)
{ {
QString build; QString build;
ProStringList ret; ProStringList ret;
@ -653,7 +653,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProBlock(
evalError(fL1S("Conditional must expand to exactly one word.")); evalError(fL1S("Conditional must expand to exactly one word."));
okey = false; okey = false;
} else { } else {
okey = isActiveConfig(curr.at(0).toQStringRef(), true); okey = isActiveConfig(curr.at(0).toQStringView(), true);
traceMsg("condition %s is %s", dbgStr(curr.at(0)), dbgBool(okey)); traceMsg("condition %s is %s", dbgStr(curr.at(0)), dbgBool(okey));
okey ^= invert; okey ^= invert;
} }
@ -780,7 +780,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProLoop(
} }
infinite = true; infinite = true;
} else { } else {
const QStringRef &itl = it_list.toQStringRef(); QStringView itl = it_list.toQStringView();
int dotdot = itl.indexOf(statics.strDotDot); int dotdot = itl.indexOf(statics.strDotDot);
if (dotdot != -1) { if (dotdot != -1) {
bool ok; bool ok;
@ -877,7 +877,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProVariable(
ProStringList varVal; ProStringList varVal;
if (expandVariableReferences(tokPtr, sizeHint, &varVal, true) == ReturnError) if (expandVariableReferences(tokPtr, sizeHint, &varVal, true) == ReturnError)
return ReturnError; return ReturnError;
const QStringRef &val = varVal.at(0).toQStringRef(); QStringView val = varVal.at(0).toQStringView();
if (val.length() < 4 || val.at(0) != QLatin1Char('s')) { if (val.length() < 4 || val.at(0) != QLatin1Char('s')) {
evalError(fL1S("The ~= operator can handle only the s/// function.")); evalError(fL1S("The ~= operator can handle only the s/// function."));
return ReturnTrue; return ReturnTrue;
@ -1315,7 +1315,7 @@ void QMakeEvaluator::setupProject()
void QMakeEvaluator::evaluateCommand(const QString &cmds, const QString &where) void QMakeEvaluator::evaluateCommand(const QString &cmds, const QString &where)
{ {
if (!cmds.isEmpty()) { if (!cmds.isEmpty()) {
ProFile *pro = m_parser->parsedProBlock(QStringRef(&cmds), 0, where, -1); ProFile *pro = m_parser->parsedProBlock(QStringView(cmds), 0, where, -1);
if (pro->isOk()) { if (pro->isOk()) {
m_locationStack.push(m_current); m_locationStack.push(m_current);
visitProBlock(pro, pro->tokPtr()); visitProBlock(pro, pro->tokPtr());
@ -1624,7 +1624,7 @@ QString QMakeEvaluator::currentDirectory() const
return QString(); return QString();
} }
bool QMakeEvaluator::isActiveConfig(const QStringRef &config, bool regex) bool QMakeEvaluator::isActiveConfig(QStringView config, bool regex)
{ {
// magic types for easy flipping // magic types for easy flipping
if (config == statics.strtrue) if (config == statics.strtrue)
@ -1820,7 +1820,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateExpandFunction(
} }
QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateConditional( QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateConditional(
const QStringRef &cond, const QString &where, int line) QStringView cond, const QString &where, int line)
{ {
VisitReturn ret = ReturnFalse; VisitReturn ret = ReturnFalse;
ProFile *pro = m_parser->parsedProBlock(cond, 0, where, line, QMakeParser::TestGrammar); ProFile *pro = m_parser->parsedProBlock(cond, 0, where, line, QMakeParser::TestGrammar);
@ -1838,7 +1838,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::checkRequirements(const ProStringLis
{ {
ProStringList &failed = valuesRef(ProKey("QMAKE_FAILED_REQUIREMENTS")); ProStringList &failed = valuesRef(ProKey("QMAKE_FAILED_REQUIREMENTS"));
for (const ProString &dep : deps) { for (const ProString &dep : deps) {
VisitReturn vr = evaluateConditional(dep.toQStringRef(), m_current.pro->fileName(), m_current.line); VisitReturn vr = evaluateConditional(dep.toQStringView(), m_current.pro->fileName(), m_current.line);
if (vr == ReturnError) if (vr == ReturnError)
return ReturnError; return ReturnError;
if (vr != ReturnTrue) if (vr != ReturnTrue)
@ -2004,7 +2004,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateFeatureFile(
int start_root = 0; int start_root = 0;
const QStringList &paths = m_featureRoots->paths; const QStringList &paths = m_featureRoots->paths;
if (!currFn.isEmpty()) { if (!currFn.isEmpty()) {
QStringRef currPath = IoUtils::pathName(currFn); QStringView currPath = IoUtils::pathName(currFn);
for (int root = 0; root < paths.size(); ++root) for (int root = 0; root < paths.size(); ++root)
if (currPath == paths.at(root)) { if (currPath == paths.at(root)) {
start_root = root + 1; start_root = root + 1;

View File

@ -180,7 +180,7 @@ public:
void setTemplate(); void setTemplate();
ProStringList split_value_list(const QStringRef &vals, int source = 0); ProStringList split_value_list(QStringView vals, int source = 0);
VisitReturn expandVariableReferences(const ushort *&tokPtr, int sizeHint, ProStringList *ret, bool joined); VisitReturn expandVariableReferences(const ushort *&tokPtr, int sizeHint, ProStringList *ret, bool joined);
QString currentFileName() const; QString currentFileName() const;
@ -224,7 +224,7 @@ public:
VisitReturn evaluateBuiltinConditional(const QMakeInternal::QMakeBuiltin &adef, VisitReturn evaluateBuiltinConditional(const QMakeInternal::QMakeBuiltin &adef,
const ProKey &function, const ProStringList &args); const ProKey &function, const ProStringList &args);
VisitReturn evaluateConditional(const QStringRef &cond, const QString &where, int line = -1); VisitReturn evaluateConditional(QStringView cond, const QString &where, int line = -1);
#ifdef PROEVALUATOR_FULL #ifdef PROEVALUATOR_FULL
VisitReturn checkRequirements(const ProStringList &deps); VisitReturn checkRequirements(const ProStringList &deps);
#endif #endif
@ -232,7 +232,7 @@ public:
void updateMkspecPaths(); void updateMkspecPaths();
void updateFeaturePaths(); void updateFeaturePaths();
bool isActiveConfig(const QStringRef &config, bool regex = false); bool isActiveConfig(QStringView config, bool regex = false);
void populateDeps( void populateDeps(
const ProStringList &deps, const ProString &prefix, const ProStringList &suffixes, const ProStringList &deps, const ProString &prefix, const ProStringList &suffixes,

View File

@ -41,7 +41,7 @@
r == ReturnNext ? "next" : \ r == ReturnNext ? "next" : \
r == ReturnReturn ? "return" : \ r == ReturnReturn ? "return" : \
"<invalid>") "<invalid>")
# define dbgKey(s) s.toString().toQStringRef().toLocal8Bit().constData() # define dbgKey(s) s.toString().toQStringView().toLocal8Bit().constData()
# define dbgStr(s) qPrintable(formatValue(s, true)) # define dbgStr(s) qPrintable(formatValue(s, true))
# define dbgStrList(s) qPrintable(formatValueList(s)) # define dbgStrList(s) qPrintable(formatValueList(s))
# define dbgSepStrList(s) qPrintable(formatValueList(s, true)) # define dbgSepStrList(s) qPrintable(formatValueList(s, true))

View File

@ -217,7 +217,7 @@ ProFile *QMakeParser::parsedProFile(const QString &fileName, ParseFlags flags)
#endif #endif
QString contents; QString contents;
if (readFile(id, flags, &contents)) { if (readFile(id, flags, &contents)) {
pro = parsedProBlock(QStringRef(&contents), id, fileName, 1, FullGrammar); pro = parsedProBlock(QStringView(contents), id, fileName, 1, FullGrammar);
pro->itemsRef()->squeeze(); pro->itemsRef()->squeeze();
pro->ref(); pro->ref();
} else { } else {
@ -238,7 +238,7 @@ ProFile *QMakeParser::parsedProFile(const QString &fileName, ParseFlags flags)
} else { } else {
QString contents; QString contents;
if (readFile(id, flags, &contents)) if (readFile(id, flags, &contents))
pro = parsedProBlock(QStringRef(&contents), id, fileName, 1, FullGrammar); pro = parsedProBlock(QStringView(contents), id, fileName, 1, FullGrammar);
else else
pro = nullptr; pro = nullptr;
} }
@ -246,7 +246,7 @@ ProFile *QMakeParser::parsedProFile(const QString &fileName, ParseFlags flags)
} }
ProFile *QMakeParser::parsedProBlock( ProFile *QMakeParser::parsedProBlock(
const QStringRef &contents, int id, const QString &name, int line, SubGrammar grammar) QStringView contents, int id, const QString &name, int line, SubGrammar grammar)
{ {
ProFile *pro = new ProFile(id, name); ProFile *pro = new ProFile(id, name);
read(pro, contents, line, grammar); read(pro, contents, line, grammar);
@ -310,7 +310,7 @@ void QMakeParser::finalizeHashStr(ushort *buf, uint len)
buf[-2] = (ushort)(hash >> 16); buf[-2] = (ushort)(hash >> 16);
} }
void QMakeParser::read(ProFile *pro, const QStringRef &in, int line, SubGrammar grammar) void QMakeParser::read(ProFile *pro, QStringView in, int line, SubGrammar grammar)
{ {
m_proFile = pro; m_proFile = pro;
m_lineNo = line; m_lineNo = line;
@ -358,7 +358,7 @@ void QMakeParser::read(ProFile *pro, const QStringRef &in, int line, SubGrammar
QStack<ParseCtx> xprStack; QStack<ParseCtx> xprStack;
xprStack.reserve(10); xprStack.reserve(10);
const ushort *cur = (const ushort *)in.unicode(); const ushort *cur = (const ushort *)in.data();
const ushort *inend = cur + in.length(); const ushort *inend = cur + in.length();
m_canElse = false; m_canElse = false;
freshLine: freshLine:
@ -1260,7 +1260,7 @@ void QMakeParser::finalizeCall(ushort *&tokPtr, ushort *uc, ushort *ptr, int arg
bool QMakeParser::resolveVariable(ushort *xprPtr, int tlen, int needSep, ushort **ptr, bool QMakeParser::resolveVariable(ushort *xprPtr, int tlen, int needSep, ushort **ptr,
ushort **buf, QString *xprBuff, ushort **buf, QString *xprBuff,
ushort **tokPtr, QString *tokBuff, ushort **tokPtr, QString *tokBuff,
const ushort *cur, const QStringRef &in) const ushort *cur, QStringView in)
{ {
QString out; QString out;
m_tmp.setRawData((const QChar *)xprPtr, tlen); m_tmp.setRawData((const QChar *)xprPtr, tlen);

View File

@ -93,7 +93,7 @@ public:
enum SubGrammar { FullGrammar, TestGrammar, ValueGrammar }; enum SubGrammar { FullGrammar, TestGrammar, ValueGrammar };
// fileName is expected to be absolute and cleanPath()ed. // fileName is expected to be absolute and cleanPath()ed.
ProFile *parsedProFile(const QString &fileName, ParseFlags flags = ParseDefault); ProFile *parsedProFile(const QString &fileName, ParseFlags flags = ParseDefault);
ProFile *parsedProBlock(const QStringRef &contents, int id, const QString &name, int line = 0, ProFile *parsedProBlock(QStringView contents, int id, const QString &name, int line = 0,
SubGrammar grammar = FullGrammar); SubGrammar grammar = FullGrammar);
void discardFileFromCache(int id); void discardFileFromCache(int id);
@ -135,7 +135,7 @@ private:
}; };
bool readFile(int id, QMakeParser::ParseFlags flags, QString *contents); bool readFile(int id, QMakeParser::ParseFlags flags, QString *contents);
void read(ProFile *pro, const QStringRef &content, int line, SubGrammar grammar); void read(ProFile *pro, QStringView content, int line, SubGrammar grammar);
ALWAYS_INLINE void putTok(ushort *&tokPtr, ushort tok); ALWAYS_INLINE void putTok(ushort *&tokPtr, ushort tok);
ALWAYS_INLINE void putBlockLen(ushort *&tokPtr, uint len); ALWAYS_INLINE void putBlockLen(ushort *&tokPtr, uint len);
@ -146,7 +146,7 @@ private:
ALWAYS_INLINE bool resolveVariable(ushort *xprPtr, int tlen, int needSep, ushort **ptr, ALWAYS_INLINE bool resolveVariable(ushort *xprPtr, int tlen, int needSep, ushort **ptr,
ushort **buf, QString *xprBuff, ushort **buf, QString *xprBuff,
ushort **tokPtr, QString *tokBuff, ushort **tokPtr, QString *tokBuff,
const ushort *cur, const QStringRef &in); const ushort *cur, QStringView in);
void finalizeCond(ushort *&tokPtr, ushort *uc, ushort *ptr, int wordCount); void finalizeCond(ushort *&tokPtr, ushort *uc, ushort *ptr, int wordCount);
void finalizeCall(ushort *&tokPtr, ushort *uc, ushort *ptr, int argc); void finalizeCall(ushort *&tokPtr, ushort *uc, ushort *ptr, int argc);
void warnOperator(const char *msg); void warnOperator(const char *msg);

View File

@ -125,7 +125,7 @@ QStringList QMakeProject::expand(const ProKey &func, const QList<ProStringList>
ProString QMakeProject::expand(const QString &expr, const QString &where, int line) ProString QMakeProject::expand(const QString &expr, const QString &where, int line)
{ {
ProString ret; ProString ret;
ProFile *pro = m_parser->parsedProBlock(QStringRef(&expr), 0, where, line, ProFile *pro = m_parser->parsedProBlock(QStringView(expr), 0, where, line,
QMakeParser::ValueGrammar); QMakeParser::ValueGrammar);
if (pro->isOk()) { if (pro->isOk()) {
m_current.pro = pro; m_current.pro = pro;

View File

@ -55,7 +55,7 @@ public:
ProString expand(const QString &v, const QString &file, int line); ProString expand(const QString &v, const QString &file, int line);
QStringList expand(const ProKey &func, const QList<ProStringList> &args); QStringList expand(const ProKey &func, const QList<ProStringList> &args);
bool test(const QString &v, const QString &file, int line) bool test(const QString &v, const QString &file, int line)
{ m_current.clear(); return evaluateConditional(QStringRef(&v), file, line) == ReturnTrue; } { m_current.clear(); return evaluateConditional(QStringView(v), file, line) == ReturnTrue; }
bool test(const ProKey &func, const QList<ProStringList> &args); bool test(const ProKey &func, const QList<ProStringList> &args);
bool isSet(const ProKey &v) const { return m_valuemapStack.front().contains(v); } bool isSet(const ProKey &v) const { return m_valuemapStack.front().contains(v); }
@ -65,7 +65,7 @@ public:
const ProValueMap &variables() const { return m_valuemapStack.front(); } const ProValueMap &variables() const { return m_valuemapStack.front(); }
ProValueMap &variables() { return m_valuemapStack.front(); } ProValueMap &variables() { return m_valuemapStack.front(); }
bool isActiveConfig(const QString &config, bool regex = false) bool isActiveConfig(const QString &config, bool regex = false)
{ return QMakeEvaluator::isActiveConfig(QStringRef(&config), regex); } { return QMakeEvaluator::isActiveConfig(QStringView(config), regex); }
void dump() const; void dump() const;

View File

@ -40,8 +40,8 @@ public:
TokenStream &operator<<(ushort n) { ts += QChar(n); return *this; } TokenStream &operator<<(ushort n) { ts += QChar(n); return *this; }
TokenStream &operator<<(uint n) { ts += QChar(n & 0xffff); ts += QChar(n >> 16); return *this; } TokenStream &operator<<(uint n) { ts += QChar(n & 0xffff); ts += QChar(n >> 16); return *this; }
TokenStream &operator<<(const QStringRef &s) { ts += s; return *this; } TokenStream &operator<<(QStringView s) { ts += s; return *this; }
TokenStream &operator<<(const ProString &s) { return *this << ushort(s.length()) << s.toQStringRef(); } TokenStream &operator<<(const ProString &s) { return *this << ushort(s.length()) << s.toQStringView(); }
TokenStream &operator<<(const ProKey &s) { return *this << s.hash() << s.toString(); } TokenStream &operator<<(const ProKey &s) { return *this << s.hash() << s.toString(); }
private: private:

View File

@ -76,10 +76,8 @@ void tst_qmakelib::proString()
QCOMPARE(ProString(qs2, 3, 13).trimmed().toQString(), QStringLiteral("spacy string")); QCOMPARE(ProString(qs2, 3, 13).trimmed().toQString(), QStringLiteral("spacy string"));
QCOMPARE(ProString(qs2, 1, 17).trimmed().toQString(), QStringLiteral("spacy string")); QCOMPARE(ProString(qs2, 1, 17).trimmed().toQString(), QStringLiteral("spacy string"));
QVERIFY(s2.toQStringRef().string()->isSharedWith(qs1));
s2.prepend(ProString("there ")); s2.prepend(ProString("there "));
QCOMPARE(s2.toQString(), QStringLiteral("there is a str")); QCOMPARE(s2.toQString(), QStringLiteral("there is a str"));
QVERIFY(!s2.toQStringRef().string()->isSharedWith(qs1));
ProString s3("this is a longish string with bells and whistles"); ProString s3("this is a longish string with bells and whistles");
s3 = s3.mid(18, 17); s3 = s3.mid(18, 17);
@ -129,7 +127,6 @@ void tst_qmakelib::proString()
ProString s5; ProString s5;
s5.append(sl2); s5.append(sl2);
QCOMPARE(s5.toQString(), QStringLiteral("foo")); QCOMPARE(s5.toQString(), QStringLiteral("foo"));
QVERIFY(s5.toQStringRef().string()->isSharedWith(*sl2.first().toQStringRef().string()));
QCOMPARE(ProString("one") + ProString(" more"), QStringLiteral("one more")); QCOMPARE(ProString("one") + ProString(" more"), QStringLiteral("one more"));
} }