summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2012-02-18 22:14:36 +0100
committerQt by Nokia <qt-info@nokia.com>2012-02-29 12:50:14 +0100
commit019a5f2dd50404abfb06f26d31aa6292eb6344fc (patch)
tree9798b09da79f0807c0160b638e12a6b2a782295e /src
parent87438fd705b2b81006a18f1c35ebd112da1b3054 (diff)
Port QDBusMetaObject to new meta-object string format
Bring QDBusMetaObject up-to-date with latest moc changes (generating the string table as an array of QByteArrayData). QDBusMetaObject now uses the same string table generator as QMetaObjectBuilder. The Q_CORE_EXPORT for rawStringData() will be removed once QtDBus has been ported to the new meta-method data format (the method name will be stored directly in the standard method descriptor, no need for QtDBus to store it as a separate string). Change-Id: I41165f48501b9b11c0288208cdc770926677a8aa Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/kernel/qmetaobject_p.h2
-rw-r--r--src/dbus/qdbusmetaobject.cpp49
-rw-r--r--src/dbus/qdbusmetaobject_p.h2
3 files changed, 9 insertions, 44 deletions
diff --git a/src/corelib/kernel/qmetaobject_p.h b/src/corelib/kernel/qmetaobject_p.h
index 509dede4cb..108d332d61 100644
--- a/src/corelib/kernel/qmetaobject_p.h
+++ b/src/corelib/kernel/qmetaobject_p.h
@@ -180,7 +180,7 @@ struct QMetaObjectPrivate
static inline const QMetaObjectPrivate *get(const QMetaObject *metaobject)
{ return reinterpret_cast<const QMetaObjectPrivate*>(metaobject->d.data); }
- static const char *rawStringData(const QMetaObject *mo, int index);
+ Q_CORE_EXPORT static const char *rawStringData(const QMetaObject *mo, int index);
static int indexOfSignalRelative(const QMetaObject **baseObject,
const char* name,
diff --git a/src/dbus/qdbusmetaobject.cpp b/src/dbus/qdbusmetaobject.cpp
index bd7b83bf65..eb2d3dffa8 100644
--- a/src/dbus/qdbusmetaobject.cpp
+++ b/src/dbus/qdbusmetaobject.cpp
@@ -54,6 +54,7 @@
#include "qdbusabstractinterface_p.h"
#include <private/qmetaobject_p.h>
+#include <private/qmetaobjectbuilder_p.h>
#ifndef QT_NO_DBUS
@@ -355,36 +356,6 @@ void QDBusMetaObjectGenerator::parseProperties()
void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj)
{
- class MetaStringTable
- {
- public:
- typedef QHash<QByteArray, int> Entries; // string --> offset mapping
- typedef Entries::const_iterator const_iterator;
- Entries::const_iterator constBegin() const
- { return m_entries.constBegin(); }
- Entries::const_iterator constEnd() const
- { return m_entries.constEnd(); }
-
- MetaStringTable() : m_offset(0) {}
-
- int enter(const QByteArray &value)
- {
- Entries::iterator it = m_entries.find(value);
- if (it != m_entries.end())
- return it.value();
- int pos = m_offset;
- m_entries.insert(value, pos);
- m_offset += value.size() + 1;
- return pos;
- }
-
- int arraySize() const { return m_offset; }
-
- private:
- Entries m_entries;
- int m_offset;
- };
-
// this code here is mostly copied from qaxbase.cpp
// with a few modifications to make it cleaner
@@ -397,7 +368,7 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj)
idata.resize(sizeof(QDBusMetaObjectPrivate) / sizeof(int));
QDBusMetaObjectPrivate *header = reinterpret_cast<QDBusMetaObjectPrivate *>(idata.data());
- Q_STATIC_ASSERT_X(QMetaObjectPrivate::OutputRevision == 6, "QtDBus meta-object generator should generate the same version as moc");
+ Q_STATIC_ASSERT_X(QMetaObjectPrivate::OutputRevision == 7, "QtDBus meta-object generator should generate the same version as moc");
header->revision = QMetaObjectPrivate::OutputRevision;
header->className = 0;
header->classInfoCount = 0;
@@ -425,7 +396,7 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj)
data_size += 2 + mm.inputTypes.count() + mm.outputTypes.count();
idata.resize(data_size + 1);
- MetaStringTable strings;
+ QMetaStringTable strings;
strings.enter(className.toLatin1());
int offset = header->methodData;
@@ -484,14 +455,8 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj)
Q_ASSERT(offset == header->propertyDBusData);
Q_ASSERT(signatureOffset == header->methodDBusData);
- char *string_data = new char[strings.arraySize()];
- {
- MetaStringTable::const_iterator it;
- for (it = strings.constBegin(); it != strings.constEnd(); ++it) {
- memcpy(string_data + it.value(), it.key().constData(), it.key().size());
- string_data[it.value() + it.key().size()] = '\0';
- }
- }
+ char *string_data = new char[strings.blobSize()];
+ strings.writeBlob(string_data);
uint *uint_data = new uint[idata.size()];
memcpy(uint_data, idata.data(), idata.size() * sizeof(int));
@@ -499,7 +464,7 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj)
// put the metaobject together
obj->d.data = uint_data;
obj->d.extradata = 0;
- obj->d.stringdata = string_data;
+ obj->d.stringdata = reinterpret_cast<const QByteArrayData *>(string_data);
obj->d.superdata = &QDBusAbstractInterface::staticMetaObject;
}
@@ -618,7 +583,7 @@ const char *QDBusMetaObject::dbusNameForMethod(int id) const
//id -= methodOffset();
if (id >= 0 && id < priv(d.data)->methodCount) {
int handle = priv(d.data)->methodDBusData + id*intsPerMethod;
- return d.stringdata + d.data[handle];
+ return QMetaObjectPrivate::rawStringData(this, d.data[handle]);
}
return 0;
}
diff --git a/src/dbus/qdbusmetaobject_p.h b/src/dbus/qdbusmetaobject_p.h
index 7a8de41fa0..23a7d53016 100644
--- a/src/dbus/qdbusmetaobject_p.h
+++ b/src/dbus/qdbusmetaobject_p.h
@@ -71,7 +71,7 @@ struct Q_DBUS_EXPORT QDBusMetaObject: public QMetaObject
QDBusError &error);
~QDBusMetaObject()
{
- delete [] d.stringdata;
+ delete [] reinterpret_cast<const char *>(d.stringdata);
delete [] d.data;
}