Port QtDeclarative from QStringRef to QStringView
Task-number: QTBUG-84319 Change-Id: I2dcfb8a2db98282c7a1acdad1e6f4f949f26df15 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
parent
b65eee0390
commit
1b10ce6a08
|
@ -257,7 +257,7 @@ void QWavefrontMesh::readData()
|
||||||
|
|
||||||
while (!stream.atEnd()) {
|
while (!stream.atEnd()) {
|
||||||
stream.readLineInto(&buffer);
|
stream.readLineInto(&buffer);
|
||||||
QVector<QStringRef> tokens = buffer.splitRef(space, Qt::SkipEmptyParts);
|
auto tokens = QStringView{buffer}.split(space, Qt::SkipEmptyParts);
|
||||||
if (tokens.size() < 2)
|
if (tokens.size() < 2)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -316,7 +316,7 @@ void QWavefrontMesh::readData()
|
||||||
if (tokens.size() >= 4 && tokens.size() <= 5) {
|
if (tokens.size() >= 4 && tokens.size() <= 5) {
|
||||||
{
|
{
|
||||||
bool ok;
|
bool ok;
|
||||||
QVector<QStringRef> faceTokens = tokens.at(1).split(slash, Qt::SkipEmptyParts);
|
auto faceTokens = tokens.at(1).split(slash, Qt::SkipEmptyParts);
|
||||||
Q_ASSERT(!faceTokens.isEmpty());
|
Q_ASSERT(!faceTokens.isEmpty());
|
||||||
|
|
||||||
p1 = faceTokens.at(0).toInt(&ok) - 1;
|
p1 = faceTokens.at(0).toInt(&ok) - 1;
|
||||||
|
@ -336,7 +336,7 @@ void QWavefrontMesh::readData()
|
||||||
|
|
||||||
{
|
{
|
||||||
bool ok;
|
bool ok;
|
||||||
QVector<QStringRef> faceTokens = tokens.at(2).split(slash, Qt::SkipEmptyParts);
|
auto faceTokens = tokens.at(2).split(slash, Qt::SkipEmptyParts);
|
||||||
Q_ASSERT(!faceTokens.isEmpty());
|
Q_ASSERT(!faceTokens.isEmpty());
|
||||||
|
|
||||||
p2 = faceTokens.at(0).toInt(&ok) - 1;
|
p2 = faceTokens.at(0).toInt(&ok) - 1;
|
||||||
|
@ -356,7 +356,7 @@ void QWavefrontMesh::readData()
|
||||||
|
|
||||||
{
|
{
|
||||||
bool ok;
|
bool ok;
|
||||||
QVector<QStringRef> faceTokens = tokens.at(3).split(slash, Qt::SkipEmptyParts);
|
auto faceTokens = tokens.at(3).split(slash, Qt::SkipEmptyParts);
|
||||||
Q_ASSERT(!faceTokens.isEmpty());
|
Q_ASSERT(!faceTokens.isEmpty());
|
||||||
|
|
||||||
p3 = faceTokens.at(0).toInt(&ok) - 1;
|
p3 = faceTokens.at(0).toInt(&ok) - 1;
|
||||||
|
@ -394,7 +394,7 @@ void QWavefrontMesh::readData()
|
||||||
|
|
||||||
if (tokens.size() == 5) {
|
if (tokens.size() == 5) {
|
||||||
bool ok;
|
bool ok;
|
||||||
QVector<QStringRef> faceTokens = tokens.at(4).split(slash, Qt::SkipEmptyParts);
|
auto faceTokens = tokens.at(4).split(slash, Qt::SkipEmptyParts);
|
||||||
Q_ASSERT(!faceTokens.isEmpty());
|
Q_ASSERT(!faceTokens.isEmpty());
|
||||||
|
|
||||||
int p4 = faceTokens.at(0).toInt(&ok) - 1;
|
int p4 = faceTokens.at(0).toInt(&ok) - 1;
|
||||||
|
|
|
@ -722,7 +722,7 @@ bool QQmlEngineDebugServiceImpl::resetBinding(int objectId, const QString &prope
|
||||||
QQmlContext *context = qmlContext(object);
|
QQmlContext *context = qmlContext(object);
|
||||||
|
|
||||||
if (object && context && context->isValid()) {
|
if (object && context && context->isValid()) {
|
||||||
QStringRef parentPropertyRef(&propertyName);
|
QStringView parentPropertyRef(propertyName);
|
||||||
const int idx = parentPropertyRef.indexOf(QLatin1Char('.'));
|
const int idx = parentPropertyRef.indexOf(QLatin1Char('.'));
|
||||||
if (idx != -1)
|
if (idx != -1)
|
||||||
parentPropertyRef = parentPropertyRef.left(idx);
|
parentPropertyRef = parentPropertyRef.left(idx);
|
||||||
|
|
|
@ -183,9 +183,9 @@ QQmlNativeDebugConnector::QQmlNativeDebugConnector()
|
||||||
: m_blockingMode(false)
|
: m_blockingMode(false)
|
||||||
{
|
{
|
||||||
const QString args = commandLineArguments();
|
const QString args = commandLineArguments();
|
||||||
const auto lstjsDebugArguments = args.splitRef(QLatin1Char(','), Qt::SkipEmptyParts);
|
const auto lstjsDebugArguments = QStringView{args}.split(QLatin1Char(','), Qt::SkipEmptyParts);
|
||||||
QStringList services;
|
QStringList services;
|
||||||
for (const QStringRef &strArgument : lstjsDebugArguments) {
|
for (const QStringView &strArgument : lstjsDebugArguments) {
|
||||||
if (strArgument == QLatin1String("block")) {
|
if (strArgument == QLatin1String("block")) {
|
||||||
m_blockingMode = true;
|
m_blockingMode = true;
|
||||||
} else if (strArgument == QLatin1String("native")) {
|
} else if (strArgument == QLatin1String("native")) {
|
||||||
|
|
|
@ -345,9 +345,9 @@ void QQmlDebugServerImpl::parseArguments()
|
||||||
QString fileName;
|
QString fileName;
|
||||||
QStringList services;
|
QStringList services;
|
||||||
|
|
||||||
const auto lstjsDebugArguments = args.splitRef(QLatin1Char(','), Qt::SkipEmptyParts);
|
const auto lstjsDebugArguments = QStringView{args}.split(QLatin1Char(','), Qt::SkipEmptyParts);
|
||||||
for (auto argsIt = lstjsDebugArguments.begin(), argsItEnd = lstjsDebugArguments.end(); argsIt != argsItEnd; ++argsIt) {
|
for (auto argsIt = lstjsDebugArguments.begin(), argsItEnd = lstjsDebugArguments.end(); argsIt != argsItEnd; ++argsIt) {
|
||||||
const QStringRef &strArgument = *argsIt;
|
const QStringView &strArgument = *argsIt;
|
||||||
if (strArgument.startsWith(QLatin1String("port:"))) {
|
if (strArgument.startsWith(QLatin1String("port:"))) {
|
||||||
portFrom = strArgument.mid(5).toInt(&ok);
|
portFrom = strArgument.mid(5).toInt(&ok);
|
||||||
portTo = portFrom;
|
portTo = portFrom;
|
||||||
|
|
|
@ -105,9 +105,9 @@ public:
|
||||||
template <typename Tp, typename... Ta> Tp *New(Ta... args)
|
template <typename Tp, typename... Ta> Tp *New(Ta... args)
|
||||||
{ return new (this->allocate(sizeof(Tp))) Tp(args...); }
|
{ return new (this->allocate(sizeof(Tp))) Tp(args...); }
|
||||||
|
|
||||||
QStringRef newString(const QString &string) {
|
QStringView newString(const QString &string) {
|
||||||
strings.append(new QString(string));
|
strings.append(new QString(string));
|
||||||
return QStringRef(strings.last());
|
return QStringView(*strings.last());
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -407,7 +407,7 @@ void ScriptDirectivesCollector::importModule(const QString &uri, const QString &
|
||||||
QV4::CompiledData::Import *import = engine->pool()->New<QV4::CompiledData::Import>();
|
QV4::CompiledData::Import *import = engine->pool()->New<QV4::CompiledData::Import>();
|
||||||
import->type = QV4::CompiledData::Import::ImportLibrary;
|
import->type = QV4::CompiledData::Import::ImportLibrary;
|
||||||
import->uriIndex = jsGenerator->registerString(uri);
|
import->uriIndex = jsGenerator->registerString(uri);
|
||||||
import->version = IRBuilder::extractVersion(QStringRef(&version));
|
import->version = IRBuilder::extractVersion(QStringView(version));
|
||||||
import->qualifierIndex = jsGenerator->registerString(module);
|
import->qualifierIndex = jsGenerator->registerString(module);
|
||||||
import->location.line = lineNumber;
|
import->location.line = lineNumber;
|
||||||
import->location.column = column;
|
import->location.column = column;
|
||||||
|
@ -526,7 +526,7 @@ bool IRBuilder::visit(QQmlJS::AST::UiObjectDefinition *node)
|
||||||
QQmlJS::AST::UiQualifiedId *lastId = node->qualifiedTypeNameId;
|
QQmlJS::AST::UiQualifiedId *lastId = node->qualifiedTypeNameId;
|
||||||
while (lastId->next)
|
while (lastId->next)
|
||||||
lastId = lastId->next;
|
lastId = lastId->next;
|
||||||
bool isType = lastId->name.unicode()->isUpper();
|
bool isType = lastId->name.data()->isUpper();
|
||||||
if (isType) {
|
if (isType) {
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
if (!defineQMLObject(&idx, node))
|
if (!defineQMLObject(&idx, node))
|
||||||
|
@ -915,7 +915,7 @@ bool IRBuilder::visit(QQmlJS::AST::UiPublicMember *node)
|
||||||
if (memberType == QLatin1String("alias")) {
|
if (memberType == QLatin1String("alias")) {
|
||||||
return appendAlias(node);
|
return appendAlias(node);
|
||||||
} else {
|
} else {
|
||||||
const QStringRef &name = node->name;
|
const QStringView &name = node->name;
|
||||||
|
|
||||||
Property *property = New<Property>();
|
Property *property = New<Property>();
|
||||||
property->isReadOnly = node->isReadonlyMember;
|
property->isReadOnly = node->isReadonlyMember;
|
||||||
|
@ -927,7 +927,7 @@ bool IRBuilder::visit(QQmlJS::AST::UiPublicMember *node)
|
||||||
property->setBuiltinType(builtinPropertyType);
|
property->setBuiltinType(builtinPropertyType);
|
||||||
|
|
||||||
if (!typeFound && memberType.at(0).isUpper()) {
|
if (!typeFound && memberType.at(0).isUpper()) {
|
||||||
const QStringRef &typeModifier = node->typeModifier;
|
const QStringView &typeModifier = node->typeModifier;
|
||||||
|
|
||||||
property->setCustomType(registerString(memberType));
|
property->setCustomType(registerString(memberType));
|
||||||
if (typeModifier == QLatin1String("list")) {
|
if (typeModifier == QLatin1String("list")) {
|
||||||
|
@ -1043,15 +1043,15 @@ QString IRBuilder::asString(QQmlJS::AST::UiQualifiedId *node)
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringRef IRBuilder::asStringRef(QQmlJS::AST::Node *node)
|
QStringView IRBuilder::asStringRef(QQmlJS::AST::Node *node)
|
||||||
{
|
{
|
||||||
if (!node)
|
if (!node)
|
||||||
return QStringRef();
|
return QStringView();
|
||||||
|
|
||||||
return textRefAt(node->firstSourceLocation(), node->lastSourceLocation());
|
return textRefAt(node->firstSourceLocation(), node->lastSourceLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
QTypeRevision IRBuilder::extractVersion(const QStringRef &string)
|
QTypeRevision IRBuilder::extractVersion(QStringView string)
|
||||||
{
|
{
|
||||||
if (string.isEmpty())
|
if (string.isEmpty())
|
||||||
return QTypeRevision();
|
return QTypeRevision();
|
||||||
|
@ -1062,9 +1062,9 @@ QTypeRevision IRBuilder::extractVersion(const QStringRef &string)
|
||||||
: QTypeRevision::fromVersion(string.left(dot).toInt(), string.mid(dot + 1).toInt());
|
: QTypeRevision::fromVersion(string.left(dot).toInt(), string.mid(dot + 1).toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringRef IRBuilder::textRefAt(const QQmlJS::SourceLocation &first, const QQmlJS::SourceLocation &last) const
|
QStringView IRBuilder::textRefAt(const QQmlJS::SourceLocation &first, const QQmlJS::SourceLocation &last) const
|
||||||
{
|
{
|
||||||
return QStringRef(&sourceCode, first.offset, last.offset + last.length - first.offset);
|
return QStringView(sourceCode).mid(first.offset, last.offset + last.length - first.offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRBuilder::setBindingValue(QV4::CompiledData::Binding *binding, QQmlJS::AST::Statement *statement, QQmlJS::AST::Node *parentNode)
|
void IRBuilder::setBindingValue(QV4::CompiledData::Binding *binding, QQmlJS::AST::Statement *statement, QQmlJS::AST::Node *parentNode)
|
||||||
|
@ -1127,7 +1127,7 @@ void IRBuilder::setBindingValue(QV4::CompiledData::Binding *binding, QQmlJS::AST
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRBuilder::tryGeneratingTranslationBinding(const QStringRef &base, AST::ArgumentList *args, QV4::CompiledData::Binding *binding)
|
void IRBuilder::tryGeneratingTranslationBinding(QStringView base, AST::ArgumentList *args, QV4::CompiledData::Binding *binding)
|
||||||
{
|
{
|
||||||
if (base == QLatin1String("qsTr")) {
|
if (base == QLatin1String("qsTr")) {
|
||||||
QV4::CompiledData::TranslationData translationData;
|
QV4::CompiledData::TranslationData translationData;
|
||||||
|
@ -1138,7 +1138,7 @@ void IRBuilder::tryGeneratingTranslationBinding(const QStringRef &base, AST::Arg
|
||||||
if (!args || !args->expression)
|
if (!args || !args->expression)
|
||||||
return; // no arguments, stop
|
return; // no arguments, stop
|
||||||
|
|
||||||
QStringRef translation;
|
QStringView translation;
|
||||||
if (QQmlJS::AST::StringLiteral *arg1 = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(args->expression)) {
|
if (QQmlJS::AST::StringLiteral *arg1 = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(args->expression)) {
|
||||||
translation = arg1->value;
|
translation = arg1->value;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1179,7 +1179,7 @@ void IRBuilder::tryGeneratingTranslationBinding(const QStringRef &base, AST::Arg
|
||||||
if (!args || !args->expression)
|
if (!args || !args->expression)
|
||||||
return; // no arguments, stop
|
return; // no arguments, stop
|
||||||
|
|
||||||
QStringRef id;
|
QStringView id;
|
||||||
if (QQmlJS::AST::StringLiteral *arg1 = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(args->expression)) {
|
if (QQmlJS::AST::StringLiteral *arg1 = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(args->expression)) {
|
||||||
id = arg1->value;
|
id = arg1->value;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1207,7 +1207,7 @@ void IRBuilder::tryGeneratingTranslationBinding(const QStringRef &base, AST::Arg
|
||||||
if (!args || !args->expression)
|
if (!args || !args->expression)
|
||||||
return; // no arguments, stop
|
return; // no arguments, stop
|
||||||
|
|
||||||
QStringRef str;
|
QStringView str;
|
||||||
if (QQmlJS::AST::StringLiteral *arg1 = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(args->expression)) {
|
if (QQmlJS::AST::StringLiteral *arg1 = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(args->expression)) {
|
||||||
str = arg1->value;
|
str = arg1->value;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1228,7 +1228,7 @@ void IRBuilder::tryGeneratingTranslationBinding(const QStringRef &base, AST::Arg
|
||||||
if (!args || !args->expression)
|
if (!args || !args->expression)
|
||||||
return; // no second arguments, stop
|
return; // no second arguments, stop
|
||||||
|
|
||||||
QStringRef str;
|
QStringView str;
|
||||||
if (QQmlJS::AST::StringLiteral *arg2 = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(args->expression)) {
|
if (QQmlJS::AST::StringLiteral *arg2 = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(args->expression)) {
|
||||||
str = arg2->value;
|
str = arg2->value;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1408,7 +1408,7 @@ Object *IRBuilder::bindingsTarget() const
|
||||||
bool IRBuilder::setId(const QQmlJS::SourceLocation &idLocation, QQmlJS::AST::Statement *value)
|
bool IRBuilder::setId(const QQmlJS::SourceLocation &idLocation, QQmlJS::AST::Statement *value)
|
||||||
{
|
{
|
||||||
QQmlJS::SourceLocation loc = value->firstSourceLocation();
|
QQmlJS::SourceLocation loc = value->firstSourceLocation();
|
||||||
QStringRef str;
|
QStringView str;
|
||||||
|
|
||||||
QQmlJS::AST::Node *node = value;
|
QQmlJS::AST::Node *node = value;
|
||||||
if (QQmlJS::AST::ExpressionStatement *stmt = QQmlJS::AST::cast<QQmlJS::AST::ExpressionStatement *>(node)) {
|
if (QQmlJS::AST::ExpressionStatement *stmt = QQmlJS::AST::cast<QQmlJS::AST::ExpressionStatement *>(node)) {
|
||||||
|
@ -1433,7 +1433,7 @@ bool IRBuilder::setId(const QQmlJS::SourceLocation &idLocation, QQmlJS::AST::Sta
|
||||||
if (!ch.isLetter() && ch != u)
|
if (!ch.isLetter() && ch != u)
|
||||||
COMPILE_EXCEPTION(loc, tr( "IDs must start with a letter or underscore"));
|
COMPILE_EXCEPTION(loc, tr( "IDs must start with a letter or underscore"));
|
||||||
|
|
||||||
for (int ii = 1; ii < str.count(); ++ii) {
|
for (int ii = 1; ii < str.size(); ++ii) {
|
||||||
ch = str.at(ii);
|
ch = str.at(ii);
|
||||||
if (!ch.isLetterOrNumber() && ch != u)
|
if (!ch.isLetterOrNumber() && ch != u)
|
||||||
COMPILE_EXCEPTION(loc, tr( "IDs must contain only letters, numbers, and underscores"));
|
COMPILE_EXCEPTION(loc, tr( "IDs must contain only letters, numbers, and underscores"));
|
||||||
|
@ -1469,7 +1469,7 @@ bool IRBuilder::resolveQualifiedId(QQmlJS::AST::UiQualifiedId **nameToResolve, O
|
||||||
qualifiedIdElement = qualifiedIdElement->next;
|
qualifiedIdElement = qualifiedIdElement->next;
|
||||||
currentName += QLatin1Char('.') + qualifiedIdElement->name;
|
currentName += QLatin1Char('.') + qualifiedIdElement->name;
|
||||||
|
|
||||||
if (!qualifiedIdElement->name.unicode()->isUpper())
|
if (!qualifiedIdElement->name.data()->isUpper())
|
||||||
COMPILE_EXCEPTION(qualifiedIdElement->firstSourceLocation(), tr("Expected type name"));
|
COMPILE_EXCEPTION(qualifiedIdElement->firstSourceLocation(), tr("Expected type name"));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -1479,7 +1479,7 @@ bool IRBuilder::resolveQualifiedId(QQmlJS::AST::UiQualifiedId **nameToResolve, O
|
||||||
*object = _object;
|
*object = _object;
|
||||||
while (qualifiedIdElement->next) {
|
while (qualifiedIdElement->next) {
|
||||||
const quint32 propertyNameIndex = registerString(currentName);
|
const quint32 propertyNameIndex = registerString(currentName);
|
||||||
const bool isAttachedProperty = qualifiedIdElement->name.unicode()->isUpper();
|
const bool isAttachedProperty = qualifiedIdElement->name.data()->isUpper();
|
||||||
|
|
||||||
Binding *binding = (*object)->findBinding(propertyNameIndex);
|
Binding *binding = (*object)->findBinding(propertyNameIndex);
|
||||||
if (binding) {
|
if (binding) {
|
||||||
|
|
|
@ -497,16 +497,16 @@ public:
|
||||||
{ return defineQMLObject(objectIndex, node->qualifiedTypeNameId, node->qualifiedTypeNameId->firstSourceLocation(), node->initializer, declarationsOverride); }
|
{ return defineQMLObject(objectIndex, node->qualifiedTypeNameId, node->qualifiedTypeNameId->firstSourceLocation(), node->initializer, declarationsOverride); }
|
||||||
|
|
||||||
static QString asString(QQmlJS::AST::UiQualifiedId *node);
|
static QString asString(QQmlJS::AST::UiQualifiedId *node);
|
||||||
QStringRef asStringRef(QQmlJS::AST::Node *node);
|
QStringView asStringRef(QQmlJS::AST::Node *node);
|
||||||
static QTypeRevision extractVersion(const QStringRef &string);
|
static QTypeRevision extractVersion(QStringView string);
|
||||||
QStringRef textRefAt(const QQmlJS::SourceLocation &loc) const
|
QStringView textRefAt(const QQmlJS::SourceLocation &loc) const
|
||||||
{ return QStringRef(&sourceCode, loc.offset, loc.length); }
|
{ return QStringView(sourceCode).mid(loc.offset, loc.length); }
|
||||||
QStringRef textRefAt(const QQmlJS::SourceLocation &first,
|
QStringView textRefAt(const QQmlJS::SourceLocation &first,
|
||||||
const QQmlJS::SourceLocation &last) const;
|
const QQmlJS::SourceLocation &last) const;
|
||||||
|
|
||||||
void setBindingValue(QV4::CompiledData::Binding *binding, QQmlJS::AST::Statement *statement,
|
void setBindingValue(QV4::CompiledData::Binding *binding, QQmlJS::AST::Statement *statement,
|
||||||
QQmlJS::AST::Node *parentNode);
|
QQmlJS::AST::Node *parentNode);
|
||||||
void tryGeneratingTranslationBinding(const QStringRef &base, QQmlJS::AST::ArgumentList *args, QV4::CompiledData::Binding *binding);
|
void tryGeneratingTranslationBinding(QStringView base, QQmlJS::AST::ArgumentList *args, QV4::CompiledData::Binding *binding);
|
||||||
|
|
||||||
void appendBinding(QQmlJS::AST::UiQualifiedId *name, QQmlJS::AST::Statement *value,
|
void appendBinding(QQmlJS::AST::UiQualifiedId *name, QQmlJS::AST::Statement *value,
|
||||||
QQmlJS::AST::Node *parentNode);
|
QQmlJS::AST::Node *parentNode);
|
||||||
|
|
|
@ -3969,14 +3969,14 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void collectIdentifiers(QVector<QStringView> &ids, AST::Node *node) {
|
void collectIdentifiers(QList<QStringView> &ids, AST::Node *node) {
|
||||||
class Collector: public QQmlJS::AST::Visitor {
|
class Collector: public QQmlJS::AST::Visitor {
|
||||||
private:
|
private:
|
||||||
QVector<QStringView> &ids;
|
QList<QStringView> &ids;
|
||||||
VolatileMemoryLocationScanner *parent;
|
VolatileMemoryLocationScanner *parent;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Collector(QVector<QStringView> &ids, VolatileMemoryLocationScanner *parent) :
|
Collector(QList<QStringView> &ids, VolatileMemoryLocationScanner *parent) :
|
||||||
QQmlJS::AST::Visitor(parent->recursionDepth()), ids(ids), parent(parent)
|
QQmlJS::AST::Visitor(parent->recursionDepth()), ids(ids), parent(parent)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
|
@ -105,15 +105,15 @@ public:
|
||||||
class VolatileMemoryLocations {
|
class VolatileMemoryLocations {
|
||||||
friend VolatileMemoryLocationScanner;
|
friend VolatileMemoryLocationScanner;
|
||||||
bool allVolatile = false;
|
bool allVolatile = false;
|
||||||
QVector<QStringView> specificLocations;
|
QList<QStringView> specificLocations;
|
||||||
public:
|
public:
|
||||||
bool isVolatile(const QStringView &name) {
|
bool isVolatile(QStringView name) {
|
||||||
if (allVolatile)
|
if (allVolatile)
|
||||||
return true;
|
return true;
|
||||||
return specificLocations.contains(name);
|
return specificLocations.contains(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void add(const QStringRef &name) { if (!allVolatile) specificLocations.append(name); }
|
void add(QStringView name) { if (!allVolatile) specificLocations.append(name); }
|
||||||
void setAllVolatile() { allVolatile = true; }
|
void setAllVolatile() { allVolatile = true; }
|
||||||
};
|
};
|
||||||
class RValue {
|
class RValue {
|
||||||
|
|
|
@ -115,7 +115,7 @@ void ScanFunctions::checkDirectivePrologue(StatementList *ast)
|
||||||
// allowed.
|
// allowed.
|
||||||
if (strLit->literalToken.length < 2)
|
if (strLit->literalToken.length < 2)
|
||||||
continue;
|
continue;
|
||||||
QStringRef str = _sourceCode.midRef(strLit->literalToken.offset + 1, strLit->literalToken.length - 2);
|
QStringView str = QStringView{_sourceCode}.mid(strLit->literalToken.offset + 1, strLit->literalToken.length - 2);
|
||||||
if (str == QLatin1String("use strict")) {
|
if (str == QLatin1String("use strict")) {
|
||||||
_context->isStrict = true;
|
_context->isStrict = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -129,7 +129,7 @@ void ScanFunctions::checkDirectivePrologue(StatementList *ast)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScanFunctions::checkName(const QStringRef &name, const QQmlJS::SourceLocation &loc)
|
void ScanFunctions::checkName(QStringView name, const QQmlJS::SourceLocation &loc)
|
||||||
{
|
{
|
||||||
if (_context->isStrict) {
|
if (_context->isStrict) {
|
||||||
if (name == QLatin1String("implements")
|
if (name == QLatin1String("implements")
|
||||||
|
@ -337,7 +337,7 @@ bool ScanFunctions::visit(PatternElement *ast)
|
||||||
for (const auto &name : qAsConst(names)) {
|
for (const auto &name : qAsConst(names)) {
|
||||||
if (_context->isStrict && (name.id == QLatin1String("eval") || name.id == QLatin1String("arguments")))
|
if (_context->isStrict && (name.id == QLatin1String("eval") || name.id == QLatin1String("arguments")))
|
||||||
_cg->throwSyntaxError(ast->identifierToken, QStringLiteral("Variable name may not be eval or arguments in strict mode"));
|
_cg->throwSyntaxError(ast->identifierToken, QStringLiteral("Variable name may not be eval or arguments in strict mode"));
|
||||||
checkName(QStringRef(&name.id), ast->identifierToken);
|
checkName(QStringView(name.id), ast->identifierToken);
|
||||||
if (name.id == QLatin1String("arguments"))
|
if (name.id == QLatin1String("arguments"))
|
||||||
_context->usesArgumentsObject = Context::ArgumentsObjectNotUsed;
|
_context->usesArgumentsObject = Context::ArgumentsObjectNotUsed;
|
||||||
if (ast->scope == VariableScope::Const && !ast->initializer && !ast->isForDeclaration && !ast->destructuringPattern()) {
|
if (ast->scope == VariableScope::Const && !ast->initializer && !ast->isForDeclaration && !ast->destructuringPattern()) {
|
||||||
|
@ -376,7 +376,7 @@ bool ScanFunctions::visit(ExpressionStatement *ast)
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
SourceLocation firstToken = ast->firstSourceLocation();
|
SourceLocation firstToken = ast->firstSourceLocation();
|
||||||
if (_sourceCode.midRef(firstToken.offset, firstToken.length) == QLatin1String("function")) {
|
if (QStringView{_sourceCode}.mid(firstToken.offset, firstToken.length) == QLatin1String("function")) {
|
||||||
_cg->throwSyntaxError(firstToken, QStringLiteral("unexpected token"));
|
_cg->throwSyntaxError(firstToken, QStringLiteral("unexpected token"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,7 @@ protected:
|
||||||
|
|
||||||
void checkDirectivePrologue(QQmlJS::AST::StatementList *ast);
|
void checkDirectivePrologue(QQmlJS::AST::StatementList *ast);
|
||||||
|
|
||||||
void checkName(const QStringRef &name, const QQmlJS::SourceLocation &loc);
|
void checkName(QStringView name, const QQmlJS::SourceLocation &loc);
|
||||||
|
|
||||||
bool visit(QQmlJS::AST::Program *ast) override;
|
bool visit(QQmlJS::AST::Program *ast) override;
|
||||||
void endVisit(QQmlJS::AST::Program *) override;
|
void endVisit(QQmlJS::AST::Program *) override;
|
||||||
|
|
|
@ -839,8 +839,8 @@ QString ExecutableCompilationUnit::bindingValueAsString(const CompiledData::Bind
|
||||||
// This code must match that in the qsTr() implementation
|
// This code must match that in the qsTr() implementation
|
||||||
const QString &path = fileName();
|
const QString &path = fileName();
|
||||||
int lastSlash = path.lastIndexOf(QLatin1Char('/'));
|
int lastSlash = path.lastIndexOf(QLatin1Char('/'));
|
||||||
QStringRef context = (lastSlash > -1) ? path.midRef(lastSlash + 1, path.length() - lastSlash - 5)
|
QStringView context = (lastSlash > -1) ? QStringView{path}.mid(lastSlash + 1, path.length() - lastSlash - 5)
|
||||||
: QStringRef();
|
: QStringView();
|
||||||
QByteArray contextUtf8 = context.toUtf8();
|
QByteArray contextUtf8 = context.toUtf8();
|
||||||
QByteArray comment = stringAt(translation.commentIndex).toUtf8();
|
QByteArray comment = stringAt(translation.commentIndex).toUtf8();
|
||||||
QByteArray text = stringAt(translation.stringIndex).toUtf8();
|
QByteArray text = stringAt(translation.stringIndex).toUtf8();
|
||||||
|
|
|
@ -198,7 +198,7 @@ Heap::FunctionObject *FunctionObject::createBuiltinFunction(ExecutionEngine *eng
|
||||||
Scope scope(engine);
|
Scope scope(engine);
|
||||||
ScopedString name(scope, nameOrSymbol);
|
ScopedString name(scope, nameOrSymbol);
|
||||||
if (!name)
|
if (!name)
|
||||||
name = engine->newString(QChar::fromLatin1('[') + nameOrSymbol->toQString().midRef(1) + QChar::fromLatin1(']'));
|
name = engine->newString(QChar::fromLatin1('[') + QStringView{nameOrSymbol->toQString()}.mid(1) + QChar::fromLatin1(']'));
|
||||||
|
|
||||||
ScopedFunctionObject function(scope, engine->memoryManager->allocate<FunctionObject>(engine->rootContext(), name, code));
|
ScopedFunctionObject function(scope, engine->memoryManager->allocate<FunctionObject>(engine->rootContext(), name, code));
|
||||||
function->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(argumentCount));
|
function->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(argumentCount));
|
||||||
|
|
|
@ -304,7 +304,7 @@ static QString decode(const QString &input, DecodeMode decodeMode, bool *ok)
|
||||||
++r;
|
++r;
|
||||||
}
|
}
|
||||||
if (*r)
|
if (*r)
|
||||||
output.append(input.midRef(start, i - start + 1));
|
output.append(QStringView{input}.mid(start, i - start + 1));
|
||||||
else
|
else
|
||||||
output.append(QChar(b));
|
output.append(QChar(b));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -177,7 +177,7 @@ void Object::defineAccessorProperty(StringOrSymbol *name, VTable::Call getter, V
|
||||||
ScopedProperty p(scope);
|
ScopedProperty p(scope);
|
||||||
QString n = name->toQString();
|
QString n = name->toQString();
|
||||||
if (n.at(0) == QLatin1Char('@'))
|
if (n.at(0) == QLatin1Char('@'))
|
||||||
n = QChar::fromLatin1('[') + n.midRef(1) + QChar::fromLatin1(']');
|
n = QChar::fromLatin1('[') + QStringView{n}.mid(1) + QChar::fromLatin1(']');
|
||||||
if (getter) {
|
if (getter) {
|
||||||
ScopedString getName(scope, v4->newString(QString::fromLatin1("get ") + n));
|
ScopedString getName(scope, v4->newString(QString::fromLatin1("get ") + n));
|
||||||
p->setGetter(ScopedFunctionObject(scope, FunctionObject::createBuiltinFunction(v4, getName, getter, 0)));
|
p->setGetter(ScopedFunctionObject(scope, FunctionObject::createBuiltinFunction(v4, getName, getter, 0)));
|
||||||
|
|
|
@ -103,7 +103,7 @@ QV4::Heap::String *QV4::PropertyKey::asFunctionName(ExecutionEngine *engine, Fun
|
||||||
if (s->internalClass->vtable->isString)
|
if (s->internalClass->vtable->isString)
|
||||||
n += s->toQString();
|
n += s->toQString();
|
||||||
else if (str.length() > 1)
|
else if (str.length() > 1)
|
||||||
n += QChar::fromLatin1('[') + str.midRef(1) + QChar::fromLatin1(']');
|
n += QChar::fromLatin1('[') + QStringView{str}.mid(1) + QChar::fromLatin1(']');
|
||||||
}
|
}
|
||||||
return engine->newString(n);
|
return engine->newString(n);
|
||||||
}
|
}
|
||||||
|
|
|
@ -726,12 +726,12 @@ ReturnedValue RegExpPrototype::method_replace(const FunctionObject *f, const Val
|
||||||
if (scope.hasException())
|
if (scope.hasException())
|
||||||
return Encode::undefined();
|
return Encode::undefined();
|
||||||
if (position >= nextSourcePosition) {
|
if (position >= nextSourcePosition) {
|
||||||
accumulatedResult += s->toQString().midRef(nextSourcePosition, position - nextSourcePosition) + replacement;
|
accumulatedResult += QStringView{s->toQString()}.mid(nextSourcePosition, position - nextSourcePosition) + replacement;
|
||||||
nextSourcePosition = position + matchLength;
|
nextSourcePosition = position + matchLength;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nextSourcePosition < lengthS) {
|
if (nextSourcePosition < lengthS) {
|
||||||
accumulatedResult += s->toQString().midRef(nextSourcePosition);
|
accumulatedResult += QStringView{s->toQString()}.mid(nextSourcePosition);
|
||||||
}
|
}
|
||||||
return scope.engine->newString(accumulatedResult)->asReturnedValue();
|
return scope.engine->newString(accumulatedResult)->asReturnedValue();
|
||||||
}
|
}
|
||||||
|
|
|
@ -417,7 +417,7 @@ double RuntimeHelpers::stringToNumber(const QString &string)
|
||||||
if (string.length() > excessiveLength)
|
if (string.length() > excessiveLength)
|
||||||
return qQNaN();
|
return qQNaN();
|
||||||
|
|
||||||
const QStringRef s = QStringRef(&string).trimmed();
|
const QStringView s = QStringView(string).trimmed();
|
||||||
if (s.startsWith(QLatin1Char('0'))) {
|
if (s.startsWith(QLatin1Char('0'))) {
|
||||||
int base = -1;
|
int base = -1;
|
||||||
if (s.startsWith(QLatin1String("0x")) || s.startsWith(QLatin1String("0X")))
|
if (s.startsWith(QLatin1String("0x")) || s.startsWith(QLatin1String("0X")))
|
||||||
|
|
|
@ -96,7 +96,7 @@ void Script::parse()
|
||||||
if (sourceCode.startsWith(QLatin1String("function("))) {
|
if (sourceCode.startsWith(QLatin1String("function("))) {
|
||||||
static const int snippetLength = 70;
|
static const int snippetLength = 70;
|
||||||
qWarning() << "Warning: Using function expressions as statements in scripts is not compliant with the ECMAScript specification:\n"
|
qWarning() << "Warning: Using function expressions as statements in scripts is not compliant with the ECMAScript specification:\n"
|
||||||
<< (sourceCode.leftRef(snippetLength) + QLatin1String("..."))
|
<< (QStringView{sourceCode}.left(snippetLength) + QLatin1String("..."))
|
||||||
<< "\nThis will throw a syntax error in Qt 5.12. If you want a function expression, surround it by parentheses.";
|
<< "\nThis will throw a syntax error in Qt 5.12. If you want a function expression, surround it by parentheses.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -464,7 +464,7 @@ ReturnedValue StringPrototype::method_endsWith(const FunctionObject *b, const Va
|
||||||
if (pos == value.length())
|
if (pos == value.length())
|
||||||
RETURN_RESULT(Encode(value.endsWith(searchString)));
|
RETURN_RESULT(Encode(value.endsWith(searchString)));
|
||||||
|
|
||||||
QStringRef stringToSearch = value.leftRef(pos);
|
QStringView stringToSearch = QStringView{value}.left(pos);
|
||||||
return Encode(stringToSearch.endsWith(searchString));
|
return Encode(stringToSearch.endsWith(searchString));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -514,7 +514,7 @@ ReturnedValue StringPrototype::method_includes(const FunctionObject *b, const Va
|
||||||
if (pos == 0)
|
if (pos == 0)
|
||||||
RETURN_RESULT(Encode(value.contains(searchString)));
|
RETURN_RESULT(Encode(value.contains(searchString)));
|
||||||
|
|
||||||
QStringRef stringToSearch = value.midRef(pos);
|
QStringView stringToSearch = QStringView{value}.mid(pos);
|
||||||
return Encode(stringToSearch.contains(searchString));
|
return Encode(stringToSearch.contains(searchString));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -765,7 +765,7 @@ static void appendReplacementString(QString *result, const QString &input, const
|
||||||
}
|
}
|
||||||
i += skip;
|
i += skip;
|
||||||
if (substStart != JSC::Yarr::offsetNoMatch && substEnd != JSC::Yarr::offsetNoMatch)
|
if (substStart != JSC::Yarr::offsetNoMatch && substEnd != JSC::Yarr::offsetNoMatch)
|
||||||
*result += input.midRef(substStart, substEnd - substStart);
|
*result += QStringView{input}.mid(substStart, substEnd - substStart);
|
||||||
else if (skip == 0) // invalid capture reference. Taken as literal value
|
else if (skip == 0) // invalid capture reference. Taken as literal value
|
||||||
*result += replaceValue.at(i);
|
*result += replaceValue.at(i);
|
||||||
} else {
|
} else {
|
||||||
|
@ -863,11 +863,11 @@ ReturnedValue StringPrototype::method_replace(const FunctionObject *b, const Val
|
||||||
Value that = Value::undefinedValue();
|
Value that = Value::undefinedValue();
|
||||||
replacement = searchCallback->call(&that, arguments, numCaptures + 2);
|
replacement = searchCallback->call(&that, arguments, numCaptures + 2);
|
||||||
CHECK_EXCEPTION();
|
CHECK_EXCEPTION();
|
||||||
result += string.midRef(lastEnd, matchStart - lastEnd);
|
result += QStringView{string}.mid(lastEnd, matchStart - lastEnd);
|
||||||
result += replacement->toQString();
|
result += replacement->toQString();
|
||||||
lastEnd = matchEnd;
|
lastEnd = matchEnd;
|
||||||
}
|
}
|
||||||
result += string.midRef(lastEnd);
|
result += QStringView{string}.mid(lastEnd);
|
||||||
} else {
|
} else {
|
||||||
QString newString = replaceValue->toQString();
|
QString newString = replaceValue->toQString();
|
||||||
result.reserve(string.length() + numStringMatches*newString.size());
|
result.reserve(string.length() + numStringMatches*newString.size());
|
||||||
|
@ -880,11 +880,11 @@ ReturnedValue StringPrototype::method_replace(const FunctionObject *b, const Val
|
||||||
if (matchStart == JSC::Yarr::offsetNoMatch)
|
if (matchStart == JSC::Yarr::offsetNoMatch)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
result += string.midRef(lastEnd, matchStart - lastEnd);
|
result += QStringView{string}.mid(lastEnd, matchStart - lastEnd);
|
||||||
appendReplacementString(&result, string, newString, matchOffsets + baseIndex, numCaptures);
|
appendReplacementString(&result, string, newString, matchOffsets + baseIndex, numCaptures);
|
||||||
lastEnd = matchEnd;
|
lastEnd = matchEnd;
|
||||||
}
|
}
|
||||||
result += string.midRef(lastEnd);
|
result += QStringView{string}.mid(lastEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (matchOffsets != _matchOffsets)
|
if (matchOffsets != _matchOffsets)
|
||||||
|
@ -1052,7 +1052,7 @@ ReturnedValue StringPrototype::method_startsWith(const FunctionObject *b, const
|
||||||
if (pos == 0)
|
if (pos == 0)
|
||||||
return Encode(value.startsWith(searchString));
|
return Encode(value.startsWith(searchString));
|
||||||
|
|
||||||
QStringRef stringToSearch = value.midRef(pos);
|
QStringView stringToSearch = QStringView{value}.mid(pos);
|
||||||
RETURN_RESULT(Encode(stringToSearch.startsWith(searchString)));
|
RETURN_RESULT(Encode(stringToSearch.startsWith(searchString)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -182,5 +182,5 @@ Heap::Symbol *Symbol::create(ExecutionEngine *e, const QString &s)
|
||||||
|
|
||||||
QString Symbol::descriptiveString() const
|
QString Symbol::descriptiveString() const
|
||||||
{
|
{
|
||||||
return QLatin1String("Symbol(") + toQString().midRef(1) + QLatin1String(")");
|
return QLatin1String("Symbol(") + QStringView{toQString()}.mid(1) + QLatin1String(")");
|
||||||
}
|
}
|
||||||
|
|
|
@ -403,10 +403,10 @@ protected:
|
||||||
inline Value &sym(int index)
|
inline Value &sym(int index)
|
||||||
{ return sym_stack [tos + index - 1]; }
|
{ return sym_stack [tos + index - 1]; }
|
||||||
|
|
||||||
inline QStringRef &stringRef(int index)
|
inline QStringView &stringRef(int index)
|
||||||
{ return string_stack [tos + index - 1]; }
|
{ return string_stack [tos + index - 1]; }
|
||||||
|
|
||||||
inline QStringRef &rawStringRef(int index)
|
inline QStringView &rawStringRef(int index)
|
||||||
{ return rawString_stack [tos + index - 1]; }
|
{ return rawString_stack [tos + index - 1]; }
|
||||||
|
|
||||||
inline SourceLocation &loc(int index)
|
inline SourceLocation &loc(int index)
|
||||||
|
@ -444,8 +444,8 @@ protected:
|
||||||
Value *sym_stack = nullptr;
|
Value *sym_stack = nullptr;
|
||||||
int *state_stack = nullptr;
|
int *state_stack = nullptr;
|
||||||
SourceLocation *location_stack = nullptr;
|
SourceLocation *location_stack = nullptr;
|
||||||
QVector<QStringRef> string_stack;
|
QList<QStringView> string_stack;
|
||||||
QVector<QStringRef> rawString_stack;
|
QList<QStringView> rawString_stack;
|
||||||
|
|
||||||
AST::Node *program = nullptr;
|
AST::Node *program = nullptr;
|
||||||
|
|
||||||
|
@ -456,14 +456,14 @@ protected:
|
||||||
int token;
|
int token;
|
||||||
double dval;
|
double dval;
|
||||||
SourceLocation loc;
|
SourceLocation loc;
|
||||||
QStringRef spell;
|
QStringView spell;
|
||||||
QStringRef raw;
|
QStringView raw;
|
||||||
};
|
};
|
||||||
|
|
||||||
int yytoken = -1;
|
int yytoken = -1;
|
||||||
double yylval = 0.;
|
double yylval = 0.;
|
||||||
QStringRef yytokenspell;
|
QStringView yytokenspell;
|
||||||
QStringRef yytokenraw;
|
QStringView yytokenraw;
|
||||||
SourceLocation yylloc;
|
SourceLocation yylloc;
|
||||||
SourceLocation yyprevlloc;
|
SourceLocation yyprevlloc;
|
||||||
|
|
||||||
|
@ -555,7 +555,7 @@ static inline SourceLocation location(Lexer *lexer)
|
||||||
|
|
||||||
AST::UiQualifiedId *Parser::reparseAsQualifiedId(AST::ExpressionNode *expr)
|
AST::UiQualifiedId *Parser::reparseAsQualifiedId(AST::ExpressionNode *expr)
|
||||||
{
|
{
|
||||||
QVarLengthArray<QStringRef, 4> nameIds;
|
QVarLengthArray<QStringView, 4> nameIds;
|
||||||
QVarLengthArray<SourceLocation, 4> locations;
|
QVarLengthArray<SourceLocation, 4> locations;
|
||||||
|
|
||||||
AST::ExpressionNode *it = expr;
|
AST::ExpressionNode *it = expr;
|
||||||
|
@ -3613,7 +3613,7 @@ ContinueStatement: T_CONTINUE IdentifierReference Semicolon;
|
||||||
BreakStatement: T_BREAK Semicolon;
|
BreakStatement: T_BREAK Semicolon;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
AST::BreakStatement *node = new (pool) AST::BreakStatement(QStringRef());
|
AST::BreakStatement *node = new (pool) AST::BreakStatement(QStringView());
|
||||||
node->breakToken = loc(1);
|
node->breakToken = loc(1);
|
||||||
node->semicolonToken = loc(2);
|
node->semicolonToken = loc(2);
|
||||||
sym(1).Node = node;
|
sym(1).Node = node;
|
||||||
|
@ -3887,7 +3887,7 @@ FunctionDeclaration_Default: Function T_LPAREN FormalParameters T_RPAREN TypeAnn
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
if (!ensureNoFunctionTypeAnnotations(sym(5).TypeAnnotation, sym(3).FormalParameterList))
|
if (!ensureNoFunctionTypeAnnotations(sym(5).TypeAnnotation, sym(3).FormalParameterList))
|
||||||
return false;
|
return false;
|
||||||
AST::FunctionDeclaration *node = new (pool) AST::FunctionDeclaration(QStringRef(), sym(3).FormalParameterList, sym(7).StatementList,
|
AST::FunctionDeclaration *node = new (pool) AST::FunctionDeclaration(QStringView(), sym(3).FormalParameterList, sym(7).StatementList,
|
||||||
/*type annotation*/nullptr);
|
/*type annotation*/nullptr);
|
||||||
node->functionToken = loc(1);
|
node->functionToken = loc(1);
|
||||||
node->lparenToken = loc(2);
|
node->lparenToken = loc(2);
|
||||||
|
@ -3921,7 +3921,7 @@ FunctionExpression: T_FUNCTION T_LPAREN FormalParameters T_RPAREN TypeAnnotation
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
if (!ensureNoFunctionTypeAnnotations(sym(5).TypeAnnotation, sym(3).FormalParameterList))
|
if (!ensureNoFunctionTypeAnnotations(sym(5).TypeAnnotation, sym(3).FormalParameterList))
|
||||||
return false;
|
return false;
|
||||||
AST::FunctionExpression *node = new (pool) AST::FunctionExpression(QStringRef(), sym(3).FormalParameterList, sym(7).StatementList,
|
AST::FunctionExpression *node = new (pool) AST::FunctionExpression(QStringView(), sym(3).FormalParameterList, sym(7).StatementList,
|
||||||
/*type annotation*/nullptr);
|
/*type annotation*/nullptr);
|
||||||
node->functionToken = loc(1);
|
node->functionToken = loc(1);
|
||||||
node->lparenToken = loc(2);
|
node->lparenToken = loc(2);
|
||||||
|
@ -4011,7 +4011,7 @@ ArrowFunction_In: ArrowParameters T_ARROW ConciseBodyLookahead AssignmentExpress
|
||||||
ret->returnToken = sym(4).Node->firstSourceLocation();
|
ret->returnToken = sym(4).Node->firstSourceLocation();
|
||||||
ret->semicolonToken = sym(4).Node->lastSourceLocation();
|
ret->semicolonToken = sym(4).Node->lastSourceLocation();
|
||||||
AST::StatementList *statements = (new (pool) AST::StatementList(ret))->finish();
|
AST::StatementList *statements = (new (pool) AST::StatementList(ret))->finish();
|
||||||
AST::FunctionExpression *f = new (pool) AST::FunctionExpression(QStringRef(), sym(1).FormalParameterList, statements);
|
AST::FunctionExpression *f = new (pool) AST::FunctionExpression(QStringView(), sym(1).FormalParameterList, statements);
|
||||||
f->isArrowFunction = true;
|
f->isArrowFunction = true;
|
||||||
f->functionToken = sym(1).Node ? sym(1).Node->firstSourceLocation() : loc(1);
|
f->functionToken = sym(1).Node ? sym(1).Node->firstSourceLocation() : loc(1);
|
||||||
f->lbraceToken = sym(4).Node->firstSourceLocation();
|
f->lbraceToken = sym(4).Node->firstSourceLocation();
|
||||||
|
@ -4025,7 +4025,7 @@ ArrowFunction: ArrowParameters T_ARROW ConciseBodyLookahead T_FORCE_BLOCK Functi
|
||||||
ArrowFunction_In: ArrowParameters T_ARROW ConciseBodyLookahead T_FORCE_BLOCK FunctionLBrace FunctionBody FunctionRBrace;
|
ArrowFunction_In: ArrowParameters T_ARROW ConciseBodyLookahead T_FORCE_BLOCK FunctionLBrace FunctionBody FunctionRBrace;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
AST::FunctionExpression *f = new (pool) AST::FunctionExpression(QStringRef(), sym(1).FormalParameterList, sym(6).StatementList);
|
AST::FunctionExpression *f = new (pool) AST::FunctionExpression(QStringView(), sym(1).FormalParameterList, sym(6).StatementList);
|
||||||
f->isArrowFunction = true;
|
f->isArrowFunction = true;
|
||||||
f->functionToken = sym(1).Node ? sym(1).Node->firstSourceLocation() : loc(1);
|
f->functionToken = sym(1).Node ? sym(1).Node->firstSourceLocation() : loc(1);
|
||||||
f->lbraceToken = loc(6);
|
f->lbraceToken = loc(6);
|
||||||
|
@ -4186,7 +4186,7 @@ GeneratorDeclaration_Default: GeneratorDeclaration;
|
||||||
GeneratorDeclaration_Default: FunctionStar GeneratorLParen FormalParameters T_RPAREN FunctionLBrace GeneratorBody GeneratorRBrace;
|
GeneratorDeclaration_Default: FunctionStar GeneratorLParen FormalParameters T_RPAREN FunctionLBrace GeneratorBody GeneratorRBrace;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
AST::FunctionDeclaration *node = new (pool) AST::FunctionDeclaration(QStringRef(), sym(3).FormalParameterList, sym(6).StatementList);
|
AST::FunctionDeclaration *node = new (pool) AST::FunctionDeclaration(QStringView(), sym(3).FormalParameterList, sym(6).StatementList);
|
||||||
node->functionToken = loc(1);
|
node->functionToken = loc(1);
|
||||||
node->lparenToken = loc(2);
|
node->lparenToken = loc(2);
|
||||||
node->rparenToken = loc(4);
|
node->rparenToken = loc(4);
|
||||||
|
@ -4216,7 +4216,7 @@ GeneratorExpression: T_FUNCTION_STAR BindingIdentifier GeneratorLParen FormalPar
|
||||||
GeneratorExpression: T_FUNCTION_STAR GeneratorLParen FormalParameters T_RPAREN FunctionLBrace GeneratorBody GeneratorRBrace;
|
GeneratorExpression: T_FUNCTION_STAR GeneratorLParen FormalParameters T_RPAREN FunctionLBrace GeneratorBody GeneratorRBrace;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
AST::FunctionExpression *node = new (pool) AST::FunctionExpression(QStringRef(), sym(3).FormalParameterList, sym(6).StatementList);
|
AST::FunctionExpression *node = new (pool) AST::FunctionExpression(QStringView(), sym(3).FormalParameterList, sym(6).StatementList);
|
||||||
node->functionToken = loc(1);
|
node->functionToken = loc(1);
|
||||||
node->lparenToken = loc(2);
|
node->lparenToken = loc(2);
|
||||||
node->rparenToken = loc(4);
|
node->rparenToken = loc(4);
|
||||||
|
@ -4291,7 +4291,7 @@ ClassExpression: T_CLASS BindingIdentifier ClassHeritageOpt ClassLBrace ClassBod
|
||||||
ClassDeclaration_Default: T_CLASS ClassHeritageOpt ClassLBrace ClassBodyOpt ClassRBrace;
|
ClassDeclaration_Default: T_CLASS ClassHeritageOpt ClassLBrace ClassBodyOpt ClassRBrace;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
AST::ClassDeclaration *node = new (pool) AST::ClassDeclaration(QStringRef(), sym(2).Expression, sym(4).ClassElementList);
|
AST::ClassDeclaration *node = new (pool) AST::ClassDeclaration(QStringView(), sym(2).Expression, sym(4).ClassElementList);
|
||||||
node->classToken = loc(1);
|
node->classToken = loc(1);
|
||||||
node->lbraceToken = loc(3);
|
node->lbraceToken = loc(3);
|
||||||
node->rbraceToken = loc(5);
|
node->rbraceToken = loc(5);
|
||||||
|
@ -4302,7 +4302,7 @@ ClassDeclaration_Default: T_CLASS ClassHeritageOpt ClassLBrace ClassBodyOpt Clas
|
||||||
ClassExpression: T_CLASS ClassHeritageOpt ClassLBrace ClassBodyOpt ClassRBrace;
|
ClassExpression: T_CLASS ClassHeritageOpt ClassLBrace ClassBodyOpt ClassRBrace;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
AST::ClassExpression *node = new (pool) AST::ClassExpression(QStringRef(), sym(2).Expression, sym(4).ClassElementList);
|
AST::ClassExpression *node = new (pool) AST::ClassExpression(QStringView(), sym(2).Expression, sym(4).ClassElementList);
|
||||||
node->classToken = loc(1);
|
node->classToken = loc(1);
|
||||||
node->lbraceToken = loc(3);
|
node->lbraceToken = loc(3);
|
||||||
node->rbraceToken = loc(5);
|
node->rbraceToken = loc(5);
|
||||||
|
|
|
@ -335,11 +335,11 @@ class QML_PARSER_EXPORT UiQualifiedId: public Node
|
||||||
public:
|
public:
|
||||||
QQMLJS_DECLARE_AST_NODE(UiQualifiedId)
|
QQMLJS_DECLARE_AST_NODE(UiQualifiedId)
|
||||||
|
|
||||||
UiQualifiedId(const QStringRef &name)
|
UiQualifiedId(QStringView name)
|
||||||
: next(this), name(name)
|
: next(this), name(name)
|
||||||
{ kind = K; }
|
{ kind = K; }
|
||||||
|
|
||||||
UiQualifiedId(UiQualifiedId *previous, const QStringRef &name)
|
UiQualifiedId(UiQualifiedId *previous, QStringView name)
|
||||||
: name(name)
|
: name(name)
|
||||||
{
|
{
|
||||||
kind = K;
|
kind = K;
|
||||||
|
@ -364,7 +364,7 @@ public:
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
UiQualifiedId *next;
|
UiQualifiedId *next;
|
||||||
QStringRef name;
|
QStringView name;
|
||||||
SourceLocation identifierToken;
|
SourceLocation identifierToken;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -549,7 +549,7 @@ class QML_PARSER_EXPORT IdentifierExpression: public LeftHandSideExpression
|
||||||
public:
|
public:
|
||||||
QQMLJS_DECLARE_AST_NODE(IdentifierExpression)
|
QQMLJS_DECLARE_AST_NODE(IdentifierExpression)
|
||||||
|
|
||||||
IdentifierExpression(const QStringRef &n):
|
IdentifierExpression(QStringView n):
|
||||||
name (n) { kind = K; }
|
name (n) { kind = K; }
|
||||||
|
|
||||||
void accept0(BaseVisitor *visitor) override;
|
void accept0(BaseVisitor *visitor) override;
|
||||||
|
@ -561,7 +561,7 @@ public:
|
||||||
{ return identifierToken; }
|
{ return identifierToken; }
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
QStringRef name;
|
QStringView name;
|
||||||
SourceLocation identifierToken;
|
SourceLocation identifierToken;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -698,7 +698,7 @@ class QML_PARSER_EXPORT StringLiteral : public LeftHandSideExpression
|
||||||
public:
|
public:
|
||||||
QQMLJS_DECLARE_AST_NODE(StringLiteral)
|
QQMLJS_DECLARE_AST_NODE(StringLiteral)
|
||||||
|
|
||||||
StringLiteral(const QStringRef &v):
|
StringLiteral(QStringView v):
|
||||||
value (v) { kind = K; }
|
value (v) { kind = K; }
|
||||||
|
|
||||||
void accept0(BaseVisitor *visitor) override;
|
void accept0(BaseVisitor *visitor) override;
|
||||||
|
@ -710,7 +710,7 @@ public:
|
||||||
{ return literalToken; }
|
{ return literalToken; }
|
||||||
|
|
||||||
// attributes:
|
// attributes:
|
||||||
QStringRef value;
|
QStringView value;
|
||||||
SourceLocation literalToken;
|
SourceLocation literalToken;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -719,7 +719,7 @@ class QML_PARSER_EXPORT TemplateLiteral : public LeftHandSideExpression
|
||||||
public:
|
public:
|
||||||
QQMLJS_DECLARE_AST_NODE(TemplateLiteral)
|
QQMLJS_DECLARE_AST_NODE(TemplateLiteral)
|
||||||
|
|
||||||
TemplateLiteral(const QStringRef &str, const QStringRef &raw, ExpressionNode *e)
|
TemplateLiteral(QStringView str, QStringView raw, ExpressionNode *e)
|
||||||
: value(str), rawValue(raw), expression(e), next(nullptr)
|
: value(str), rawValue(raw), expression(e), next(nullptr)
|
||||||
{ kind = K; }
|
{ kind = K; }
|
||||||
|
|
||||||
|
@ -734,8 +734,8 @@ public:
|
||||||
|
|
||||||
void accept0(BaseVisitor *visitor) override;
|
void accept0(BaseVisitor *visitor) override;
|
||||||
|
|
||||||
QStringRef value;
|
QStringView value;
|
||||||
QStringRef rawValue;
|
QStringView rawValue;
|
||||||
ExpressionNode *expression;
|
ExpressionNode *expression;
|
||||||
TemplateLiteral *next;
|
TemplateLiteral *next;
|
||||||
SourceLocation literalToken;
|
SourceLocation literalToken;
|
||||||
|
@ -746,7 +746,7 @@ class QML_PARSER_EXPORT RegExpLiteral: public LeftHandSideExpression
|
||||||
public:
|
public:
|
||||||
QQMLJS_DECLARE_AST_NODE(RegExpLiteral)
|
QQMLJS_DECLARE_AST_NODE(RegExpLiteral)
|
||||||
|
|
||||||
RegExpLiteral(const QStringRef &p, int f):
|
RegExpLiteral(QStringView p, int f):
|
||||||
pattern (p), flags (f) { kind = K; }
|
pattern (p), flags (f) { kind = K; }
|
||||||
|
|
||||||
void accept0(BaseVisitor *visitor) override;
|
void accept0(BaseVisitor *visitor) override;
|
||||||
|
@ -758,7 +758,7 @@ public:
|
||||||
{ return literalToken; }
|
{ return literalToken; }
|
||||||
|
|
||||||
// attributes:
|
// attributes:
|
||||||
QStringRef pattern;
|
QStringView pattern;
|
||||||
int flags;
|
int flags;
|
||||||
SourceLocation literalToken;
|
SourceLocation literalToken;
|
||||||
};
|
};
|
||||||
|
@ -937,7 +937,7 @@ public:
|
||||||
: initializer(i), type(t)
|
: initializer(i), type(t)
|
||||||
{ kind = K; }
|
{ kind = K; }
|
||||||
|
|
||||||
PatternElement(const QStringRef &n, TypeAnnotation *typeAnnotation = nullptr, ExpressionNode *i = nullptr, Type t = Binding)
|
PatternElement(QStringView n, TypeAnnotation *typeAnnotation = nullptr, ExpressionNode *i = nullptr, Type t = Binding)
|
||||||
: bindingIdentifier(n), initializer(i), type(t)
|
: bindingIdentifier(n), initializer(i), type(t)
|
||||||
, typeAnnotation(typeAnnotation)
|
, typeAnnotation(typeAnnotation)
|
||||||
{
|
{
|
||||||
|
@ -973,7 +973,7 @@ public:
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
SourceLocation identifierToken;
|
SourceLocation identifierToken;
|
||||||
QStringRef bindingIdentifier;
|
QStringView bindingIdentifier;
|
||||||
ExpressionNode *bindingTarget = nullptr;
|
ExpressionNode *bindingTarget = nullptr;
|
||||||
ExpressionNode *initializer = nullptr;
|
ExpressionNode *initializer = nullptr;
|
||||||
Type type = Literal;
|
Type type = Literal;
|
||||||
|
@ -1032,7 +1032,7 @@ public:
|
||||||
: PatternElement(i, t), name(name)
|
: PatternElement(i, t), name(name)
|
||||||
{ kind = K; }
|
{ kind = K; }
|
||||||
|
|
||||||
PatternProperty(PropertyName *name, const QStringRef &n, ExpressionNode *i = nullptr)
|
PatternProperty(PropertyName *name, QStringView n, ExpressionNode *i = nullptr)
|
||||||
: PatternElement(n, /*type annotation*/nullptr, i), name(name)
|
: PatternElement(n, /*type annotation*/nullptr, i), name(name)
|
||||||
{ kind = K; }
|
{ kind = K; }
|
||||||
|
|
||||||
|
@ -1102,7 +1102,7 @@ class QML_PARSER_EXPORT IdentifierPropertyName: public PropertyName
|
||||||
public:
|
public:
|
||||||
QQMLJS_DECLARE_AST_NODE(IdentifierPropertyName)
|
QQMLJS_DECLARE_AST_NODE(IdentifierPropertyName)
|
||||||
|
|
||||||
IdentifierPropertyName(const QStringRef &n):
|
IdentifierPropertyName(QStringView n):
|
||||||
id (n) { kind = K; }
|
id (n) { kind = K; }
|
||||||
|
|
||||||
void accept0(BaseVisitor *visitor) override;
|
void accept0(BaseVisitor *visitor) override;
|
||||||
|
@ -1110,7 +1110,7 @@ public:
|
||||||
QString asString() const override { return id.toString(); }
|
QString asString() const override { return id.toString(); }
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
QStringRef id;
|
QStringView id;
|
||||||
};
|
};
|
||||||
|
|
||||||
class QML_PARSER_EXPORT StringLiteralPropertyName: public PropertyName
|
class QML_PARSER_EXPORT StringLiteralPropertyName: public PropertyName
|
||||||
|
@ -1118,7 +1118,7 @@ class QML_PARSER_EXPORT StringLiteralPropertyName: public PropertyName
|
||||||
public:
|
public:
|
||||||
QQMLJS_DECLARE_AST_NODE(StringLiteralPropertyName)
|
QQMLJS_DECLARE_AST_NODE(StringLiteralPropertyName)
|
||||||
|
|
||||||
StringLiteralPropertyName(const QStringRef &n):
|
StringLiteralPropertyName(QStringView n):
|
||||||
id (n) { kind = K; }
|
id (n) { kind = K; }
|
||||||
|
|
||||||
void accept0(BaseVisitor *visitor) override;
|
void accept0(BaseVisitor *visitor) override;
|
||||||
|
@ -1126,7 +1126,7 @@ public:
|
||||||
QString asString() const override { return id.toString(); }
|
QString asString() const override { return id.toString(); }
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
QStringRef id;
|
QStringView id;
|
||||||
};
|
};
|
||||||
|
|
||||||
class QML_PARSER_EXPORT NumericLiteralPropertyName: public PropertyName
|
class QML_PARSER_EXPORT NumericLiteralPropertyName: public PropertyName
|
||||||
|
@ -1198,7 +1198,7 @@ class QML_PARSER_EXPORT FieldMemberExpression: public LeftHandSideExpression
|
||||||
public:
|
public:
|
||||||
QQMLJS_DECLARE_AST_NODE(FieldMemberExpression)
|
QQMLJS_DECLARE_AST_NODE(FieldMemberExpression)
|
||||||
|
|
||||||
FieldMemberExpression(ExpressionNode *b, const QStringRef &n):
|
FieldMemberExpression(ExpressionNode *b, QStringView n):
|
||||||
base (b), name (n)
|
base (b), name (n)
|
||||||
{ kind = K; }
|
{ kind = K; }
|
||||||
|
|
||||||
|
@ -1212,7 +1212,7 @@ public:
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
ExpressionNode *base;
|
ExpressionNode *base;
|
||||||
QStringRef name;
|
QStringView name;
|
||||||
SourceLocation dotToken;
|
SourceLocation dotToken;
|
||||||
SourceLocation identifierToken;
|
SourceLocation identifierToken;
|
||||||
};
|
};
|
||||||
|
@ -1988,7 +1988,7 @@ class QML_PARSER_EXPORT ContinueStatement: public Statement
|
||||||
public:
|
public:
|
||||||
QQMLJS_DECLARE_AST_NODE(ContinueStatement)
|
QQMLJS_DECLARE_AST_NODE(ContinueStatement)
|
||||||
|
|
||||||
ContinueStatement(const QStringRef &l = QStringRef()):
|
ContinueStatement(QStringView l = QStringView()):
|
||||||
label (l) { kind = K; }
|
label (l) { kind = K; }
|
||||||
|
|
||||||
void accept0(BaseVisitor *visitor) override;
|
void accept0(BaseVisitor *visitor) override;
|
||||||
|
@ -2000,7 +2000,7 @@ public:
|
||||||
{ return semicolonToken; }
|
{ return semicolonToken; }
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
QStringRef label;
|
QStringView label;
|
||||||
SourceLocation continueToken;
|
SourceLocation continueToken;
|
||||||
SourceLocation identifierToken;
|
SourceLocation identifierToken;
|
||||||
SourceLocation semicolonToken;
|
SourceLocation semicolonToken;
|
||||||
|
@ -2011,7 +2011,7 @@ class QML_PARSER_EXPORT BreakStatement: public Statement
|
||||||
public:
|
public:
|
||||||
QQMLJS_DECLARE_AST_NODE(BreakStatement)
|
QQMLJS_DECLARE_AST_NODE(BreakStatement)
|
||||||
|
|
||||||
BreakStatement(const QStringRef &l):
|
BreakStatement(QStringView l):
|
||||||
label (l) { kind = K; }
|
label (l) { kind = K; }
|
||||||
|
|
||||||
void accept0(BaseVisitor *visitor) override;
|
void accept0(BaseVisitor *visitor) override;
|
||||||
|
@ -2023,7 +2023,7 @@ public:
|
||||||
{ return semicolonToken; }
|
{ return semicolonToken; }
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
QStringRef label;
|
QStringView label;
|
||||||
SourceLocation breakToken;
|
SourceLocation breakToken;
|
||||||
SourceLocation identifierToken;
|
SourceLocation identifierToken;
|
||||||
SourceLocation semicolonToken;
|
SourceLocation semicolonToken;
|
||||||
|
@ -2239,7 +2239,7 @@ class QML_PARSER_EXPORT LabelledStatement: public Statement
|
||||||
public:
|
public:
|
||||||
QQMLJS_DECLARE_AST_NODE(LabelledStatement)
|
QQMLJS_DECLARE_AST_NODE(LabelledStatement)
|
||||||
|
|
||||||
LabelledStatement(const QStringRef &l, Statement *stmt):
|
LabelledStatement(QStringView l, Statement *stmt):
|
||||||
label (l), statement (stmt)
|
label (l), statement (stmt)
|
||||||
{ kind = K; }
|
{ kind = K; }
|
||||||
|
|
||||||
|
@ -2252,7 +2252,7 @@ public:
|
||||||
{ return statement->lastSourceLocation(); }
|
{ return statement->lastSourceLocation(); }
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
QStringRef label;
|
QStringView label;
|
||||||
Statement *statement;
|
Statement *statement;
|
||||||
SourceLocation identifierToken;
|
SourceLocation identifierToken;
|
||||||
SourceLocation colonToken;
|
SourceLocation colonToken;
|
||||||
|
@ -2372,7 +2372,7 @@ class QML_PARSER_EXPORT FunctionExpression: public ExpressionNode
|
||||||
public:
|
public:
|
||||||
QQMLJS_DECLARE_AST_NODE(FunctionExpression)
|
QQMLJS_DECLARE_AST_NODE(FunctionExpression)
|
||||||
|
|
||||||
FunctionExpression(const QStringRef &n, FormalParameterList *f, StatementList *b, TypeAnnotation *typeAnnotation = nullptr):
|
FunctionExpression(QStringView n, FormalParameterList *f, StatementList *b, TypeAnnotation *typeAnnotation = nullptr):
|
||||||
name (n), formals (f), body (b),
|
name (n), formals (f), body (b),
|
||||||
typeAnnotation(typeAnnotation)
|
typeAnnotation(typeAnnotation)
|
||||||
{ kind = K; }
|
{ kind = K; }
|
||||||
|
@ -2388,7 +2388,7 @@ public:
|
||||||
FunctionExpression *asFunctionDefinition() override;
|
FunctionExpression *asFunctionDefinition() override;
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
QStringRef name;
|
QStringView name;
|
||||||
bool isArrowFunction = false;
|
bool isArrowFunction = false;
|
||||||
bool isGenerator = false;
|
bool isGenerator = false;
|
||||||
FormalParameterList *formals;
|
FormalParameterList *formals;
|
||||||
|
@ -2407,7 +2407,7 @@ class QML_PARSER_EXPORT FunctionDeclaration: public FunctionExpression
|
||||||
public:
|
public:
|
||||||
QQMLJS_DECLARE_AST_NODE(FunctionDeclaration)
|
QQMLJS_DECLARE_AST_NODE(FunctionDeclaration)
|
||||||
|
|
||||||
FunctionDeclaration(const QStringRef &n, FormalParameterList *f, StatementList *b, TypeAnnotation *typeAnnotation = nullptr):
|
FunctionDeclaration(QStringView n, FormalParameterList *f, StatementList *b, TypeAnnotation *typeAnnotation = nullptr):
|
||||||
FunctionExpression(n, f, b, typeAnnotation)
|
FunctionExpression(n, f, b, typeAnnotation)
|
||||||
{ kind = K; }
|
{ kind = K; }
|
||||||
|
|
||||||
|
@ -2504,7 +2504,7 @@ class QML_PARSER_EXPORT ClassExpression : public ExpressionNode
|
||||||
public:
|
public:
|
||||||
QQMLJS_DECLARE_AST_NODE(ClassExpression)
|
QQMLJS_DECLARE_AST_NODE(ClassExpression)
|
||||||
|
|
||||||
ClassExpression(const QStringRef &n, ExpressionNode *heritage, ClassElementList *elements)
|
ClassExpression(QStringView n, ExpressionNode *heritage, ClassElementList *elements)
|
||||||
: name(n), heritage(heritage), elements(elements)
|
: name(n), heritage(heritage), elements(elements)
|
||||||
{ kind = K; }
|
{ kind = K; }
|
||||||
|
|
||||||
|
@ -2519,7 +2519,7 @@ public:
|
||||||
ClassExpression *asClassDefinition() override;
|
ClassExpression *asClassDefinition() override;
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
QStringRef name;
|
QStringView name;
|
||||||
ExpressionNode *heritage;
|
ExpressionNode *heritage;
|
||||||
ClassElementList *elements;
|
ClassElementList *elements;
|
||||||
SourceLocation classToken;
|
SourceLocation classToken;
|
||||||
|
@ -2533,7 +2533,7 @@ class QML_PARSER_EXPORT ClassDeclaration: public ClassExpression
|
||||||
public:
|
public:
|
||||||
QQMLJS_DECLARE_AST_NODE(ClassDeclaration)
|
QQMLJS_DECLARE_AST_NODE(ClassDeclaration)
|
||||||
|
|
||||||
ClassDeclaration(const QStringRef &n, ExpressionNode *heritage, ClassElementList *elements)
|
ClassDeclaration(QStringView n, ExpressionNode *heritage, ClassElementList *elements)
|
||||||
: ClassExpression(n, heritage, elements)
|
: ClassExpression(n, heritage, elements)
|
||||||
{ kind = K; }
|
{ kind = K; }
|
||||||
|
|
||||||
|
@ -2604,13 +2604,13 @@ class QML_PARSER_EXPORT ImportSpecifier: public Node
|
||||||
public:
|
public:
|
||||||
QQMLJS_DECLARE_AST_NODE(ImportSpecifier)
|
QQMLJS_DECLARE_AST_NODE(ImportSpecifier)
|
||||||
|
|
||||||
ImportSpecifier(const QStringRef &importedBinding)
|
ImportSpecifier(QStringView importedBinding)
|
||||||
: importedBinding(importedBinding)
|
: importedBinding(importedBinding)
|
||||||
{
|
{
|
||||||
kind = K;
|
kind = K;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImportSpecifier(const QStringRef &identifier, const QStringRef &importedBinding)
|
ImportSpecifier(QStringView identifier, QStringView importedBinding)
|
||||||
: identifier(identifier), importedBinding(importedBinding)
|
: identifier(identifier), importedBinding(importedBinding)
|
||||||
{
|
{
|
||||||
kind = K;
|
kind = K;
|
||||||
|
@ -2626,8 +2626,8 @@ public:
|
||||||
// attributes
|
// attributes
|
||||||
SourceLocation identifierToken;
|
SourceLocation identifierToken;
|
||||||
SourceLocation importedBindingToken;
|
SourceLocation importedBindingToken;
|
||||||
QStringRef identifier;
|
QStringView identifier;
|
||||||
QStringRef importedBinding;
|
QStringView importedBinding;
|
||||||
};
|
};
|
||||||
|
|
||||||
class QML_PARSER_EXPORT ImportsList: public Node
|
class QML_PARSER_EXPORT ImportsList: public Node
|
||||||
|
@ -2711,7 +2711,7 @@ class QML_PARSER_EXPORT NameSpaceImport: public Node
|
||||||
public:
|
public:
|
||||||
QQMLJS_DECLARE_AST_NODE(NameSpaceImport)
|
QQMLJS_DECLARE_AST_NODE(NameSpaceImport)
|
||||||
|
|
||||||
NameSpaceImport(const QStringRef &importedBinding)
|
NameSpaceImport(QStringView importedBinding)
|
||||||
: importedBinding(importedBinding)
|
: importedBinding(importedBinding)
|
||||||
{
|
{
|
||||||
kind = K;
|
kind = K;
|
||||||
|
@ -2727,7 +2727,7 @@ public:
|
||||||
// attributes
|
// attributes
|
||||||
SourceLocation starToken;
|
SourceLocation starToken;
|
||||||
SourceLocation importedBindingToken;
|
SourceLocation importedBindingToken;
|
||||||
QStringRef importedBinding;
|
QStringView importedBinding;
|
||||||
};
|
};
|
||||||
|
|
||||||
class QML_PARSER_EXPORT ImportClause: public Node
|
class QML_PARSER_EXPORT ImportClause: public Node
|
||||||
|
@ -2735,7 +2735,7 @@ class QML_PARSER_EXPORT ImportClause: public Node
|
||||||
public:
|
public:
|
||||||
QQMLJS_DECLARE_AST_NODE(ImportClause)
|
QQMLJS_DECLARE_AST_NODE(ImportClause)
|
||||||
|
|
||||||
ImportClause(const QStringRef &importedDefaultBinding)
|
ImportClause(QStringView importedDefaultBinding)
|
||||||
: importedDefaultBinding(importedDefaultBinding)
|
: importedDefaultBinding(importedDefaultBinding)
|
||||||
{
|
{
|
||||||
kind = K;
|
kind = K;
|
||||||
|
@ -2753,14 +2753,14 @@ public:
|
||||||
kind = K;
|
kind = K;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImportClause(const QStringRef &importedDefaultBinding, NameSpaceImport *nameSpaceImport)
|
ImportClause(QStringView importedDefaultBinding, NameSpaceImport *nameSpaceImport)
|
||||||
: importedDefaultBinding(importedDefaultBinding)
|
: importedDefaultBinding(importedDefaultBinding)
|
||||||
, nameSpaceImport(nameSpaceImport)
|
, nameSpaceImport(nameSpaceImport)
|
||||||
{
|
{
|
||||||
kind = K;
|
kind = K;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImportClause(const QStringRef &importedDefaultBinding, NamedImports *namedImports)
|
ImportClause(QStringView importedDefaultBinding, NamedImports *namedImports)
|
||||||
: importedDefaultBinding(importedDefaultBinding)
|
: importedDefaultBinding(importedDefaultBinding)
|
||||||
, namedImports(namedImports)
|
, namedImports(namedImports)
|
||||||
{
|
{
|
||||||
|
@ -2776,7 +2776,7 @@ public:
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
SourceLocation importedDefaultBindingToken;
|
SourceLocation importedDefaultBindingToken;
|
||||||
QStringRef importedDefaultBinding;
|
QStringView importedDefaultBinding;
|
||||||
NameSpaceImport *nameSpaceImport = nullptr;
|
NameSpaceImport *nameSpaceImport = nullptr;
|
||||||
NamedImports *namedImports = nullptr;
|
NamedImports *namedImports = nullptr;
|
||||||
};
|
};
|
||||||
|
@ -2786,7 +2786,7 @@ class QML_PARSER_EXPORT FromClause: public Node
|
||||||
public:
|
public:
|
||||||
QQMLJS_DECLARE_AST_NODE(FromClause)
|
QQMLJS_DECLARE_AST_NODE(FromClause)
|
||||||
|
|
||||||
FromClause(const QStringRef &moduleSpecifier)
|
FromClause(QStringView moduleSpecifier)
|
||||||
: moduleSpecifier(moduleSpecifier)
|
: moduleSpecifier(moduleSpecifier)
|
||||||
{
|
{
|
||||||
kind = K;
|
kind = K;
|
||||||
|
@ -2803,7 +2803,7 @@ public:
|
||||||
// attributes
|
// attributes
|
||||||
SourceLocation fromToken;
|
SourceLocation fromToken;
|
||||||
SourceLocation moduleSpecifierToken;
|
SourceLocation moduleSpecifierToken;
|
||||||
QStringRef moduleSpecifier;
|
QStringView moduleSpecifier;
|
||||||
};
|
};
|
||||||
|
|
||||||
class QML_PARSER_EXPORT ImportDeclaration: public Statement
|
class QML_PARSER_EXPORT ImportDeclaration: public Statement
|
||||||
|
@ -2817,7 +2817,7 @@ public:
|
||||||
kind = K;
|
kind = K;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImportDeclaration(const QStringRef &moduleSpecifier)
|
ImportDeclaration(QStringView moduleSpecifier)
|
||||||
: moduleSpecifier(moduleSpecifier)
|
: moduleSpecifier(moduleSpecifier)
|
||||||
{
|
{
|
||||||
kind = K;
|
kind = K;
|
||||||
|
@ -2834,7 +2834,7 @@ public:
|
||||||
// attributes
|
// attributes
|
||||||
SourceLocation importToken;
|
SourceLocation importToken;
|
||||||
SourceLocation moduleSpecifierToken;
|
SourceLocation moduleSpecifierToken;
|
||||||
QStringRef moduleSpecifier;
|
QStringView moduleSpecifier;
|
||||||
ImportClause *importClause = nullptr;
|
ImportClause *importClause = nullptr;
|
||||||
FromClause *fromClause = nullptr;
|
FromClause *fromClause = nullptr;
|
||||||
};
|
};
|
||||||
|
@ -2844,13 +2844,13 @@ class QML_PARSER_EXPORT ExportSpecifier: public Node
|
||||||
public:
|
public:
|
||||||
QQMLJS_DECLARE_AST_NODE(ExportSpecifier)
|
QQMLJS_DECLARE_AST_NODE(ExportSpecifier)
|
||||||
|
|
||||||
ExportSpecifier(const QStringRef &identifier)
|
ExportSpecifier(QStringView identifier)
|
||||||
: identifier(identifier), exportedIdentifier(identifier)
|
: identifier(identifier), exportedIdentifier(identifier)
|
||||||
{
|
{
|
||||||
kind = K;
|
kind = K;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExportSpecifier(const QStringRef &identifier, const QStringRef &exportedIdentifier)
|
ExportSpecifier(QStringView identifier, QStringView exportedIdentifier)
|
||||||
: identifier(identifier), exportedIdentifier(exportedIdentifier)
|
: identifier(identifier), exportedIdentifier(exportedIdentifier)
|
||||||
{
|
{
|
||||||
kind = K;
|
kind = K;
|
||||||
|
@ -2866,8 +2866,8 @@ public:
|
||||||
// attributes
|
// attributes
|
||||||
SourceLocation identifierToken;
|
SourceLocation identifierToken;
|
||||||
SourceLocation exportedIdentifierToken;
|
SourceLocation exportedIdentifierToken;
|
||||||
QStringRef identifier;
|
QStringView identifier;
|
||||||
QStringRef exportedIdentifier;
|
QStringView exportedIdentifier;
|
||||||
};
|
};
|
||||||
|
|
||||||
class QML_PARSER_EXPORT ExportsList: public Node
|
class QML_PARSER_EXPORT ExportsList: public Node
|
||||||
|
@ -3038,7 +3038,7 @@ class QML_PARSER_EXPORT UiImport: public Node
|
||||||
public:
|
public:
|
||||||
QQMLJS_DECLARE_AST_NODE(UiImport)
|
QQMLJS_DECLARE_AST_NODE(UiImport)
|
||||||
|
|
||||||
UiImport(const QStringRef &fileName)
|
UiImport(QStringView fileName)
|
||||||
: fileName(fileName), importUri(nullptr)
|
: fileName(fileName), importUri(nullptr)
|
||||||
{ kind = K; }
|
{ kind = K; }
|
||||||
|
|
||||||
|
@ -3055,9 +3055,9 @@ public:
|
||||||
{ return semicolonToken; }
|
{ return semicolonToken; }
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
QStringRef fileName;
|
QStringView fileName;
|
||||||
UiQualifiedId *importUri;
|
UiQualifiedId *importUri;
|
||||||
QStringRef importId;
|
QStringView importId;
|
||||||
SourceLocation importToken;
|
SourceLocation importToken;
|
||||||
SourceLocation fileNameToken;
|
SourceLocation fileNameToken;
|
||||||
SourceLocation asToken;
|
SourceLocation asToken;
|
||||||
|
@ -3120,7 +3120,7 @@ class QML_PARSER_EXPORT UiPragma: public Node
|
||||||
public:
|
public:
|
||||||
QQMLJS_DECLARE_AST_NODE(UiPragma)
|
QQMLJS_DECLARE_AST_NODE(UiPragma)
|
||||||
|
|
||||||
UiPragma(QStringRef name)
|
UiPragma(QStringView name)
|
||||||
: name(name)
|
: name(name)
|
||||||
{ kind = K; }
|
{ kind = K; }
|
||||||
|
|
||||||
|
@ -3133,7 +3133,7 @@ public:
|
||||||
{ return semicolonToken; }
|
{ return semicolonToken; }
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
QStringRef name;
|
QStringView name;
|
||||||
SourceLocation pragmaToken;
|
SourceLocation pragmaToken;
|
||||||
SourceLocation semicolonToken;
|
SourceLocation semicolonToken;
|
||||||
};
|
};
|
||||||
|
@ -3143,7 +3143,7 @@ class QML_PARSER_EXPORT UiRequired: public Node
|
||||||
public:
|
public:
|
||||||
QQMLJS_DECLARE_AST_NODE(UiRequired)
|
QQMLJS_DECLARE_AST_NODE(UiRequired)
|
||||||
|
|
||||||
UiRequired(QStringRef name)
|
UiRequired(QStringView name)
|
||||||
:name(name)
|
:name(name)
|
||||||
{ kind = K; }
|
{ kind = K; }
|
||||||
|
|
||||||
|
@ -3155,7 +3155,7 @@ public:
|
||||||
SourceLocation lastSourceLocation() const override
|
SourceLocation lastSourceLocation() const override
|
||||||
{ return semicolonToken; }
|
{ return semicolonToken; }
|
||||||
|
|
||||||
QStringRef name;
|
QStringView name;
|
||||||
SourceLocation requiredToken;
|
SourceLocation requiredToken;
|
||||||
SourceLocation semicolonToken;
|
SourceLocation semicolonToken;
|
||||||
};
|
};
|
||||||
|
@ -3309,11 +3309,11 @@ class QML_PARSER_EXPORT UiParameterList: public Node
|
||||||
public:
|
public:
|
||||||
QQMLJS_DECLARE_AST_NODE(UiParameterList)
|
QQMLJS_DECLARE_AST_NODE(UiParameterList)
|
||||||
|
|
||||||
UiParameterList(UiQualifiedId *t, const QStringRef &n):
|
UiParameterList(UiQualifiedId *t, QStringView n):
|
||||||
type (t), name (n), next (this)
|
type (t), name (n), next (this)
|
||||||
{ kind = K; }
|
{ kind = K; }
|
||||||
|
|
||||||
UiParameterList(UiParameterList *previous, UiQualifiedId *t, const QStringRef &n):
|
UiParameterList(UiParameterList *previous, UiQualifiedId *t, QStringView n):
|
||||||
type (t), name (n)
|
type (t), name (n)
|
||||||
{
|
{
|
||||||
kind = K;
|
kind = K;
|
||||||
|
@ -3341,7 +3341,7 @@ public:
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
UiQualifiedId *type;
|
UiQualifiedId *type;
|
||||||
QStringRef name;
|
QStringView name;
|
||||||
UiParameterList *next;
|
UiParameterList *next;
|
||||||
SourceLocation commaToken;
|
SourceLocation commaToken;
|
||||||
SourceLocation propertyTypeToken;
|
SourceLocation propertyTypeToken;
|
||||||
|
@ -3355,12 +3355,12 @@ public:
|
||||||
QQMLJS_DECLARE_AST_NODE(UiPublicMember)
|
QQMLJS_DECLARE_AST_NODE(UiPublicMember)
|
||||||
|
|
||||||
UiPublicMember(UiQualifiedId *memberType,
|
UiPublicMember(UiQualifiedId *memberType,
|
||||||
const QStringRef &name)
|
QStringView name)
|
||||||
: type(Property), memberType(memberType), name(name), statement(nullptr), binding(nullptr), isDefaultMember(false), isReadonlyMember(false), parameters(nullptr)
|
: type(Property), memberType(memberType), name(name), statement(nullptr), binding(nullptr), isDefaultMember(false), isReadonlyMember(false), parameters(nullptr)
|
||||||
{ kind = K; }
|
{ kind = K; }
|
||||||
|
|
||||||
UiPublicMember(UiQualifiedId *memberType,
|
UiPublicMember(UiQualifiedId *memberType,
|
||||||
const QStringRef &name,
|
QStringView name,
|
||||||
Statement *statement)
|
Statement *statement)
|
||||||
: type(Property), memberType(memberType), name(name), statement(statement), binding(nullptr), isDefaultMember(false), isReadonlyMember(false), parameters(nullptr)
|
: type(Property), memberType(memberType), name(name), statement(statement), binding(nullptr), isDefaultMember(false), isReadonlyMember(false), parameters(nullptr)
|
||||||
{ kind = K; }
|
{ kind = K; }
|
||||||
|
@ -3391,9 +3391,9 @@ public:
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
enum { Signal, Property } type;
|
enum { Signal, Property } type;
|
||||||
QStringRef typeModifier;
|
QStringView typeModifier;
|
||||||
UiQualifiedId *memberType;
|
UiQualifiedId *memberType;
|
||||||
QStringRef name;
|
QStringView name;
|
||||||
Statement *statement; // initialized with a JS expression
|
Statement *statement; // initialized with a JS expression
|
||||||
UiObjectMember *binding; // initialized with a QML object or array.
|
UiObjectMember *binding; // initialized with a QML object or array.
|
||||||
bool isDefaultMember;
|
bool isDefaultMember;
|
||||||
|
@ -3440,7 +3440,7 @@ class QML_PARSER_EXPORT UiInlineComponent: public UiObjectMember
|
||||||
public:
|
public:
|
||||||
QQMLJS_DECLARE_AST_NODE(UiInlineComponent)
|
QQMLJS_DECLARE_AST_NODE(UiInlineComponent)
|
||||||
|
|
||||||
UiInlineComponent(const QStringRef& inlineComponentName, UiObjectDefinition* inlineComponent)
|
UiInlineComponent(QStringView inlineComponentName, UiObjectDefinition* inlineComponent)
|
||||||
: name(inlineComponentName), component(inlineComponent)
|
: name(inlineComponentName), component(inlineComponent)
|
||||||
{ kind = K; }
|
{ kind = K; }
|
||||||
|
|
||||||
|
@ -3453,7 +3453,7 @@ public:
|
||||||
void accept0(BaseVisitor *visitor) override;
|
void accept0(BaseVisitor *visitor) override;
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
QStringRef name;
|
QStringView name;
|
||||||
UiObjectDefinition* component;
|
UiObjectDefinition* component;
|
||||||
SourceLocation componentToken;
|
SourceLocation componentToken;
|
||||||
};
|
};
|
||||||
|
@ -3586,11 +3586,11 @@ class QML_PARSER_EXPORT UiEnumMemberList: public Node
|
||||||
{
|
{
|
||||||
QQMLJS_DECLARE_AST_NODE(UiEnumMemberList)
|
QQMLJS_DECLARE_AST_NODE(UiEnumMemberList)
|
||||||
public:
|
public:
|
||||||
UiEnumMemberList(const QStringRef &member, double v = 0.0)
|
UiEnumMemberList(QStringView member, double v = 0.0)
|
||||||
: next(this), member(member), value(v)
|
: next(this), member(member), value(v)
|
||||||
{ kind = K; }
|
{ kind = K; }
|
||||||
|
|
||||||
UiEnumMemberList(UiEnumMemberList *previous, const QStringRef &member)
|
UiEnumMemberList(UiEnumMemberList *previous, QStringView member)
|
||||||
: member(member)
|
: member(member)
|
||||||
{
|
{
|
||||||
kind = K;
|
kind = K;
|
||||||
|
@ -3599,7 +3599,7 @@ public:
|
||||||
value = previous->value + 1;
|
value = previous->value + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
UiEnumMemberList(UiEnumMemberList *previous, const QStringRef &member, double v)
|
UiEnumMemberList(UiEnumMemberList *previous, QStringView member, double v)
|
||||||
: member(member), value(v)
|
: member(member), value(v)
|
||||||
{
|
{
|
||||||
kind = K;
|
kind = K;
|
||||||
|
@ -3627,7 +3627,7 @@ public:
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
UiEnumMemberList *next;
|
UiEnumMemberList *next;
|
||||||
QStringRef member;
|
QStringView member;
|
||||||
double value;
|
double value;
|
||||||
SourceLocation memberToken;
|
SourceLocation memberToken;
|
||||||
SourceLocation valueToken;
|
SourceLocation valueToken;
|
||||||
|
@ -3638,7 +3638,7 @@ class QML_PARSER_EXPORT UiEnumDeclaration: public UiObjectMember
|
||||||
public:
|
public:
|
||||||
QQMLJS_DECLARE_AST_NODE(UiEnumDeclaration)
|
QQMLJS_DECLARE_AST_NODE(UiEnumDeclaration)
|
||||||
|
|
||||||
UiEnumDeclaration(const QStringRef &name,
|
UiEnumDeclaration(QStringView name,
|
||||||
UiEnumMemberList *members)
|
UiEnumMemberList *members)
|
||||||
: name(name)
|
: name(name)
|
||||||
, members(members)
|
, members(members)
|
||||||
|
@ -3655,7 +3655,7 @@ public:
|
||||||
// attributes
|
// attributes
|
||||||
SourceLocation enumToken;
|
SourceLocation enumToken;
|
||||||
SourceLocation rbraceToken;
|
SourceLocation rbraceToken;
|
||||||
QStringRef name;
|
QStringView name;
|
||||||
UiEnumMemberList *members;
|
UiEnumMemberList *members;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -143,14 +143,13 @@ void Engine::setDirectives(Directives *directives)
|
||||||
MemoryPool *Engine::pool()
|
MemoryPool *Engine::pool()
|
||||||
{ return &_pool; }
|
{ return &_pool; }
|
||||||
|
|
||||||
QStringRef Engine::newStringRef(const QString &text)
|
QStringView Engine::newStringRef(const QString &text)
|
||||||
{
|
{
|
||||||
const int pos = _extraCode.length();
|
_extraCode.append(text);
|
||||||
_extraCode += text;
|
return QStringView{_extraCode.last()};
|
||||||
return _extraCode.midRef(pos, text.length());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringRef Engine::newStringRef(const QChar *chars, int size)
|
QStringView Engine::newStringRef(const QChar *chars, int size)
|
||||||
{ return newStringRef(QString(chars, size)); }
|
{ return newStringRef(QString(chars, size)); }
|
||||||
|
|
||||||
} // end of namespace QQmlJS
|
} // end of namespace QQmlJS
|
||||||
|
|
|
@ -98,7 +98,7 @@ class QML_PARSER_EXPORT Engine
|
||||||
Directives *_directives;
|
Directives *_directives;
|
||||||
MemoryPool _pool;
|
MemoryPool _pool;
|
||||||
QList<SourceLocation> _comments;
|
QList<SourceLocation> _comments;
|
||||||
QString _extraCode;
|
QStringList _extraCode;
|
||||||
QString _code;
|
QString _code;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -119,10 +119,10 @@ public:
|
||||||
|
|
||||||
MemoryPool *pool();
|
MemoryPool *pool();
|
||||||
|
|
||||||
inline QStringRef midRef(int position, int size) { return _code.midRef(position, size); }
|
inline QStringView midRef(int position, int size) { return QStringView{_code}.mid(position, size); }
|
||||||
|
|
||||||
QStringRef newStringRef(const QString &s);
|
QStringView newStringRef(const QString &s);
|
||||||
QStringRef newStringRef(const QChar *chars, int size);
|
QStringView newStringRef(const QChar *chars, int size);
|
||||||
};
|
};
|
||||||
|
|
||||||
double integerFromString(const char *buf, int size, int radix);
|
double integerFromString(const char *buf, int size, int radix);
|
||||||
|
|
|
@ -132,8 +132,8 @@ void Lexer::setCode(const QString &code, int lineno, bool qmlMode)
|
||||||
_tokenText.clear();
|
_tokenText.clear();
|
||||||
_tokenText.reserve(1024);
|
_tokenText.reserve(1024);
|
||||||
_errorMessage.clear();
|
_errorMessage.clear();
|
||||||
_tokenSpell = QStringRef();
|
_tokenSpell = QStringView();
|
||||||
_rawString = QStringRef();
|
_rawString = QStringView();
|
||||||
|
|
||||||
_codePtr = code.unicode();
|
_codePtr = code.unicode();
|
||||||
_endPtr = _codePtr + code.length();
|
_endPtr = _codePtr + code.length();
|
||||||
|
@ -256,8 +256,8 @@ int Lexer::lex()
|
||||||
const int previousTokenKind = _tokenKind;
|
const int previousTokenKind = _tokenKind;
|
||||||
|
|
||||||
again:
|
again:
|
||||||
_tokenSpell = QStringRef();
|
_tokenSpell = QStringView();
|
||||||
_rawString = QStringRef();
|
_rawString = QStringView();
|
||||||
_tokenKind = scanToken();
|
_tokenKind = scanToken();
|
||||||
_tokenLength = _codePtr - _tokenStartPtr - 1;
|
_tokenLength = _codePtr - _tokenStartPtr - 1;
|
||||||
|
|
||||||
|
|
|
@ -165,8 +165,8 @@ public:
|
||||||
int tokenStartLine() const { return _tokenLine; }
|
int tokenStartLine() const { return _tokenLine; }
|
||||||
int tokenStartColumn() const { return _tokenColumn; }
|
int tokenStartColumn() const { return _tokenColumn; }
|
||||||
|
|
||||||
inline QStringRef tokenSpell() const { return _tokenSpell; }
|
inline QStringView tokenSpell() const { return _tokenSpell; }
|
||||||
inline QStringRef rawString() const { return _rawString; }
|
inline QStringView rawString() const { return _rawString; }
|
||||||
double tokenValue() const { return _tokenValue; }
|
double tokenValue() const { return _tokenValue; }
|
||||||
QString tokenText() const;
|
QString tokenText() const;
|
||||||
|
|
||||||
|
@ -219,8 +219,8 @@ private:
|
||||||
QString _code;
|
QString _code;
|
||||||
QString _tokenText;
|
QString _tokenText;
|
||||||
QString _errorMessage;
|
QString _errorMessage;
|
||||||
QStringRef _tokenSpell;
|
QStringView _tokenSpell;
|
||||||
QStringRef _rawString;
|
QStringView _rawString;
|
||||||
|
|
||||||
const QChar *_codePtr;
|
const QChar *_codePtr;
|
||||||
const QChar *_endPtr;
|
const QChar *_endPtr;
|
||||||
|
|
|
@ -100,7 +100,7 @@ class Q_QML_PRIVATE_EXPORT QHashedStringRef
|
||||||
public:
|
public:
|
||||||
inline QHashedStringRef();
|
inline QHashedStringRef();
|
||||||
inline QHashedStringRef(const QString &);
|
inline QHashedStringRef(const QString &);
|
||||||
inline QHashedStringRef(const QStringRef &);
|
inline QHashedStringRef(QStringView);
|
||||||
inline QHashedStringRef(const QChar *, int);
|
inline QHashedStringRef(const QChar *, int);
|
||||||
inline QHashedStringRef(const QChar *, int, quint32);
|
inline QHashedStringRef(const QChar *, int, quint32);
|
||||||
inline QHashedStringRef(const QHashedString &);
|
inline QHashedStringRef(const QHashedString &);
|
||||||
|
@ -242,7 +242,7 @@ QHashedStringRef::QHashedStringRef(const QString &str)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QHashedStringRef::QHashedStringRef(const QStringRef &str)
|
QHashedStringRef::QHashedStringRef(QStringView str)
|
||||||
: m_data(str.constData()), m_length(str.length()), m_hash(0)
|
: m_data(str.constData()), m_length(str.length()), m_hash(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -253,7 +253,7 @@ template<typename T>
|
||||||
struct HashedForm {};
|
struct HashedForm {};
|
||||||
|
|
||||||
template<> struct HashedForm<QString> { typedef QHashedString Type; };
|
template<> struct HashedForm<QString> { typedef QHashedString Type; };
|
||||||
template<> struct HashedForm<QStringRef> { typedef QHashedStringRef Type; };
|
template<> struct HashedForm<QStringView> { typedef QHashedStringRef Type; };
|
||||||
template<> struct HashedForm<QHashedString> { typedef const QHashedString &Type; };
|
template<> struct HashedForm<QHashedString> { typedef const QHashedString &Type; };
|
||||||
template<> struct HashedForm<QV4::String *> { typedef const QV4::String *Type; };
|
template<> struct HashedForm<QV4::String *> { typedef const QV4::String *Type; };
|
||||||
template<> struct HashedForm<const QV4::String *> { typedef const QV4::String *Type; };
|
template<> struct HashedForm<const QV4::String *> { typedef const QV4::String *Type; };
|
||||||
|
@ -265,7 +265,7 @@ class QStringHashBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static HashedForm<QString>::Type hashedString(const QString &s) { return QHashedString(s);}
|
static HashedForm<QString>::Type hashedString(const QString &s) { return QHashedString(s);}
|
||||||
static HashedForm<QStringRef>::Type hashedString(const QStringRef &s) { return QHashedStringRef(s.constData(), s.size());}
|
static HashedForm<QStringView>::Type hashedString(QStringView s) { return QHashedStringRef(s.constData(), s.size());}
|
||||||
static HashedForm<QHashedString>::Type hashedString(const QHashedString &s) { return s; }
|
static HashedForm<QHashedString>::Type hashedString(const QHashedString &s) { return s; }
|
||||||
static HashedForm<QV4::String *>::Type hashedString(QV4::String *s) { return s; }
|
static HashedForm<QV4::String *>::Type hashedString(QV4::String *s) { return s; }
|
||||||
static HashedForm<const QV4::String *>::Type hashedString(const QV4::String *s) { return s; }
|
static HashedForm<const QV4::String *>::Type hashedString(const QV4::String *s) { return s; }
|
||||||
|
|
|
@ -318,10 +318,10 @@ QDebug operator<<(QDebug debug, const QQmlError &error)
|
||||||
QByteArray data = f.readAll();
|
QByteArray data = f.readAll();
|
||||||
QTextStream stream(data, QIODevice::ReadOnly);
|
QTextStream stream(data, QIODevice::ReadOnly);
|
||||||
const QString code = stream.readAll();
|
const QString code = stream.readAll();
|
||||||
const auto lines = code.splitRef(QLatin1Char('\n'));
|
const auto lines = QStringView{code}.split(QLatin1Char('\n'));
|
||||||
|
|
||||||
if (lines.count() >= error.line()) {
|
if (lines.count() >= error.line()) {
|
||||||
const QStringRef &line = lines.at(error.line() - 1);
|
const QStringView &line = lines.at(error.line() - 1);
|
||||||
debug << "\n " << line.toLocal8Bit().constData();
|
debug << "\n " << line.toLocal8Bit().constData();
|
||||||
|
|
||||||
if(error.column() > 0) {
|
if(error.column() > 0) {
|
||||||
|
|
|
@ -616,13 +616,13 @@ QString QQmlFile::urlToLocalFileOrQrc(const QString& url)
|
||||||
{
|
{
|
||||||
if (url.startsWith(QLatin1String("qrc://"), Qt::CaseInsensitive)) {
|
if (url.startsWith(QLatin1String("qrc://"), Qt::CaseInsensitive)) {
|
||||||
if (url.length() > 6)
|
if (url.length() > 6)
|
||||||
return QLatin1Char(':') + url.midRef(6);
|
return QLatin1Char(':') + QStringView{url}.mid(6);
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (url.startsWith(QLatin1String("qrc:"), Qt::CaseInsensitive)) {
|
if (url.startsWith(QLatin1String("qrc:"), Qt::CaseInsensitive)) {
|
||||||
if (url.length() > 4)
|
if (url.length() > 4)
|
||||||
return QLatin1Char(':') + url.midRef(4);
|
return QLatin1Char(':') + QStringView{url}.mid(4);
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ QString resolveLocalUrl(const QString &url, const QString &relative)
|
||||||
} else if (relative.at(0) == Slash || !url.contains(Slash)) {
|
} else if (relative.at(0) == Slash || !url.contains(Slash)) {
|
||||||
return relative;
|
return relative;
|
||||||
} else {
|
} else {
|
||||||
const QStringRef baseRef = url.leftRef(url.lastIndexOf(Slash) + 1);
|
const QStringView baseRef = QStringView{url}.left(url.lastIndexOf(Slash) + 1);
|
||||||
if (relative == QLatin1String("."))
|
if (relative == QLatin1String("."))
|
||||||
return baseRef.toString();
|
return baseRef.toString();
|
||||||
|
|
||||||
|
@ -406,7 +406,7 @@ bool excludeBaseUrl(const QString &importUrl, const QString &fileName, const QSt
|
||||||
|
|
||||||
if (baseUrl.startsWith(importUrl))
|
if (baseUrl.startsWith(importUrl))
|
||||||
{
|
{
|
||||||
if (fileName == baseUrl.midRef(importUrl.size()))
|
if (fileName == QStringView{baseUrl}.mid(importUrl.size()))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1000,17 +1000,17 @@ bool QQmlImportNamespace::resolveType(QQmlTypeLoader *typeLoader, const QHashedS
|
||||||
QString u1 = import->url;
|
QString u1 = import->url;
|
||||||
QString u2 = import2->url;
|
QString u2 = import2->url;
|
||||||
if (base) {
|
if (base) {
|
||||||
QStringRef b(base);
|
QStringView b(*base);
|
||||||
int dot = b.lastIndexOf(Dot);
|
int dot = b.lastIndexOf(Dot);
|
||||||
if (dot >= 0) {
|
if (dot >= 0) {
|
||||||
b = b.left(dot+1);
|
b = b.left(dot+1);
|
||||||
QStringRef l = b.left(dot);
|
QStringView l = b.left(dot);
|
||||||
if (u1.startsWith(b))
|
if (u1.startsWith(b))
|
||||||
u1 = u1.mid(b.count());
|
u1 = u1.mid(b.size());
|
||||||
else if (u1 == l)
|
else if (u1 == l)
|
||||||
u1 = QQmlImportDatabase::tr("local directory");
|
u1 = QQmlImportDatabase::tr("local directory");
|
||||||
if (u2.startsWith(b))
|
if (u2.startsWith(b))
|
||||||
u2 = u2.mid(b.count());
|
u2 = u2.mid(b.size());
|
||||||
else if (u2 == l)
|
else if (u2 == l)
|
||||||
u2 = QQmlImportDatabase::tr("local directory");
|
u2 = QQmlImportDatabase::tr("local directory");
|
||||||
}
|
}
|
||||||
|
@ -1400,7 +1400,7 @@ QQmlImports::LocalQmldirResult QQmlImportsPrivate::locateLocalQmldir(
|
||||||
QString absoluteFilePath = typeLoader.absoluteFilePath(qmldirPath);
|
QString absoluteFilePath = typeLoader.absoluteFilePath(qmldirPath);
|
||||||
if (!absoluteFilePath.isEmpty()) {
|
if (!absoluteFilePath.isEmpty()) {
|
||||||
QString url;
|
QString url;
|
||||||
const QStringRef absolutePath = absoluteFilePath.leftRef(absoluteFilePath.lastIndexOf(Slash) + 1);
|
const QStringView absolutePath = QStringView{absoluteFilePath}.left(absoluteFilePath.lastIndexOf(Slash) + 1);
|
||||||
if (absolutePath.at(0) == Colon)
|
if (absolutePath.at(0) == Colon)
|
||||||
url = QLatin1String("qrc") + absolutePath;
|
url = QLatin1String("qrc") + absolutePath;
|
||||||
else
|
else
|
||||||
|
|
|
@ -91,7 +91,7 @@ public:
|
||||||
inline QQmlInfo &operator<<(double t) { QDebug::operator<<(t); return *this; }
|
inline QQmlInfo &operator<<(double t) { QDebug::operator<<(t); return *this; }
|
||||||
inline QQmlInfo &operator<<(const char* t) { QDebug::operator<<(t); return *this; }
|
inline QQmlInfo &operator<<(const char* t) { QDebug::operator<<(t); return *this; }
|
||||||
inline QQmlInfo &operator<<(const QString & t) { QDebug::operator<<(t.toLocal8Bit().constData()); return *this; }
|
inline QQmlInfo &operator<<(const QString & t) { QDebug::operator<<(t.toLocal8Bit().constData()); return *this; }
|
||||||
inline QQmlInfo &operator<<(const QStringRef & t) { return operator<<(t.toString()); }
|
inline QQmlInfo &operator<<(QStringView t) { return operator<<(t.toString()); }
|
||||||
inline QQmlInfo &operator<<(const QLatin1String &t) { QDebug::operator<<(t.latin1()); return *this; }
|
inline QQmlInfo &operator<<(const QLatin1String &t) { QDebug::operator<<(t.latin1()); return *this; }
|
||||||
inline QQmlInfo &operator<<(const QByteArray & t) { QDebug::operator<<(t); return *this; }
|
inline QQmlInfo &operator<<(const QByteArray & t) { QDebug::operator<<(t); return *this; }
|
||||||
inline QQmlInfo &operator<<(const void * t) { QDebug::operator<<(t); return *this; }
|
inline QQmlInfo &operator<<(const void * t) { QDebug::operator<<(t); return *this; }
|
||||||
|
|
|
@ -1481,7 +1481,7 @@ QString QQmlMetaType::prettyTypeName(const QObject *object)
|
||||||
|
|
||||||
marker = typeName.indexOf(QLatin1String("_QML_"));
|
marker = typeName.indexOf(QLatin1String("_QML_"));
|
||||||
if (marker != -1) {
|
if (marker != -1) {
|
||||||
typeName = typeName.leftRef(marker) + QLatin1Char('*');
|
typeName = QStringView{typeName}.left(marker) + QLatin1Char('*');
|
||||||
type = QQmlMetaType::qmlType(QMetaType::type(typeName.toLatin1()));
|
type = QQmlMetaType::qmlType(QMetaType::type(typeName.toLatin1()));
|
||||||
if (type.isValid()) {
|
if (type.isValid()) {
|
||||||
QString qmlTypeName = type.qmlTypeName();
|
QString qmlTypeName = type.qmlTypeName();
|
||||||
|
|
|
@ -262,16 +262,16 @@ void QQmlPropertyPrivate::initProperty(QObject *obj, const QString &name)
|
||||||
QQmlRefPointer<QQmlTypeNameCache> typeNameCache = context ? context->imports() : nullptr;
|
QQmlRefPointer<QQmlTypeNameCache> typeNameCache = context ? context->imports() : nullptr;
|
||||||
|
|
||||||
QObject *currentObject = obj;
|
QObject *currentObject = obj;
|
||||||
QVector<QStringRef> path;
|
QList<QStringView> path;
|
||||||
QStringRef terminal(&name);
|
QStringView terminal(name);
|
||||||
|
|
||||||
if (name.contains(QLatin1Char('.'))) {
|
if (name.contains(QLatin1Char('.'))) {
|
||||||
path = name.splitRef(QLatin1Char('.'));
|
path = QStringView{name}.split(QLatin1Char('.'));
|
||||||
if (path.isEmpty()) return;
|
if (path.isEmpty()) return;
|
||||||
|
|
||||||
// Everything up to the last property must be an "object type" property
|
// Everything up to the last property must be an "object type" property
|
||||||
for (int ii = 0; ii < path.count() - 1; ++ii) {
|
for (int ii = 0; ii < path.count() - 1; ++ii) {
|
||||||
const QStringRef &pathName = path.at(ii);
|
const QStringView &pathName = path.at(ii);
|
||||||
|
|
||||||
// Types must begin with an uppercase letter (see checkRegistration()
|
// Types must begin with an uppercase letter (see checkRegistration()
|
||||||
// in qqmlmetatype.cpp for the enforcement of this).
|
// in qqmlmetatype.cpp for the enforcement of this).
|
||||||
|
@ -355,7 +355,7 @@ void QQmlPropertyPrivate::initProperty(QObject *obj, const QString &name)
|
||||||
terminal = path.last();
|
terminal = path.last();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (terminal.count() >= 3 && terminal.at(0) == u'o' && terminal.at(1) == u'n'
|
if (terminal.size() >= 3 && terminal.at(0) == u'o' && terminal.at(1) == u'n'
|
||||||
&& (terminal.at(2).isUpper() || terminal.at(2) == u'_')) {
|
&& (terminal.at(2).isUpper() || terminal.at(2) == u'_')) {
|
||||||
|
|
||||||
QString signalName = terminal.mid(2).toString();
|
QString signalName = terminal.mid(2).toString();
|
||||||
|
@ -384,7 +384,7 @@ void QQmlPropertyPrivate::initProperty(QObject *obj, const QString &name)
|
||||||
|
|
||||||
// Try property
|
// Try property
|
||||||
if (signalName.endsWith(QLatin1String("Changed"))) {
|
if (signalName.endsWith(QLatin1String("Changed"))) {
|
||||||
const QStringRef propName = signalName.midRef(0, signalName.length() - 7);
|
const QStringView propName = QStringView{signalName}.mid(0, signalName.length() - 7);
|
||||||
QQmlPropertyData *d = ddata->propertyCache->property(propName, currentObject, context);
|
QQmlPropertyData *d = ddata->propertyCache->property(propName, currentObject, context);
|
||||||
while (d && d->isFunction())
|
while (d && d->isFunction())
|
||||||
d = ddata->propertyCache->overrideData(d);
|
d = ddata->propertyCache->overrideData(d);
|
||||||
|
|
|
@ -551,7 +551,7 @@ void QQmlPropertyCache::append(const QMetaObject *metaObject,
|
||||||
setNamedProperty(methodName, ii, data, (old != nullptr));
|
setNamedProperty(methodName, ii, data, (old != nullptr));
|
||||||
|
|
||||||
if (data->isSignal()) {
|
if (data->isSignal()) {
|
||||||
QHashedString on(QLatin1String("on") % methodName.at(0).toUpper() % methodName.midRef(1));
|
QHashedString on(QLatin1String("on") % methodName.at(0).toUpper() % QStringView{methodName}.mid(1));
|
||||||
setNamedProperty(on, ii, sigdata, (old != nullptr));
|
setNamedProperty(on, ii, sigdata, (old != nullptr));
|
||||||
++signalHandlerIndex;
|
++signalHandlerIndex;
|
||||||
}
|
}
|
||||||
|
@ -991,7 +991,7 @@ static inline const char *qQmlPropertyCacheToString(QLatin1String string)
|
||||||
return string.data();
|
return string.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline QByteArray qQmlPropertyCacheToString(const QStringRef &string)
|
static inline QByteArray qQmlPropertyCacheToString(QStringView string)
|
||||||
{
|
{
|
||||||
return string.toUtf8();
|
return string.toUtf8();
|
||||||
}
|
}
|
||||||
|
@ -1043,10 +1043,10 @@ QQmlPropertyCache::property(QJSEngine *engine, QObject *obj, const QV4::String *
|
||||||
}
|
}
|
||||||
|
|
||||||
QQmlPropertyData *
|
QQmlPropertyData *
|
||||||
QQmlPropertyCache::property(QJSEngine *engine, QObject *obj, const QStringRef &name,
|
QQmlPropertyCache::property(QJSEngine *engine, QObject *obj, QStringView name,
|
||||||
const QQmlRefPointer<QQmlContextData> &context, QQmlPropertyData *local)
|
const QQmlRefPointer<QQmlContextData> &context, QQmlPropertyData *local)
|
||||||
{
|
{
|
||||||
return qQmlPropertyCacheProperty<const QStringRef &>(engine, obj, name, context, local);
|
return qQmlPropertyCacheProperty<const QStringView &>(engine, obj, name, context, local);
|
||||||
}
|
}
|
||||||
|
|
||||||
QQmlPropertyData *
|
QQmlPropertyData *
|
||||||
|
|
|
@ -185,7 +185,7 @@ public:
|
||||||
inline QQmlPropertyData *overrideData(QQmlPropertyData *) const;
|
inline QQmlPropertyData *overrideData(QQmlPropertyData *) const;
|
||||||
inline bool isAllowedInRevision(QQmlPropertyData *) const;
|
inline bool isAllowedInRevision(QQmlPropertyData *) const;
|
||||||
|
|
||||||
static QQmlPropertyData *property(QJSEngine *, QObject *, const QStringRef &,
|
static QQmlPropertyData *property(QJSEngine *, QObject *, QStringView,
|
||||||
const QQmlRefPointer<QQmlContextData> &, QQmlPropertyData *);
|
const QQmlRefPointer<QQmlContextData> &, QQmlPropertyData *);
|
||||||
static QQmlPropertyData *property(QJSEngine *, QObject *, const QLatin1String &,
|
static QQmlPropertyData *property(QJSEngine *, QObject *, const QLatin1String &,
|
||||||
const QQmlRefPointer<QQmlContextData> &, QQmlPropertyData *);
|
const QQmlRefPointer<QQmlContextData> &, QQmlPropertyData *);
|
||||||
|
@ -196,7 +196,7 @@ public:
|
||||||
const QQmlRefPointer<QQmlContextData> &context,
|
const QQmlRefPointer<QQmlContextData> &context,
|
||||||
QQmlPropertyData *local)
|
QQmlPropertyData *local)
|
||||||
{
|
{
|
||||||
return property(engine, obj, QStringRef(&name), context, local);
|
return property(engine, obj, QStringView(name), context, local);
|
||||||
}
|
}
|
||||||
|
|
||||||
//see QMetaObjectPrivate::originalClone
|
//see QMetaObjectPrivate::originalClone
|
||||||
|
|
|
@ -82,7 +82,7 @@ QByteArray QQmlPropertyCacheCreatorBase::createClassNameTypeByUrl(const QUrl &ur
|
||||||
if (lastSlash <= -1)
|
if (lastSlash <= -1)
|
||||||
return QByteArray();
|
return QByteArray();
|
||||||
// ### this might not be correct for .ui.qml files
|
// ### this might not be correct for .ui.qml files
|
||||||
const QStringRef nameBase = path.midRef(lastSlash + 1, path.length() - lastSlash - 5);
|
const QStringView nameBase = QStringView{path}.mid(lastSlash + 1, path.length() - lastSlash - 5);
|
||||||
// Not a reusable type if it doesn't start with a upper case letter.
|
// Not a reusable type if it doesn't start with a upper case letter.
|
||||||
if (nameBase.isEmpty() || !nameBase.at(0).isUpper())
|
if (nameBase.isEmpty() || !nameBase.at(0).isUpper())
|
||||||
return QByteArray();
|
return QByteArray();
|
||||||
|
|
|
@ -143,8 +143,8 @@ QPointF QQmlStringConverters::pointFFromString(const QString &s, bool *ok)
|
||||||
|
|
||||||
bool xGood, yGood;
|
bool xGood, yGood;
|
||||||
int index = s.indexOf(QLatin1Char(','));
|
int index = s.indexOf(QLatin1Char(','));
|
||||||
qreal xCoord = s.leftRef(index).toDouble(&xGood);
|
qreal xCoord = QStringView{s}.left(index).toDouble(&xGood);
|
||||||
qreal yCoord = s.midRef(index+1).toDouble(&yGood);
|
qreal yCoord = QStringView{s}.mid(index+1).toDouble(&yGood);
|
||||||
if (!xGood || !yGood) {
|
if (!xGood || !yGood) {
|
||||||
if (ok)
|
if (ok)
|
||||||
*ok = false;
|
*ok = false;
|
||||||
|
@ -167,8 +167,8 @@ QSizeF QQmlStringConverters::sizeFFromString(const QString &s, bool *ok)
|
||||||
|
|
||||||
bool wGood, hGood;
|
bool wGood, hGood;
|
||||||
int index = s.indexOf(QLatin1Char('x'));
|
int index = s.indexOf(QLatin1Char('x'));
|
||||||
qreal width = s.leftRef(index).toDouble(&wGood);
|
qreal width = QStringView{s}.left(index).toDouble(&wGood);
|
||||||
qreal height = s.midRef(index+1).toDouble(&hGood);
|
qreal height = QStringView{s}.mid(index+1).toDouble(&hGood);
|
||||||
if (!wGood || !hGood) {
|
if (!wGood || !hGood) {
|
||||||
if (ok)
|
if (ok)
|
||||||
*ok = false;
|
*ok = false;
|
||||||
|
@ -191,12 +191,12 @@ QRectF QQmlStringConverters::rectFFromString(const QString &s, bool *ok)
|
||||||
|
|
||||||
bool xGood, yGood, wGood, hGood;
|
bool xGood, yGood, wGood, hGood;
|
||||||
int index = s.indexOf(QLatin1Char(','));
|
int index = s.indexOf(QLatin1Char(','));
|
||||||
qreal x = s.leftRef(index).toDouble(&xGood);
|
qreal x = QStringView{s}.left(index).toDouble(&xGood);
|
||||||
int index2 = s.indexOf(QLatin1Char(','), index+1);
|
int index2 = s.indexOf(QLatin1Char(','), index+1);
|
||||||
qreal y = s.midRef(index+1, index2-index-1).toDouble(&yGood);
|
qreal y = QStringView{s}.mid(index+1, index2-index-1).toDouble(&yGood);
|
||||||
index = s.indexOf(QLatin1Char('x'), index2+1);
|
index = s.indexOf(QLatin1Char('x'), index2+1);
|
||||||
qreal width = s.midRef(index2+1, index-index2-1).toDouble(&wGood);
|
qreal width = QStringView{s}.mid(index2+1, index-index2-1).toDouble(&wGood);
|
||||||
qreal height = s.midRef(index+1).toDouble(&hGood);
|
qreal height = QStringView{s}.mid(index+1).toDouble(&hGood);
|
||||||
if (!xGood || !yGood || !wGood || !hGood) {
|
if (!xGood || !yGood || !wGood || !hGood) {
|
||||||
if (ok)
|
if (ok)
|
||||||
*ok = false;
|
*ok = false;
|
||||||
|
|
|
@ -846,7 +846,7 @@ int QQmlType::scopedEnumValue(QQmlEnginePrivate *engine, const QByteArray &scope
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int QQmlType::scopedEnumValue(QQmlEnginePrivate *engine, const QStringRef &scopedEnumName, const QStringRef &name, bool *ok) const
|
int QQmlType::scopedEnumValue(QQmlEnginePrivate *engine, QStringView scopedEnumName, QStringView name, bool *ok) const
|
||||||
{
|
{
|
||||||
Q_ASSERT(ok);
|
Q_ASSERT(ok);
|
||||||
if (d) {
|
if (d) {
|
||||||
|
|
|
@ -169,7 +169,7 @@ public:
|
||||||
int scopedEnumValue(QQmlEnginePrivate *engine, int index, const QV4::String *, bool *ok) const;
|
int scopedEnumValue(QQmlEnginePrivate *engine, int index, const QV4::String *, bool *ok) const;
|
||||||
int scopedEnumValue(QQmlEnginePrivate *engine, int index, const QString &, bool *ok) const;
|
int scopedEnumValue(QQmlEnginePrivate *engine, int index, const QString &, bool *ok) const;
|
||||||
int scopedEnumValue(QQmlEnginePrivate *engine, const QByteArray &, const QByteArray &, bool *ok) const;
|
int scopedEnumValue(QQmlEnginePrivate *engine, const QByteArray &, const QByteArray &, bool *ok) const;
|
||||||
int scopedEnumValue(QQmlEnginePrivate *engine, const QStringRef &, const QStringRef &, bool *ok) const;
|
int scopedEnumValue(QQmlEnginePrivate *engine, QStringView, QStringView, bool *ok) const;
|
||||||
int inlineComponentObjectId() const;
|
int inlineComponentObjectId() const;
|
||||||
void setInlineComponentObjectId(int id) const; // TODO: const setters are BAD
|
void setInlineComponentObjectId(int id) const; // TODO: const setters are BAD
|
||||||
|
|
||||||
|
|
|
@ -249,7 +249,7 @@ QQmlJS::MemoryPool *QQmlTypeCompiler::memoryPool()
|
||||||
return document->jsParserEngine.pool();
|
return document->jsParserEngine.pool();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringRef QQmlTypeCompiler::newStringRef(const QString &string)
|
QStringView QQmlTypeCompiler::newStringRef(const QString &string)
|
||||||
{
|
{
|
||||||
return document->jsParserEngine.newStringRef(string);
|
return document->jsParserEngine.newStringRef(string);
|
||||||
}
|
}
|
||||||
|
@ -468,7 +468,7 @@ bool SignalHandlerConverter::convertSignalHandlerExpressionsToFunctionDeclaratio
|
||||||
|
|
||||||
QQmlJS::AST::FormalParameterList *paramList = nullptr;
|
QQmlJS::AST::FormalParameterList *paramList = nullptr;
|
||||||
for (const QString ¶m : qAsConst(parameters)) {
|
for (const QString ¶m : qAsConst(parameters)) {
|
||||||
QStringRef paramNameRef = compiler->newStringRef(param);
|
QStringView paramNameRef = compiler->newStringRef(param);
|
||||||
|
|
||||||
QQmlJS::AST::PatternElement *b = new (pool) QQmlJS::AST::PatternElement(paramNameRef, nullptr);
|
QQmlJS::AST::PatternElement *b = new (pool) QQmlJS::AST::PatternElement(paramNameRef, nullptr);
|
||||||
paramList = new (pool) QQmlJS::AST::FormalParameterList(paramList, b);
|
paramList = new (pool) QQmlJS::AST::FormalParameterList(paramList, b);
|
||||||
|
@ -551,7 +551,7 @@ bool QQmlEnumTypeResolver::resolveEnumBindings()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QQmlEnumTypeResolver::assignEnumToBinding(QmlIR::Binding *binding, const QStringRef &, int enumValue, bool)
|
bool QQmlEnumTypeResolver::assignEnumToBinding(QmlIR::Binding *binding, QStringView, int enumValue, bool)
|
||||||
{
|
{
|
||||||
binding->type = QV4::CompiledData::Binding::Type_Number;
|
binding->type = QV4::CompiledData::Binding::Type_Number;
|
||||||
binding->value.constantValueIndex = compiler->registerConstant(QV4::Encode((double)enumValue));
|
binding->value.constantValueIndex = compiler->registerConstant(QV4::Encode((double)enumValue));
|
||||||
|
@ -592,9 +592,9 @@ bool QQmlEnumTypeResolver::tryQualifiedEnumAssignment(const QmlIR::Object *obj,
|
||||||
|
|
||||||
QHashedStringRef typeName(string.constData(), dot);
|
QHashedStringRef typeName(string.constData(), dot);
|
||||||
const bool isQtObject = (typeName == QLatin1String("Qt"));
|
const bool isQtObject = (typeName == QLatin1String("Qt"));
|
||||||
const QStringRef scopedEnumName = (dot2 != -1 ? string.midRef(dot + 1, dot2 - dot - 1) : QStringRef());
|
const QStringView scopedEnumName = (dot2 != -1 ? QStringView{string}.mid(dot + 1, dot2 - dot - 1) : QStringView());
|
||||||
// ### consider supporting scoped enums in Qt namespace
|
// ### consider supporting scoped enums in Qt namespace
|
||||||
const QStringRef enumValue = string.midRef(!isQtObject && dot2 != -1 ? dot2 + 1 : dot + 1);
|
const QStringView enumValue = QStringView{string}.mid(!isQtObject && dot2 != -1 ? dot2 + 1 : dot + 1);
|
||||||
|
|
||||||
if (isIntProp) { // ### C++11 allows enums to be other integral types. Should we support other integral types here?
|
if (isIntProp) { // ### C++11 allows enums to be other integral types. Should we support other integral types here?
|
||||||
// Allow enum assignment to ints.
|
// Allow enum assignment to ints.
|
||||||
|
@ -652,7 +652,7 @@ bool QQmlEnumTypeResolver::tryQualifiedEnumAssignment(const QmlIR::Object *obj,
|
||||||
return assignEnumToBinding(binding, enumValue, value, isQtObject);
|
return assignEnumToBinding(binding, enumValue, value, isQtObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
int QQmlEnumTypeResolver::evaluateEnum(const QString &scope, const QStringRef &enumName, const QStringRef &enumValue, bool *ok) const
|
int QQmlEnumTypeResolver::evaluateEnum(const QString &scope, QStringView enumName, QStringView enumValue, bool *ok) const
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(ok, "QQmlEnumTypeResolver::evaluateEnum", "ok must not be a null pointer");
|
Q_ASSERT_X(ok, "QQmlEnumTypeResolver::evaluateEnum", "ok must not be a null pointer");
|
||||||
*ok = false;
|
*ok = false;
|
||||||
|
@ -1104,15 +1104,15 @@ QQmlComponentAndAliasResolver::resolveAliasesInObject(int objectIndex,
|
||||||
|
|
||||||
const QString aliasPropertyValue = stringAt(alias->propertyNameIndex);
|
const QString aliasPropertyValue = stringAt(alias->propertyNameIndex);
|
||||||
|
|
||||||
QStringRef property;
|
QStringView property;
|
||||||
QStringRef subProperty;
|
QStringView subProperty;
|
||||||
|
|
||||||
const int propertySeparator = aliasPropertyValue.indexOf(QLatin1Char('.'));
|
const int propertySeparator = aliasPropertyValue.indexOf(QLatin1Char('.'));
|
||||||
if (propertySeparator != -1) {
|
if (propertySeparator != -1) {
|
||||||
property = aliasPropertyValue.leftRef(propertySeparator);
|
property = QStringView{aliasPropertyValue}.left(propertySeparator);
|
||||||
subProperty = aliasPropertyValue.midRef(propertySeparator + 1);
|
subProperty = QStringView{aliasPropertyValue}.mid(propertySeparator + 1);
|
||||||
} else
|
} else
|
||||||
property = QStringRef(&aliasPropertyValue, 0, aliasPropertyValue.length());
|
property = QStringView(aliasPropertyValue);
|
||||||
|
|
||||||
QQmlPropertyIndex propIdx;
|
QQmlPropertyIndex propIdx;
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,7 @@ public:
|
||||||
void setComponentRoots(const QVector<quint32> &roots) { m_componentRoots = roots; }
|
void setComponentRoots(const QVector<quint32> &roots) { m_componentRoots = roots; }
|
||||||
const QVector<quint32> &componentRoots() const { return m_componentRoots; }
|
const QVector<quint32> &componentRoots() const { return m_componentRoots; }
|
||||||
QQmlJS::MemoryPool *memoryPool();
|
QQmlJS::MemoryPool *memoryPool();
|
||||||
QStringRef newStringRef(const QString &string);
|
QStringView newStringRef(const QString &string);
|
||||||
const QV4::Compiler::StringTableGenerator *stringPool() const;
|
const QV4::Compiler::StringTableGenerator *stringPool() const;
|
||||||
|
|
||||||
const QHash<int, QQmlCustomParser*> &customParserCache() const { return customParsers; }
|
const QHash<int, QQmlCustomParser*> &customParserCache() const { return customParsers; }
|
||||||
|
@ -207,15 +207,15 @@ public:
|
||||||
bool resolveEnumBindings();
|
bool resolveEnumBindings();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool assignEnumToBinding(QmlIR::Binding *binding, const QStringRef &enumName, int enumValue, bool isQtObject);
|
bool assignEnumToBinding(QmlIR::Binding *binding, QStringView enumName, int enumValue, bool isQtObject);
|
||||||
bool assignEnumToBinding(QmlIR::Binding *binding, const QString &enumName, int enumValue, bool isQtObject)
|
bool assignEnumToBinding(QmlIR::Binding *binding, const QString &enumName, int enumValue, bool isQtObject)
|
||||||
{
|
{
|
||||||
return assignEnumToBinding(binding, QStringRef(&enumName), enumValue, isQtObject);
|
return assignEnumToBinding(binding, QStringView(enumName), enumValue, isQtObject);
|
||||||
}
|
}
|
||||||
bool tryQualifiedEnumAssignment(const QmlIR::Object *obj, const QQmlPropertyCache *propertyCache,
|
bool tryQualifiedEnumAssignment(const QmlIR::Object *obj, const QQmlPropertyCache *propertyCache,
|
||||||
const QQmlPropertyData *prop,
|
const QQmlPropertyData *prop,
|
||||||
QmlIR::Binding *binding);
|
QmlIR::Binding *binding);
|
||||||
int evaluateEnum(const QString &scope, const QStringRef &enumName, const QStringRef &enumValue, bool *ok) const;
|
int evaluateEnum(const QString &scope, QStringView enumName, QStringView enumValue, bool *ok) const;
|
||||||
|
|
||||||
|
|
||||||
const QVector<QmlIR::Object*> &qmlObjects;
|
const QVector<QmlIR::Object*> &qmlObjects;
|
||||||
|
|
|
@ -358,7 +358,7 @@ void QQmlTypeData::done()
|
||||||
error.setUrl(url());
|
error.setUrl(url());
|
||||||
error.setLine(qmlConvertSourceCoordinate<quint32, int>(type.location.line));
|
error.setLine(qmlConvertSourceCoordinate<quint32, int>(type.location.line));
|
||||||
error.setColumn(qmlConvertSourceCoordinate<quint32, int>(type.location.column));
|
error.setColumn(qmlConvertSourceCoordinate<quint32, int>(type.location.column));
|
||||||
error.setDescription(QQmlTypeLoader::tr("Type %1 has no inline component type called %2").arg(typeName.leftRef(lastDot), type.type.pendingResolutionName()));
|
error.setDescription(QQmlTypeLoader::tr("Type %1 has no inline component type called %2").arg(QStringView{typeName}.left(lastDot), type.type.pendingResolutionName()));
|
||||||
errors.prepend(error);
|
errors.prepend(error);
|
||||||
setError(errors);
|
setError(errors);
|
||||||
return;
|
return;
|
||||||
|
@ -505,7 +505,7 @@ void QQmlTypeData::done()
|
||||||
|
|
||||||
// associate inline components to root component
|
// associate inline components to root component
|
||||||
{
|
{
|
||||||
auto typeName = finalUrlString().splitRef(u'/').last().split(u'.').first().toString();
|
auto typeName = QStringView{finalUrlString()}.split(u'/').last().split(u'.').first().toString();
|
||||||
// typeName can be empty if a QQmlComponent was constructed with an empty QUrl parameter
|
// typeName can be empty if a QQmlComponent was constructed with an empty QUrl parameter
|
||||||
if (!typeName.isEmpty() && typeName.at(0).isUpper() && !m_inlineComponentData.isEmpty()) {
|
if (!typeName.isEmpty() && typeName.at(0).isUpper() && !m_inlineComponentData.isEmpty()) {
|
||||||
QHashedStringRef const hashedStringRef { typeName };
|
QHashedStringRef const hashedStringRef { typeName };
|
||||||
|
@ -529,7 +529,7 @@ void QQmlTypeData::done()
|
||||||
for (int scriptIndex = 0; scriptIndex < m_scripts.count(); ++scriptIndex) {
|
for (int scriptIndex = 0; scriptIndex < m_scripts.count(); ++scriptIndex) {
|
||||||
const QQmlTypeData::ScriptReference &script = m_scripts.at(scriptIndex);
|
const QQmlTypeData::ScriptReference &script = m_scripts.at(scriptIndex);
|
||||||
|
|
||||||
QStringRef qualifier(&script.qualifier);
|
QStringView qualifier(script.qualifier);
|
||||||
QString enclosingNamespace;
|
QString enclosingNamespace;
|
||||||
|
|
||||||
const int lastDotIndex = qualifier.lastIndexOf(QLatin1Char('.'));
|
const int lastDotIndex = qualifier.lastIndexOf(QLatin1Char('.'));
|
||||||
|
|
|
@ -728,7 +728,7 @@ ReturnedValue Text::method_isElementContentWhitespace(const FunctionObject *b, c
|
||||||
if (!r)
|
if (!r)
|
||||||
RETURN_UNDEFINED();
|
RETURN_UNDEFINED();
|
||||||
|
|
||||||
return Encode(QStringRef(&r->d()->d->data).trimmed().isEmpty());
|
return Encode(QStringView(r->d()->d->data).trimmed().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnedValue Text::method_wholeText(const FunctionObject *b, const Value *thisObject, const Value *, int)
|
ReturnedValue Text::method_wholeText(const FunctionObject *b, const Value *thisObject, const Value *, int)
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
static int parseInt(const QStringRef &str, bool *ok)
|
static int parseInt(QStringView str, bool *ok)
|
||||||
{
|
{
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
int number = 0;
|
int number = 0;
|
||||||
|
@ -65,9 +65,9 @@ static QTypeRevision parseVersion(const QString &str)
|
||||||
const int dotIndex = str.indexOf(QLatin1Char('.'));
|
const int dotIndex = str.indexOf(QLatin1Char('.'));
|
||||||
if (dotIndex != -1 && str.indexOf(QLatin1Char('.'), dotIndex + 1) == -1) {
|
if (dotIndex != -1 && str.indexOf(QLatin1Char('.'), dotIndex + 1) == -1) {
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
const int major = parseInt(QStringRef(&str, 0, dotIndex), &ok);
|
const int major = parseInt(QStringView(str).left(dotIndex), &ok);
|
||||||
if (!ok) return QTypeRevision();
|
if (!ok) return QTypeRevision();
|
||||||
const int minor = parseInt(QStringRef(&str, dotIndex + 1, str.length() - dotIndex - 1), &ok);
|
const int minor = parseInt(QStringView(str).mid(dotIndex + 1, str.length() - dotIndex - 1), &ok);
|
||||||
return ok ? QTypeRevision::fromVersion(major, minor) : QTypeRevision();
|
return ok ? QTypeRevision::fromVersion(major, minor) : QTypeRevision();
|
||||||
}
|
}
|
||||||
return QTypeRevision();
|
return QTypeRevision();
|
||||||
|
|
|
@ -54,13 +54,13 @@ enum ImportVersion { FullyVersioned, PartiallyVersioned, Unversioned };
|
||||||
- base/QtQml.2/Models
|
- base/QtQml.2/Models
|
||||||
- base/QtQml/Models
|
- base/QtQml/Models
|
||||||
*/
|
*/
|
||||||
QStringList qQmlResolveImportPaths(const QString &uri, const QStringList &basePaths,
|
QStringList qQmlResolveImportPaths(QStringView uri, const QStringList &basePaths,
|
||||||
QTypeRevision version)
|
QTypeRevision version)
|
||||||
{
|
{
|
||||||
static const QLatin1Char Slash('/');
|
static const QLatin1Char Slash('/');
|
||||||
static const QLatin1Char Backslash('\\');
|
static const QLatin1Char Backslash('\\');
|
||||||
|
|
||||||
const QVector<QStringRef> parts = uri.splitRef(QLatin1Char('.'), Qt::SkipEmptyParts);
|
const QVector<QStringView> parts = uri.split(u'.', Qt::SkipEmptyParts);
|
||||||
|
|
||||||
QStringList importPaths;
|
QStringList importPaths;
|
||||||
// fully & partially versioned parts + 1 unversioned for each base path
|
// fully & partially versioned parts + 1 unversioned for each base path
|
||||||
|
@ -81,7 +81,7 @@ QStringList qQmlResolveImportPaths(const QString &uri, const QStringList &basePa
|
||||||
return QString();
|
return QString();
|
||||||
};
|
};
|
||||||
|
|
||||||
auto joinStringRefs = [](const QVector<QStringRef> &refs, const QChar &sep) {
|
auto joinStringRefs = [](const QVector<QStringView> &refs, const QChar &sep) {
|
||||||
QString str;
|
QString str;
|
||||||
for (auto it = refs.cbegin(); it != refs.cend(); ++it) {
|
for (auto it = refs.cbegin(); it != refs.cend(); ++it) {
|
||||||
if (it != refs.cbegin())
|
if (it != refs.cbegin())
|
||||||
|
|
|
@ -57,7 +57,7 @@
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
QStringList qQmlResolveImportPaths(const QString &uri, const QStringList &basePaths,
|
QStringList qQmlResolveImportPaths(QStringView uri, const QStringList &basePaths,
|
||||||
QTypeRevision version);
|
QTypeRevision version);
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
|
@ -1365,7 +1365,7 @@ QVariant QQmlDelegateModelPrivate::variantValue(QQmlListCompositor::Group group,
|
||||||
return QVariant();
|
return QVariant();
|
||||||
const int from = dot + 1;
|
const int from = dot + 1;
|
||||||
dot = name.indexOf(QLatin1Char('.'), from);
|
dot = name.indexOf(QLatin1Char('.'), from);
|
||||||
value = obj->property(name.midRef(from, dot - from).toUtf8());
|
value = obj->property(QStringView{name}.mid(from, dot - from).toUtf8());
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -576,7 +576,7 @@ int quick_test_main_with_setup(int argc, char **argv, const char *name, const ch
|
||||||
QTestRootObject::instance()->init();
|
QTestRootObject::instance()->init();
|
||||||
QString path = fi.absoluteFilePath();
|
QString path = fi.absoluteFilePath();
|
||||||
if (path.startsWith(QLatin1String(":/")))
|
if (path.startsWith(QLatin1String(":/")))
|
||||||
view.setSource(QUrl(QLatin1String("qrc:") + path.midRef(1)));
|
view.setSource(QUrl(QLatin1String("qrc:") + QStringView{path}.mid(1)));
|
||||||
else
|
else
|
||||||
view.setSource(QUrl::fromLocalFile(path));
|
view.setSource(QUrl::fromLocalFile(path));
|
||||||
|
|
||||||
|
|
|
@ -1133,7 +1133,7 @@ static const char* mimeToType(const QString &mime)
|
||||||
const QLatin1String imagePrefix("image/");
|
const QLatin1String imagePrefix("image/");
|
||||||
if (!mime.startsWith(imagePrefix))
|
if (!mime.startsWith(imagePrefix))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
const QStringRef mimeExt = mime.midRef(imagePrefix.size());
|
const QStringView mimeExt = QStringView{mime}.mid(imagePrefix.size());
|
||||||
if (mimeExt == QLatin1String("png"))
|
if (mimeExt == QLatin1String("png"))
|
||||||
return "png";
|
return "png";
|
||||||
else if (mimeExt == QLatin1String("bmp"))
|
else if (mimeExt == QLatin1String("bmp"))
|
||||||
|
|
|
@ -205,7 +205,7 @@ Q_QUICK_PRIVATE_EXPORT QColor qt_color_from_string(const QV4::Value &name)
|
||||||
return QColor();
|
return QColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int qParseFontSizeFromToken(const QStringRef &fontSizeToken, bool &ok)
|
static int qParseFontSizeFromToken(QStringView fontSizeToken, bool &ok)
|
||||||
{
|
{
|
||||||
ok = false;
|
ok = false;
|
||||||
float size = fontSizeToken.trimmed().toFloat(&ok);
|
float size = fontSizeToken.trimmed().toFloat(&ok);
|
||||||
|
@ -221,11 +221,11 @@ static int qParseFontSizeFromToken(const QStringRef &fontSizeToken, bool &ok)
|
||||||
\c true if successful. If the font size is invalid, \c false is returned
|
\c true if successful. If the font size is invalid, \c false is returned
|
||||||
and a warning is printed.
|
and a warning is printed.
|
||||||
*/
|
*/
|
||||||
static bool qSetFontSizeFromToken(QFont &font, const QStringRef &fontSizeToken)
|
static bool qSetFontSizeFromToken(QFont &font, QStringView fontSizeToken)
|
||||||
{
|
{
|
||||||
const QStringRef trimmedToken = fontSizeToken.trimmed();
|
const QStringView trimmedToken = fontSizeToken.trimmed();
|
||||||
const QStringRef unitStr = trimmedToken.right(2);
|
const QStringView unitStr = trimmedToken.right(2);
|
||||||
const QStringRef value = trimmedToken.left(trimmedToken.size() - 2);
|
const QStringView value = trimmedToken.left(trimmedToken.size() - 2);
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
int size = 0;
|
int size = 0;
|
||||||
if (unitStr == QLatin1String("px")) {
|
if (unitStr == QLatin1String("px")) {
|
||||||
|
@ -251,7 +251,7 @@ static bool qSetFontSizeFromToken(QFont &font, const QStringRef &fontSizeToken)
|
||||||
each family is separated by spaces. Families with spaces in their name
|
each family is separated by spaces. Families with spaces in their name
|
||||||
must be quoted.
|
must be quoted.
|
||||||
*/
|
*/
|
||||||
static QStringList qExtractFontFamiliesFromString(const QStringRef &fontFamiliesString)
|
static QStringList qExtractFontFamiliesFromString(QStringView fontFamiliesString)
|
||||||
{
|
{
|
||||||
QStringList extractedFamilies;
|
QStringList extractedFamilies;
|
||||||
int quoteIndex = -1;
|
int quoteIndex = -1;
|
||||||
|
@ -395,16 +395,16 @@ static QFont qt_font_from_string(const QString& fontString, const QFont ¤t
|
||||||
fontSizeEnd += 3;
|
fontSizeEnd += 3;
|
||||||
|
|
||||||
QFont newFont;
|
QFont newFont;
|
||||||
if (!qSetFontSizeFromToken(newFont, fontString.midRef(fontSizeStart, fontSizeEnd - fontSizeStart)))
|
if (!qSetFontSizeFromToken(newFont, QStringView{fontString}.mid(fontSizeStart, fontSizeEnd - fontSizeStart)))
|
||||||
return currentFont;
|
return currentFont;
|
||||||
|
|
||||||
// We don't want to parse the size twice, so remove it now.
|
// We don't want to parse the size twice, so remove it now.
|
||||||
QString remainingFontString = fontString;
|
QString remainingFontString = fontString;
|
||||||
remainingFontString.remove(fontSizeStart, fontSizeEnd - fontSizeStart);
|
remainingFontString.remove(fontSizeStart, fontSizeEnd - fontSizeStart);
|
||||||
QStringRef remainingFontStringRef(&remainingFontString);
|
QStringView remainingFontStringRef(remainingFontString);
|
||||||
|
|
||||||
// Next, we have to take any font families out, as QString::split() will ruin quoted family names.
|
// Next, we have to take any font families out, as QString::split() will ruin quoted family names.
|
||||||
const QStringRef fontFamiliesString = remainingFontStringRef.mid(fontSizeStart);
|
const QStringView fontFamiliesString = remainingFontStringRef.mid(fontSizeStart);
|
||||||
remainingFontStringRef.truncate(fontSizeStart);
|
remainingFontStringRef.truncate(fontSizeStart);
|
||||||
QStringList fontFamilies = qExtractFontFamiliesFromString(fontFamiliesString);
|
QStringList fontFamilies = qExtractFontFamiliesFromString(fontFamiliesString);
|
||||||
if (fontFamilies.isEmpty()) {
|
if (fontFamilies.isEmpty()) {
|
||||||
|
@ -414,7 +414,7 @@ static QFont qt_font_from_string(const QString& fontString, const QFont ¤t
|
||||||
return currentFont;
|
return currentFont;
|
||||||
|
|
||||||
// Now that we've removed the messy parts, we can split the font string on spaces.
|
// Now that we've removed the messy parts, we can split the font string on spaces.
|
||||||
const QStringRef trimmedTokensStr = remainingFontStringRef.trimmed();
|
const QStringView trimmedTokensStr = remainingFontStringRef.trimmed();
|
||||||
if (trimmedTokensStr.isEmpty()) {
|
if (trimmedTokensStr.isEmpty()) {
|
||||||
// No optional properties.
|
// No optional properties.
|
||||||
return newFont;
|
return newFont;
|
||||||
|
@ -423,7 +423,7 @@ static QFont qt_font_from_string(const QString& fontString, const QFont ¤t
|
||||||
|
|
||||||
int usedTokens = NoTokens;
|
int usedTokens = NoTokens;
|
||||||
// Optional properties can be in any order, but font-size and font-family must be last.
|
// Optional properties can be in any order, but font-size and font-family must be last.
|
||||||
for (const QStringRef &token : tokens) {
|
for (const QStringView &token : tokens) {
|
||||||
if (token.compare(QLatin1String("normal")) == 0) {
|
if (token.compare(QLatin1String("normal")) == 0) {
|
||||||
if (!(usedTokens & FontStyle) || !(usedTokens & FontVariant) || !(usedTokens & FontWeight)) {
|
if (!(usedTokens & FontStyle) || !(usedTokens & FontVariant) || !(usedTokens & FontWeight)) {
|
||||||
// Could be font-style, font-variant or font-weight.
|
// Could be font-style, font-variant or font-weight.
|
||||||
|
|
|
@ -1990,7 +1990,7 @@ void QQuickPathView::refill()
|
||||||
if (lcItemViewDelegateLifecycle().isDebugEnabled()) {
|
if (lcItemViewDelegateLifecycle().isDebugEnabled()) {
|
||||||
QQuickText *text = qmlobject_cast<QQuickText*>(item);
|
QQuickText *text = qmlobject_cast<QQuickText*>(item);
|
||||||
if (text)
|
if (text)
|
||||||
qCDebug(lcItemViewDelegateLifecycle) << "idx" << idx << "@" << pos << ": QQuickText" << text->objectName() << text->text().leftRef(40);
|
qCDebug(lcItemViewDelegateLifecycle) << "idx" << idx << "@" << pos << ": QQuickText" << text->objectName() << QStringView{text->text()}.left(40);
|
||||||
else
|
else
|
||||||
qCDebug(lcItemViewDelegateLifecycle) << "idx" << idx << "@" << pos << ":" << item;
|
qCDebug(lcItemViewDelegateLifecycle) << "idx" << idx << "@" << pos << ":" << item;
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,8 +140,8 @@ QQuickGridScaledImage::QQuickGridScaledImage(QIODevice *data)
|
||||||
if (colonId <= 0)
|
if (colonId <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const QStringRef property = line.leftRef(colonId).trimmed();
|
const QStringView property = QStringView{line}.left(colonId).trimmed();
|
||||||
QStringRef value = line.midRef(colonId + 1).trimmed();
|
QStringView value = QStringView{line}.mid(colonId + 1).trimmed();
|
||||||
|
|
||||||
if (property == QLatin1String("border.left")) {
|
if (property == QLatin1String("border.left")) {
|
||||||
l = value.toInt();
|
l = value.toInt();
|
||||||
|
@ -169,9 +169,9 @@ QQuickGridScaledImage::QQuickGridScaledImage(QIODevice *data)
|
||||||
_pix = imgFile;
|
_pix = imgFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
QQuickBorderImage::TileMode QQuickGridScaledImage::stringToRule(const QStringRef &s)
|
QQuickBorderImage::TileMode QQuickGridScaledImage::stringToRule(QStringView s)
|
||||||
{
|
{
|
||||||
QStringRef string = s;
|
QStringView string = s;
|
||||||
if (string.startsWith(QLatin1Char('"')) && string.endsWith(QLatin1Char('"')))
|
if (string.startsWith(QLatin1Char('"')) && string.endsWith(QLatin1Char('"')))
|
||||||
string = string.mid(1, string.size() - 2); // remove leading/trailing quotes.
|
string = string.mid(1, string.size() - 2); // remove leading/trailing quotes.
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,7 @@ public:
|
||||||
QString pixmapUrl() const;
|
QString pixmapUrl() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static QQuickBorderImage::TileMode stringToRule(const QStringRef &);
|
static QQuickBorderImage::TileMode stringToRule(QStringView);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int _l;
|
int _l;
|
||||||
|
|
|
@ -1461,7 +1461,7 @@ QVariant QQuickTextControl::inputMethodQuery(Qt::InputMethodQuery property, cons
|
||||||
tmpCursor.movePosition(QTextCursor::NextBlock);
|
tmpCursor.movePosition(QTextCursor::NextBlock);
|
||||||
--numBlocks;
|
--numBlocks;
|
||||||
}
|
}
|
||||||
result += block.text().midRef(0,localPos);
|
result += QStringView{block.text()}.mid(0,localPos);
|
||||||
return QVariant(result);
|
return QVariant(result);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -1999,7 +1999,7 @@ QVariant QQuickTextInput::inputMethodQuery(Qt::InputMethodQuery property, const
|
||||||
return QVariant(d->m_text.mid(d->m_cursor));
|
return QVariant(d->m_text.mid(d->m_cursor));
|
||||||
case Qt::ImTextBeforeCursor:
|
case Qt::ImTextBeforeCursor:
|
||||||
if (argument.isValid())
|
if (argument.isValid())
|
||||||
return QVariant(d->m_text.leftRef(d->m_cursor).right(argument.toInt()).toString());
|
return QVariant(QStringView{d->m_text}.left(d->m_cursor).right(argument.toInt()).toString());
|
||||||
return QVariant(d->m_text.left(d->m_cursor));
|
return QVariant(d->m_text.left(d->m_cursor));
|
||||||
default:
|
default:
|
||||||
return QQuickItem::inputMethodQuery(property);
|
return QQuickItem::inputMethodQuery(property);
|
||||||
|
@ -2041,7 +2041,7 @@ bool QQuickTextInput::isRightToLeft(int start, int end)
|
||||||
qmlWarning(this) << "isRightToLeft(start, end) called with the end property being smaller than the start.";
|
qmlWarning(this) << "isRightToLeft(start, end) called with the end property being smaller than the start.";
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return text().midRef(start, end - start).isRightToLeft();
|
return QStringView{text()}.mid(start, end - start).isRightToLeft();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3728,7 +3728,7 @@ void QQuickTextInputPrivate::internalInsert(const QString &s)
|
||||||
} else {
|
} else {
|
||||||
int remaining = m_maxLength - m_text.length();
|
int remaining = m_maxLength - m_text.length();
|
||||||
if (remaining != 0) {
|
if (remaining != 0) {
|
||||||
const QStringRef remainingStr = s.leftRef(remaining);
|
const QStringView remainingStr = QStringView{s}.left(remaining);
|
||||||
m_text.insert(m_cursor, remainingStr);
|
m_text.insert(m_cursor, remainingStr);
|
||||||
for (auto e : remainingStr)
|
for (auto e : remainingStr)
|
||||||
addCommand(Command(Insert, m_cursor++, e, -1, -1));
|
addCommand(Command(Insert, m_cursor++, e, -1, -1));
|
||||||
|
@ -4084,14 +4084,14 @@ QString QQuickTextInputPrivate::maskString(uint pos, const QString &str, bool cl
|
||||||
int n = findInMask(i, true, true, str[strIndex]);
|
int n = findInMask(i, true, true, str[strIndex]);
|
||||||
if (n != -1) {
|
if (n != -1) {
|
||||||
if (str.length() != 1 || i == 0 || (i > 0 && (!m_maskData[i-1].separator || m_maskData[i-1].maskChar != str[strIndex]))) {
|
if (str.length() != 1 || i == 0 || (i > 0 && (!m_maskData[i-1].separator || m_maskData[i-1].maskChar != str[strIndex]))) {
|
||||||
s += fill.midRef(i, n-i+1);
|
s += QStringView{fill}.mid(i, n-i+1);
|
||||||
i = n + 1; // update i to find + 1
|
i = n + 1; // update i to find + 1
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// search for valid m_blank if not
|
// search for valid m_blank if not
|
||||||
n = findInMask(i, true, false, str[strIndex]);
|
n = findInMask(i, true, false, str[strIndex]);
|
||||||
if (n != -1) {
|
if (n != -1) {
|
||||||
s += fill.midRef(i, n-i);
|
s += QStringView{fill}.mid(i, n-i);
|
||||||
switch (m_maskData[n].caseMode) {
|
switch (m_maskData[n].caseMode) {
|
||||||
case MaskInputData::Upper:
|
case MaskInputData::Upper:
|
||||||
s += str[strIndex].toUpper();
|
s += str[strIndex].toUpper();
|
||||||
|
|
|
@ -1010,7 +1010,7 @@ void QQuickScriptActionPrivate::debugAction(QDebug d, int indentLevel) const
|
||||||
QByteArray ind(indentLevel, u' ');
|
QByteArray ind(indentLevel, u' ');
|
||||||
QString exprStr = expr.expression();
|
QString exprStr = expr.expression();
|
||||||
int endOfFirstLine = exprStr.indexOf(u'\n');
|
int endOfFirstLine = exprStr.indexOf(u'\n');
|
||||||
d << "\n" << ind.constData() << exprStr.leftRef(endOfFirstLine);
|
d << "\n" << ind.constData() << QStringView{exprStr}.left(endOfFirstLine);
|
||||||
if (endOfFirstLine != -1 && endOfFirstLine < exprStr.length())
|
if (endOfFirstLine != -1 && endOfFirstLine < exprStr.length())
|
||||||
d << "...";
|
d << "...";
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,8 +178,8 @@ public:
|
||||||
int index = s.indexOf(QLatin1Char(','));
|
int index = s.indexOf(QLatin1Char(','));
|
||||||
|
|
||||||
bool xGood, yGood;
|
bool xGood, yGood;
|
||||||
float xCoord = s.leftRef(index).toFloat(&xGood);
|
float xCoord = QStringView{s}.left(index).toFloat(&xGood);
|
||||||
float yCoord = s.midRef(index + 1).toFloat(&yGood);
|
float yCoord = QStringView{s}.mid(index + 1).toFloat(&yGood);
|
||||||
|
|
||||||
if (xGood && yGood) {
|
if (xGood && yGood) {
|
||||||
if (ok) *ok = true;
|
if (ok) *ok = true;
|
||||||
|
@ -198,9 +198,9 @@ public:
|
||||||
int index2 = s.indexOf(QLatin1Char(','), index+1);
|
int index2 = s.indexOf(QLatin1Char(','), index+1);
|
||||||
|
|
||||||
bool xGood, yGood, zGood;
|
bool xGood, yGood, zGood;
|
||||||
float xCoord = s.leftRef(index).toFloat(&xGood);
|
float xCoord = QStringView{s}.left(index).toFloat(&xGood);
|
||||||
float yCoord = s.midRef(index + 1, index2 - index - 1).toFloat(&yGood);
|
float yCoord = QStringView{s}.mid(index + 1, index2 - index - 1).toFloat(&yGood);
|
||||||
float zCoord = s.midRef(index2 + 1).toFloat(&zGood);
|
float zCoord = QStringView{s}.mid(index2 + 1).toFloat(&zGood);
|
||||||
|
|
||||||
if (xGood && yGood && zGood) {
|
if (xGood && yGood && zGood) {
|
||||||
if (ok) *ok = true;
|
if (ok) *ok = true;
|
||||||
|
@ -220,10 +220,10 @@ public:
|
||||||
int index3 = s.indexOf(QLatin1Char(','), index2+1);
|
int index3 = s.indexOf(QLatin1Char(','), index2+1);
|
||||||
|
|
||||||
bool xGood, yGood, zGood, wGood;
|
bool xGood, yGood, zGood, wGood;
|
||||||
float xCoord = s.leftRef(index).toFloat(&xGood);
|
float xCoord = QStringView{s}.left(index).toFloat(&xGood);
|
||||||
float yCoord = s.midRef(index + 1, index2 - index - 1).toFloat(&yGood);
|
float yCoord = QStringView{s}.mid(index + 1, index2 - index - 1).toFloat(&yGood);
|
||||||
float zCoord = s.midRef(index2 + 1, index3 - index2 - 1).toFloat(&zGood);
|
float zCoord = QStringView{s}.mid(index2 + 1, index3 - index2 - 1).toFloat(&zGood);
|
||||||
float wCoord = s.midRef(index3 + 1).toFloat(&wGood);
|
float wCoord = QStringView{s}.mid(index3 + 1).toFloat(&wGood);
|
||||||
|
|
||||||
if (xGood && yGood && zGood && wGood) {
|
if (xGood && yGood && zGood && wGood) {
|
||||||
if (ok) *ok = true;
|
if (ok) *ok = true;
|
||||||
|
@ -243,10 +243,10 @@ public:
|
||||||
int index3 = s.indexOf(QLatin1Char(','), index2+1);
|
int index3 = s.indexOf(QLatin1Char(','), index2+1);
|
||||||
|
|
||||||
bool sGood, xGood, yGood, zGood;
|
bool sGood, xGood, yGood, zGood;
|
||||||
qreal sCoord = s.leftRef(index).toDouble(&sGood);
|
qreal sCoord = QStringView{s}.left(index).toDouble(&sGood);
|
||||||
qreal xCoord = s.midRef(index+1, index2-index-1).toDouble(&xGood);
|
qreal xCoord = QStringView{s}.mid(index+1, index2-index-1).toDouble(&xGood);
|
||||||
qreal yCoord = s.midRef(index2+1, index3-index2-1).toDouble(&yGood);
|
qreal yCoord = QStringView{s}.mid(index2+1, index3-index2-1).toDouble(&yGood);
|
||||||
qreal zCoord = s.midRef(index3+1).toDouble(&zGood);
|
qreal zCoord = QStringView{s}.mid(index3+1).toDouble(&zGood);
|
||||||
|
|
||||||
if (sGood && xGood && yGood && zGood) {
|
if (sGood && xGood && yGood && zGood) {
|
||||||
if (ok) *ok = true;
|
if (ok) *ok = true;
|
||||||
|
@ -263,7 +263,7 @@ public:
|
||||||
if (s.count(QLatin1Char(',')) == 15) {
|
if (s.count(QLatin1Char(',')) == 15) {
|
||||||
float matValues[16];
|
float matValues[16];
|
||||||
bool vOK = true;
|
bool vOK = true;
|
||||||
QStringRef mutableStr(&s);
|
QStringView mutableStr(s);
|
||||||
for (int i = 0; vOK && i < 16; ++i) {
|
for (int i = 0; vOK && i < 16; ++i) {
|
||||||
int cidx = mutableStr.indexOf(QLatin1Char(','));
|
int cidx = mutableStr.indexOf(QLatin1Char(','));
|
||||||
matValues[i] = mutableStr.left(cidx).toDouble(&vOK);
|
matValues[i] = mutableStr.left(cidx).toDouble(&vOK);
|
||||||
|
|
|
@ -420,26 +420,26 @@ QQuickTransition *QQuickStateGroupPrivate::findTransition(const QString &from, c
|
||||||
const QString fromStateStr = t->fromState();
|
const QString fromStateStr = t->fromState();
|
||||||
const QString toStateStr = t->toState();
|
const QString toStateStr = t->toState();
|
||||||
|
|
||||||
QVector<QStringRef> fromState = fromStateStr.splitRef(QLatin1Char(','));
|
auto fromState = QStringView{fromStateStr}.split(QLatin1Char(','));
|
||||||
for (int jj = 0; jj < fromState.count(); ++jj)
|
for (int jj = 0; jj < fromState.count(); ++jj)
|
||||||
fromState[jj] = fromState.at(jj).trimmed();
|
fromState[jj] = fromState.at(jj).trimmed();
|
||||||
QVector<QStringRef> toState = toStateStr.splitRef(QLatin1Char(','));
|
auto toState = QStringView{toStateStr}.split(QLatin1Char(','));
|
||||||
for (int jj = 0; jj < toState.count(); ++jj)
|
for (int jj = 0; jj < toState.count(); ++jj)
|
||||||
toState[jj] = toState.at(jj).trimmed();
|
toState[jj] = toState.at(jj).trimmed();
|
||||||
if (ii == 1)
|
if (ii == 1)
|
||||||
qSwap(fromState, toState);
|
qSwap(fromState, toState);
|
||||||
int tScore = 0;
|
int tScore = 0;
|
||||||
const QString asterisk = QStringLiteral("*");
|
const QString asterisk = QStringLiteral("*");
|
||||||
if (fromState.contains(QStringRef(&from)))
|
if (fromState.contains(QStringView(from)))
|
||||||
tScore += 2;
|
tScore += 2;
|
||||||
else if (fromState.contains(QStringRef(&asterisk)))
|
else if (fromState.contains(QStringView(asterisk)))
|
||||||
tScore += 1;
|
tScore += 1;
|
||||||
else
|
else
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (toState.contains(QStringRef(&to)))
|
if (toState.contains(QStringView(to)))
|
||||||
tScore += 2;
|
tScore += 2;
|
||||||
else if (toState.contains(QStringRef(&asterisk)))
|
else if (toState.contains(QStringView(asterisk)))
|
||||||
tScore += 1;
|
tScore += 1;
|
||||||
else
|
else
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -104,8 +104,8 @@ public:
|
||||||
bool parseUnorderedListAttributes(const QChar *&ch, const QString &textIn);
|
bool parseUnorderedListAttributes(const QChar *&ch, const QString &textIn);
|
||||||
bool parseAnchorAttributes(const QChar *&ch, const QString &textIn, QTextCharFormat &format);
|
bool parseAnchorAttributes(const QChar *&ch, const QString &textIn, QTextCharFormat &format);
|
||||||
void parseImageAttributes(const QChar *&ch, const QString &textIn, QString &textOut);
|
void parseImageAttributes(const QChar *&ch, const QString &textIn, QString &textOut);
|
||||||
QPair<QStringRef,QStringRef> parseAttribute(const QChar *&ch, const QString &textIn);
|
QPair<QStringView,QStringView> parseAttribute(const QChar *&ch, const QString &textIn);
|
||||||
QStringRef parseValue(const QChar *&ch, const QString &textIn);
|
QStringView parseValue(const QChar *&ch, const QString &textIn);
|
||||||
void setFontSize(int size, QTextCharFormat &format);
|
void setFontSize(int size, QTextCharFormat &format);
|
||||||
|
|
||||||
inline void skipSpace(const QChar *&ch) {
|
inline void skipSpace(const QChar *&ch) {
|
||||||
|
@ -298,7 +298,7 @@ void QQuickStyledTextPrivate::appendText(const QString &textIn, int start, int l
|
||||||
{
|
{
|
||||||
if (prependSpace)
|
if (prependSpace)
|
||||||
textOut.append(space);
|
textOut.append(space);
|
||||||
textOut.append(QStringRef(&textIn, start, length));
|
textOut.append(QStringView(textIn).mid(start, length));
|
||||||
prependSpace = false;
|
prependSpace = false;
|
||||||
hasSpace = false;
|
hasSpace = false;
|
||||||
hasNewLine = false;
|
hasNewLine = false;
|
||||||
|
@ -328,7 +328,7 @@ bool QQuickStyledTextPrivate::parseTag(const QChar *&ch, const QString &textIn,
|
||||||
if (*ch == greaterThan) {
|
if (*ch == greaterThan) {
|
||||||
if (tagLength == 0)
|
if (tagLength == 0)
|
||||||
return false;
|
return false;
|
||||||
QStringRef tag(&textIn, tagStart, tagLength);
|
auto tag = QStringView(textIn).mid(tagStart, tagLength);
|
||||||
const QChar char0 = tag.at(0);
|
const QChar char0 = tag.at(0);
|
||||||
if (char0 == QLatin1Char('b')) {
|
if (char0 == QLatin1Char('b')) {
|
||||||
if (tagLength == 1) {
|
if (tagLength == 1) {
|
||||||
|
@ -437,7 +437,7 @@ bool QQuickStyledTextPrivate::parseTag(const QChar *&ch, const QString &textIn,
|
||||||
return false;
|
return false;
|
||||||
} else if (ch->isSpace()) {
|
} else if (ch->isSpace()) {
|
||||||
// may have params.
|
// may have params.
|
||||||
QStringRef tag(&textIn, tagStart, tagLength);
|
auto tag = QStringView(textIn).mid(tagStart, tagLength);
|
||||||
if (tag == QLatin1String("font"))
|
if (tag == QLatin1String("font"))
|
||||||
return parseFontAttributes(ch, textIn, format);
|
return parseFontAttributes(ch, textIn, format);
|
||||||
if (tag == QLatin1String("ol")) {
|
if (tag == QLatin1String("ol")) {
|
||||||
|
@ -475,7 +475,7 @@ bool QQuickStyledTextPrivate::parseCloseTag(const QChar *&ch, const QString &tex
|
||||||
if (*ch == greaterThan) {
|
if (*ch == greaterThan) {
|
||||||
if (tagLength == 0)
|
if (tagLength == 0)
|
||||||
return false;
|
return false;
|
||||||
QStringRef tag(&textIn, tagStart, tagLength);
|
auto tag = QStringView(textIn).mid(tagStart, tagLength);
|
||||||
const QChar char0 = tag.at(0);
|
const QChar char0 = tag.at(0);
|
||||||
hasNewLine = false;
|
hasNewLine = false;
|
||||||
if (char0 == QLatin1Char('b')) {
|
if (char0 == QLatin1Char('b')) {
|
||||||
|
@ -555,7 +555,7 @@ void QQuickStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textI
|
||||||
int entityLength = 0;
|
int entityLength = 0;
|
||||||
while (!ch->isNull()) {
|
while (!ch->isNull()) {
|
||||||
if (*ch == QLatin1Char(';')) {
|
if (*ch == QLatin1Char(';')) {
|
||||||
QStringRef entity(&textIn, entityStart, entityLength);
|
auto entity = QStringView(textIn).mid(entityStart, entityLength);
|
||||||
if (entity == QLatin1String("gt"))
|
if (entity == QLatin1String("gt"))
|
||||||
textOut += QChar(62);
|
textOut += QChar(62);
|
||||||
else if (entity == QLatin1String("lt"))
|
else if (entity == QLatin1String("lt"))
|
||||||
|
@ -568,7 +568,7 @@ void QQuickStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textI
|
||||||
textOut += QChar(QChar::Nbsp);
|
textOut += QChar(QChar::Nbsp);
|
||||||
return;
|
return;
|
||||||
} else if (*ch == QLatin1Char(' ')) {
|
} else if (*ch == QLatin1Char(' ')) {
|
||||||
QStringRef entity(&textIn, entityStart - 1, entityLength + 1);
|
auto entity = QStringView(textIn).mid(entityStart - 1, entityLength + 1);
|
||||||
textOut += entity + *ch;
|
textOut += entity + *ch;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -580,7 +580,7 @@ void QQuickStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textI
|
||||||
bool QQuickStyledTextPrivate::parseFontAttributes(const QChar *&ch, const QString &textIn, QTextCharFormat &format)
|
bool QQuickStyledTextPrivate::parseFontAttributes(const QChar *&ch, const QString &textIn, QTextCharFormat &format)
|
||||||
{
|
{
|
||||||
bool valid = false;
|
bool valid = false;
|
||||||
QPair<QStringRef,QStringRef> attr;
|
QPair<QStringView,QStringView> attr;
|
||||||
do {
|
do {
|
||||||
attr = parseAttribute(ch, textIn);
|
attr = parseAttribute(ch, textIn);
|
||||||
if (attr.first == QLatin1String("color")) {
|
if (attr.first == QLatin1String("color")) {
|
||||||
|
@ -608,7 +608,7 @@ bool QQuickStyledTextPrivate::parseOrderedListAttributes(const QChar *&ch, const
|
||||||
listItem.type = Ordered;
|
listItem.type = Ordered;
|
||||||
listItem.format = Decimal;
|
listItem.format = Decimal;
|
||||||
|
|
||||||
QPair<QStringRef,QStringRef> attr;
|
QPair<QStringView,QStringView> attr;
|
||||||
do {
|
do {
|
||||||
attr = parseAttribute(ch, textIn);
|
attr = parseAttribute(ch, textIn);
|
||||||
if (attr.first == QLatin1String("type")) {
|
if (attr.first == QLatin1String("type")) {
|
||||||
|
@ -637,7 +637,7 @@ bool QQuickStyledTextPrivate::parseUnorderedListAttributes(const QChar *&ch, con
|
||||||
listItem.type = Unordered;
|
listItem.type = Unordered;
|
||||||
listItem.format = Bullet;
|
listItem.format = Bullet;
|
||||||
|
|
||||||
QPair<QStringRef,QStringRef> attr;
|
QPair<QStringView,QStringView> attr;
|
||||||
do {
|
do {
|
||||||
attr = parseAttribute(ch, textIn);
|
attr = parseAttribute(ch, textIn);
|
||||||
if (attr.first == QLatin1String("type")) {
|
if (attr.first == QLatin1String("type")) {
|
||||||
|
@ -657,7 +657,7 @@ bool QQuickStyledTextPrivate::parseAnchorAttributes(const QChar *&ch, const QStr
|
||||||
{
|
{
|
||||||
bool valid = false;
|
bool valid = false;
|
||||||
|
|
||||||
QPair<QStringRef,QStringRef> attr;
|
QPair<QStringView,QStringView> attr;
|
||||||
do {
|
do {
|
||||||
attr = parseAttribute(ch, textIn);
|
attr = parseAttribute(ch, textIn);
|
||||||
if (attr.first == QLatin1String("href")) {
|
if (attr.first == QLatin1String("href")) {
|
||||||
|
@ -682,7 +682,7 @@ void QQuickStyledTextPrivate::parseImageAttributes(const QChar *&ch, const QStri
|
||||||
QQuickStyledTextImgTag *image = new QQuickStyledTextImgTag;
|
QQuickStyledTextImgTag *image = new QQuickStyledTextImgTag;
|
||||||
image->position = textOut.length() + (trailingSpace ? 0 : 1);
|
image->position = textOut.length() + (trailingSpace ? 0 : 1);
|
||||||
|
|
||||||
QPair<QStringRef,QStringRef> attr;
|
QPair<QStringView,QStringView> attr;
|
||||||
do {
|
do {
|
||||||
attr = parseAttribute(ch, textIn);
|
attr = parseAttribute(ch, textIn);
|
||||||
if (attr.first == QLatin1String("src")) {
|
if (attr.first == QLatin1String("src")) {
|
||||||
|
@ -727,7 +727,7 @@ void QQuickStyledTextPrivate::parseImageAttributes(const QChar *&ch, const QStri
|
||||||
image->position = textOut.length() + (trailingSpace ? 0 : 1);
|
image->position = textOut.length() + (trailingSpace ? 0 : 1);
|
||||||
imgWidth = image->size.width();
|
imgWidth = image->size.width();
|
||||||
image->offset = -std::fmod(imgWidth, spaceWidth) / 2.0;
|
image->offset = -std::fmod(imgWidth, spaceWidth) / 2.0;
|
||||||
QPair<QStringRef,QStringRef> attr;
|
QPair<QStringView,QStringView> attr;
|
||||||
do {
|
do {
|
||||||
attr = parseAttribute(ch, textIn);
|
attr = parseAttribute(ch, textIn);
|
||||||
} while (!ch->isNull() && !attr.first.isEmpty());
|
} while (!ch->isNull() && !attr.first.isEmpty());
|
||||||
|
@ -740,7 +740,7 @@ void QQuickStyledTextPrivate::parseImageAttributes(const QChar *&ch, const QStri
|
||||||
textOut += padding + QLatin1Char(' ');
|
textOut += padding + QLatin1Char(' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
QPair<QStringRef,QStringRef> QQuickStyledTextPrivate::parseAttribute(const QChar *&ch, const QString &textIn)
|
QPair<QStringView,QStringView> QQuickStyledTextPrivate::parseAttribute(const QChar *&ch, const QString &textIn)
|
||||||
{
|
{
|
||||||
skipSpace(ch);
|
skipSpace(ch);
|
||||||
|
|
||||||
|
@ -759,10 +759,10 @@ QPair<QStringRef,QStringRef> QQuickStyledTextPrivate::parseAttribute(const QChar
|
||||||
++ch;
|
++ch;
|
||||||
if (!attrLength)
|
if (!attrLength)
|
||||||
break;
|
break;
|
||||||
QStringRef attr(&textIn, attrStart, attrLength);
|
auto attr = QStringView(textIn).mid(attrStart, attrLength);
|
||||||
QStringRef val = parseValue(ch, textIn);
|
QStringView val = parseValue(ch, textIn);
|
||||||
if (!val.isEmpty())
|
if (!val.isEmpty())
|
||||||
return QPair<QStringRef,QStringRef>(attr,val);
|
return QPair<QStringView,QStringView>(attr,val);
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
++attrLength;
|
++attrLength;
|
||||||
|
@ -770,10 +770,10 @@ QPair<QStringRef,QStringRef> QQuickStyledTextPrivate::parseAttribute(const QChar
|
||||||
++ch;
|
++ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
return QPair<QStringRef,QStringRef>();
|
return QPair<QStringView,QStringView>();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringRef QQuickStyledTextPrivate::parseValue(const QChar *&ch, const QString &textIn)
|
QStringView QQuickStyledTextPrivate::parseValue(const QChar *&ch, const QString &textIn)
|
||||||
{
|
{
|
||||||
int valStart = ch - textIn.constData();
|
int valStart = ch - textIn.constData();
|
||||||
int valLength = 0;
|
int valLength = 0;
|
||||||
|
@ -782,10 +782,10 @@ QStringRef QQuickStyledTextPrivate::parseValue(const QChar *&ch, const QString &
|
||||||
++ch;
|
++ch;
|
||||||
}
|
}
|
||||||
if (ch->isNull())
|
if (ch->isNull())
|
||||||
return QStringRef();
|
return QStringView();
|
||||||
++ch; // skip quote
|
++ch; // skip quote
|
||||||
|
|
||||||
return QStringRef(&textIn, valStart, valLength);
|
return QStringView(textIn).mid(valStart, valLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QQuickStyledTextPrivate::toAlpha(int value, bool upper)
|
QString QQuickStyledTextPrivate::toAlpha(int value, bool upper)
|
||||||
|
|
|
@ -178,7 +178,7 @@ void tst_qqmlinfo::types()
|
||||||
//### should this be quoted?
|
//### should this be quoted?
|
||||||
QTest::ignoreMessage(QtInfoMsg, "<Unknown File>: World");
|
QTest::ignoreMessage(QtInfoMsg, "<Unknown File>: World");
|
||||||
QString str("Hello World");
|
QString str("Hello World");
|
||||||
QStringRef ref(&str, 6, 5);
|
auto ref = QStringView(str).mid(6, 5);
|
||||||
qmlInfo(nullptr) << ref;
|
qmlInfo(nullptr) << ref;
|
||||||
|
|
||||||
//### should this be quoted?
|
//### should this be quoted?
|
||||||
|
@ -189,7 +189,7 @@ void tst_qqmlinfo::types()
|
||||||
void tst_qqmlinfo::chaining()
|
void tst_qqmlinfo::chaining()
|
||||||
{
|
{
|
||||||
QString str("Hello World");
|
QString str("Hello World");
|
||||||
QStringRef ref(&str, 6, 5);
|
auto ref = QStringView(str).mid(6, 5);
|
||||||
QTest::ignoreMessage(QtInfoMsg, "<Unknown File>: false 1.1 1.2 15 hello 'b' World \"Qt\" true Quick QUrl(\"http://www.qt-project.org\") ");
|
QTest::ignoreMessage(QtInfoMsg, "<Unknown File>: false 1.1 1.2 15 hello 'b' World \"Qt\" true Quick QUrl(\"http://www.qt-project.org\") ");
|
||||||
qmlInfo(nullptr) << false << ' '
|
qmlInfo(nullptr) << false << ' '
|
||||||
<< 1.1 << ' '
|
<< 1.1 << ' '
|
||||||
|
|
|
@ -342,7 +342,7 @@ void tst_qqmlparser::stringLiteral()
|
||||||
QVERIFY(expression);
|
QVERIFY(expression);
|
||||||
auto *literal = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(expression);
|
auto *literal = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(expression);
|
||||||
QVERIFY(literal);
|
QVERIFY(literal);
|
||||||
QCOMPARE(literal->value, "hello string");
|
QCOMPARE(literal->value, u"hello string");
|
||||||
QCOMPARE(literal->firstSourceLocation().begin(), 0u);
|
QCOMPARE(literal->firstSourceLocation().begin(), 0u);
|
||||||
QCOMPARE(literal->lastSourceLocation().end(), quint32(code.size()));
|
QCOMPARE(literal->lastSourceLocation().end(), quint32(code.size()));
|
||||||
|
|
||||||
|
@ -361,7 +361,7 @@ void tst_qqmlparser::stringLiteral()
|
||||||
|
|
||||||
literal = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(binaryExpression->left);
|
literal = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(binaryExpression->left);
|
||||||
QVERIFY(literal);
|
QVERIFY(literal);
|
||||||
QCOMPARE(literal->value, "hello\n\tstring");
|
QCOMPARE(literal->value, u"hello\n\tstring");
|
||||||
QCOMPARE(literal->firstSourceLocation().begin(), 0u);
|
QCOMPARE(literal->firstSourceLocation().begin(), 0u);
|
||||||
QCOMPARE(literal->firstSourceLocation().startLine, 1u);
|
QCOMPARE(literal->firstSourceLocation().startLine, 1u);
|
||||||
QCOMPARE(literal->lastSourceLocation().end(), quint32(leftCode.size()));
|
QCOMPARE(literal->lastSourceLocation().end(), quint32(leftCode.size()));
|
||||||
|
@ -369,7 +369,7 @@ void tst_qqmlparser::stringLiteral()
|
||||||
QVERIFY(binaryExpression->right);
|
QVERIFY(binaryExpression->right);
|
||||||
literal = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(binaryExpression->right);
|
literal = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(binaryExpression->right);
|
||||||
QVERIFY(literal);
|
QVERIFY(literal);
|
||||||
QCOMPARE(literal->value, "\nbye");
|
QCOMPARE(literal->value, u"\nbye");
|
||||||
quint32 offset = quint32(leftCode.size() + plusCode.size());
|
quint32 offset = quint32(leftCode.size() + plusCode.size());
|
||||||
QCOMPARE(literal->firstSourceLocation().begin(), offset);
|
QCOMPARE(literal->firstSourceLocation().begin(), offset);
|
||||||
QCOMPARE(literal->firstSourceLocation().startLine, 1u);
|
QCOMPARE(literal->firstSourceLocation().startLine, 1u);
|
||||||
|
@ -387,14 +387,14 @@ void tst_qqmlparser::stringLiteral()
|
||||||
|
|
||||||
literal = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(binaryExpression->left);
|
literal = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(binaryExpression->left);
|
||||||
QVERIFY(literal);
|
QVERIFY(literal);
|
||||||
QCOMPARE(literal->value, "\nhello\nbye");
|
QCOMPARE(literal->value, u"\nhello\nbye");
|
||||||
QCOMPARE(literal->firstSourceLocation().begin(), 0u);
|
QCOMPARE(literal->firstSourceLocation().begin(), 0u);
|
||||||
QCOMPARE(literal->firstSourceLocation().startLine, 1u);
|
QCOMPARE(literal->firstSourceLocation().startLine, 1u);
|
||||||
QCOMPARE(literal->lastSourceLocation().end(), leftCode.size());
|
QCOMPARE(literal->lastSourceLocation().end(), leftCode.size());
|
||||||
|
|
||||||
literal = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(binaryExpression->right);
|
literal = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(binaryExpression->right);
|
||||||
QVERIFY(literal);
|
QVERIFY(literal);
|
||||||
QCOMPARE(literal->value, "\nbye");
|
QCOMPARE(literal->value, u"\nbye");
|
||||||
offset = quint32(leftCode.size() + plusCode.size());
|
offset = quint32(leftCode.size() + plusCode.size());
|
||||||
QCOMPARE(literal->firstSourceLocation().begin(), offset);
|
QCOMPARE(literal->firstSourceLocation().begin(), offset);
|
||||||
QCOMPARE(literal->lastSourceLocation().startLine, 3u);
|
QCOMPARE(literal->lastSourceLocation().startLine, 3u);
|
||||||
|
@ -479,7 +479,7 @@ void tst_qqmlparser::noSubstitutionTemplateLiteral()
|
||||||
auto *literal = QQmlJS::AST::cast<QQmlJS::AST::TemplateLiteral *>(expression);
|
auto *literal = QQmlJS::AST::cast<QQmlJS::AST::TemplateLiteral *>(expression);
|
||||||
QVERIFY(literal);
|
QVERIFY(literal);
|
||||||
|
|
||||||
QCOMPARE(literal->value, "hello template");
|
QCOMPARE(literal->value, u"hello template");
|
||||||
QCOMPARE(literal->firstSourceLocation().begin(), 0u);
|
QCOMPARE(literal->firstSourceLocation().begin(), 0u);
|
||||||
QCOMPARE(literal->lastSourceLocation().end(), quint32(code.size()));
|
QCOMPARE(literal->lastSourceLocation().end(), quint32(code.size()));
|
||||||
}
|
}
|
||||||
|
@ -696,7 +696,7 @@ void tst_qqmlparser::annotations_data()
|
||||||
|
|
||||||
for (const QString &file: qAsConst(files)) {
|
for (const QString &file: qAsConst(files)) {
|
||||||
auto fileNameStart = file.lastIndexOf(QDir::separator());
|
auto fileNameStart = file.lastIndexOf(QDir::separator());
|
||||||
QStringRef fileName(&file, fileNameStart, file.length()-fileNameStart);
|
auto fileName = QStringView(file).mid(fileNameStart, file.length()-fileNameStart);
|
||||||
auto ref=std::find_if(refFiles.constBegin(),refFiles.constEnd(), [fileName](const QString &s){ return s.endsWith(fileName); });
|
auto ref=std::find_if(refFiles.constBegin(),refFiles.constEnd(), [fileName](const QString &s){ return s.endsWith(fileName); });
|
||||||
if (ref != refFiles.constEnd())
|
if (ref != refFiles.constEnd())
|
||||||
QTest::newRow(qPrintable(file)) << file << *ref;
|
QTest::newRow(qPrintable(file)) << file << *ref;
|
||||||
|
|
|
@ -212,7 +212,7 @@ QString AstDumper::qs(const char *s) {
|
||||||
return qs(QLatin1String(s));
|
return qs(QLatin1String(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AstDumper::qs(const QStringRef &s) {
|
QString AstDumper::qs(QStringView s) {
|
||||||
return qs(s.toString());
|
return qs(s.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ public:
|
||||||
|
|
||||||
QString qs(const QString &s);
|
QString qs(const QString &s);
|
||||||
QString qs(const char *s);
|
QString qs(const char *s);
|
||||||
QString qs(const QStringRef &s);
|
QString qs(QStringView s);
|
||||||
|
|
||||||
QString loc(const SourceLocation &s);
|
QString loc(const SourceLocation &s);
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ int filterResourceFile(const QString &input, const QString &output)
|
||||||
while (!reader.atEnd()) {
|
while (!reader.atEnd()) {
|
||||||
switch (reader.readNext()) {
|
switch (reader.readNext()) {
|
||||||
case QXmlStreamReader::StartDocument: {
|
case QXmlStreamReader::StartDocument: {
|
||||||
QStringRef version = reader.documentVersion();
|
QStringView version = reader.documentVersion();
|
||||||
if (!version.isEmpty())
|
if (!version.isEmpty())
|
||||||
writer.writeStartDocument(version.toString());
|
writer.writeStartDocument(version.toString());
|
||||||
else
|
else
|
||||||
|
|
|
@ -675,12 +675,12 @@ void SplineEditor::setEasingCurve(const QString &code)
|
||||||
if (m_block)
|
if (m_block)
|
||||||
return;
|
return;
|
||||||
if (code.startsWith(QLatin1Char('[')) && code.endsWith(QLatin1Char(']'))) {
|
if (code.startsWith(QLatin1Char('[')) && code.endsWith(QLatin1Char(']'))) {
|
||||||
const QStringRef cleanCode(&code, 1, code.size() - 2);
|
const auto cleanCode = QStringView(code).mid(1, code.size() - 2);
|
||||||
const auto stringList = cleanCode.split(QLatin1Char(','), Qt::SkipEmptyParts);
|
const auto stringList = cleanCode.split(QLatin1Char(','), Qt::SkipEmptyParts);
|
||||||
if (stringList.count() >= 6 && (stringList.count() % 6 == 0)) {
|
if (stringList.count() >= 6 && (stringList.count() % 6 == 0)) {
|
||||||
QVector<qreal> realList;
|
QVector<qreal> realList;
|
||||||
realList.reserve(stringList.count());
|
realList.reserve(stringList.count());
|
||||||
for (const QStringRef &string : stringList) {
|
for (const QStringView &string : stringList) {
|
||||||
bool ok;
|
bool ok;
|
||||||
realList.append(string.toDouble(&ok));
|
realList.append(string.toDouble(&ok));
|
||||||
if (!ok)
|
if (!ok)
|
||||||
|
|
|
@ -254,7 +254,7 @@ QVariantList findPathsForModuleImports(const QVariantList &imports)
|
||||||
if (plugininfo.contains(dependenciesLiteral())) {
|
if (plugininfo.contains(dependenciesLiteral())) {
|
||||||
const QStringList dependencies = plugininfo.value(dependenciesLiteral()).toStringList();
|
const QStringList dependencies = plugininfo.value(dependenciesLiteral()).toStringList();
|
||||||
for (const QString &line : dependencies) {
|
for (const QString &line : dependencies) {
|
||||||
const auto dep = line.splitRef(QLatin1Char(' '));
|
const auto dep = QStringView{line}.split(QLatin1Char(' '));
|
||||||
QVariantMap depImport;
|
QVariantMap depImport;
|
||||||
depImport[typeLiteral()] = moduleLiteral();
|
depImport[typeLiteral()] = moduleLiteral();
|
||||||
depImport[nameLiteral()] = dep[0].toString();
|
depImport[nameLiteral()] = dep[0].toString();
|
||||||
|
|
|
@ -37,21 +37,21 @@ class IssueLocationWithContext
|
||||||
public:
|
public:
|
||||||
IssueLocationWithContext(const QString &code, const QQmlJS::SourceLocation &location) {
|
IssueLocationWithContext(const QString &code, const QQmlJS::SourceLocation &location) {
|
||||||
int before = std::max(0,code.lastIndexOf(QLatin1Char('\n'), location.offset));
|
int before = std::max(0,code.lastIndexOf(QLatin1Char('\n'), location.offset));
|
||||||
m_beforeText = code.midRef(before + 1, int(location.offset - (before + 1)));
|
m_beforeText = QStringView{code}.mid(before + 1, int(location.offset - (before + 1)));
|
||||||
m_issueText = code.midRef(location.offset, location.length);
|
m_issueText = QStringView{code}.mid(location.offset, location.length);
|
||||||
int after = code.indexOf(QLatin1Char('\n'), int(location.offset + location.length));
|
int after = code.indexOf(QLatin1Char('\n'), int(location.offset + location.length));
|
||||||
m_afterText = code.midRef(int(location.offset + location.length),
|
m_afterText = QStringView{code}.mid(int(location.offset + location.length),
|
||||||
int(after - (location.offset+location.length)));
|
int(after - (location.offset+location.length)));
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringRef beforeText() const { return m_beforeText; }
|
QStringView beforeText() const { return m_beforeText; }
|
||||||
QStringRef issueText() const { return m_issueText; }
|
QStringView issueText() const { return m_issueText; }
|
||||||
QStringRef afterText() const { return m_afterText; }
|
QStringView afterText() const { return m_afterText; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QStringRef m_beforeText;
|
QStringView m_beforeText;
|
||||||
QStringRef m_issueText;
|
QStringView m_issueText;
|
||||||
QStringRef m_afterText;
|
QStringView m_afterText;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void writeWarning(ColorOutput *out)
|
static void writeWarning(ColorOutput *out)
|
||||||
|
|
|
@ -317,7 +317,7 @@ void FindWarningVisitor::importFileOrDirectory(const QString &fileOrDirectory,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FindWarningVisitor::importExportedNames(const QStringRef &prefix, QString name)
|
void FindWarningVisitor::importExportedNames(QStringView prefix, QString name)
|
||||||
{
|
{
|
||||||
QList<ScopeTree::ConstPtr> scopes;
|
QList<ScopeTree::ConstPtr> scopes;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@ -780,7 +780,7 @@ bool FindWarningVisitor::visit(QQmlJS::AST::UiObjectBinding *uiob)
|
||||||
|
|
||||||
QString name {};
|
QString name {};
|
||||||
auto id = uiob->qualifiedTypeNameId;
|
auto id = uiob->qualifiedTypeNameId;
|
||||||
QStringRef prefix = uiob->qualifiedTypeNameId->name;
|
QStringView prefix = uiob->qualifiedTypeNameId->name;
|
||||||
while (id) {
|
while (id) {
|
||||||
name += id->name.toString() + QLatin1Char('.');
|
name += id->name.toString() + QLatin1Char('.');
|
||||||
id = id->next;
|
id = id->next;
|
||||||
|
@ -816,7 +816,7 @@ bool FindWarningVisitor::visit(QQmlJS::AST::UiObjectDefinition *uiod)
|
||||||
|
|
||||||
QString name {};
|
QString name {};
|
||||||
auto id = uiod->qualifiedTypeNameId;
|
auto id = uiod->qualifiedTypeNameId;
|
||||||
QStringRef prefix = uiod->qualifiedTypeNameId->name;
|
QStringView prefix = uiod->qualifiedTypeNameId->name;
|
||||||
while (id) {
|
while (id) {
|
||||||
name += id->name.toString() + QLatin1Char('.');
|
name += id->name.toString() + QLatin1Char('.');
|
||||||
id = id->next;
|
id = id->next;
|
||||||
|
|
|
@ -106,7 +106,7 @@ private:
|
||||||
ScopeTree::Ptr localFile2ScopeTree(const QString &filePath);
|
ScopeTree::Ptr localFile2ScopeTree(const QString &filePath);
|
||||||
|
|
||||||
void importFileOrDirectory(const QString &directory, const QString &prefix);
|
void importFileOrDirectory(const QString &directory, const QString &prefix);
|
||||||
void importExportedNames(const QStringRef &prefix, QString name);
|
void importExportedNames(QStringView prefix, QString name);
|
||||||
|
|
||||||
void parseHeaders(QQmlJS::AST::UiHeaderItemList *headers);
|
void parseHeaders(QQmlJS::AST::UiHeaderItemList *headers);
|
||||||
ScopeTree::Ptr parseProgram(QQmlJS::AST::Program *program, const QString &name);
|
ScopeTree::Ptr parseProgram(QQmlJS::AST::Program *program, const QString &name);
|
||||||
|
|
|
@ -354,7 +354,7 @@ bool QmlProfilerApplication::checkOutputFile(PendingRequest pending)
|
||||||
|
|
||||||
void QmlProfilerApplication::userCommand(const QString &command)
|
void QmlProfilerApplication::userCommand(const QString &command)
|
||||||
{
|
{
|
||||||
auto args = command.splitRef(QChar::Space, Qt::SkipEmptyParts);
|
auto args = QStringView{command}.split(QChar::Space, Qt::SkipEmptyParts);
|
||||||
if (args.isEmpty()) {
|
if (args.isEmpty()) {
|
||||||
prompt();
|
prompt();
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -198,7 +198,7 @@ void QmlProfilerData::addEventType(const QQmlProfilerEventType &type)
|
||||||
break;
|
break;
|
||||||
case PixmapCacheEvent: {
|
case PixmapCacheEvent: {
|
||||||
const QString filePath = QUrl(type.location().filename()).path();
|
const QString filePath = QUrl(type.location().filename()).path();
|
||||||
displayName = filePath.midRef(filePath.lastIndexOf(QLatin1Char('/')) + 1)
|
displayName = QStringView{filePath}.mid(filePath.lastIndexOf(QLatin1Char('/')) + 1)
|
||||||
+ QLatin1Char(':') + QString::number(type.detailType());
|
+ QLatin1Char(':') + QString::number(type.detailType());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -218,7 +218,7 @@ void QmlProfilerData::addEventType(const QQmlProfilerEventType &type)
|
||||||
displayName = QString::fromLatin1("Unknown");
|
displayName = QString::fromLatin1("Unknown");
|
||||||
} else {
|
} else {
|
||||||
const QString filePath = QUrl(eventLocation.filename()).path();
|
const QString filePath = QUrl(eventLocation.filename()).path();
|
||||||
displayName = filePath.midRef(
|
displayName = QStringView{filePath}.mid(
|
||||||
filePath.lastIndexOf(QLatin1Char('/')) + 1) +
|
filePath.lastIndexOf(QLatin1Char('/')) + 1) +
|
||||||
QLatin1Char(':') + QString::number(eventLocation.line());
|
QLatin1Char(':') + QString::number(eventLocation.line());
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,10 +35,10 @@ ComponentVersion::ComponentVersion(const QString &versionString)
|
||||||
if (dotIdx == -1)
|
if (dotIdx == -1)
|
||||||
return;
|
return;
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
const int maybeMajor = versionString.leftRef(dotIdx).toInt(&ok);
|
const int maybeMajor = QStringView{versionString}.left(dotIdx).toInt(&ok);
|
||||||
if (!ok)
|
if (!ok)
|
||||||
return;
|
return;
|
||||||
const int maybeMinor = versionString.midRef(dotIdx + 1).toInt(&ok);
|
const int maybeMinor = QStringView{versionString}.mid(dotIdx + 1).toInt(&ok);
|
||||||
if (!ok)
|
if (!ok)
|
||||||
return;
|
return;
|
||||||
m_version = QTypeRevision::fromVersion(maybeMajor, maybeMinor);
|
m_version = QTypeRevision::fromVersion(maybeMajor, maybeMinor);
|
||||||
|
|
Loading…
Reference in New Issue