aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-06-02 16:08:59 +0200
committerUlf Hermann <ulf.hermann@qt.io>2020-06-03 15:47:06 +0200
commit33a7f5ee4d8d4dc197100e3cda141063b89f74e6 (patch)
tree58a48bb5ab2a45d35c11187c6aeb4c94f974724c /src/qml/jsruntime
parent5e0bf417fb38c53d4ae43f9f84fe42461cd2e00c (diff)
QtQml: Use unicode character literals
This avoids the warnings on conversion to QChar. Change-Id: Ib774f24592d6f09a531c60bb6fa6e5bdbec88120 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r--src/qml/jsruntime/qv4dateobject.cpp20
-rw-r--r--src/qml/jsruntime/qv4globalobject.cpp10
-rw-r--r--src/qml/jsruntime/qv4jsonobject.cpp112
-rw-r--r--src/qml/jsruntime/qv4regexpobject.cpp2
4 files changed, 72 insertions, 72 deletions
diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp
index bebcbd7e44..310d393c12 100644
--- a/src/qml/jsruntime/qv4dateobject.cpp
+++ b/src/qml/jsruntime/qv4dateobject.cpp
@@ -452,16 +452,16 @@ static inline double ParseString(const QString &s, double localTZA)
bool seenZ = false; // Have seen zone, i.e. +HH:mm or literal Z.
bool error = false;
- if (*ch == '+' || *ch == '-') {
+ if (*ch == u'+' || *ch == u'-') {
extendedYear = true;
- if (*ch == '-')
+ if (*ch == u'-')
yearSign = -1;
++ch;
}
for (; ch <= end && !error && format != Done; ++ch) {
- if (*ch >= '0' && *ch <= '9') {
+ if (*ch >= u'0' && *ch <= u'9') {
current *= 10;
- current += ch->unicode() - '0';
+ current += ch->unicode() - u'0';
++currentSize;
} else { // other char, delimits field
switch (format) {
@@ -507,12 +507,12 @@ static inline double ParseString(const QString &s, double localTZA)
error = (currentSize != 2) || current >= 60;
break;
}
- if (*ch == 'T') {
+ if (*ch == u'T') {
if (format >= Hour)
error = true;
format = Hour;
seenT = true;
- } else if (*ch == '-') {
+ } else if (*ch == u'-') {
if (format < Day)
++format;
else if (format < Minute)
@@ -524,19 +524,19 @@ static inline double ParseString(const QString &s, double localTZA)
offsetSign = -1;
format = TimezoneHour;
}
- } else if (*ch == ':') {
+ } else if (*ch == u':') {
if (format != Hour && format != Minute && format != TimezoneHour)
error = true;
++format;
- } else if (*ch == '.') {
+ } else if (*ch == u'.') {
if (format != Second)
error = true;
++format;
- } else if (*ch == '+') {
+ } else if (*ch == u'+') {
if (seenZ || format < Minute || format >= TimezoneHour)
error = true;
format = TimezoneHour;
- } else if (*ch == 'Z') {
+ } else if (*ch == u'Z') {
if (seenZ || format < Minute || format >= TimezoneHour)
error = true;
else
diff --git a/src/qml/jsruntime/qv4globalobject.cpp b/src/qml/jsruntime/qv4globalobject.cpp
index 1b47620572..7fa32da8aa 100644
--- a/src/qml/jsruntime/qv4globalobject.cpp
+++ b/src/qml/jsruntime/qv4globalobject.cpp
@@ -80,13 +80,13 @@ static QString escape(const QString &input)
|| (uc == 0x5F)) {
output.append(QChar(uc));
} else {
- output.append('%');
+ output.append(u'%');
output.append(QLatin1Char(toHexUpper(uc >> 4)));
output.append(QLatin1Char(toHexUpper(uc)));
}
} else {
- output.append('%');
- output.append('u');
+ output.append(u'%');
+ output.append(u'u');
output.append(QLatin1Char(toHexUpper(uc >> 12)));
output.append(QLatin1Char(toHexUpper(uc >> 8)));
output.append(QLatin1Char(toHexUpper(uc >> 4)));
@@ -104,9 +104,9 @@ static QString unescape(const QString &input)
const int length = input.length();
while (i < length) {
QChar c = input.at(i++);
- if ((c == '%') && (i + 1 < length)) {
+ if ((c == u'%') && (i + 1 < length)) {
QChar a = input.at(i);
- if ((a == 'u') && (i + 4 < length)) {
+ if ((a == u'u') && (i + 4 < length)) {
int d3 = fromHex(input.at(i+1).unicode());
int d2 = fromHex(input.at(i+2).unicode());
int d1 = fromHex(input.at(i+3).unicode());
diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp
index ce759111f4..2007c775c4 100644
--- a/src/qml/jsruntime/qv4jsonobject.cpp
+++ b/src/qml/jsruntime/qv4jsonobject.cpp
@@ -332,14 +332,14 @@ bool JsonParser::parseValue(Value *val)
BEGIN << "parse Value" << *json;
switch ((json++)->unicode()) {
- case 'n':
+ case u'n':
if (end - json < 3) {
lastError = QJsonParseError::IllegalValue;
return false;
}
- if (*json++ == 'u' &&
- *json++ == 'l' &&
- *json++ == 'l') {
+ if (*json++ == u'u' &&
+ *json++ == u'l' &&
+ *json++ == u'l') {
*val = Value::nullValue();
DEBUG << "value: null";
END;
@@ -347,14 +347,14 @@ bool JsonParser::parseValue(Value *val)
}
lastError = QJsonParseError::IllegalValue;
return false;
- case 't':
+ case u't':
if (end - json < 3) {
lastError = QJsonParseError::IllegalValue;
return false;
}
- if (*json++ == 'r' &&
- *json++ == 'u' &&
- *json++ == 'e') {
+ if (*json++ == u'r' &&
+ *json++ == u'u' &&
+ *json++ == u'e') {
*val = Value::fromBoolean(true);
DEBUG << "value: true";
END;
@@ -362,15 +362,15 @@ bool JsonParser::parseValue(Value *val)
}
lastError = QJsonParseError::IllegalValue;
return false;
- case 'f':
+ case u'f':
if (end - json < 4) {
lastError = QJsonParseError::IllegalValue;
return false;
}
- if (*json++ == 'a' &&
- *json++ == 'l' &&
- *json++ == 's' &&
- *json++ == 'e') {
+ if (*json++ == u'a' &&
+ *json++ == u'l' &&
+ *json++ == u's' &&
+ *json++ == u'e') {
*val = Value::fromBoolean(false);
DEBUG << "value: false";
END;
@@ -443,32 +443,32 @@ bool JsonParser::parseNumber(Value *val)
bool isInt = true;
// minus
- if (json < end && *json == '-')
+ if (json < end && *json == u'-')
++json;
// int = zero / ( digit1-9 *DIGIT )
- if (json < end && *json == '0') {
+ if (json < end && *json == u'0') {
++json;
} else {
- while (json < end && *json >= '0' && *json <= '9')
+ while (json < end && *json >= u'0' && *json <= u'9')
++json;
}
// frac = decimal-point 1*DIGIT
- if (json < end && *json == '.') {
+ if (json < end && *json == u'.') {
isInt = false;
++json;
- while (json < end && *json >= '0' && *json <= '9')
+ while (json < end && *json >= u'0' && *json <= u'9')
++json;
}
// exp = e [ minus / plus ] 1*DIGIT
- if (json < end && (*json == 'e' || *json == 'E')) {
+ if (json < end && (*json == u'e' || *json == u'E')) {
isInt = false;
++json;
- if (json < end && (*json == '-' || *json == '+'))
+ if (json < end && (*json == u'-' || *json == u'+'))
++json;
- while (json < end && *json >= '0' && *json <= '9')
+ while (json < end && *json >= u'0' && *json <= u'9')
++json;
}
@@ -526,12 +526,12 @@ static inline bool addHexDigit(QChar digit, uint *result)
{
ushort d = digit.unicode();
*result <<= 4;
- if (d >= '0' && d <= '9')
- *result |= (d - '0');
- else if (d >= 'a' && d <= 'f')
- *result |= (d - 'a') + 10;
- else if (d >= 'A' && d <= 'F')
- *result |= (d - 'A') + 10;
+ if (d >= u'0' && d <= u'9')
+ *result |= (d - u'0');
+ else if (d >= u'a' && d <= u'f')
+ *result |= (d - u'a') + 10;
+ else if (d >= u'A' && d <= u'F')
+ *result |= (d - u'A') + 10;
else
return false;
return true;
@@ -546,23 +546,23 @@ static inline bool scanEscapeSequence(const QChar *&json, const QChar *end, uint
DEBUG << "scan escape";
uint escaped = (json++)->unicode();
switch (escaped) {
- case '"':
+ case u'"':
*ch = '"'; break;
- case '\\':
+ case u'\\':
*ch = '\\'; break;
- case '/':
+ case u'/':
*ch = '/'; break;
- case 'b':
+ case u'b':
*ch = 0x8; break;
- case 'f':
+ case u'f':
*ch = 0xc; break;
- case 'n':
+ case u'n':
*ch = 0xa; break;
- case 'r':
+ case u'r':
*ch = 0xd; break;
- case 't':
+ case u't':
*ch = 0x9; break;
- case 'u': {
+ case u'u': {
*ch = 0;
if (json > end - 4)
return false;
@@ -585,9 +585,9 @@ bool JsonParser::parseString(QString *string)
BEGIN << "parse string stringPos=" << json;
while (json < end) {
- if (*json == '"')
+ if (*json == u'"')
break;
- else if (*json == '\\') {
+ else if (*json == u'\\') {
uint ch = 0;
if (!scanEscapeSequence(json, end, &ch)) {
lastError = QJsonParseError::IllegalEscapeSequence;
@@ -650,42 +650,42 @@ static QString quote(const QString &str)
QString product;
const int length = str.length();
product.reserve(length + 2);
- product += QLatin1Char('"');
+ product += u'"';
for (int i = 0; i < length; ++i) {
QChar c = str.at(i);
switch (c.unicode()) {
- case '"':
+ case u'"':
product += QLatin1String("\\\"");
break;
- case '\\':
+ case u'\\':
product += QLatin1String("\\\\");
break;
- case '\b':
+ case u'\b':
product += QLatin1String("\\b");
break;
- case '\f':
+ case u'\f':
product += QLatin1String("\\f");
break;
- case '\n':
+ case u'\n':
product += QLatin1String("\\n");
break;
- case '\r':
+ case u'\r':
product += QLatin1String("\\r");
break;
- case '\t':
+ case u'\t':
product += QLatin1String("\\t");
break;
default:
if (c.unicode() <= 0x1f) {
product += QLatin1String("\\u00");
- product += (c.unicode() > 0xf ? QLatin1Char('1') : QLatin1Char('0')) +
+ product += (c.unicode() > 0xf ? u'1' : u'0') +
QLatin1Char("0123456789abcdef"[c.unicode() & 0xf]);
} else {
product += c;
}
}
}
- product += QLatin1Char('"');
+ product += u'"';
return product;
}
@@ -764,9 +764,9 @@ QString Stringify::makeMember(const QString &key, const Value &v)
{
QString strP = Str(key, v);
if (!strP.isEmpty()) {
- QString member = quote(key) + QLatin1Char(':');
+ QString member = quote(key) + u':';
if (!gap.isEmpty())
- member += QLatin1Char(' ');
+ member += u' ';
member += strP;
return member;
}
@@ -821,11 +821,11 @@ QString Stringify::JO(Object *o)
if (partial.isEmpty()) {
result = QStringLiteral("{}");
} else if (gap.isEmpty()) {
- result = QLatin1Char('{') + partial.join(QLatin1Char(',')) + QLatin1Char('}');
+ result = u'{' + partial.join(u',') + u'}';
} else {
QString separator = QLatin1String(",\n") + indent;
- result = QLatin1String("{\n") + indent + partial.join(separator) + QLatin1Char('\n')
- + stepback + QLatin1Char('}');
+ result = QLatin1String("{\n") + indent + partial.join(separator) + u'\n'
+ + stepback + u'}';
}
indent = stepback;
@@ -867,10 +867,10 @@ QString Stringify::JA(Object *a)
if (partial.isEmpty()) {
result = QStringLiteral("[]");
} else if (gap.isEmpty()) {
- result = QLatin1Char('[') + partial.join(QLatin1Char(',')) + QLatin1Char(']');
+ result = u'[' + partial.join(u',') + u']';
} else {
QString separator = QLatin1String(",\n") + indent;
- result = QLatin1String("[\n") + indent + partial.join(separator) + QLatin1Char('\n') + stepback + QLatin1Char(']');
+ result = QLatin1String("[\n") + indent + partial.join(separator) + u'\n' + stepback + u']';
}
indent = stepback;
@@ -948,7 +948,7 @@ ReturnedValue JsonObject::method_stringify(const FunctionObject *b, const Value
s = so->d()->string;
if (s->isNumber()) {
- stringify.gap = QString(qMin(10, (int)s->toInteger()), ' ');
+ stringify.gap = QString(qMin(10, (int)s->toInteger()), u' ');
} else if (String *str = s->stringValue()) {
stringify.gap = str->toQString().left(10);
}
diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp
index 73122fbf75..c2171d7c0e 100644
--- a/src/qml/jsruntime/qv4regexpobject.cpp
+++ b/src/qml/jsruntime/qv4regexpobject.cpp
@@ -171,7 +171,7 @@ QString RegExpObject::toString() const
p = QStringLiteral("(?:)");
} else {
// escape certain parts, see ch. 15.10.4
- p.replace('/', QLatin1String("\\/"));
+ p.replace(u'/', QLatin1String("\\/"));
}
return p;
}