Moc/Generator: fix 64-to-32 narrowing conversion warnigns

Change-Id: Id1094aaba284c51c3a840a8e107abd837a825593
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit e22f766bda7c405ab4daa27b553d4100dcfa811f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Ahmad Samir 2023-05-22 16:21:53 +03:00 committed by Qt Cherry-pick Bot
parent f22bedf5af
commit 059acac8f9

View File

@ -70,11 +70,11 @@ QT_FOR_EACH_STATIC_TYPE(RETURN_METATYPENAME_STRING)
purestSuperClass = cdef->superclassList.constFirst().first; purestSuperClass = cdef->superclassList.constFirst().first;
} }
static inline int lengthOfEscapeSequence(const QByteArray &s, int i) static inline qsizetype lengthOfEscapeSequence(const QByteArray &s, qsizetype i)
{ {
if (s.at(i) != '\\' || i >= s.size() - 1) if (s.at(i) != '\\' || i >= s.size() - 1)
return 1; return 1;
const int startPos = i; const qsizetype startPos = i;
++i; ++i;
char ch = s.at(i); char ch = s.at(i);
if (ch == 'x') { if (ch == 'x') {
@ -111,18 +111,18 @@ static inline uint lengthOfEscapedString(const QByteArray &str)
static void printStringWithIndentation(FILE *out, const QByteArray &s) static void printStringWithIndentation(FILE *out, const QByteArray &s)
{ {
static constexpr int ColumnWidth = 72; static constexpr int ColumnWidth = 72;
int len = s.size(); const qsizetype len = s.size();
int idx = 0; qsizetype idx = 0;
do { do {
int spanLen = qMin(ColumnWidth - 2, len - idx); qsizetype spanLen = qMin(ColumnWidth - 2, len - idx);
// don't cut escape sequences at the end of a line // don't cut escape sequences at the end of a line
int backSlashPos = s.lastIndexOf('\\', idx + spanLen - 1); const qsizetype backSlashPos = s.lastIndexOf('\\', idx + spanLen - 1);
if (backSlashPos >= idx) { if (backSlashPos >= idx) {
int escapeLen = lengthOfEscapeSequence(s, backSlashPos); const qsizetype escapeLen = lengthOfEscapeSequence(s, backSlashPos);
spanLen = qBound(spanLen, backSlashPos + escapeLen - idx, len - idx); spanLen = qBound(spanLen, backSlashPos + escapeLen - idx, len - idx);
} }
fprintf(out, "\n \"%.*s\"", spanLen, s.constData() + idx); fprintf(out, "\n \"%.*s\"", int(spanLen), s.constData() + idx);
idx += spanLen; idx += spanLen;
} while (idx < len); } while (idx < len);
} }
@ -357,8 +357,8 @@ void Generator::generateCode()
fprintf(out, " %4d, %4d, // classinfo\n", int(cdef->classInfoList.size()), int(cdef->classInfoList.size() ? index : 0)); fprintf(out, " %4d, %4d, // classinfo\n", int(cdef->classInfoList.size()), int(cdef->classInfoList.size() ? index : 0));
index += cdef->classInfoList.size() * 2; index += cdef->classInfoList.size() * 2;
int methodCount = cdef->signalList.size() + cdef->slotList.size() + cdef->methodList.size(); const qsizetype methodCount = cdef->signalList.size() + cdef->slotList.size() + cdef->methodList.size();
fprintf(out, " %4d, %4d, // methods\n", methodCount, methodCount ? index : 0); fprintf(out, " %4" PRIdQSIZETYPE ", %4d, // methods\n", methodCount, methodCount ? index : 0);
index += methodCount * QMetaObjectPrivate::IntsPerMethod; index += methodCount * QMetaObjectPrivate::IntsPerMethod;
if (cdef->revisionedMethods) if (cdef->revisionedMethods)
index += methodCount; index += methodCount;