diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-03-19 13:11:20 +0100 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-03-20 10:24:27 +0100 |
commit | 411ab34c962249dae3a4db721a3d2d002b7b95d5 (patch) | |
tree | 83fcb6d0f07d00417c6d801b941f7ca41c160ec5 /src/corelib/kernel/qmetaobjectbuilder.cpp | |
parent | 90fd142b098c32eec81fabbcb29843e9e03e5063 (diff) |
QMetaObjectBuilder: remove unused serialization code
Change-Id: I73a13265a69079581d2974400b3311d3fdfda2d0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/kernel/qmetaobjectbuilder.cpp')
-rw-r--r-- | src/corelib/kernel/qmetaobjectbuilder.cpp | 268 |
1 files changed, 0 insertions, 268 deletions
diff --git a/src/corelib/kernel/qmetaobjectbuilder.cpp b/src/corelib/kernel/qmetaobjectbuilder.cpp index c842cd68b9..3ee7d17545 100644 --- a/src/corelib/kernel/qmetaobjectbuilder.cpp +++ b/src/corelib/kernel/qmetaobjectbuilder.cpp @@ -1526,274 +1526,6 @@ void QMetaObjectBuilder::setStaticMetacallFunction d->staticMetacallFunction = value; } -#ifndef QT_NO_DATASTREAM - -/*! - Serializes the contents of the meta object builder onto \a stream. - - \sa deserialize() -*/ -void QMetaObjectBuilder::serialize(QDataStream &stream) const -{ - int index; - - // Write the class and super class names. - stream << d->className; - if (d->superClass) - stream << QByteArray(d->superClass->className()); - else - stream << QByteArray(); - - // Write the counts for each type of class member. - stream << int(d->classInfoNames.size()); - stream << int(d->methods.size()); - stream << int(d->properties.size()); - stream << int(d->enumerators.size()); - stream << int(d->constructors.size()); - stream << int(d->relatedMetaObjects.size()); - - // Write the items of class information. - for (index = 0; index < d->classInfoNames.size(); ++index) { - stream << d->classInfoNames[index]; - stream << d->classInfoValues[index]; - } - - // Write the methods. - for (const auto &method : d->methods) { - stream << method.signature; - stream << method.returnType; - stream << method.parameterNames; - stream << method.tag; - stream << method.attributes; - if (method.revision) - stream << method.revision; - } - - // Write the properties. - for (const auto &property : d->properties) { - stream << property.name; - stream << property.type; - stream << property.flags; - stream << property.notifySignal; - stream << property.revision; - } - - // Write the enumerators. - for (const auto &enumerator : d->enumerators) { - stream << enumerator.name; - stream << enumerator.isFlag; - stream << enumerator.isScoped; - stream << enumerator.keys; - stream << enumerator.values; - } - - // Write the constructors. - for (const auto &ctor : d->constructors) { - stream << ctor.signature; - stream << ctor.returnType; - stream << ctor.parameterNames; - stream << ctor.tag; - stream << ctor.attributes; - } - - // Write the related meta objects. - for (index = 0; index < d->relatedMetaObjects.size(); ++index) { - const QMetaObject *meta = d->relatedMetaObjects[index]; - stream << QByteArray(meta->className()); - } - - // Add an extra empty QByteArray for additional data in future versions. - // This should help maintain backwards compatibility, allowing older - // versions to read newer data. - stream << QByteArray(); -} - -// Resolve a class name using the name reference map. -static const QMetaObject *resolveClassName(const QMap<QByteArray, const QMetaObject *> &references, - const QByteArray &name) -{ - if (name == QByteArray("QObject")) - return &QObject::staticMetaObject; - else - return references.value(name, nullptr); -} - -/*! - Deserializes a meta object builder from \a stream into - this meta object builder. - - The \a references parameter specifies a mapping from class names - to QMetaObject instances for resolving the super class name and - related meta objects in the object that is deserialized. - The meta object for QObject is implicitly added to \a references - and does not need to be supplied. - - The QDataStream::status() value on \a stream will be set to - QDataStream::ReadCorruptData if the input data is corrupt. - The status will be set to QDataStream::ReadPastEnd if the - input was exhausted before the full meta object was read. - - \sa serialize() -*/ -void QMetaObjectBuilder::deserialize - (QDataStream& stream, - const QMap<QByteArray, const QMetaObject *>& references) -{ - QByteArray name; - const QMetaObject *cl; - int index; - - // Clear all members in the builder to their default states. - d->className.clear(); - d->superClass = &QObject::staticMetaObject; - d->classInfoNames.clear(); - d->classInfoValues.clear(); - d->methods.clear(); - d->properties.clear(); - d->enumerators.clear(); - d->constructors.clear(); - d->relatedMetaObjects.clear(); - d->staticMetacallFunction = nullptr; - - // Read the class and super class names. - stream >> d->className; - stream >> name; - if (name.isEmpty()) { - d->superClass = nullptr; - } else if ((cl = resolveClassName(references, name)) != nullptr) { - d->superClass = cl; - } else { - stream.setStatus(QDataStream::ReadCorruptData); - return; - } - - // Read the counts for each type of class member. - int classInfoCount, methodCount, propertyCount; - int enumeratorCount, constructorCount, relatedMetaObjectCount; - stream >> classInfoCount; - stream >> methodCount; - stream >> propertyCount; - stream >> enumeratorCount; - stream >> constructorCount; - stream >> relatedMetaObjectCount; - if (classInfoCount < 0 || methodCount < 0 || - propertyCount < 0 || enumeratorCount < 0 || - constructorCount < 0 || relatedMetaObjectCount < 0) { - stream.setStatus(QDataStream::ReadCorruptData); - return; - } - - // Read the items of class information. - for (index = 0; index < classInfoCount; ++index) { - if (stream.status() != QDataStream::Ok) - return; - QByteArray value; - stream >> name; - stream >> value; - addClassInfo(name, value); - } - - // Read the member methods. - for (index = 0; index < methodCount; ++index) { - if (stream.status() != QDataStream::Ok) - return; - stream >> name; - addMethod(name); - QMetaMethodBuilderPrivate &method = d->methods[index]; - stream >> method.returnType; - 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); - return; - } - } - - // Read the properties. - for (index = 0; index < propertyCount; ++index) { - if (stream.status() != QDataStream::Ok) - return; - QByteArray type; - stream >> name; - stream >> type; - addProperty(name, type); - QMetaPropertyBuilderPrivate &property = d->properties[index]; - stream >> property.flags; - stream >> property.notifySignal; - if (property.notifySignal < -1 || - property.notifySignal >= int(d->methods.size())) { - // Notify signal method index is out of range. - stream.setStatus(QDataStream::ReadCorruptData); - return; - } - if (property.notifySignal >= 0 && - d->methods[property.notifySignal].methodType() != QMetaMethod::Signal) { - // Notify signal method index does not refer to a signal. - stream.setStatus(QDataStream::ReadCorruptData); - return; - } - stream >> property.revision; - } - - // Read the enumerators. - for (index = 0; index < enumeratorCount; ++index) { - if (stream.status() != QDataStream::Ok) - return; - stream >> name; - addEnumerator(name); - QMetaEnumBuilderPrivate &enumerator = d->enumerators[index]; - stream >> enumerator.isFlag; - stream >> enumerator.isScoped; - stream >> enumerator.keys; - stream >> enumerator.values; - if (enumerator.keys.size() != enumerator.values.size()) { - // Mismatch between number of keys and number of values. - stream.setStatus(QDataStream::ReadCorruptData); - return; - } - } - - // Read the constructor methods. - for (index = 0; index < constructorCount; ++index) { - if (stream.status() != QDataStream::Ok) - return; - stream >> name; - addConstructor(name); - QMetaMethodBuilderPrivate &method = d->constructors[index]; - stream >> method.returnType; - stream >> method.parameterNames; - stream >> method.tag; - stream >> method.attributes; - if (method.methodType() != QMetaMethod::Constructor) { - // The type must be Constructor. - stream.setStatus(QDataStream::ReadCorruptData); - return; - } - } - - // Read the related meta objects. - for (index = 0; index < relatedMetaObjectCount; ++index) { - if (stream.status() != QDataStream::Ok) - return; - stream >> name; - cl = resolveClassName(references, name); - if (!cl) { - stream.setStatus(QDataStream::ReadCorruptData); - return; - } - addRelatedMetaObject(cl); - } - - // Read the extra data block, which is reserved for future use. - stream >> name; -} - -#endif // !QT_NO_DATASTREAM - /*! \class QMetaMethodBuilder \inmodule QtCore |