Moc: port to qsizetype

Simple s/int/qsizetype/. Fixes some narrowing conversion warnings.

Pick-to: 6.5
Change-Id: Ied82e861298fa9763089cadc7eae6e536f1bb9ca
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Ahmad Samir 2023-05-21 01:06:21 +03:00
parent c452a43b59
commit 44cfdfa7c0
4 changed files with 10 additions and 10 deletions

View File

@ -186,7 +186,7 @@ bool Generator::registerableMetaType(const QByteArray &propertyType)
for (const QByteArray &oneArgTemplateType : oneArgTemplates) {
QByteArray ba = oneArgTemplateType + "<";
if (propertyType.startsWith(ba) && propertyType.endsWith(">")) {
const int argumentSize = propertyType.size() - oneArgTemplateType.size() - 1
const qsizetype argumentSize = propertyType.size() - oneArgTemplateType.size() - 1
// The closing '>'
- 1
// templates inside templates have an extra whitespace char to strip.
@ -204,7 +204,7 @@ static bool qualifiedNameEquals(const QByteArray &qualifiedName, const QByteArra
{
if (qualifiedName == name)
return true;
int index = qualifiedName.indexOf("::");
const qsizetype index = qualifiedName.indexOf("::");
if (index == -1)
return false;
return qualifiedNameEquals(qualifiedName.mid(index+2), name);
@ -468,7 +468,7 @@ void Generator::generateCode()
if (p.type.contains('*') || p.type.contains('<') || p.type.contains('>'))
continue;
int s = p.type.lastIndexOf("::");
const qsizetype s = p.type.lastIndexOf("::");
if (s <= 0)
continue;
@ -479,7 +479,7 @@ void Generator::generateCode()
QByteArray thisScope = cdef->qualified;
do {
int s = thisScope.lastIndexOf("::");
const qsizetype s = thisScope.lastIndexOf("::");
thisScope = thisScope.left(s);
QByteArray currentScope = thisScope.isEmpty() ? unqualifiedScope : thisScope + "::" + unqualifiedScope;
scopeIt = knownExtraMetaObject.constFind(currentScope);
@ -505,7 +505,7 @@ void Generator::generateCode()
for (auto it = cdef->enumDeclarations.keyBegin(),
end = cdef->enumDeclarations.keyEnd(); it != end; ++it) {
const QByteArray &enumKey = *it;
int s = enumKey.lastIndexOf("::");
const qsizetype s = enumKey.lastIndexOf("::");
if (s > 0) {
QByteArray scope = enumKey.left(s);
if (scope != "Qt" && !qualifiedNameEquals(cdef->qualified, scope) && !extraList.contains(scope))
@ -1617,7 +1617,7 @@ void Generator::generatePluginMetaData()
};
// 'Use' all namespaces.
int pos = cdef->qualified.indexOf("::");
qsizetype pos = cdef->qualified.indexOf("::");
for ( ; pos != -1 ; pos = cdef->qualified.indexOf("::", pos + 2) )
fprintf(out, "using namespace %s;\n", cdef->qualified.left(pos).constData());

View File

@ -399,7 +399,7 @@ int runMoc(int argc, char **argv)
for (const QString &arg : defines) {
QByteArray name = arg.toLocal8Bit();
QByteArray value("1");
int eq = name.indexOf('=');
const qsizetype eq = name.indexOf('=');
if (eq >= 0) {
value = name.mid(eq + 1);
name = name.left(eq);

View File

@ -1629,7 +1629,7 @@ void Moc::parseInterfaces(ClassDef *def)
}
}
// resolve from classnames to interface ids
for (int i = 0; i < iface.size(); ++i) {
for (qsizetype i = 0; i < iface.size(); ++i) {
const QByteArray iid = interface2IdMap.value(iface.at(i).className);
if (iid.isEmpty())
error("Undefined interface");

View File

@ -966,7 +966,7 @@ static void mergeStringLiterals(Symbols *_symbols)
for (Symbols::iterator i = symbols.begin(); i != symbols.end(); ++i) {
if (i->token == STRING_LITERAL) {
Symbols::Iterator mergeSymbol = i;
int literalsLength = mergeSymbol->len;
qsizetype literalsLength = mergeSymbol->len;
while (++i != symbols.end() && i->token == STRING_LITERAL)
literalsLength += i->len - 2; // no quotes
@ -1005,7 +1005,7 @@ static QByteArray searchIncludePaths(const QList<Parser::IncludePath> &includepa
break;
if (p.isFrameworkPath) {
const int slashPos = include.indexOf('/');
const qsizetype slashPos = include.indexOf('/');
if (slashPos == -1)
continue;
fi.setFile(QString::fromLocal8Bit(p.path + '/' + include.left(slashPos) + ".framework/Headers/"),