diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2015-06-14 11:36:46 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2015-10-07 19:00:21 +0000 |
commit | abf51f0b274f100736f227d550b65ba6c5ae9266 (patch) | |
tree | 13eed5867c10448df6fedd90bd7641050ae3afe9 /src/corelib/kernel/qmetaobjectbuilder.cpp | |
parent | d02645438bcabce074bb83d356d7018570186e19 (diff) |
QMetaObjectBuilder: replace a QVector with std::vector
...with minimal other changes: signed/unsigned warning fixes, and
API adjustments.
I chose std::vector instead of QVector because it does not require the
contained type to have a default constructor (QVector does). All three
QMeta*Private types in question didn't have a default ctor before they
were ported to be held in QVectors (instead of QLists).
std::vector generally also produces less executable code, and its
push_back() is overloaded for rvalue references, and the code happens to
pass only QMeta*Private temporaries to it, which are conveniently
implicitly move-enabled.
Even though std::vector doesn't care, keep the QMeta*Private classes
marked as Q_MOVABLE_TYPE, so the next person doesn't wonder whether
it was forgotten or intentional.
There are a lot of for loops which use int-based indexing. They all
needed to be adjusted to use size_t-based indexing. Eventually, we
will change that to C++11 range-for loops.
In most places, index validation could now be done in a single unsigned
comparison, but keep that for a separate commit to keep the change
minimal.
Added lots of casts to int from size_t to avoid MSVC's narrowing
conversion warnings.
Saves more than 4.5K of text size on GCC 4.9 optimized C++11 AMD64
Linux builds.
Change-Id: I889eba20fcfb4cb14b1f55f5bc1aad0a767d7bd5
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'src/corelib/kernel/qmetaobjectbuilder.cpp')
-rw-r--r-- | src/corelib/kernel/qmetaobjectbuilder.cpp | 204 |
1 files changed, 101 insertions, 103 deletions
diff --git a/src/corelib/kernel/qmetaobjectbuilder.cpp b/src/corelib/kernel/qmetaobjectbuilder.cpp index 021e137273..ded1126e8c 100644 --- a/src/corelib/kernel/qmetaobjectbuilder.cpp +++ b/src/corelib/kernel/qmetaobjectbuilder.cpp @@ -36,6 +36,7 @@ #include "qobject_p.h" #include "qmetaobject_p.h" +#include <vector> #include <stdlib.h> QT_BEGIN_NAMESPACE @@ -88,7 +89,6 @@ static inline Q_DECL_UNUSED const QMetaObjectPrivate *priv(const uint* data) class QMetaMethodBuilderPrivate { public: - QMetaMethodBuilderPrivate() {} // for QVector, don't use QMetaMethodBuilderPrivate (QMetaMethod::MethodType _methodType, const QByteArray& _signature, @@ -145,7 +145,6 @@ Q_DECLARE_TYPEINFO(QMetaMethodBuilderPrivate, Q_MOVABLE_TYPE); class QMetaPropertyBuilderPrivate { public: - QMetaPropertyBuilderPrivate() {} // for QVector, don't use QMetaPropertyBuilderPrivate (const QByteArray& _name, const QByteArray& _type, int notifierIdx=-1, int _revision = 0) @@ -184,7 +183,6 @@ Q_DECLARE_TYPEINFO(QMetaPropertyBuilderPrivate, Q_MOVABLE_TYPE); class QMetaEnumBuilderPrivate { public: - QMetaEnumBuilderPrivate() {} // for QVector, don't use QMetaEnumBuilderPrivate(const QByteArray& _name) : name(_name), isFlag(false) { @@ -213,19 +211,19 @@ public: QByteArray className; const QMetaObject *superClass; QMetaObjectBuilder::StaticMetacallFunction staticMetacallFunction; - QVector<QMetaMethodBuilderPrivate> methods; - QVector<QMetaMethodBuilderPrivate> constructors; - QVector<QMetaPropertyBuilderPrivate> properties; + std::vector<QMetaMethodBuilderPrivate> methods; + std::vector<QMetaMethodBuilderPrivate> constructors; + std::vector<QMetaPropertyBuilderPrivate> properties; QList<QByteArray> classInfoNames; QList<QByteArray> classInfoValues; - QVector<QMetaEnumBuilderPrivate> enumerators; + std::vector<QMetaEnumBuilderPrivate> enumerators; QList<const QMetaObject *> relatedMetaObjects; int flags; }; bool QMetaObjectBuilderPrivate::hasRevisionedProperties() const { - for (int i = 0; i < properties.size(); ++i) { + for (size_t i = 0; i < properties.size(); ++i) { if (properties.at(i).revision) return true; } @@ -234,7 +232,7 @@ bool QMetaObjectBuilderPrivate::hasRevisionedProperties() const bool QMetaObjectBuilderPrivate::hasRevisionedMethods() const { - for (int i = 0; i < methods.size(); ++i) { + for (size_t i = 0; i < methods.size(); ++i) { if (methods.at(i).revision) return true; } @@ -353,7 +351,7 @@ void QMetaObjectBuilder::setFlags(MetaObjectFlags flags) */ int QMetaObjectBuilder::methodCount() const { - return d->methods.size(); + return int(d->methods.size()); } /*! @@ -363,7 +361,7 @@ int QMetaObjectBuilder::methodCount() const */ int QMetaObjectBuilder::constructorCount() const { - return d->constructors.size(); + return int(d->constructors.size()); } /*! @@ -374,7 +372,7 @@ int QMetaObjectBuilder::constructorCount() const */ int QMetaObjectBuilder::propertyCount() const { - return d->properties.size(); + return int(d->properties.size()); } /*! @@ -386,7 +384,7 @@ int QMetaObjectBuilder::propertyCount() const */ int QMetaObjectBuilder::enumeratorCount() const { - return d->enumerators.size(); + return int(d->enumerators.size()); } /*! @@ -427,8 +425,8 @@ int QMetaObjectBuilder::relatedMetaObjectCount() const */ QMetaMethodBuilder QMetaObjectBuilder::addMethod(const QByteArray& signature) { - int index = d->methods.size(); - d->methods.append(QMetaMethodBuilderPrivate(QMetaMethod::Method, signature)); + int index = int(d->methods.size()); + d->methods.push_back(QMetaMethodBuilderPrivate(QMetaMethod::Method, signature)); return QMetaMethodBuilder(this, index); } @@ -444,8 +442,8 @@ QMetaMethodBuilder QMetaObjectBuilder::addMethod(const QByteArray& signature) QMetaMethodBuilder QMetaObjectBuilder::addMethod (const QByteArray& signature, const QByteArray& returnType) { - int index = d->methods.size(); - d->methods.append(QMetaMethodBuilderPrivate + int index = int(d->methods.size()); + d->methods.push_back(QMetaMethodBuilderPrivate (QMetaMethod::Method, signature, returnType)); return QMetaMethodBuilder(this, index); } @@ -491,8 +489,8 @@ QMetaMethodBuilder QMetaObjectBuilder::addMethod(const QMetaMethod& prototype) */ QMetaMethodBuilder QMetaObjectBuilder::addSlot(const QByteArray& signature) { - int index = d->methods.size(); - d->methods.append(QMetaMethodBuilderPrivate(QMetaMethod::Slot, signature)); + int index = int(d->methods.size()); + d->methods.push_back(QMetaMethodBuilderPrivate(QMetaMethod::Slot, signature)); return QMetaMethodBuilder(this, index); } @@ -506,8 +504,8 @@ QMetaMethodBuilder QMetaObjectBuilder::addSlot(const QByteArray& signature) */ QMetaMethodBuilder QMetaObjectBuilder::addSignal(const QByteArray& signature) { - int index = d->methods.size(); - d->methods.append(QMetaMethodBuilderPrivate + int index = int(d->methods.size()); + d->methods.push_back(QMetaMethodBuilderPrivate (QMetaMethod::Signal, signature, QByteArray("void"), QMetaMethod::Public)); return QMetaMethodBuilder(this, index); } @@ -523,9 +521,9 @@ QMetaMethodBuilder QMetaObjectBuilder::addSignal(const QByteArray& signature) */ QMetaMethodBuilder QMetaObjectBuilder::addConstructor(const QByteArray& signature) { - int index = d->constructors.size(); - d->constructors.append(QMetaMethodBuilderPrivate(QMetaMethod::Constructor, signature, - /*returnType=*/QByteArray())); + int index = int(d->constructors.size()); + d->constructors.push_back(QMetaMethodBuilderPrivate(QMetaMethod::Constructor, signature, + /*returnType=*/QByteArray())); return QMetaMethodBuilder(this, -(index + 1)); } @@ -564,8 +562,8 @@ QMetaMethodBuilder QMetaObjectBuilder::addConstructor(const QMetaMethod& prototy QMetaPropertyBuilder QMetaObjectBuilder::addProperty (const QByteArray& name, const QByteArray& type, int notifierId) { - int index = d->properties.size(); - d->properties.append(QMetaPropertyBuilderPrivate(name, type, notifierId)); + int index = int(d->properties.size()); + d->properties.push_back(QMetaPropertyBuilderPrivate(name, type, notifierId)); return QMetaPropertyBuilder(this, index); } @@ -615,8 +613,8 @@ QMetaPropertyBuilder QMetaObjectBuilder::addProperty(const QMetaProperty& protot */ QMetaEnumBuilder QMetaObjectBuilder::addEnumerator(const QByteArray& name) { - int index = d->enumerators.size(); - d->enumerators.append(QMetaEnumBuilderPrivate(name)); + int index = int(d->enumerators.size()); + d->enumerators.push_back(QMetaEnumBuilderPrivate(name)); return QMetaEnumBuilder(this, index); } @@ -762,7 +760,7 @@ void QMetaObjectBuilder::addMetaObject */ QMetaMethodBuilder QMetaObjectBuilder::method(int index) const { - if (index >= 0 && index < d->methods.size()) + if (index >= 0 && index < int(d->methods.size())) return QMetaMethodBuilder(this, index); else return QMetaMethodBuilder(); @@ -775,7 +773,7 @@ QMetaMethodBuilder QMetaObjectBuilder::method(int index) const */ QMetaMethodBuilder QMetaObjectBuilder::constructor(int index) const { - if (index >= 0 && index < d->constructors.size()) + if (index >= 0 && index < int(d->constructors.size())) return QMetaMethodBuilder(this, -(index + 1)); else return QMetaMethodBuilder(); @@ -788,7 +786,7 @@ QMetaMethodBuilder QMetaObjectBuilder::constructor(int index) const */ QMetaPropertyBuilder QMetaObjectBuilder::property(int index) const { - if (index >= 0 && index < d->properties.size()) + if (index >= 0 && index < int(d->properties.size())) return QMetaPropertyBuilder(this, index); else return QMetaPropertyBuilder(); @@ -802,7 +800,7 @@ QMetaPropertyBuilder QMetaObjectBuilder::property(int index) const */ QMetaEnumBuilder QMetaObjectBuilder::enumerator(int index) const { - if (index >= 0 && index < d->enumerators.size()) + if (index >= 0 && index < int(d->enumerators.size())) return QMetaEnumBuilder(this, index); else return QMetaEnumBuilder(); @@ -866,9 +864,9 @@ QByteArray QMetaObjectBuilder::classInfoValue(int index) const */ void QMetaObjectBuilder::removeMethod(int index) { - if (index >= 0 && index < d->methods.size()) { - d->methods.removeAt(index); - for (int prop = 0; prop < d->properties.size(); ++prop) { + if (index >= 0 && index < int(d->methods.size())) { + d->methods.erase(d->methods.begin() + index); + for (size_t prop = 0; prop < d->properties.size(); ++prop) { // Adjust the indices of property notify signal references. if (d->properties[prop].notifySignal == index) { d->properties[prop].notifySignal = -1; @@ -888,8 +886,8 @@ void QMetaObjectBuilder::removeMethod(int index) */ void QMetaObjectBuilder::removeConstructor(int index) { - if (index >= 0 && index < d->constructors.size()) - d->constructors.removeAt(index); + if (index >= 0 && index < int(d->constructors.size())) + d->constructors.erase(d->constructors.begin() + index); } /*! @@ -900,8 +898,8 @@ void QMetaObjectBuilder::removeConstructor(int index) */ void QMetaObjectBuilder::removeProperty(int index) { - if (index >= 0 && index < d->properties.size()) - d->properties.removeAt(index); + if (index >= 0 && index < int(d->properties.size())) + d->properties.erase(d->properties.begin() + index); } /*! @@ -913,8 +911,8 @@ void QMetaObjectBuilder::removeProperty(int index) */ void QMetaObjectBuilder::removeEnumerator(int index) { - if (index >= 0 && index < d->enumerators.size()) - d->enumerators.removeAt(index); + if (index >= 0 && index < int(d->enumerators.size())) + d->enumerators.erase(d->enumerators.begin() + index); } /*! @@ -959,9 +957,9 @@ void QMetaObjectBuilder::removeRelatedMetaObject(int index) int QMetaObjectBuilder::indexOfMethod(const QByteArray& signature) { QByteArray sig = QMetaObject::normalizedSignature(signature); - for (int index = 0; index < d->methods.size(); ++index) { + for (size_t index = 0; index < d->methods.size(); ++index) { if (sig == d->methods[index].signature) - return index; + return int(index); } return -1; } @@ -975,10 +973,10 @@ int QMetaObjectBuilder::indexOfMethod(const QByteArray& signature) int QMetaObjectBuilder::indexOfSignal(const QByteArray& signature) { QByteArray sig = QMetaObject::normalizedSignature(signature); - for (int index = 0; index < d->methods.size(); ++index) { + for (size_t index = 0; index < d->methods.size(); ++index) { if (sig == d->methods[index].signature && d->methods[index].methodType() == QMetaMethod::Signal) - return index; + return int(index); } return -1; } @@ -992,10 +990,10 @@ int QMetaObjectBuilder::indexOfSignal(const QByteArray& signature) int QMetaObjectBuilder::indexOfSlot(const QByteArray& signature) { QByteArray sig = QMetaObject::normalizedSignature(signature); - for (int index = 0; index < d->methods.size(); ++index) { + for (size_t index = 0; index < d->methods.size(); ++index) { if (sig == d->methods[index].signature && d->methods[index].methodType() == QMetaMethod::Slot) - return index; + return int(index); } return -1; } @@ -1009,9 +1007,9 @@ int QMetaObjectBuilder::indexOfSlot(const QByteArray& signature) int QMetaObjectBuilder::indexOfConstructor(const QByteArray& signature) { QByteArray sig = QMetaObject::normalizedSignature(signature); - for (int index = 0; index < d->constructors.size(); ++index) { + for (size_t index = 0; index < d->constructors.size(); ++index) { if (sig == d->constructors[index].signature) - return index; + return int(index); } return -1; } @@ -1024,9 +1022,9 @@ int QMetaObjectBuilder::indexOfConstructor(const QByteArray& signature) */ int QMetaObjectBuilder::indexOfProperty(const QByteArray& name) { - for (int index = 0; index < d->properties.size(); ++index) { + for (size_t index = 0; index < d->properties.size(); ++index) { if (name == d->properties[index].name) - return index; + return int(index); } return -1; } @@ -1039,9 +1037,9 @@ int QMetaObjectBuilder::indexOfProperty(const QByteArray& name) */ int QMetaObjectBuilder::indexOfEnumerator(const QByteArray& name) { - for (int index = 0; index < d->enumerators.size(); ++index) { + for (size_t index = 0; index < d->enumerators.size(); ++index) { if (name == d->enumerators[index].name) - return index; + return int(index); } return -1; } @@ -1155,10 +1153,10 @@ void QMetaStringTable::writeBlob(char *out) const // Returns the sum of all parameters (including return type) for the given // \a methods. This is needed for calculating the size of the methods' // parameter type/name meta-data. -static int aggregateParameterCount(const QVector<QMetaMethodBuilderPrivate> &methods) +static int aggregateParameterCount(const std::vector<QMetaMethodBuilderPrivate> &methods) { int sum = 0; - for (int i = 0; i < methods.size(); ++i) + for (size_t i = 0; i < methods.size(); ++i) sum += methods.at(i).parameterCount() + 1; // +1 for return type return sum; } @@ -1200,7 +1198,7 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf, = reinterpret_cast<QMetaObjectPrivate *>(buf + size); int pmetaSize = size; dataIndex = MetaObjectPrivateFieldCount; - for (index = 0; index < d->properties.size(); ++index) { + for (size_t index = 0; index < d->properties.size(); ++index) { if (d->properties[index].notifySignal != -1) { hasNotifySignals = true; break; @@ -1209,8 +1207,8 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf, int methodParametersDataSize = ((aggregateParameterCount(d->methods) + aggregateParameterCount(d->constructors)) * 2) // types and parameter names - - d->methods.size() // return "parameters" don't have names - - d->constructors.size(); // "this" parameters don't have names + - int(d->methods.size()) // return "parameters" don't have names + - int(d->constructors.size()); // "this" parameters don't have names if (buf) { Q_STATIC_ASSERT_X(QMetaObjectPrivate::OutputRevision == 7, "QMetaObjectBuilder should generate the same version as moc"); pmeta->revision = QMetaObjectPrivate::OutputRevision; @@ -1222,48 +1220,48 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf, pmeta->classInfoData = dataIndex; dataIndex += 2 * d->classInfoNames.size(); - pmeta->methodCount = d->methods.size(); + pmeta->methodCount = int(d->methods.size()); pmeta->methodData = dataIndex; - dataIndex += 5 * d->methods.size(); + dataIndex += 5 * int(d->methods.size()); if (hasRevisionedMethods) - dataIndex += d->methods.size(); + dataIndex += int(d->methods.size()); paramsIndex = dataIndex; dataIndex += methodParametersDataSize; - pmeta->propertyCount = d->properties.size(); + pmeta->propertyCount = int(d->properties.size()); pmeta->propertyData = dataIndex; - dataIndex += 3 * d->properties.size(); + dataIndex += 3 * int(d->properties.size()); if (hasNotifySignals) - dataIndex += d->properties.size(); + dataIndex += int(d->properties.size()); if (hasRevisionedProperties) - dataIndex += d->properties.size(); + dataIndex += int(d->properties.size()); - pmeta->enumeratorCount = d->enumerators.size(); + pmeta->enumeratorCount = int(d->enumerators.size()); pmeta->enumeratorData = dataIndex; - dataIndex += 4 * d->enumerators.size(); + dataIndex += 4 * int(d->enumerators.size()); - pmeta->constructorCount = d->constructors.size(); + pmeta->constructorCount = int(d->constructors.size()); pmeta->constructorData = dataIndex; - dataIndex += 5 * d->constructors.size(); + dataIndex += 5 * int(d->constructors.size()); } else { - dataIndex += 2 * d->classInfoNames.size(); - dataIndex += 5 * d->methods.size(); + dataIndex += 2 * int(d->classInfoNames.size()); + dataIndex += 5 * int(d->methods.size()); if (hasRevisionedMethods) - dataIndex += d->methods.size(); + dataIndex += int(d->methods.size()); paramsIndex = dataIndex; dataIndex += methodParametersDataSize; - dataIndex += 3 * d->properties.size(); + dataIndex += 3 * int(d->properties.size()); if (hasNotifySignals) - dataIndex += d->properties.size(); + dataIndex += int(d->properties.size()); if (hasRevisionedProperties) - dataIndex += d->properties.size(); - dataIndex += 4 * d->enumerators.size(); - dataIndex += 5 * d->constructors.size(); + dataIndex += int(d->properties.size()); + dataIndex += 4 * int(d->enumerators.size()); + dataIndex += 5 * int(d->constructors.size()); } // Allocate space for the enumerator key names and values. enumIndex = dataIndex; - for (index = 0; index < d->enumerators.size(); ++index) { + for (size_t index = 0; index < d->enumerators.size(); ++index) { QMetaEnumBuilderPrivate *enumerator = &(d->enumerators[index]); dataIndex += 2 * enumerator->keys.size(); } @@ -1305,7 +1303,7 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf, // Output the methods in the class. Q_ASSERT(!buf || dataIndex == pmeta->methodData); - for (index = 0; index < d->methods.size(); ++index) { + for (size_t index = 0; index < d->methods.size(); ++index) { QMetaMethodBuilderPrivate *method = &(d->methods[index]); int name = strings.enter(method->name()); int argc = method->parameterCount(); @@ -1324,7 +1322,7 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf, paramsIndex += 1 + argc * 2; } if (hasRevisionedMethods) { - for (index = 0; index < d->methods.size(); ++index) { + for (size_t index = 0; index < d->methods.size(); ++index) { QMetaMethodBuilderPrivate *method = &(d->methods[index]); if (buf) data[dataIndex] = method->revision; @@ -1333,12 +1331,12 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf, } // Output the method parameters in the class. - Q_ASSERT(!buf || dataIndex == pmeta->methodData + d->methods.size() * 5 - + (hasRevisionedMethods ? d->methods.size() : 0)); + Q_ASSERT(!buf || dataIndex == pmeta->methodData + int(d->methods.size()) * 5 + + (hasRevisionedMethods ? int(d->methods.size()) : 0)); for (int x = 0; x < 2; ++x) { - QVector<QMetaMethodBuilderPrivate> &methods = (x == 0) ? d->methods : d->constructors; - for (index = 0; index < methods.size(); ++index) { - QMetaMethodBuilderPrivate *method = &(methods[index]); + const std::vector<QMetaMethodBuilderPrivate> &methods = (x == 0) ? d->methods : d->constructors; + for (size_t index = 0; index < methods.size(); ++index) { + const QMetaMethodBuilderPrivate *method = &(methods[index]); QList<QByteArray> paramTypeNames = method->parameterTypes(); int paramCount = paramTypeNames.size(); for (int i = -1; i < paramCount; ++i) { @@ -1367,7 +1365,7 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf, // Output the properties in the class. Q_ASSERT(!buf || dataIndex == pmeta->propertyData); - for (index = 0; index < d->properties.size(); ++index) { + for (size_t index = 0; index < d->properties.size(); ++index) { QMetaPropertyBuilderPrivate *prop = &(d->properties[index]); int name = strings.enter(prop->name); @@ -1390,7 +1388,7 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf, dataIndex += 3; } if (hasNotifySignals) { - for (index = 0; index < d->properties.size(); ++index) { + for (size_t index = 0; index < d->properties.size(); ++index) { QMetaPropertyBuilderPrivate *prop = &(d->properties[index]); if (buf) { if (prop->notifySignal != -1) @@ -1402,7 +1400,7 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf, } } if (hasRevisionedProperties) { - for (index = 0; index < d->properties.size(); ++index) { + for (size_t index = 0; index < d->properties.size(); ++index) { QMetaPropertyBuilderPrivate *prop = &(d->properties[index]); if (buf) data[dataIndex] = prop->revision; @@ -1412,7 +1410,7 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf, // Output the enumerators in the class. Q_ASSERT(!buf || dataIndex == pmeta->enumeratorData); - for (index = 0; index < d->enumerators.size(); ++index) { + for (size_t index = 0; index < d->enumerators.size(); ++index) { QMetaEnumBuilderPrivate *enumerator = &(d->enumerators[index]); int name = strings.enter(enumerator->name); int isFlag = (int)(enumerator->isFlag); @@ -1437,7 +1435,7 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf, // Output the constructors in the class. Q_ASSERT(!buf || dataIndex == pmeta->constructorData); - for (index = 0; index < d->constructors.size(); ++index) { + for (size_t index = 0; index < d->constructors.size(); ++index) { QMetaMethodBuilderPrivate *method = &(d->constructors[index]); int name = strings.enter(method->name()); int argc = method->parameterCount(); @@ -1612,10 +1610,10 @@ void QMetaObjectBuilder::serialize(QDataStream& stream) const // Write the counts for each type of class member. stream << d->classInfoNames.size(); - stream << d->methods.size(); - stream << d->properties.size(); - stream << d->enumerators.size(); - stream << d->constructors.size(); + stream << int(d->methods.size()); + stream << int(d->properties.size()); + stream << int(d->enumerators.size()); + stream << int(d->constructors.size()); stream << d->relatedMetaObjects.size(); // Write the items of class information. @@ -1625,7 +1623,7 @@ void QMetaObjectBuilder::serialize(QDataStream& stream) const } // Write the methods. - for (index = 0; index < d->methods.size(); ++index) { + for (size_t index = 0; index < d->methods.size(); ++index) { const QMetaMethodBuilderPrivate *method = &(d->methods[index]); stream << method->signature; stream << method->returnType; @@ -1637,7 +1635,7 @@ void QMetaObjectBuilder::serialize(QDataStream& stream) const } // Write the properties. - for (index = 0; index < d->properties.size(); ++index) { + for (size_t index = 0; index < d->properties.size(); ++index) { const QMetaPropertyBuilderPrivate *property = &(d->properties[index]); stream << property->name; stream << property->type; @@ -1648,7 +1646,7 @@ void QMetaObjectBuilder::serialize(QDataStream& stream) const } // Write the enumerators. - for (index = 0; index < d->enumerators.size(); ++index) { + for (size_t index = 0; index < d->enumerators.size(); ++index) { const QMetaEnumBuilderPrivate *enumerator = &(d->enumerators[index]); stream << enumerator->name; stream << enumerator->isFlag; @@ -1657,7 +1655,7 @@ void QMetaObjectBuilder::serialize(QDataStream& stream) const } // Write the constructors. - for (index = 0; index < d->constructors.size(); ++index) { + for (size_t index = 0; index < d->constructors.size(); ++index) { const QMetaMethodBuilderPrivate *method = &(d->constructors[index]); stream << method->signature; stream << method->returnType; @@ -1796,7 +1794,7 @@ void QMetaObjectBuilder::deserialize stream >> property->flags; stream >> property->notifySignal; if (property->notifySignal < -1 || - property->notifySignal >= d->methods.size()) { + property->notifySignal >= int(d->methods.size())) { // Notify signal method index is out of range. stream.setStatus(QDataStream::ReadCorruptData); return; @@ -1875,9 +1873,9 @@ void QMetaObjectBuilder::deserialize QMetaMethodBuilderPrivate *QMetaMethodBuilder::d_func() const { // Positive indices indicate methods, negative indices indicate constructors. - if (_mobj && _index >= 0 && _index < _mobj->d->methods.size()) + if (_mobj && _index >= 0 && _index < int(_mobj->d->methods.size())) return &(_mobj->d->methods[_index]); - else if (_mobj && -_index >= 1 && -_index <= _mobj->d->constructors.size()) + else if (_mobj && -_index >= 1 && -_index <= int(_mobj->d->constructors.size())) return &(_mobj->d->constructors[(-_index) - 1]); else return 0; @@ -2116,7 +2114,7 @@ void QMetaMethodBuilder::setRevision(int revision) QMetaPropertyBuilderPrivate *QMetaPropertyBuilder::d_func() const { - if (_mobj && _index >= 0 && _index < _mobj->d->properties.size()) + if (_mobj && _index >= 0 && _index < int(_mobj->d->properties.size())) return &(_mobj->d->properties[_index]); else return 0; @@ -2588,7 +2586,7 @@ void QMetaPropertyBuilder::setRevision(int revision) QMetaEnumBuilderPrivate *QMetaEnumBuilder::d_func() const { - if (_mobj && _index >= 0 && _index < _mobj->d->enumerators.size()) + if (_mobj && _index >= 0 && _index < int(_mobj->d->enumerators.size())) return &(_mobj->d->enumerators[_index]); else return 0; |