(QMetaMethod::MethodType _methodType,
const QByteArray& _signature,
const QByteArray& _returnType = QByteArray(),
- QMetaMethod::Access _access = QMetaMethod::Public)
+ QMetaMethod::Access _access = QMetaMethod::Public,
+ int _revision = 0)
: signature(QMetaObject::normalizedSignature(_signature.constData())),
returnType(QMetaObject::normalizedType(_returnType)),
- attributes(((int)_access) | (((int)_methodType) << 2))
+ attributes(((int)_access) | (((int)_methodType) << 2)),
+ revision(_revision)
{
}
QList<QByteArray> parameterNames;
QByteArray tag;
int attributes;
+ int revision;
QMetaMethod::MethodType methodType() const
{
{
public:
QMetaPropertyBuilderPrivate
- (const QByteArray& _name, const QByteArray& _type, int notifierIdx=-1)
+ (const QByteArray& _name, const QByteArray& _type, int notifierIdx=-1,
+ int _revision = 0)
: name(_name),
type(QMetaObject::normalizedType(_type.constData())),
- flags(Readable | Writable | Scriptable), notifySignal(-1)
+ flags(Readable | Writable | Scriptable), notifySignal(-1),
+ revision(_revision)
{
if (notifierIdx >= 0) {
flags |= Notify;
QByteArray type;
int flags;
int notifySignal;
+ int revision;
bool flag(int f) const
{
staticMetacallFunction = 0;
}
+ bool hasRevisionedProperties() const;
+ bool hasRevisionedMethods() const;
+
QByteArray className;
const QMetaObject *superClass;
QMetaObjectBuilder::StaticMetacallFunction staticMetacallFunction;
int flags;
};
+bool QMetaObjectBuilderPrivate::hasRevisionedProperties() const
+{
+ for (int i = 0; i < properties.size(); ++i) {
+ if (properties.at(i).revision)
+ return true;
+ }
+ return false;
+}
+
+bool QMetaObjectBuilderPrivate::hasRevisionedMethods() const
+{
+ for (int i = 0; i < methods.size(); ++i) {
+ if (methods.at(i).revision)
+ return true;
+ }
+ return false;
+}
+
/*!
Constructs a new QMetaObjectBuilder.
*/
method.setTag(prototype.tag());
method.setAccess(prototype.access());
method.setAttributes(prototype.attributes());
+ method.setRevision(prototype.revision());
return method;
}
property.setEnumOrFlag(prototype.isEnumType());
property.setConstant(prototype.isConstant());
property.setFinal(prototype.isFinal());
+ property.setRevision(prototype.revision());
if (prototype.hasNotifySignal()) {
// Find an existing method for the notify signal, or add a new one.
QMetaMethod method = prototype.notifySignal();
int dataIndex;
int enumIndex;
int index;
+ bool hasRevisionedMethods = d->hasRevisionedMethods();
+ bool hasRevisionedProperties = d->hasRevisionedProperties();
bool hasNotifySignals = false;
if (relocatable &&
pmeta->methodCount = d->methods.size();
pmeta->methodData = dataIndex;
dataIndex += 5 * d->methods.size();
+ if (hasRevisionedMethods)
+ dataIndex += d->methods.size();
pmeta->propertyCount = d->properties.size();
pmeta->propertyData = dataIndex;
dataIndex += 3 * d->properties.size();
if (hasNotifySignals)
dataIndex += d->properties.size();
+ if (hasRevisionedProperties)
+ dataIndex += d->properties.size();
pmeta->enumeratorCount = d->enumerators.size();
pmeta->enumeratorData = dataIndex;
} else {
dataIndex += 2 * d->classInfoNames.size();
dataIndex += 5 * d->methods.size();
+ if (hasRevisionedMethods)
+ dataIndex += d->methods.size();
dataIndex += 3 * d->properties.size();
if (hasNotifySignals)
dataIndex += d->properties.size();
+ if (hasRevisionedProperties)
+ dataIndex += d->properties.size();
dataIndex += 4 * d->enumerators.size();
dataIndex += 5 * d->constructors.size();
}
}
dataIndex += 5;
}
+ if (hasRevisionedMethods) {
+ for (index = 0; index < d->methods.size(); ++index) {
+ QMetaMethodBuilderPrivate *method = &(d->methods[index]);
+ if (buf)
+ data[dataIndex] = method->revision;
+ ++dataIndex;
+ }
+ }
// Output the properties in the class.
for (index = 0; index < d->properties.size(); ++index) {
++dataIndex;
}
}
+ if (hasRevisionedProperties) {
+ for (index = 0; index < d->properties.size(); ++index) {
+ QMetaPropertyBuilderPrivate *prop = &(d->properties[index]);
+ if (buf)
+ data[dataIndex] = prop->revision;
+ ++dataIndex;
+ }
+ }
// Output the enumerators in the class.
for (index = 0; index < d->enumerators.size(); ++index) {
stream << method->parameterNames;
stream << method->tag;
stream << method->attributes;
+ if (method->revision)
+ stream << method->revision;
}
// Write the properties.
stream << property->type;
stream << property->flags;
stream << property->notifySignal;
+ if (property->revision)
+ stream << property->revision;
}
// Write the enumerators.
stream >> method->parameterNames;
stream >> method->tag;
stream >> method->attributes;
+ if (method->attributes & MethodRevisioned)
+ stream >> method->revision;
if (method->methodType() == QMetaMethod::Constructor) {
// Cannot add a constructor in this set of methods.
stream.setStatus(QDataStream::ReadCorruptData);
stream.setStatus(QDataStream::ReadCorruptData);
return;
}
+ if (property->flags & Revisioned)
+ stream >> property->revision;
}
// Read the enumerators.
}
/*!
+ Returns the revision of this method.
+
+ \sa setRevision()
+*/
+int QMetaMethodBuilder::revision() const
+{
+ QMetaMethodBuilderPrivate *d = d_func();
+ if (d)
+ return d->revision;
+ return 0;
+
+}
+
+/*!
+ Sets the \a revision of this method.
+
+ \sa revision()
+*/
+void QMetaMethodBuilder::setRevision(int revision)
+{
+ QMetaMethodBuilderPrivate *d = d_func();
+ if (d) {
+ d->revision = revision;
+ if (revision)
+ d->attributes |= MethodRevisioned;
+ else
+ d->attributes &= ~MethodRevisioned;
+ }
+}
+
+/*!
\class QMetaPropertyBuilder
\internal
\brief The QMetaPropertyBuilder class enables modifications to a property definition on a meta object builder.
d->setFlag(Final, value);
}
+/*!
+ Returns the revision of this property.
+
+ \sa setRevision()
+*/
+int QMetaPropertyBuilder::revision() const
+{
+ QMetaPropertyBuilderPrivate *d = d_func();
+ if (d)
+ return d->revision;
+ return 0;
+
+}
+
+/*!
+ Sets the \a revision of this property.
+
+ \sa revision()
+*/
+void QMetaPropertyBuilder::setRevision(int revision)
+{
+ QMetaPropertyBuilderPrivate *d = d_func();
+ if (d) {
+ d->revision = revision;
+ d->setFlag(Revisioned, revision != 0);
+ }
+}
+
/*!
\class QMetaEnumBuilder
Q_CLASSINFO("ci_bar", "DEF")
Q_PROPERTY(QString prop READ prop WRITE setProp NOTIFY propChanged)
Q_PROPERTY(QString prop2 READ prop WRITE setProp)
+ Q_PROPERTY(QString revisionProp READ prop WRITE setProp REVISION 42)
Q_PROPERTY(SomethingEnum eprop READ eprop)
Q_PROPERTY(SomethingFlagEnum fprop READ fprop)
Q_PROPERTY(QLocale::Language language READ language)
public slots:
void slot1(const QString&) {}
void slot2(int, const QString&) {}
+ Q_REVISION(24) void revisionSlot() {}
private slots:
void slot3() {}
QVERIFY(nullMethod.tag().isEmpty());
QVERIFY(nullMethod.access() == QMetaMethod::Public);
QCOMPARE(nullMethod.attributes(), 0);
+ QCOMPARE(nullMethod.revision(), 0);
QCOMPARE(nullMethod.index(), 0);
// Add a method and check its attributes.
QVERIFY(method1.tag().isEmpty());
QVERIFY(method1.access() == QMetaMethod::Public);
QCOMPARE(method1.attributes(), 0);
+ QCOMPARE(method1.revision(), 0);
QCOMPARE(method1.index(), 0);
QCOMPARE(builder.methodCount(), 1);
QVERIFY(method2.tag().isEmpty());
QVERIFY(method2.access() == QMetaMethod::Public);
QCOMPARE(method2.attributes(), 0);
+ QCOMPARE(method2.revision(), 0);
QCOMPARE(method2.index(), 1);
QCOMPARE(builder.methodCount(), 2);
method1.setTag("tag");
method1.setAccess(QMetaMethod::Private);
method1.setAttributes(42);
+ method1.setRevision(123);
// Check that method1 is changed, but method2 is not.
QCOMPARE(method1.signature(), QByteArray("foo(QString,int)"));
QCOMPARE(method1.tag(), QByteArray("tag"));
QVERIFY(method1.access() == QMetaMethod::Private);
QCOMPARE(method1.attributes(), 42);
+ QCOMPARE(method1.revision(), 123);
QCOMPARE(method1.index(), 0);
QCOMPARE(method2.signature(), QByteArray("bar(QString)"));
QVERIFY(method2.methodType() == QMetaMethod::Method);
QVERIFY(method2.tag().isEmpty());
QVERIFY(method2.access() == QMetaMethod::Public);
QCOMPARE(method2.attributes(), 0);
+ QCOMPARE(method2.revision(), 0);
QCOMPARE(method2.index(), 1);
QCOMPARE(builder.methodCount(), 2);
method2.setTag("Q_FOO");
method2.setAccess(QMetaMethod::Protected);
method2.setAttributes(24);
+ method2.setRevision(321);
// This time check that only method2 changed.
QCOMPARE(method1.signature(), QByteArray("foo(QString,int)"));
QCOMPARE(method1.tag(), QByteArray("tag"));
QVERIFY(method1.access() == QMetaMethod::Private);
QCOMPARE(method1.attributes(), 42);
+ QCOMPARE(method1.revision(), 123);
QCOMPARE(method1.index(), 0);
QCOMPARE(method2.signature(), QByteArray("bar(QString)"));
QVERIFY(method2.methodType() == QMetaMethod::Method);
QCOMPARE(method2.tag(), QByteArray("Q_FOO"));
QVERIFY(method2.access() == QMetaMethod::Protected);
QCOMPARE(method2.attributes(), 24);
+ QCOMPARE(method2.revision(), 321);
QCOMPARE(method2.index(), 1);
QCOMPARE(builder.methodCount(), 2);
QCOMPARE(method2.tag(), QByteArray("Q_FOO"));
QVERIFY(method2.access() == QMetaMethod::Protected);
QCOMPARE(method2.attributes(), 24);
+ QCOMPARE(method2.revision(), 321);
QCOMPARE(method2.index(), 0);
// Perform index-based lookup again.
QVERIFY(!nullProp.isConstant());
QVERIFY(!nullProp.isFinal());
QCOMPARE(nullProp.index(), 0);
+ QCOMPARE(nullProp.revision(), 0);
// Add a property and check its attributes.
QMetaPropertyBuilder prop1 = builder.addProperty("foo", "const QString &");
QVERIFY(!prop1.isEnumOrFlag());
QVERIFY(!prop1.isConstant());
QVERIFY(!prop1.isFinal());
+ QCOMPARE(prop1.revision(), 0);
QCOMPARE(prop1.index(), 0);
QCOMPARE(builder.propertyCount(), 1);
QVERIFY(!prop2.isEnumOrFlag());
QVERIFY(!prop2.isConstant());
QVERIFY(!prop2.isFinal());
+ QCOMPARE(prop2.revision(), 0);
QCOMPARE(prop2.index(), 1);
QCOMPARE(builder.propertyCount(), 2);
prop1.setEnumOrFlag(true);
prop1.setConstant(true);
prop1.setFinal(true);
+ prop1.setRevision(123);
// Check that prop1 is changed, but prop2 is not.
QCOMPARE(prop1.name(), QByteArray("foo"));
QVERIFY(prop1.isEnumOrFlag());
QVERIFY(prop1.isConstant());
QVERIFY(prop1.isFinal());
+ QCOMPARE(prop1.revision(), 123);
QVERIFY(prop2.isReadable());
QVERIFY(prop2.isWritable());
QCOMPARE(prop2.name(), QByteArray("bar"));
QVERIFY(!prop2.isEnumOrFlag());
QVERIFY(!prop2.isConstant());
QVERIFY(!prop2.isFinal());
+ QCOMPARE(prop2.revision(), 0);
// Remove prop1 and check that prop2 becomes index 0.
builder.removeProperty(0);
QVERIFY(!prop2.isEnumOrFlag());
QVERIFY(!prop2.isConstant());
QVERIFY(!prop2.isFinal());
+ QCOMPARE(prop2.revision(), 0);
QCOMPARE(prop2.index(), 0);
// Perform index-based lookup again.
if (method1.attributes() != method2.attributes())
return false;
+ if (method1.revision() != method2.revision())
+ return false;
+
return true;
}
return false;
}
+ if (prop1.revision() != prop2.revision())
+ return false;
+
return true;
}