Replace ushort*/uint* with char16_t*/char32_t* in private API [1]
Task-number: QTBUG-110403 Pick-to: 6.5 Change-Id: Ie20a831f22212d56659cf3c6940d17134ab5f2c5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
2ad63a0975
commit
f325bdacb6
@ -195,10 +195,8 @@ void QDebug::putUcs4(uint ucs4)
|
|||||||
// These two functions return true if the character should be printed by QDebug.
|
// These two functions return true if the character should be printed by QDebug.
|
||||||
// For QByteArray, this is technically identical to US-ASCII isprint();
|
// For QByteArray, this is technically identical to US-ASCII isprint();
|
||||||
// for QString, we use QChar::isPrint, which requires a full UCS-4 decode.
|
// for QString, we use QChar::isPrint, which requires a full UCS-4 decode.
|
||||||
static inline bool isPrintable(uint ucs4)
|
static inline bool isPrintable(char32_t ucs4) { return QChar::isPrint(ucs4); }
|
||||||
{ return QChar::isPrint(ucs4); }
|
static inline bool isPrintable(char16_t uc) { return QChar::isPrint(uc); }
|
||||||
static inline bool isPrintable(ushort uc)
|
|
||||||
{ return QChar::isPrint(uc); }
|
|
||||||
static inline bool isPrintable(uchar c)
|
static inline bool isPrintable(uchar c)
|
||||||
{ return c >= ' ' && c < 0x7f; }
|
{ return c >= ' ' && c < 0x7f; }
|
||||||
|
|
||||||
@ -240,7 +238,7 @@ static inline void putEscapedString(QTextStreamPrivate *d, const Char *begin, si
|
|||||||
|
|
||||||
// print as an escape sequence (maybe, see below for surrogate pairs)
|
// print as an escape sequence (maybe, see below for surrogate pairs)
|
||||||
qsizetype buflen = 2;
|
qsizetype buflen = 2;
|
||||||
ushort buf[sizeof "\\U12345678" - 1];
|
char16_t buf[std::char_traits<char>::length("\\U12345678")];
|
||||||
buf[0] = '\\';
|
buf[0] = '\\';
|
||||||
|
|
||||||
switch (*p) {
|
switch (*p) {
|
||||||
@ -276,7 +274,7 @@ static inline void putEscapedString(QTextStreamPrivate *d, const Char *begin, si
|
|||||||
if (QChar::isHighSurrogate(*p)) {
|
if (QChar::isHighSurrogate(*p)) {
|
||||||
if ((p + 1) != end && QChar::isLowSurrogate(p[1])) {
|
if ((p + 1) != end && QChar::isLowSurrogate(p[1])) {
|
||||||
// properly-paired surrogates
|
// properly-paired surrogates
|
||||||
uint ucs4 = QChar::surrogateToUcs4(*p, p[1]);
|
char32_t ucs4 = QChar::surrogateToUcs4(*p, p[1]);
|
||||||
if (isPrintable(ucs4)) {
|
if (isPrintable(ucs4)) {
|
||||||
buf[0] = *p;
|
buf[0] = *p;
|
||||||
buf[1] = p[1];
|
buf[1] = p[1];
|
||||||
@ -299,8 +297,8 @@ static inline void putEscapedString(QTextStreamPrivate *d, const Char *begin, si
|
|||||||
// improperly-paired surrogates, fall through
|
// improperly-paired surrogates, fall through
|
||||||
}
|
}
|
||||||
buf[1] = 'u';
|
buf[1] = 'u';
|
||||||
buf[2] = toHexUpper(ushort(*p) >> 12);
|
buf[2] = toHexUpper(char16_t(*p) >> 12);
|
||||||
buf[3] = toHexUpper(ushort(*p) >> 8);
|
buf[3] = toHexUpper(char16_t(*p) >> 8);
|
||||||
buf[4] = toHexUpper(*p >> 4);
|
buf[4] = toHexUpper(*p >> 4);
|
||||||
buf[5] = toHexUpper(*p);
|
buf[5] = toHexUpper(*p);
|
||||||
buflen = 6;
|
buflen = 6;
|
||||||
@ -325,7 +323,7 @@ void QDebug::putString(const QChar *begin, size_t length)
|
|||||||
// we'll reset the QTextStream formatting mechanisms, so save the state
|
// we'll reset the QTextStream formatting mechanisms, so save the state
|
||||||
QDebugStateSaver saver(*this);
|
QDebugStateSaver saver(*this);
|
||||||
stream->ts.d_ptr->params.reset();
|
stream->ts.d_ptr->params.reset();
|
||||||
putEscapedString(stream->ts.d_ptr.data(), reinterpret_cast<const ushort *>(begin), length);
|
putEscapedString(stream->ts.d_ptr.data(), reinterpret_cast<const char16_t *>(begin), length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ public:
|
|||||||
inline QDebug &operator<<(char t) { stream->ts << t; return maybeSpace(); }
|
inline QDebug &operator<<(char t) { stream->ts << t; return maybeSpace(); }
|
||||||
inline QDebug &operator<<(signed short t) { stream->ts << t; return maybeSpace(); }
|
inline QDebug &operator<<(signed short t) { stream->ts << t; return maybeSpace(); }
|
||||||
inline QDebug &operator<<(unsigned short t) { stream->ts << t; return maybeSpace(); }
|
inline QDebug &operator<<(unsigned short t) { stream->ts << t; return maybeSpace(); }
|
||||||
inline QDebug &operator<<(char16_t t) { return *this << QChar(ushort(t)); }
|
inline QDebug &operator<<(char16_t t) { return *this << QChar(t); }
|
||||||
inline QDebug &operator<<(char32_t t) { putUcs4(t); return maybeSpace(); }
|
inline QDebug &operator<<(char32_t t) { putUcs4(t); return maybeSpace(); }
|
||||||
inline QDebug &operator<<(signed int t) { stream->ts << t; return maybeSpace(); }
|
inline QDebug &operator<<(signed int t) { stream->ts << t; return maybeSpace(); }
|
||||||
inline QDebug &operator<<(unsigned int t) { stream->ts << t; return maybeSpace(); }
|
inline QDebug &operator<<(unsigned int t) { stream->ts << t; return maybeSpace(); }
|
||||||
|
@ -2217,8 +2217,8 @@ QString qt_normalizePathSegments(const QString &name, QDirPrivate::PathNormaliza
|
|||||||
QVarLengthArray<char16_t> outVector(len);
|
QVarLengthArray<char16_t> outVector(len);
|
||||||
qsizetype used = len;
|
qsizetype used = len;
|
||||||
char16_t *out = outVector.data();
|
char16_t *out = outVector.data();
|
||||||
const ushort *p = reinterpret_cast<const ushort *>(name.data());
|
const char16_t *p = reinterpret_cast<const char16_t *>(name.data());
|
||||||
const ushort *prefix = p;
|
const char16_t *prefix = p;
|
||||||
qsizetype up = 0;
|
qsizetype up = 0;
|
||||||
|
|
||||||
const qsizetype prefixLength = rootLength(name, allowUncPaths);
|
const qsizetype prefixLength = rootLength(name, allowUncPaths);
|
||||||
@ -2232,10 +2232,10 @@ QString qt_normalizePathSegments(const QString &name, QDirPrivate::PathNormaliza
|
|||||||
--i;
|
--i;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto isDot = [](const ushort *p, qsizetype i) {
|
auto isDot = [](const char16_t *p, qsizetype i) {
|
||||||
return i > 1 && p[i - 1] == '.' && p[i - 2] == '/';
|
return i > 1 && p[i - 1] == '.' && p[i - 2] == '/';
|
||||||
};
|
};
|
||||||
auto isDotDot = [](const ushort *p, qsizetype i) {
|
auto isDotDot = [](const char16_t *p, qsizetype i) {
|
||||||
return i > 2 && p[i - 1] == '.' && p[i - 2] == '.' && p[i - 3] == '/';
|
return i > 2 && p[i - 1] == '.' && p[i - 2] == '.' && p[i - 3] == '/';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -22,9 +22,9 @@ static QString number(quint8 val)
|
|||||||
typedef QVarLengthArray<char, 64> Buffer;
|
typedef QVarLengthArray<char, 64> Buffer;
|
||||||
static const QChar *checkedToAscii(Buffer &buffer, const QChar *begin, const QChar *end)
|
static const QChar *checkedToAscii(Buffer &buffer, const QChar *begin, const QChar *end)
|
||||||
{
|
{
|
||||||
const ushort *const ubegin = reinterpret_cast<const ushort *>(begin);
|
const auto *const ubegin = reinterpret_cast<const char16_t *>(begin);
|
||||||
const ushort *const uend = reinterpret_cast<const ushort *>(end);
|
const auto *const uend = reinterpret_cast<const char16_t *>(end);
|
||||||
const ushort *src = ubegin;
|
auto *src = ubegin;
|
||||||
|
|
||||||
buffer.resize(uend - ubegin + 1);
|
buffer.resize(uend - ubegin + 1);
|
||||||
char *dst = buffer.data();
|
char *dst = buffer.data();
|
||||||
|
@ -753,7 +753,7 @@ inline QString QResourceRoot::name(int node) const
|
|||||||
|
|
||||||
ret.resize(name_length);
|
ret.resize(name_length);
|
||||||
QChar *strData = ret.data();
|
QChar *strData = ret.data();
|
||||||
qFromBigEndian<ushort>(names + name_offset, name_length, strData);
|
qFromBigEndian<char16_t>(names + name_offset, name_length, strData);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,8 +320,8 @@ Q_CONSTINIT static QStringList *user_idn_whitelist = nullptr;
|
|||||||
|
|
||||||
static bool lessThan(const QChar *a, int l, const char *c)
|
static bool lessThan(const QChar *a, int l, const char *c)
|
||||||
{
|
{
|
||||||
const ushort *uc = (const ushort *)a;
|
const auto *uc = reinterpret_cast<const char16_t *>(a);
|
||||||
const ushort *e = uc + l;
|
const char16_t *e = uc + l;
|
||||||
|
|
||||||
if (!c || *c == 0)
|
if (!c || *c == 0)
|
||||||
return false;
|
return false;
|
||||||
|
@ -914,7 +914,7 @@ end:
|
|||||||
if (!tn)
|
if (!tn)
|
||||||
return QString();
|
return QString();
|
||||||
QString str(tn_length / 2, Qt::Uninitialized);
|
QString str(tn_length / 2, Qt::Uninitialized);
|
||||||
qFromBigEndian<ushort>(tn, str.size(), str.data());
|
qFromBigEndian<char16_t>(tn, str.size(), str.data());
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1721,7 +1721,7 @@ void QXmlStreamReaderPrivate::checkPublicLiteral(QStringView publicId)
|
|||||||
{
|
{
|
||||||
//#x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%]
|
//#x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%]
|
||||||
|
|
||||||
const ushort *data = reinterpret_cast<const ushort *>(publicId.constData());
|
const char16_t *data = publicId.utf16();
|
||||||
uchar c = 0;
|
uchar c = 0;
|
||||||
qsizetype i;
|
qsizetype i;
|
||||||
for (i = publicId.size() - 1; i >= 0; --i) {
|
for (i = publicId.size() - 1; i >= 0; --i) {
|
||||||
|
@ -2060,7 +2060,7 @@ static bool normalizationQuickCheckHelper(QString *str, QString::NormalizationFo
|
|||||||
|
|
||||||
enum { NFQC_YES = 0, NFQC_NO = 1, NFQC_MAYBE = 3 };
|
enum { NFQC_YES = 0, NFQC_NO = 1, NFQC_MAYBE = 3 };
|
||||||
|
|
||||||
const ushort *string = reinterpret_cast<const ushort *>(str->constData());
|
const auto *string = reinterpret_cast<const char16_t *>(str->constData());
|
||||||
qsizetype length = str->size();
|
qsizetype length = str->size();
|
||||||
|
|
||||||
// this avoids one out of bounds check in the loop
|
// this avoids one out of bounds check in the loop
|
||||||
|
@ -1603,8 +1603,8 @@ public:
|
|||||||
return nodeName == "QToolTip"_L1;
|
return nodeName == "QToolTip"_L1;
|
||||||
#endif
|
#endif
|
||||||
do {
|
do {
|
||||||
const ushort *uc = (const ushort *)nodeName.constData();
|
const auto *uc = reinterpret_cast<const char16_t *>(nodeName.constData());
|
||||||
const ushort *e = uc + nodeName.size();
|
const auto *e = uc + nodeName.size();
|
||||||
const uchar *c = (const uchar *)metaObject->className();
|
const uchar *c = (const uchar *)metaObject->className();
|
||||||
while (*c && uc != e && (*uc == *c || (*c == ':' && *uc == '-'))) {
|
while (*c && uc != e && (*uc == *c || (*c == ':' && *uc == '-'))) {
|
||||||
++uc;
|
++uc;
|
||||||
|
@ -2018,7 +2018,7 @@ void tst_Collections::qstring()
|
|||||||
s = "ascii";
|
s = "ascii";
|
||||||
s += QChar((uchar) 0xb0);
|
s += QChar((uchar) 0xb0);
|
||||||
QVERIFY(s.toUtf8() != s.toLatin1());
|
QVERIFY(s.toUtf8() != s.toLatin1());
|
||||||
QCOMPARE(s[s.size()-1].unicode(), (ushort)0xb0);
|
QCOMPARE(s[s.size()-1].unicode(), char16_t(0xb0));
|
||||||
QCOMPARE(s.left(s.size()-1), QLatin1String("ascii"));
|
QCOMPARE(s.left(s.size()-1), QLatin1String("ascii"));
|
||||||
|
|
||||||
QVERIFY(s == QString::fromUtf8(s.toUtf8().constData()));
|
QVERIFY(s == QString::fromUtf8(s.toUtf8().constData()));
|
||||||
|
@ -42,7 +42,7 @@ size_t qHash(const Qt50String &key, size_t seed)
|
|||||||
// (for instance, gcc 4.4 does that even at -O0).
|
// (for instance, gcc 4.4 does that even at -O0).
|
||||||
size_t qHash(const JavaString &str)
|
size_t qHash(const JavaString &str)
|
||||||
{
|
{
|
||||||
const unsigned short *p = (unsigned short *)str.constData();
|
const auto *p = reinterpret_cast<const char16_t *>(str.constData());
|
||||||
const qsizetype len = str.size();
|
const qsizetype len = str.size();
|
||||||
|
|
||||||
uint h = 0;
|
uint h = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user