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>
This commit is contained in:
parent
d02645438b
commit
abf51f0b27
@ -36,6 +36,7 @@
|
|||||||
#include "qobject_p.h"
|
#include "qobject_p.h"
|
||||||
#include "qmetaobject_p.h"
|
#include "qmetaobject_p.h"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
@ -88,7 +89,6 @@ static inline Q_DECL_UNUSED const QMetaObjectPrivate *priv(const uint* data)
|
|||||||
class QMetaMethodBuilderPrivate
|
class QMetaMethodBuilderPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QMetaMethodBuilderPrivate() {} // for QVector, don't use
|
|
||||||
QMetaMethodBuilderPrivate
|
QMetaMethodBuilderPrivate
|
||||||
(QMetaMethod::MethodType _methodType,
|
(QMetaMethod::MethodType _methodType,
|
||||||
const QByteArray& _signature,
|
const QByteArray& _signature,
|
||||||
@ -145,7 +145,6 @@ Q_DECLARE_TYPEINFO(QMetaMethodBuilderPrivate, Q_MOVABLE_TYPE);
|
|||||||
class QMetaPropertyBuilderPrivate
|
class QMetaPropertyBuilderPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QMetaPropertyBuilderPrivate() {} // for QVector, don't use
|
|
||||||
QMetaPropertyBuilderPrivate
|
QMetaPropertyBuilderPrivate
|
||||||
(const QByteArray& _name, const QByteArray& _type, int notifierIdx=-1,
|
(const QByteArray& _name, const QByteArray& _type, int notifierIdx=-1,
|
||||||
int _revision = 0)
|
int _revision = 0)
|
||||||
@ -184,7 +183,6 @@ Q_DECLARE_TYPEINFO(QMetaPropertyBuilderPrivate, Q_MOVABLE_TYPE);
|
|||||||
class QMetaEnumBuilderPrivate
|
class QMetaEnumBuilderPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QMetaEnumBuilderPrivate() {} // for QVector, don't use
|
|
||||||
QMetaEnumBuilderPrivate(const QByteArray& _name)
|
QMetaEnumBuilderPrivate(const QByteArray& _name)
|
||||||
: name(_name), isFlag(false)
|
: name(_name), isFlag(false)
|
||||||
{
|
{
|
||||||
@ -213,19 +211,19 @@ public:
|
|||||||
QByteArray className;
|
QByteArray className;
|
||||||
const QMetaObject *superClass;
|
const QMetaObject *superClass;
|
||||||
QMetaObjectBuilder::StaticMetacallFunction staticMetacallFunction;
|
QMetaObjectBuilder::StaticMetacallFunction staticMetacallFunction;
|
||||||
QVector<QMetaMethodBuilderPrivate> methods;
|
std::vector<QMetaMethodBuilderPrivate> methods;
|
||||||
QVector<QMetaMethodBuilderPrivate> constructors;
|
std::vector<QMetaMethodBuilderPrivate> constructors;
|
||||||
QVector<QMetaPropertyBuilderPrivate> properties;
|
std::vector<QMetaPropertyBuilderPrivate> properties;
|
||||||
QList<QByteArray> classInfoNames;
|
QList<QByteArray> classInfoNames;
|
||||||
QList<QByteArray> classInfoValues;
|
QList<QByteArray> classInfoValues;
|
||||||
QVector<QMetaEnumBuilderPrivate> enumerators;
|
std::vector<QMetaEnumBuilderPrivate> enumerators;
|
||||||
QList<const QMetaObject *> relatedMetaObjects;
|
QList<const QMetaObject *> relatedMetaObjects;
|
||||||
int flags;
|
int flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool QMetaObjectBuilderPrivate::hasRevisionedProperties() const
|
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)
|
if (properties.at(i).revision)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -234,7 +232,7 @@ bool QMetaObjectBuilderPrivate::hasRevisionedProperties() const
|
|||||||
|
|
||||||
bool QMetaObjectBuilderPrivate::hasRevisionedMethods() 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)
|
if (methods.at(i).revision)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -353,7 +351,7 @@ void QMetaObjectBuilder::setFlags(MetaObjectFlags flags)
|
|||||||
*/
|
*/
|
||||||
int QMetaObjectBuilder::methodCount() const
|
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
|
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
|
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
|
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)
|
QMetaMethodBuilder QMetaObjectBuilder::addMethod(const QByteArray& signature)
|
||||||
{
|
{
|
||||||
int index = d->methods.size();
|
int index = int(d->methods.size());
|
||||||
d->methods.append(QMetaMethodBuilderPrivate(QMetaMethod::Method, signature));
|
d->methods.push_back(QMetaMethodBuilderPrivate(QMetaMethod::Method, signature));
|
||||||
return QMetaMethodBuilder(this, index);
|
return QMetaMethodBuilder(this, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -444,8 +442,8 @@ QMetaMethodBuilder QMetaObjectBuilder::addMethod(const QByteArray& signature)
|
|||||||
QMetaMethodBuilder QMetaObjectBuilder::addMethod
|
QMetaMethodBuilder QMetaObjectBuilder::addMethod
|
||||||
(const QByteArray& signature, const QByteArray& returnType)
|
(const QByteArray& signature, const QByteArray& returnType)
|
||||||
{
|
{
|
||||||
int index = d->methods.size();
|
int index = int(d->methods.size());
|
||||||
d->methods.append(QMetaMethodBuilderPrivate
|
d->methods.push_back(QMetaMethodBuilderPrivate
|
||||||
(QMetaMethod::Method, signature, returnType));
|
(QMetaMethod::Method, signature, returnType));
|
||||||
return QMetaMethodBuilder(this, index);
|
return QMetaMethodBuilder(this, index);
|
||||||
}
|
}
|
||||||
@ -491,8 +489,8 @@ QMetaMethodBuilder QMetaObjectBuilder::addMethod(const QMetaMethod& prototype)
|
|||||||
*/
|
*/
|
||||||
QMetaMethodBuilder QMetaObjectBuilder::addSlot(const QByteArray& signature)
|
QMetaMethodBuilder QMetaObjectBuilder::addSlot(const QByteArray& signature)
|
||||||
{
|
{
|
||||||
int index = d->methods.size();
|
int index = int(d->methods.size());
|
||||||
d->methods.append(QMetaMethodBuilderPrivate(QMetaMethod::Slot, signature));
|
d->methods.push_back(QMetaMethodBuilderPrivate(QMetaMethod::Slot, signature));
|
||||||
return QMetaMethodBuilder(this, index);
|
return QMetaMethodBuilder(this, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -506,8 +504,8 @@ QMetaMethodBuilder QMetaObjectBuilder::addSlot(const QByteArray& signature)
|
|||||||
*/
|
*/
|
||||||
QMetaMethodBuilder QMetaObjectBuilder::addSignal(const QByteArray& signature)
|
QMetaMethodBuilder QMetaObjectBuilder::addSignal(const QByteArray& signature)
|
||||||
{
|
{
|
||||||
int index = d->methods.size();
|
int index = int(d->methods.size());
|
||||||
d->methods.append(QMetaMethodBuilderPrivate
|
d->methods.push_back(QMetaMethodBuilderPrivate
|
||||||
(QMetaMethod::Signal, signature, QByteArray("void"), QMetaMethod::Public));
|
(QMetaMethod::Signal, signature, QByteArray("void"), QMetaMethod::Public));
|
||||||
return QMetaMethodBuilder(this, index);
|
return QMetaMethodBuilder(this, index);
|
||||||
}
|
}
|
||||||
@ -523,9 +521,9 @@ QMetaMethodBuilder QMetaObjectBuilder::addSignal(const QByteArray& signature)
|
|||||||
*/
|
*/
|
||||||
QMetaMethodBuilder QMetaObjectBuilder::addConstructor(const QByteArray& signature)
|
QMetaMethodBuilder QMetaObjectBuilder::addConstructor(const QByteArray& signature)
|
||||||
{
|
{
|
||||||
int index = d->constructors.size();
|
int index = int(d->constructors.size());
|
||||||
d->constructors.append(QMetaMethodBuilderPrivate(QMetaMethod::Constructor, signature,
|
d->constructors.push_back(QMetaMethodBuilderPrivate(QMetaMethod::Constructor, signature,
|
||||||
/*returnType=*/QByteArray()));
|
/*returnType=*/QByteArray()));
|
||||||
return QMetaMethodBuilder(this, -(index + 1));
|
return QMetaMethodBuilder(this, -(index + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -564,8 +562,8 @@ QMetaMethodBuilder QMetaObjectBuilder::addConstructor(const QMetaMethod& prototy
|
|||||||
QMetaPropertyBuilder QMetaObjectBuilder::addProperty
|
QMetaPropertyBuilder QMetaObjectBuilder::addProperty
|
||||||
(const QByteArray& name, const QByteArray& type, int notifierId)
|
(const QByteArray& name, const QByteArray& type, int notifierId)
|
||||||
{
|
{
|
||||||
int index = d->properties.size();
|
int index = int(d->properties.size());
|
||||||
d->properties.append(QMetaPropertyBuilderPrivate(name, type, notifierId));
|
d->properties.push_back(QMetaPropertyBuilderPrivate(name, type, notifierId));
|
||||||
return QMetaPropertyBuilder(this, index);
|
return QMetaPropertyBuilder(this, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -615,8 +613,8 @@ QMetaPropertyBuilder QMetaObjectBuilder::addProperty(const QMetaProperty& protot
|
|||||||
*/
|
*/
|
||||||
QMetaEnumBuilder QMetaObjectBuilder::addEnumerator(const QByteArray& name)
|
QMetaEnumBuilder QMetaObjectBuilder::addEnumerator(const QByteArray& name)
|
||||||
{
|
{
|
||||||
int index = d->enumerators.size();
|
int index = int(d->enumerators.size());
|
||||||
d->enumerators.append(QMetaEnumBuilderPrivate(name));
|
d->enumerators.push_back(QMetaEnumBuilderPrivate(name));
|
||||||
return QMetaEnumBuilder(this, index);
|
return QMetaEnumBuilder(this, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -762,7 +760,7 @@ void QMetaObjectBuilder::addMetaObject
|
|||||||
*/
|
*/
|
||||||
QMetaMethodBuilder QMetaObjectBuilder::method(int index) const
|
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);
|
return QMetaMethodBuilder(this, index);
|
||||||
else
|
else
|
||||||
return QMetaMethodBuilder();
|
return QMetaMethodBuilder();
|
||||||
@ -775,7 +773,7 @@ QMetaMethodBuilder QMetaObjectBuilder::method(int index) const
|
|||||||
*/
|
*/
|
||||||
QMetaMethodBuilder QMetaObjectBuilder::constructor(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));
|
return QMetaMethodBuilder(this, -(index + 1));
|
||||||
else
|
else
|
||||||
return QMetaMethodBuilder();
|
return QMetaMethodBuilder();
|
||||||
@ -788,7 +786,7 @@ QMetaMethodBuilder QMetaObjectBuilder::constructor(int index) const
|
|||||||
*/
|
*/
|
||||||
QMetaPropertyBuilder QMetaObjectBuilder::property(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);
|
return QMetaPropertyBuilder(this, index);
|
||||||
else
|
else
|
||||||
return QMetaPropertyBuilder();
|
return QMetaPropertyBuilder();
|
||||||
@ -802,7 +800,7 @@ QMetaPropertyBuilder QMetaObjectBuilder::property(int index) const
|
|||||||
*/
|
*/
|
||||||
QMetaEnumBuilder QMetaObjectBuilder::enumerator(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);
|
return QMetaEnumBuilder(this, index);
|
||||||
else
|
else
|
||||||
return QMetaEnumBuilder();
|
return QMetaEnumBuilder();
|
||||||
@ -866,9 +864,9 @@ QByteArray QMetaObjectBuilder::classInfoValue(int index) const
|
|||||||
*/
|
*/
|
||||||
void QMetaObjectBuilder::removeMethod(int index)
|
void QMetaObjectBuilder::removeMethod(int index)
|
||||||
{
|
{
|
||||||
if (index >= 0 && index < d->methods.size()) {
|
if (index >= 0 && index < int(d->methods.size())) {
|
||||||
d->methods.removeAt(index);
|
d->methods.erase(d->methods.begin() + index);
|
||||||
for (int prop = 0; prop < d->properties.size(); ++prop) {
|
for (size_t prop = 0; prop < d->properties.size(); ++prop) {
|
||||||
// Adjust the indices of property notify signal references.
|
// Adjust the indices of property notify signal references.
|
||||||
if (d->properties[prop].notifySignal == index) {
|
if (d->properties[prop].notifySignal == index) {
|
||||||
d->properties[prop].notifySignal = -1;
|
d->properties[prop].notifySignal = -1;
|
||||||
@ -888,8 +886,8 @@ void QMetaObjectBuilder::removeMethod(int index)
|
|||||||
*/
|
*/
|
||||||
void QMetaObjectBuilder::removeConstructor(int index)
|
void QMetaObjectBuilder::removeConstructor(int index)
|
||||||
{
|
{
|
||||||
if (index >= 0 && index < d->constructors.size())
|
if (index >= 0 && index < int(d->constructors.size()))
|
||||||
d->constructors.removeAt(index);
|
d->constructors.erase(d->constructors.begin() + index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -900,8 +898,8 @@ void QMetaObjectBuilder::removeConstructor(int index)
|
|||||||
*/
|
*/
|
||||||
void QMetaObjectBuilder::removeProperty(int index)
|
void QMetaObjectBuilder::removeProperty(int index)
|
||||||
{
|
{
|
||||||
if (index >= 0 && index < d->properties.size())
|
if (index >= 0 && index < int(d->properties.size()))
|
||||||
d->properties.removeAt(index);
|
d->properties.erase(d->properties.begin() + index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -913,8 +911,8 @@ void QMetaObjectBuilder::removeProperty(int index)
|
|||||||
*/
|
*/
|
||||||
void QMetaObjectBuilder::removeEnumerator(int index)
|
void QMetaObjectBuilder::removeEnumerator(int index)
|
||||||
{
|
{
|
||||||
if (index >= 0 && index < d->enumerators.size())
|
if (index >= 0 && index < int(d->enumerators.size()))
|
||||||
d->enumerators.removeAt(index);
|
d->enumerators.erase(d->enumerators.begin() + index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -959,9 +957,9 @@ void QMetaObjectBuilder::removeRelatedMetaObject(int index)
|
|||||||
int QMetaObjectBuilder::indexOfMethod(const QByteArray& signature)
|
int QMetaObjectBuilder::indexOfMethod(const QByteArray& signature)
|
||||||
{
|
{
|
||||||
QByteArray sig = QMetaObject::normalizedSignature(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)
|
if (sig == d->methods[index].signature)
|
||||||
return index;
|
return int(index);
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -975,10 +973,10 @@ int QMetaObjectBuilder::indexOfMethod(const QByteArray& signature)
|
|||||||
int QMetaObjectBuilder::indexOfSignal(const QByteArray& signature)
|
int QMetaObjectBuilder::indexOfSignal(const QByteArray& signature)
|
||||||
{
|
{
|
||||||
QByteArray sig = QMetaObject::normalizedSignature(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 &&
|
if (sig == d->methods[index].signature &&
|
||||||
d->methods[index].methodType() == QMetaMethod::Signal)
|
d->methods[index].methodType() == QMetaMethod::Signal)
|
||||||
return index;
|
return int(index);
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -992,10 +990,10 @@ int QMetaObjectBuilder::indexOfSignal(const QByteArray& signature)
|
|||||||
int QMetaObjectBuilder::indexOfSlot(const QByteArray& signature)
|
int QMetaObjectBuilder::indexOfSlot(const QByteArray& signature)
|
||||||
{
|
{
|
||||||
QByteArray sig = QMetaObject::normalizedSignature(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 &&
|
if (sig == d->methods[index].signature &&
|
||||||
d->methods[index].methodType() == QMetaMethod::Slot)
|
d->methods[index].methodType() == QMetaMethod::Slot)
|
||||||
return index;
|
return int(index);
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1009,9 +1007,9 @@ int QMetaObjectBuilder::indexOfSlot(const QByteArray& signature)
|
|||||||
int QMetaObjectBuilder::indexOfConstructor(const QByteArray& signature)
|
int QMetaObjectBuilder::indexOfConstructor(const QByteArray& signature)
|
||||||
{
|
{
|
||||||
QByteArray sig = QMetaObject::normalizedSignature(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)
|
if (sig == d->constructors[index].signature)
|
||||||
return index;
|
return int(index);
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1024,9 +1022,9 @@ int QMetaObjectBuilder::indexOfConstructor(const QByteArray& signature)
|
|||||||
*/
|
*/
|
||||||
int QMetaObjectBuilder::indexOfProperty(const QByteArray& name)
|
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)
|
if (name == d->properties[index].name)
|
||||||
return index;
|
return int(index);
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1039,9 +1037,9 @@ int QMetaObjectBuilder::indexOfProperty(const QByteArray& name)
|
|||||||
*/
|
*/
|
||||||
int QMetaObjectBuilder::indexOfEnumerator(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)
|
if (name == d->enumerators[index].name)
|
||||||
return index;
|
return int(index);
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1155,10 +1153,10 @@ void QMetaStringTable::writeBlob(char *out) const
|
|||||||
// Returns the sum of all parameters (including return type) for the given
|
// Returns the sum of all parameters (including return type) for the given
|
||||||
// \a methods. This is needed for calculating the size of the methods'
|
// \a methods. This is needed for calculating the size of the methods'
|
||||||
// parameter type/name meta-data.
|
// parameter type/name meta-data.
|
||||||
static int aggregateParameterCount(const QVector<QMetaMethodBuilderPrivate> &methods)
|
static int aggregateParameterCount(const std::vector<QMetaMethodBuilderPrivate> &methods)
|
||||||
{
|
{
|
||||||
int sum = 0;
|
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
|
sum += methods.at(i).parameterCount() + 1; // +1 for return type
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
@ -1200,7 +1198,7 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
|
|||||||
= reinterpret_cast<QMetaObjectPrivate *>(buf + size);
|
= reinterpret_cast<QMetaObjectPrivate *>(buf + size);
|
||||||
int pmetaSize = size;
|
int pmetaSize = size;
|
||||||
dataIndex = MetaObjectPrivateFieldCount;
|
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) {
|
if (d->properties[index].notifySignal != -1) {
|
||||||
hasNotifySignals = true;
|
hasNotifySignals = true;
|
||||||
break;
|
break;
|
||||||
@ -1209,8 +1207,8 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
|
|||||||
int methodParametersDataSize =
|
int methodParametersDataSize =
|
||||||
((aggregateParameterCount(d->methods)
|
((aggregateParameterCount(d->methods)
|
||||||
+ aggregateParameterCount(d->constructors)) * 2) // types and parameter names
|
+ aggregateParameterCount(d->constructors)) * 2) // types and parameter names
|
||||||
- d->methods.size() // return "parameters" don't have names
|
- int(d->methods.size()) // return "parameters" don't have names
|
||||||
- d->constructors.size(); // "this" parameters don't have names
|
- int(d->constructors.size()); // "this" parameters don't have names
|
||||||
if (buf) {
|
if (buf) {
|
||||||
Q_STATIC_ASSERT_X(QMetaObjectPrivate::OutputRevision == 7, "QMetaObjectBuilder should generate the same version as moc");
|
Q_STATIC_ASSERT_X(QMetaObjectPrivate::OutputRevision == 7, "QMetaObjectBuilder should generate the same version as moc");
|
||||||
pmeta->revision = QMetaObjectPrivate::OutputRevision;
|
pmeta->revision = QMetaObjectPrivate::OutputRevision;
|
||||||
@ -1222,48 +1220,48 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
|
|||||||
pmeta->classInfoData = dataIndex;
|
pmeta->classInfoData = dataIndex;
|
||||||
dataIndex += 2 * d->classInfoNames.size();
|
dataIndex += 2 * d->classInfoNames.size();
|
||||||
|
|
||||||
pmeta->methodCount = d->methods.size();
|
pmeta->methodCount = int(d->methods.size());
|
||||||
pmeta->methodData = dataIndex;
|
pmeta->methodData = dataIndex;
|
||||||
dataIndex += 5 * d->methods.size();
|
dataIndex += 5 * int(d->methods.size());
|
||||||
if (hasRevisionedMethods)
|
if (hasRevisionedMethods)
|
||||||
dataIndex += d->methods.size();
|
dataIndex += int(d->methods.size());
|
||||||
paramsIndex = dataIndex;
|
paramsIndex = dataIndex;
|
||||||
dataIndex += methodParametersDataSize;
|
dataIndex += methodParametersDataSize;
|
||||||
|
|
||||||
pmeta->propertyCount = d->properties.size();
|
pmeta->propertyCount = int(d->properties.size());
|
||||||
pmeta->propertyData = dataIndex;
|
pmeta->propertyData = dataIndex;
|
||||||
dataIndex += 3 * d->properties.size();
|
dataIndex += 3 * int(d->properties.size());
|
||||||
if (hasNotifySignals)
|
if (hasNotifySignals)
|
||||||
dataIndex += d->properties.size();
|
dataIndex += int(d->properties.size());
|
||||||
if (hasRevisionedProperties)
|
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;
|
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;
|
pmeta->constructorData = dataIndex;
|
||||||
dataIndex += 5 * d->constructors.size();
|
dataIndex += 5 * int(d->constructors.size());
|
||||||
} else {
|
} else {
|
||||||
dataIndex += 2 * d->classInfoNames.size();
|
dataIndex += 2 * int(d->classInfoNames.size());
|
||||||
dataIndex += 5 * d->methods.size();
|
dataIndex += 5 * int(d->methods.size());
|
||||||
if (hasRevisionedMethods)
|
if (hasRevisionedMethods)
|
||||||
dataIndex += d->methods.size();
|
dataIndex += int(d->methods.size());
|
||||||
paramsIndex = dataIndex;
|
paramsIndex = dataIndex;
|
||||||
dataIndex += methodParametersDataSize;
|
dataIndex += methodParametersDataSize;
|
||||||
dataIndex += 3 * d->properties.size();
|
dataIndex += 3 * int(d->properties.size());
|
||||||
if (hasNotifySignals)
|
if (hasNotifySignals)
|
||||||
dataIndex += d->properties.size();
|
dataIndex += int(d->properties.size());
|
||||||
if (hasRevisionedProperties)
|
if (hasRevisionedProperties)
|
||||||
dataIndex += d->properties.size();
|
dataIndex += int(d->properties.size());
|
||||||
dataIndex += 4 * d->enumerators.size();
|
dataIndex += 4 * int(d->enumerators.size());
|
||||||
dataIndex += 5 * d->constructors.size();
|
dataIndex += 5 * int(d->constructors.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate space for the enumerator key names and values.
|
// Allocate space for the enumerator key names and values.
|
||||||
enumIndex = dataIndex;
|
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]);
|
QMetaEnumBuilderPrivate *enumerator = &(d->enumerators[index]);
|
||||||
dataIndex += 2 * enumerator->keys.size();
|
dataIndex += 2 * enumerator->keys.size();
|
||||||
}
|
}
|
||||||
@ -1305,7 +1303,7 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
|
|||||||
|
|
||||||
// Output the methods in the class.
|
// Output the methods in the class.
|
||||||
Q_ASSERT(!buf || dataIndex == pmeta->methodData);
|
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]);
|
QMetaMethodBuilderPrivate *method = &(d->methods[index]);
|
||||||
int name = strings.enter(method->name());
|
int name = strings.enter(method->name());
|
||||||
int argc = method->parameterCount();
|
int argc = method->parameterCount();
|
||||||
@ -1324,7 +1322,7 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
|
|||||||
paramsIndex += 1 + argc * 2;
|
paramsIndex += 1 + argc * 2;
|
||||||
}
|
}
|
||||||
if (hasRevisionedMethods) {
|
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]);
|
QMetaMethodBuilderPrivate *method = &(d->methods[index]);
|
||||||
if (buf)
|
if (buf)
|
||||||
data[dataIndex] = method->revision;
|
data[dataIndex] = method->revision;
|
||||||
@ -1333,12 +1331,12 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Output the method parameters in the class.
|
// Output the method parameters in the class.
|
||||||
Q_ASSERT(!buf || dataIndex == pmeta->methodData + d->methods.size() * 5
|
Q_ASSERT(!buf || dataIndex == pmeta->methodData + int(d->methods.size()) * 5
|
||||||
+ (hasRevisionedMethods ? d->methods.size() : 0));
|
+ (hasRevisionedMethods ? int(d->methods.size()) : 0));
|
||||||
for (int x = 0; x < 2; ++x) {
|
for (int x = 0; x < 2; ++x) {
|
||||||
QVector<QMetaMethodBuilderPrivate> &methods = (x == 0) ? d->methods : d->constructors;
|
const std::vector<QMetaMethodBuilderPrivate> &methods = (x == 0) ? d->methods : d->constructors;
|
||||||
for (index = 0; index < methods.size(); ++index) {
|
for (size_t index = 0; index < methods.size(); ++index) {
|
||||||
QMetaMethodBuilderPrivate *method = &(methods[index]);
|
const QMetaMethodBuilderPrivate *method = &(methods[index]);
|
||||||
QList<QByteArray> paramTypeNames = method->parameterTypes();
|
QList<QByteArray> paramTypeNames = method->parameterTypes();
|
||||||
int paramCount = paramTypeNames.size();
|
int paramCount = paramTypeNames.size();
|
||||||
for (int i = -1; i < paramCount; ++i) {
|
for (int i = -1; i < paramCount; ++i) {
|
||||||
@ -1367,7 +1365,7 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
|
|||||||
|
|
||||||
// Output the properties in the class.
|
// Output the properties in the class.
|
||||||
Q_ASSERT(!buf || dataIndex == pmeta->propertyData);
|
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]);
|
QMetaPropertyBuilderPrivate *prop = &(d->properties[index]);
|
||||||
int name = strings.enter(prop->name);
|
int name = strings.enter(prop->name);
|
||||||
|
|
||||||
@ -1390,7 +1388,7 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
|
|||||||
dataIndex += 3;
|
dataIndex += 3;
|
||||||
}
|
}
|
||||||
if (hasNotifySignals) {
|
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]);
|
QMetaPropertyBuilderPrivate *prop = &(d->properties[index]);
|
||||||
if (buf) {
|
if (buf) {
|
||||||
if (prop->notifySignal != -1)
|
if (prop->notifySignal != -1)
|
||||||
@ -1402,7 +1400,7 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hasRevisionedProperties) {
|
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]);
|
QMetaPropertyBuilderPrivate *prop = &(d->properties[index]);
|
||||||
if (buf)
|
if (buf)
|
||||||
data[dataIndex] = prop->revision;
|
data[dataIndex] = prop->revision;
|
||||||
@ -1412,7 +1410,7 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
|
|||||||
|
|
||||||
// Output the enumerators in the class.
|
// Output the enumerators in the class.
|
||||||
Q_ASSERT(!buf || dataIndex == pmeta->enumeratorData);
|
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]);
|
QMetaEnumBuilderPrivate *enumerator = &(d->enumerators[index]);
|
||||||
int name = strings.enter(enumerator->name);
|
int name = strings.enter(enumerator->name);
|
||||||
int isFlag = (int)(enumerator->isFlag);
|
int isFlag = (int)(enumerator->isFlag);
|
||||||
@ -1437,7 +1435,7 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
|
|||||||
|
|
||||||
// Output the constructors in the class.
|
// Output the constructors in the class.
|
||||||
Q_ASSERT(!buf || dataIndex == pmeta->constructorData);
|
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]);
|
QMetaMethodBuilderPrivate *method = &(d->constructors[index]);
|
||||||
int name = strings.enter(method->name());
|
int name = strings.enter(method->name());
|
||||||
int argc = method->parameterCount();
|
int argc = method->parameterCount();
|
||||||
@ -1612,10 +1610,10 @@ void QMetaObjectBuilder::serialize(QDataStream& stream) const
|
|||||||
|
|
||||||
// Write the counts for each type of class member.
|
// Write the counts for each type of class member.
|
||||||
stream << d->classInfoNames.size();
|
stream << d->classInfoNames.size();
|
||||||
stream << d->methods.size();
|
stream << int(d->methods.size());
|
||||||
stream << d->properties.size();
|
stream << int(d->properties.size());
|
||||||
stream << d->enumerators.size();
|
stream << int(d->enumerators.size());
|
||||||
stream << d->constructors.size();
|
stream << int(d->constructors.size());
|
||||||
stream << d->relatedMetaObjects.size();
|
stream << d->relatedMetaObjects.size();
|
||||||
|
|
||||||
// Write the items of class information.
|
// Write the items of class information.
|
||||||
@ -1625,7 +1623,7 @@ void QMetaObjectBuilder::serialize(QDataStream& stream) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write the methods.
|
// 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]);
|
const QMetaMethodBuilderPrivate *method = &(d->methods[index]);
|
||||||
stream << method->signature;
|
stream << method->signature;
|
||||||
stream << method->returnType;
|
stream << method->returnType;
|
||||||
@ -1637,7 +1635,7 @@ void QMetaObjectBuilder::serialize(QDataStream& stream) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write the properties.
|
// 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]);
|
const QMetaPropertyBuilderPrivate *property = &(d->properties[index]);
|
||||||
stream << property->name;
|
stream << property->name;
|
||||||
stream << property->type;
|
stream << property->type;
|
||||||
@ -1648,7 +1646,7 @@ void QMetaObjectBuilder::serialize(QDataStream& stream) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write the enumerators.
|
// 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]);
|
const QMetaEnumBuilderPrivate *enumerator = &(d->enumerators[index]);
|
||||||
stream << enumerator->name;
|
stream << enumerator->name;
|
||||||
stream << enumerator->isFlag;
|
stream << enumerator->isFlag;
|
||||||
@ -1657,7 +1655,7 @@ void QMetaObjectBuilder::serialize(QDataStream& stream) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write the constructors.
|
// 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]);
|
const QMetaMethodBuilderPrivate *method = &(d->constructors[index]);
|
||||||
stream << method->signature;
|
stream << method->signature;
|
||||||
stream << method->returnType;
|
stream << method->returnType;
|
||||||
@ -1796,7 +1794,7 @@ void QMetaObjectBuilder::deserialize
|
|||||||
stream >> property->flags;
|
stream >> property->flags;
|
||||||
stream >> property->notifySignal;
|
stream >> property->notifySignal;
|
||||||
if (property->notifySignal < -1 ||
|
if (property->notifySignal < -1 ||
|
||||||
property->notifySignal >= d->methods.size()) {
|
property->notifySignal >= int(d->methods.size())) {
|
||||||
// Notify signal method index is out of range.
|
// Notify signal method index is out of range.
|
||||||
stream.setStatus(QDataStream::ReadCorruptData);
|
stream.setStatus(QDataStream::ReadCorruptData);
|
||||||
return;
|
return;
|
||||||
@ -1875,9 +1873,9 @@ void QMetaObjectBuilder::deserialize
|
|||||||
QMetaMethodBuilderPrivate *QMetaMethodBuilder::d_func() const
|
QMetaMethodBuilderPrivate *QMetaMethodBuilder::d_func() const
|
||||||
{
|
{
|
||||||
// Positive indices indicate methods, negative indices indicate constructors.
|
// 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]);
|
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]);
|
return &(_mobj->d->constructors[(-_index) - 1]);
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
@ -2116,7 +2114,7 @@ void QMetaMethodBuilder::setRevision(int revision)
|
|||||||
|
|
||||||
QMetaPropertyBuilderPrivate *QMetaPropertyBuilder::d_func() const
|
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]);
|
return &(_mobj->d->properties[_index]);
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
@ -2588,7 +2586,7 @@ void QMetaPropertyBuilder::setRevision(int revision)
|
|||||||
|
|
||||||
QMetaEnumBuilderPrivate *QMetaEnumBuilder::d_func() const
|
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]);
|
return &(_mobj->d->enumerators[_index]);
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user