summaryrefslogtreecommitdiffstats
path: root/src/tools/moc/moc.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-09-30 14:09:04 +0200
committerMarc Mutz <marc.mutz@qt.io>2022-10-04 07:40:08 +0200
commitdf9d882d41b741fef7c5beeddb0abe9d904443d8 (patch)
tree6f3e90dacad4581b7f1cabe235cca298833a3da4 /src/tools/moc/moc.cpp
parent109e088c7c5d0c9325966e88d55fd9f7a58f67ea (diff)
Port from container.count()/length() to size()
This is semantic patch using ClangTidyTransformator: auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o) makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'. <classes> are: // sequential: "QByteArray", "QList", "QQueue", "QStack", "QString", "QVarLengthArray", "QVector", // associative: "QHash", "QMultiHash", "QMap", "QMultiMap", "QSet", // Qt has no QMultiSet Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/tools/moc/moc.cpp')
-rw-r--r--src/tools/moc/moc.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp
index 58e28687aa..a74dc246d7 100644
--- a/src/tools/moc/moc.cpp
+++ b/src/tools/moc/moc.cpp
@@ -368,7 +368,7 @@ QTypeRevision Moc::parseRevision()
revisionString.remove(0, 1);
revisionString.chop(1);
const QList<QByteArray> majorMinor = revisionString.split(',');
- switch (majorMinor.length()) {
+ switch (majorMinor.size()) {
case 1: {
bool ok = false;
const int revision = revisionString.toInt(&ok);
@@ -1061,7 +1061,7 @@ static QByteArrayList requiredQtContainers(const QList<ClassDef> &classes)
void Moc::generate(FILE *out, FILE *jsonOutput)
{
QByteArray fn = filename;
- int i = filename.length()-1;
+ int i = filename.size()-1;
while (i > 0 && filename.at(i - 1) != '/' && filename.at(i - 1) != '\\')
--i; // skip path
if (i >= 0)
@@ -1311,7 +1311,7 @@ void Moc::parsePropertyAttributes(PropertyDef &propDef)
QByteArray v, v2;
if (test(LPAREN)) {
v = lexemUntil(RPAREN);
- v = v.mid(1, v.length() - 2); // removes the '(' and ')'
+ v = v.mid(1, v.size() - 2); // removes the '(' and ')'
} else if (test(INTEGER_LITERAL)) {
v = lexem();
if (l != "REVISION")
@@ -1608,7 +1608,7 @@ void Moc::parseInterfaces(ClassDef *def)
}
}
// resolve from classnames to interface ids
- for (int i = 0; i < iface.count(); ++i) {
+ for (int i = 0; i < iface.size(); ++i) {
const QByteArray iid = interface2IdMap.value(iface.at(i).className);
if (iid.isEmpty())
error("Undefined interface");
@@ -1800,7 +1800,7 @@ void Moc::checkSuperClasses(ClassDef *def)
#endif
return;
}
- for (int i = 1; i < def->superclassList.count(); ++i) {
+ for (int i = 1; i < def->superclassList.size(); ++i) {
const QByteArray superClass = def->superclassList.at(i).first;
if (knownQObjectClasses.contains(superClass)) {
const QByteArray msg
@@ -1816,7 +1816,7 @@ void Moc::checkSuperClasses(ClassDef *def)
if (interface2IdMap.contains(superClass)) {
bool registeredInterface = false;
- for (int i = 0; i < def->interfaceList.count(); ++i)
+ for (int i = 0; i < def->interfaceList.size(); ++i)
if (def->interfaceList.at(i).constFirst().className == superClass) {
registeredInterface = true;
break;
@@ -1843,8 +1843,8 @@ void Moc::checkProperties(ClassDef *cdef)
// specify get function, for compatibility we accept functions
// returning pointers, or const char * for QByteArray.
//
- QDuplicateTracker<QByteArray> definedProperties(cdef->propertyList.count());
- for (int i = 0; i < cdef->propertyList.count(); ++i) {
+ QDuplicateTracker<QByteArray> definedProperties(cdef->propertyList.size());
+ for (int i = 0; i < cdef->propertyList.size(); ++i) {
PropertyDef &p = cdef->propertyList[i];
if (definedProperties.hasSeen(p.name)) {
QByteArray msg = "The property '" + p.name + "' is defined multiple times in class " + cdef->classname + ".";
@@ -1866,7 +1866,7 @@ void Moc::checkProperties(ClassDef *cdef)
continue;
}
- for (int j = 0; j < cdef->publicList.count(); ++j) {
+ for (int j = 0; j < cdef->publicList.size(); ++j) {
const FunctionDef &f = cdef->publicList.at(j);
if (f.name != p.read)
continue;
@@ -1893,7 +1893,7 @@ void Moc::checkProperties(ClassDef *cdef)
}
if (!p.notify.isEmpty()) {
int notifyId = -1;
- for (int j = 0; j < cdef->signalList.count(); ++j) {
+ for (int j = 0; j < cdef->signalList.size(); ++j) {
const FunctionDef &f = cdef->signalList.at(j);
if (f.name != p.notify) {
continue;
@@ -1907,7 +1907,7 @@ void Moc::checkProperties(ClassDef *cdef)
int index = cdef->nonClassSignalList.indexOf(p.notify);
if (index == -1) {
cdef->nonClassSignalList << p.notify;
- p.notifyId = -1 - cdef->nonClassSignalList.count();
+ p.notifyId = -1 - cdef->nonClassSignalList.size();
} else {
p.notifyId = -2 - index;
}