summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kanavin <alex.kanavin@gmail.com>2015-05-18 16:58:37 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-05-20 21:41:08 +0100
commitb2365c4e186bc57155edd68eed06e468b3aabdf4 (patch)
treef72813d9419d5cdf53f1154562d1c081ca1712bf
parent50ce68aa27e6620d76f71b8c20495d3db4e9f546 (diff)
downloadpoky-b2365c4e186bc57155edd68eed06e468b3aabdf4.tar.gz
qt4: remove Qt Mobility
Qt Mobility is an obsolete and unmaintained framework that is also dependent on gstreamer 0.10 https://bugzilla.yoctoproject.org/show_bug.cgi?id=6294 (From OE-Core rev: bbad6c226f1ff2657c6095141bbf3ec936a42feb) Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com> Signed-off-by: Alexander Kanavin <alexander.kanavin@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/recipes-qt/qt4/qt-mobility-1.2.0/0001-fix-embedded-usage-doesn-t-work-outside-of-Qt.patch73
-rw-r--r--meta/recipes-qt/qt4/qt-mobility-1.2.0/0001-gstvideoconnector-fixed-buffers-allocation.patch34
-rw-r--r--meta/recipes-qt/qt4/qt-mobility-1.2.0/0002-Remove-unnecessary-rpaths-from-qml_device-example.patch28
-rw-r--r--meta/recipes-qt/qt4/qt-mobility-1.2.0/fix-compile-error-no-bluez.patch338
-rw-r--r--meta/recipes-qt/qt4/qt-mobility-1.2.0/fix_metaobjectbuilder_build_err.patch4707
-rw-r--r--meta/recipes-qt/qt4/qt-mobility-1.2.0/gcc-scope.patch48
-rw-r--r--meta/recipes-qt/qt4/qt-mobility-1.2.0/qt-mobility-configure.patch17
-rw-r--r--meta/recipes-qt/qt4/qt-mobility-1.2.0/qt-mobility-no-opengl.patch38
-rw-r--r--meta/recipes-qt/qt4/qt-mobility-1.2.0/qt-mobility-no-xvideo.patch26
-rw-r--r--meta/recipes-qt/qt4/qt-mobility-embedded_1.2.0.bb11
-rw-r--r--meta/recipes-qt/qt4/qt-mobility-x11_1.2.0.bb10
-rw-r--r--meta/recipes-qt/qt4/qt-mobility_1.2.0.inc112
12 files changed, 0 insertions, 5442 deletions
diff --git a/meta/recipes-qt/qt4/qt-mobility-1.2.0/0001-fix-embedded-usage-doesn-t-work-outside-of-Qt.patch b/meta/recipes-qt/qt4/qt-mobility-1.2.0/0001-fix-embedded-usage-doesn-t-work-outside-of-Qt.patch
deleted file mode 100644
index d8d88c2cfc..0000000000
--- a/meta/recipes-qt/qt4/qt-mobility-1.2.0/0001-fix-embedded-usage-doesn-t-work-outside-of-Qt.patch
+++ /dev/null
@@ -1,73 +0,0 @@
1From de2b568a4f14f38ae26960f543277bd2ac57c9d6 Mon Sep 17 00:00:00 2001
2From: Alex <qt-info@nokia.com>
3Date: Tue, 10 May 2011 14:54:49 +1000
4Subject: [PATCH] fix !embedded usage (doesn't work outside of Qt)
5
6embedded is part of QT_CONFIG and not CONFIG
7
8Task-number: QTMOBILITY-1586
9---
10Upstream-Status: Backport
11https://qt.gitorious.org/qt-mobility/qt-mobility/commit/de2b568a4f14f38ae26960f543277bd2ac57c9d6
12EB: refreshed the patch for it to apply properly
13
14 plugins/multimedia/gstreamer/gstreamer.pro | 2 +-
15 src/systeminfo/systeminfo.pro | 6 +++---
16 tests/auto/auto.pro | 2 +-
17 3 files changed, 5 insertions(+), 5 deletions(-)
18
19Index: qt-mobility-opensource-src-1.2.0/plugins/multimedia/gstreamer/gstreamer.pro
20===================================================================
21--- qt-mobility-opensource-src-1.2.0.orig/plugins/multimedia/gstreamer/gstreamer.pro 2013-09-19 10:34:40.880862884 +0200
22+++ qt-mobility-opensource-src-1.2.0/plugins/multimedia/gstreamer/gstreamer.pro 2013-09-19 10:35:22.844862550 +0200
23@@ -85,7 +85,7 @@
24 qgstutils.cpp
25
26
27-!win32:!embedded:!mac:!symbian:!simulator:!contains(QT_CONFIG, qpa) {
28+!win32:!contains(QT_CONFIG,embedded):!mac:!symbian:!simulator:!contains(QT_CONFIG, qpa) {
29 LIBS += -lXv -lX11 -lXext
30
31 HEADERS += \
32Index: qt-mobility-opensource-src-1.2.0/src/systeminfo/systeminfo.pro
33===================================================================
34--- qt-mobility-opensource-src-1.2.0.orig/src/systeminfo/systeminfo.pro 2013-09-19 10:34:40.884862884 +0200
35+++ qt-mobility-opensource-src-1.2.0/src/systeminfo/systeminfo.pro 2013-09-19 10:36:05.480862210 +0200
36@@ -101,7 +101,7 @@
37 LIBS += -lblkid
38 }
39
40- !embedded:!contains(QT_CONFIG,qpa): {
41+ !contains(QT_CONFIG,embedded):!contains(QT_CONFIG,qpa): {
42 LIBS += -lX11 -lXrandr
43 }
44
45@@ -154,7 +154,7 @@
46 #for now... udisks
47 } else {
48 DEFINES += QT_NO_UDISKS
49- !embedded:!contains(QT_CONFIG,qpa): LIBS += -lX11 -lXrandr
50+ !contains(QT_CONFIG,embedded):!contains(QT_CONFIG,qpa): LIBS += -lX11 -lXrandr
51 }
52
53 contains(connman_enabled, yes): {
54@@ -165,7 +165,7 @@
55 }
56 } else {
57 DEFINES += QT_NO_NETWORKMANAGER QT_NO_UDISKS QT_NO_CONNMAN
58- !embedded:!contains(QT_CONFIG,qpa): LIBS += -lX11 -lXrandr
59+ !contains(QT_CONFIG,embedded):!contains(QT_CONFIG,qpa): LIBS += -lX11 -lXrandr
60 }
61 }
62
63Index: qt-mobility-opensource-src-1.2.0/tests/auto/auto.pro
64===================================================================
65--- qt-mobility-opensource-src-1.2.0.orig/tests/auto/auto.pro 2013-09-19 10:34:40.884862884 +0200
66+++ qt-mobility-opensource-src-1.2.0/tests/auto/auto.pro 2013-09-19 10:35:22.844862550 +0200
67@@ -21,5 +21,5 @@
68 # which require that the autotest is run on the same machine
69 # doing the build - i.e. cross-compilation is not allowed.
70 win32|mac|linux-g++* {
71- !embedded:!maemo5:!maemo6:SUBDIRS+=host.pro
72+ !contains(QT_CONFIG,embedded):!maemo5:!maemo6:SUBDIRS+=host.pro
73 }
diff --git a/meta/recipes-qt/qt4/qt-mobility-1.2.0/0001-gstvideoconnector-fixed-buffers-allocation.patch b/meta/recipes-qt/qt4/qt-mobility-1.2.0/0001-gstvideoconnector-fixed-buffers-allocation.patch
deleted file mode 100644
index 2df76fc778..0000000000
--- a/meta/recipes-qt/qt4/qt-mobility-1.2.0/0001-gstvideoconnector-fixed-buffers-allocation.patch
+++ /dev/null
@@ -1,34 +0,0 @@
1Upstream-Status: Submitted [QTMOBILITY-1611]
2
3From b308508b49afa9a129b4e4589c57cd107d1320b8 Mon Sep 17 00:00:00 2001
4From: Dmytro Poplavskiy <dmytro.poplavskiy@nokia.com>
5Date: Fri, 6 May 2011 10:35:11 +1000
6Subject: [PATCH] gstvideoconnector: fixed buffers allocation
7
8It should not be necessary, but at least theora video decoder doesn't
9iniatilize *buf, while gst_pad_alloc_buffer relies on buf being NULL.
10
11Task-number: QTMOBILITY-1611
12Reviewed-by: Michael Goddard
13---
14 plugins/multimedia/gstreamer/gstvideoconnector.c | 4 ++++
15 1 files changed, 4 insertions(+), 0 deletions(-)
16
17diff --git a/plugins/multimedia/gstreamer/gstvideoconnector.c b/plugins/multimedia/gstreamer/gstvideoconnector.c
18index ddf68e0..9f8ceae 100644
19--- a/plugins/multimedia/gstreamer/gstvideoconnector.c
20+++ b/plugins/multimedia/gstreamer/gstvideoconnector.c
21@@ -186,6 +186,10 @@ gst_video_connector_buffer_alloc (GstPad * pad, guint64 offset, guint size,
22 GstFlowReturn res = GST_FLOW_OK;
23 element = GST_VIDEO_CONNECTOR (GST_PAD_PARENT (pad));
24
25+ if (!buf)
26+ return GST_FLOW_ERROR;
27+ *buf = NULL;
28+
29 GST_OBJECT_LOCK (element);
30 gst_object_ref(element->srcpad);
31 GST_OBJECT_UNLOCK (element);
32--
331.7.4.1
34
diff --git a/meta/recipes-qt/qt4/qt-mobility-1.2.0/0002-Remove-unnecessary-rpaths-from-qml_device-example.patch b/meta/recipes-qt/qt4/qt-mobility-1.2.0/0002-Remove-unnecessary-rpaths-from-qml_device-example.patch
deleted file mode 100644
index a411640b73..0000000000
--- a/meta/recipes-qt/qt4/qt-mobility-1.2.0/0002-Remove-unnecessary-rpaths-from-qml_device-example.patch
+++ /dev/null
@@ -1,28 +0,0 @@
1From 92e0c611f4969c716616d64df64831387e5b1632 Mon Sep 17 00:00:00 2001
2From: Paul Eggleton <paul.eggleton@linux.intel.com>
3Date: Fri, 16 Mar 2012 10:24:00 +0000
4Subject: [PATCH] Remove unnecessary rpaths from qml_device example
5
6These can't be valid in any case.
7
8Upstream-Status: Pending
9
10Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
11---
12 examples/declarative-systeminfo/device/device.pro | 3 ---
13 1 files changed, 0 insertions(+), 3 deletions(-)
14
15diff --git a/examples/declarative-systeminfo/device/device.pro b/examples/declarative-systeminfo/device/device.pro
16index 698e5fb..05be9b7 100644
17--- a/examples/declarative-systeminfo/device/device.pro
18+++ b/examples/declarative-systeminfo/device/device.pro
19@@ -17,6 +17,3 @@ symbian {
20 }
21 RESOURCES += device.qrc
22
23-QMAKE_LFLAGS_DEBUG += "-Wl,-rpath,/home/user/qt/lib"
24-QMAKE_LFLAGS_RPATH += "-Wl,-rpath,/home/user/qt/lib"
25-QMAKE_LFLAGS_RELEASE += "-Wl,-rpath,/home/user/qt/lib"
26--
271.7.5.4
28
diff --git a/meta/recipes-qt/qt4/qt-mobility-1.2.0/fix-compile-error-no-bluez.patch b/meta/recipes-qt/qt4/qt-mobility-1.2.0/fix-compile-error-no-bluez.patch
deleted file mode 100644
index 3f03cf7165..0000000000
--- a/meta/recipes-qt/qt4/qt-mobility-1.2.0/fix-compile-error-no-bluez.patch
+++ /dev/null
@@ -1,338 +0,0 @@
1From bb05733bd5a685b00f80ddc73a1b7a9a2ba0eb11 Mon Sep 17 00:00:00 2001
2From: Andrew Stanley-Jones <andrew.stanley-jones@nokia.com>
3Date: Thu, 12 May 2011 13:07:13 +1000
4Subject: [PATCH] Fix compile error if bluez is not installed
5
6Upstream-Status: Backport
7
8Task-number: QTMOBILITY-1576
9---
10 src/connectivity/bluetooth/bluetooth.pri | 1 +
11 .../bluetooth/qbluetoothdevicediscoveryagent.h | 2 +-
12 .../bluetooth/qbluetoothdevicediscoveryagent_p.cpp | 2 +-
13 .../bluetooth/qbluetoothdevicediscoveryagent_p.h | 6 +++---
14 .../bluetooth/qbluetoothlocaldevice_p.h | 4 ++--
15 .../bluetooth/qbluetoothservicediscoveryagent.h | 2 +-
16 .../bluetooth/qbluetoothservicediscoveryagent_p.h | 8 ++++----
17 .../bluetooth/qbluetoothserviceinfo_p.cpp | 2 +-
18 .../bluetooth/qbluetoothserviceinfo_p.h | 4 ++--
19 src/connectivity/bluetooth/ql2capserver.h | 2 +-
20 src/connectivity/bluetooth/ql2capserver_p.cpp | 2 +-
21 src/connectivity/bluetooth/ql2capserver_p.h | 6 +++---
22 src/connectivity/bluetooth/qrfcommserver.h | 2 +-
23 src/connectivity/bluetooth/qrfcommserver_p.cpp | 2 +-
24 src/connectivity/bluetooth/qrfcommserver_p.h | 6 +++---
25 tests/tests.pro | 4 +++-
26 16 files changed, 29 insertions(+), 26 deletions(-)
27
28diff --git a/src/connectivity/bluetooth/bluetooth.pri b/src/connectivity/bluetooth/bluetooth.pri
29index 717a1ad..4fa2c15 100644
30--- a/src/connectivity/bluetooth/bluetooth.pri
31+++ b/src/connectivity/bluetooth/bluetooth.pri
32@@ -103,6 +103,7 @@ symbian {
33 }
34 } else:contains(bluez_enabled, yes):contains(QT_CONFIG, dbus) {
35 QT *= dbus
36+ DEFINES += QTM_BLUEZ_BLUETOOTH
37
38 include(bluez/bluez.pri)
39
40diff --git a/src/connectivity/bluetooth/qbluetoothdevicediscoveryagent.h b/src/connectivity/bluetooth/qbluetoothdevicediscoveryagent.h
41index a95c467..00cfd14 100644
42--- a/src/connectivity/bluetooth/qbluetoothdevicediscoveryagent.h
43+++ b/src/connectivity/bluetooth/qbluetoothdevicediscoveryagent.h
44@@ -101,7 +101,7 @@ private:
45 Q_DECLARE_PRIVATE(QBluetoothDeviceDiscoveryAgent)
46 QBluetoothDeviceDiscoveryAgentPrivate *d_ptr;
47
48-#ifndef QT_NO_DBUS
49+#ifdef QTM_BLUEZ_BLUETOOTH
50 Q_PRIVATE_SLOT(d_func(), void _q_deviceFound(const QString &address, const QVariantMap &dict));
51 Q_PRIVATE_SLOT(d_func(), void _q_propertyChanged(const QString &name, const QDBusVariant &value));
52 #endif
53diff --git a/src/connectivity/bluetooth/qbluetoothdevicediscoveryagent_p.cpp b/src/connectivity/bluetooth/qbluetoothdevicediscoveryagent_p.cpp
54index 6edbd16..512002d 100644
55--- a/src/connectivity/bluetooth/qbluetoothdevicediscoveryagent_p.cpp
56+++ b/src/connectivity/bluetooth/qbluetoothdevicediscoveryagent_p.cpp
57@@ -69,7 +69,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::start()
58 void QBluetoothDeviceDiscoveryAgentPrivate::stop()
59 {
60 }
61-#ifndef QT_NO_DBUS
62+#ifdef QTM_BLUEZ_BLUETOOTH
63 void QBluetoothDeviceDiscoveryAgentPrivate::_q_deviceFound(const QString &address,
64 const QVariantMap &dict)
65 {
66diff --git a/src/connectivity/bluetooth/qbluetoothdevicediscoveryagent_p.h b/src/connectivity/bluetooth/qbluetoothdevicediscoveryagent_p.h
67index 0e34e05..700e78d 100644
68--- a/src/connectivity/bluetooth/qbluetoothdevicediscoveryagent_p.h
69+++ b/src/connectivity/bluetooth/qbluetoothdevicediscoveryagent_p.h
70@@ -46,7 +46,7 @@
71
72 #include <QVariantMap>
73
74-#ifndef QT_NO_DBUS
75+#ifdef QTM_BLUEZ_BLUETOOTH
76 class OrgBluezManagerInterface;
77 class OrgBluezAdapterInterface;
78 class QDBusVariant;
79@@ -80,7 +80,7 @@ public:
80 QString errorDescription);
81 #endif
82
83-#ifndef QT_NO_DBUS
84+#ifdef QTM_BLUEZ_BLUETOOTH
85 void _q_deviceFound(const QString &address, const QVariantMap &dict);
86 void _q_propertyChanged(const QString &name, const QDBusVariant &value);
87 #endif
88@@ -100,7 +100,7 @@ private:
89 bool pendingCancel;
90 bool pendingStart;
91
92-#if !defined(QT_NO_DBUS)
93+#ifdef QTM_BLUEZ_BLUETOOTH
94 OrgBluezManagerInterface *manager;
95 OrgBluezAdapterInterface *adapter;
96 #endif
97diff --git a/src/connectivity/bluetooth/qbluetoothlocaldevice_p.h b/src/connectivity/bluetooth/qbluetoothlocaldevice_p.h
98index 750c286..381d6b5 100644
99--- a/src/connectivity/bluetooth/qbluetoothlocaldevice_p.h
100+++ b/src/connectivity/bluetooth/qbluetoothlocaldevice_p.h
101@@ -51,7 +51,7 @@
102 #include <btengsettings.h>
103 #endif
104
105-#ifndef QT_NO_DBUS
106+#ifdef QTM_BLUEZ_BLUETOOTH
107 #include <QObject>
108 #include <QDBusContext>
109 #include <QDBusObjectPath>
110@@ -68,7 +68,7 @@ QTM_BEGIN_NAMESPACE
111
112 class QBluetoothAddress;
113
114-#ifndef QT_NO_DBUS
115+#ifdef QTM_BLUEZ_BLUETOOTH
116 class QBluetoothLocalDevicePrivate : public QObject,
117 protected QDBusContext
118 {
119diff --git a/src/connectivity/bluetooth/qbluetoothservicediscoveryagent.h b/src/connectivity/bluetooth/qbluetoothservicediscoveryagent.h
120index 6279432..7eeccfc 100644
121--- a/src/connectivity/bluetooth/qbluetoothservicediscoveryagent.h
122+++ b/src/connectivity/bluetooth/qbluetoothservicediscoveryagent.h
123@@ -105,7 +105,7 @@ private:
124 Q_PRIVATE_SLOT(d_func(), void _q_deviceDiscovered(const QBluetoothDeviceInfo &info))
125 Q_PRIVATE_SLOT(d_func(), void _q_deviceDiscoveryFinished())
126 Q_PRIVATE_SLOT(d_func(), void _q_serviceDiscoveryFinished())
127-#ifndef QT_NO_DBUS
128+#ifdef QTM_BLUEZ_BLUETOOTH
129 Q_PRIVATE_SLOT(d_func(), void _q_discoveredServices(QDBusPendingCallWatcher*))
130 Q_PRIVATE_SLOT(d_func(), void _q_createdDevice(QDBusPendingCallWatcher*))
131 #endif
132diff --git a/src/connectivity/bluetooth/qbluetoothservicediscoveryagent_p.h b/src/connectivity/bluetooth/qbluetoothservicediscoveryagent_p.h
133index 5e7da43..f25c293 100644
134--- a/src/connectivity/bluetooth/qbluetoothservicediscoveryagent_p.h
135+++ b/src/connectivity/bluetooth/qbluetoothservicediscoveryagent_p.h
136@@ -53,7 +53,7 @@
137 #include <btsdp.h>
138 #endif
139
140-#ifndef QT_NO_DBUS
141+#ifdef QTM_BLUEZ_BLUETOOTH
142 class OrgBluezManagerInterface;
143 class OrgBluezAdapterInterface;
144 class OrgBluezDeviceInterface;
145@@ -99,7 +99,7 @@ public:
146 void _q_deviceDiscoveryFinished();
147 void _q_deviceDiscovered(const QBluetoothDeviceInfo &info);
148 void _q_serviceDiscoveryFinished();
149-#ifndef QT_NO_DBUS
150+#ifdef QTM_BLUEZ_BLUETOOTH
151 void _q_discoveredServices(QDBusPendingCallWatcher *watcher);
152 void _q_createdDevice(QDBusPendingCallWatcher *watcher);
153 #endif
154@@ -123,7 +123,7 @@ private:
155 #ifdef QTM_SYMBIAN_BLUETOOTH
156 void startL(const QBluetoothAddress &address);
157 void initL(const QBluetoothAddress &address);
158-#elif !defined(QT_NO_DBUS)
159+#elif defined(QTM_BLUEZ_BLUETOOTH)
160 QVariant readAttributeValue(QXmlStreamReader &xml);
161 #endif
162
163@@ -153,7 +153,7 @@ private:
164 TSdpAttributeID m_currentAttributeId;
165
166 QStack<QVariant> m_stack;
167-#elif !defined(QT_NO_DBUS)
168+#elif defined(QTM_BLUEZ_BLUETOOTH)
169 OrgBluezManagerInterface *manager;
170 OrgBluezAdapterInterface *adapter;
171 OrgBluezDeviceInterface *device;
172diff --git a/src/connectivity/bluetooth/qbluetoothserviceinfo_p.cpp b/src/connectivity/bluetooth/qbluetoothserviceinfo_p.cpp
173index 814458c..dd96dcc 100644
174--- a/src/connectivity/bluetooth/qbluetoothserviceinfo_p.cpp
175+++ b/src/connectivity/bluetooth/qbluetoothserviceinfo_p.cpp
176@@ -79,7 +79,7 @@ void QBluetoothServiceInfoPrivate::removeRegisteredAttribute(quint16 attributeId
177 Q_UNUSED(attributeId);
178 }
179
180-#ifndef QT_NO_DBUS
181+#ifdef QTM_BLUEZ_BLUETOOTH
182 bool QBluetoothServiceInfoPrivate::registerService() const
183 {
184 return false;
185diff --git a/src/connectivity/bluetooth/qbluetoothserviceinfo_p.h b/src/connectivity/bluetooth/qbluetoothserviceinfo_p.h
186index 5be7341..8e4254c 100644
187--- a/src/connectivity/bluetooth/qbluetoothserviceinfo_p.h
188+++ b/src/connectivity/bluetooth/qbluetoothserviceinfo_p.h
189@@ -72,7 +72,7 @@ public:
190
191 bool ensureSdpConnection() const;
192
193-#ifndef QT_NO_DBUS
194+#ifdef QTM_BLUEZ_BLUETOOTH
195 bool registerService() const;
196 #endif
197
198@@ -89,7 +89,7 @@ public:
199 mutable TSdpServRecordHandle serviceRecord;
200 #endif
201
202-#ifndef QT_NO_DBUS
203+#ifdef QTM_BLUEZ_BLUETOOTH
204 mutable OrgBluezServiceInterface *service;
205 mutable quint32 serviceRecord;
206 mutable bool registered;
207diff --git a/src/connectivity/bluetooth/ql2capserver.h b/src/connectivity/bluetooth/ql2capserver.h
208index 99c20a5..bed65a3 100644
209--- a/src/connectivity/bluetooth/ql2capserver.h
210+++ b/src/connectivity/bluetooth/ql2capserver.h
211@@ -97,7 +97,7 @@ private:
212 Q_PRIVATE_SLOT(d_func(), void _q_disconnected())
213 #endif //QTM_SYMBIAN_BLUETOOTH
214
215-#ifndef QT_NO_DBUS
216+#ifdef QTM_BLUEZ_BLUETOOTH
217 Q_PRIVATE_SLOT(d_func(), void _q_newConnection())
218 #endif
219
220diff --git a/src/connectivity/bluetooth/ql2capserver_p.cpp b/src/connectivity/bluetooth/ql2capserver_p.cpp
221index 3a2199f..f19977e 100644
222--- a/src/connectivity/bluetooth/ql2capserver_p.cpp
223+++ b/src/connectivity/bluetooth/ql2capserver_p.cpp
224@@ -101,7 +101,7 @@ QBluetooth::SecurityFlags QL2capServer::securityFlags() const
225
226
227
228-#ifndef QT_NO_DBUS
229+#ifdef QTM_BLUEZ_BLUETOOTH
230 void QL2capServerPrivate::_q_newConnection()
231 {
232 }
233diff --git a/src/connectivity/bluetooth/ql2capserver_p.h b/src/connectivity/bluetooth/ql2capserver_p.h
234index b5e76d9..2823106 100644
235--- a/src/connectivity/bluetooth/ql2capserver_p.h
236+++ b/src/connectivity/bluetooth/ql2capserver_p.h
237@@ -50,7 +50,7 @@
238 #include <bt_sock.h>
239 #endif //QTM_SYMBIAN_BLUETOOTH
240
241-#ifndef QT_NO_DBUS
242+#ifdef QTM_BLUEZ_BLUETOOTH
243 QT_FORWARD_DECLARE_CLASS(QSocketNotifier)
244 #endif
245
246@@ -82,7 +82,7 @@ public:
247 void _q_disconnected();
248 #endif //QTM_SYMBIAN_BLUETOOTH
249
250-#ifndef QT_NO_DBUS
251+#ifdef QTM_BLUEZ_BLUETOOTH
252 void _q_newConnection();
253 #endif
254
255@@ -103,7 +103,7 @@ protected:
256 QL2capServer *q_ptr;
257
258 private:
259-#ifndef QT_NO_DBUS
260+#ifdef QTM_BLUEZ_BLUETOOTH
261 QSocketNotifier *socketNotifier;
262 #endif
263 };
264diff --git a/src/connectivity/bluetooth/qrfcommserver.h b/src/connectivity/bluetooth/qrfcommserver.h
265index 3f348dd..7974ba6 100644
266--- a/src/connectivity/bluetooth/qrfcommserver.h
267+++ b/src/connectivity/bluetooth/qrfcommserver.h
268@@ -97,7 +97,7 @@ private:
269 Q_PRIVATE_SLOT(d_func(), void _q_disconnected())
270 #endif //QTM_SYMBIAN_BLUETOOTH
271
272-#ifndef QT_NO_DBUS
273+#ifdef QTM_BLUEZ_BLUETOOTH
274 Q_PRIVATE_SLOT(d_func(), void _q_newConnection())
275 #endif
276 };
277diff --git a/src/connectivity/bluetooth/qrfcommserver_p.cpp b/src/connectivity/bluetooth/qrfcommserver_p.cpp
278index f8145d9..eb14d64 100644
279--- a/src/connectivity/bluetooth/qrfcommserver_p.cpp
280+++ b/src/connectivity/bluetooth/qrfcommserver_p.cpp
281@@ -90,7 +90,7 @@ quint16 QRfcommServer::serverPort() const
282 }
283
284
285-#ifndef QT_NO_DBUS
286+#ifdef QTM_BLUEZ_BLUETOOTH
287 void QRfcommServerPrivate::_q_newConnection()
288 {
289 }
290diff --git a/src/connectivity/bluetooth/qrfcommserver_p.h b/src/connectivity/bluetooth/qrfcommserver_p.h
291index da6e28b..af40df7 100644
292--- a/src/connectivity/bluetooth/qrfcommserver_p.h
293+++ b/src/connectivity/bluetooth/qrfcommserver_p.h
294@@ -51,7 +51,7 @@
295 #include <bt_sock.h>
296 #endif
297
298-#ifndef QT_NO_DBUS
299+#ifdef QTM_BLUEZ_BLUETOOTH
300 QT_FORWARD_DECLARE_CLASS(QSocketNotifier)
301 #endif
302
303@@ -83,7 +83,7 @@ public:
304 void _q_disconnected();
305 #endif //QTM_SYMBIAN_BLUETOOTH
306
307-#ifndef QT_NO_DBUS
308+#ifdef QTM_BLUEZ_BLUETOOTH
309 void _q_newConnection();
310 #endif
311
312@@ -102,7 +102,7 @@ protected:
313 QRfcommServer *q_ptr;
314
315 private:
316-#ifndef QT_NO_DBUS
317+#ifdef QTM_BLUEZ_BLUETOOTH
318 QSocketNotifier *socketNotifier;
319 #endif
320 };
321diff --git a/tests/tests.pro b/tests/tests.pro
322index 2f2c355..4800e5e 100644
323--- a/tests/tests.pro
324+++ b/tests/tests.pro
325@@ -16,7 +16,9 @@ contains(mobility_modules,systeminfo): SUBDIRS += sysinfo-tester
326 contains(mobility_modules,connectivity) {
327 SUBDIRS += nfctestserver
328
329- linux*:!linux-armcc: SUBDIRS += btclient
330+ linux*:!linux-armcc:contains(bluez_enabled, yes):contains(QT_CONFIG, dbus) {
331+ SUBDIRS += btclient
332+ }
333 }
334
335 symbian {
336--
3371.7.1
338
diff --git a/meta/recipes-qt/qt4/qt-mobility-1.2.0/fix_metaobjectbuilder_build_err.patch b/meta/recipes-qt/qt4/qt-mobility-1.2.0/fix_metaobjectbuilder_build_err.patch
deleted file mode 100644
index cffb06706f..0000000000
--- a/meta/recipes-qt/qt4/qt-mobility-1.2.0/fix_metaobjectbuilder_build_err.patch
+++ /dev/null
@@ -1,4707 +0,0 @@
1Fix metaobjectbuilder build errors against Qt 4.8 and 4.7
2
3Error message:
4ipc/qmetaobjectbuilder.cpp:803:65: error: invalid conversion from \
5'QMetaObjectExtraData::StaticMetacallFunction {aka void (*)(QObject*, \
6QMetaObject::Call, int, void**)}' to 'QtMobility::QMetaObjectBuilder:: \
7StaticMetacallFunction {aka int (*)(QMetaObject::Call, int, void**)}
8
9Upstream-commit:
10http://qt.gitorious.org/qt-mobility/qt-mobility/commit/f102053b28009b3094b0e5777177208afa6097c5
11
12Task-number: QTMOBILITY-1990
13
14Upstream-Status: Backport
15
16Signed-off-by: Wenzong Fan <wenzong.fan@windriver.com>
17------------------------------------------------------
18diff --git a/plugins/declarative/common/dynamicproperties.pri b/plugins/declarative/common/dynamicproperties.pri
19index 52737a3..4bd06de 100644
20--- a/plugins/declarative/common/dynamicproperties.pri
21+++ b/plugins/declarative/common/dynamicproperties.pri
22@@ -1,6 +1,8 @@
23 INCLUDEPATH += ../../../plugins/declarative/common/dynamicproperties/
24-HEADERS += ../../../plugins/declarative/common/dynamicproperties/qdeclarativeopenmetaobject_p.h \
25- ../../../plugins/declarative/common/dynamicproperties/qmetaobjectbuilder_p.h
26-SOURCES += ../../../plugins/declarative/common/dynamicproperties/qdeclarativeopenmetaobject.cpp \
27- ../../../src/serviceframework/ipc/qmetaobjectbuilder.cpp
28-
29+HEADERS += ../../../plugins/declarative/common/dynamicproperties/qdeclarativeopenmetaobject_p.h
30+SOURCES += ../../../plugins/declarative/common/dynamicproperties/qdeclarativeopenmetaobject.cpp
31+include(../../../src/serviceframework/ipc/metaobjectbuilder.pri)
32+INCLUDEPATH += ../../../src/serviceframework/$$OBJECTBUILDER_INCLUDEPATH
33+DEPENDPATH += ../../../src/serviceframework/$$OBJECTBUILDER_DEPENDPATH
34+HEADERS += ../../../src/serviceframework/$$OBJECTBUILDER_HEADERS
35+SOURCES += ../../../src/serviceframework/$$OBJECTBUILDER_SOURCES
36diff --git a/plugins/declarative/common/dynamicproperties/qdeclarativeopenmetaobject.cpp b/plugins/declarative/common/dynamicproperties/qdeclarativeopenmetaobject.cpp
37index 79a2064..9eb6810 100644
38--- a/plugins/declarative/common/dynamicproperties/qdeclarativeopenmetaobject.cpp
39+++ b/plugins/declarative/common/dynamicproperties/qdeclarativeopenmetaobject.cpp
40@@ -65,8 +65,7 @@ public:
41 {
42 int id = mob.propertyCount();
43 mob.addSignal("__" + QByteArray::number(id) + "()");
44- QMetaPropertyBuilder build = mob.addProperty(name, type, id);
45- build.setDynamic(true);
46+ mob.addProperty(name, type, id);
47 qFree(mem);
48 mem = mob.toMetaObject();
49
50diff --git a/plugins/declarative/common/dynamicproperties/qmetaobjectbuilder_p.h b/plugins/declarative/common/dynamicproperties/qmetaobjectbuilder_p.h
51deleted file mode 100644
52index bd937e4..0000000
53--- a/plugins/declarative/common/dynamicproperties/qmetaobjectbuilder_p.h
54+++ /dev/null
55@@ -1,48 +0,0 @@
56-/****************************************************************************
57-**
58-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
59-** All rights reserved.
60-** Contact: Nokia Corporation (qt-info@nokia.com)
61-**
62-** This file is part of the Qt Mobility Components.
63-**
64-** $QT_BEGIN_LICENSE:LGPL$
65-** No Commercial Usage
66-** This file contains pre-release code and may not be distributed.
67-** You may use this file in accordance with the terms and conditions
68-** contained in the Technology Preview License Agreement accompanying
69-** this package.
70-**
71-** GNU Lesser General Public License Usage
72-** Alternatively, this file may be used under the terms of the GNU Lesser
73-** General Public License version 2.1 as published by the Free Software
74-** Foundation and appearing in the file LICENSE.LGPL included in the
75-** packaging of this file. Please review the following information to
76-** ensure the GNU Lesser General Public License version 2.1 requirements
77-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
78-**
79-** In addition, as a special exception, Nokia gives you certain additional
80-** rights. These rights are described in the Nokia Qt LGPL Exception
81-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
82-**
83-** If you have questions regarding the use of this file, please contact
84-** Nokia at qt-info@nokia.com.
85-**
86-**
87-**
88-**
89-**
90-**
91-**
92-**
93-** $QT_END_LICENSE$
94-**
95-****************************************************************************/
96-
97-/*
98-This header gets used in a number of different QML plugins
99-and also in the source tree of Mobility itself.
100-
101-So this header is just a wrapper to grab it from there.
102-*/
103-#include "../../../../src/serviceframework/ipc/qmetaobjectbuilder_p.h"
104diff --git a/src/serviceframework/ipc/ipc.pri b/src/serviceframework/ipc/ipc.pri
105index 28b910f..d809f59 100644
106--- a/src/serviceframework/ipc/ipc.pri
107+++ b/src/serviceframework/ipc/ipc.pri
108@@ -25,9 +25,14 @@ else {
109 }
110 }
111
112+include(metaobjectbuilder.pri)
113+INCLUDEPATH += $$OBJECTBUILDER_INCLUDEPATH
114+DEPENDPATH += $$OBJECTBUILDER_DEPENDPATH
115+PRIVATE_HEADERS += $$OBJECTBUILDER_HEADERS
116+SOURCES += $$OBJECTBUILDER_SOURCES
117+
118 PRIVATE_HEADERS += ipc/qslotinvoker_p.h \
119 ipc/qsignalintercepter_p.h \
120- ipc/qmetaobjectbuilder_p.h \
121 ipc/instancemanager_p.h \
122 ipc/qservicepackage_p.h \
123 ipc/proxyobject_p.h \
124@@ -37,7 +42,6 @@ PRIVATE_HEADERS += ipc/qslotinvoker_p.h \
125
126 SOURCES += ipc/qslotinvoker.cpp \
127 ipc/qsignalintercepter.cpp \
128- ipc/qmetaobjectbuilder.cpp \
129 ipc/instancemanager.cpp \
130 ipc/qservicepackage.cpp \
131 ipc/proxyobject.cpp \
132diff --git a/src/serviceframework/ipc/metaobjectbuilder.pri b/src/serviceframework/ipc/metaobjectbuilder.pri
133new file mode 100644
134index 0000000..cc905f9
135--- /dev/null
136+++ b/src/serviceframework/ipc/metaobjectbuilder.pri
137@@ -0,0 +1,12 @@
138+#check version for 4.7 ...
139+contains(QT_MAJOR_VERSION, 4):lessThan(QT_MINOR_VERSION, 8) {
140+ OBJECTBUILDER_INCLUDEPATH += ipc
141+ OBJECTBUILDER_DEPENDPATH += ipc
142+ OBJECTBUILDER_HEADERS += ipc/qmetaobjectbuilder_47_p.h
143+ OBJECTBUILDER_SOURCES += ipc/qmetaobjectbuilder_47.cpp
144+} else {
145+ OBJECTBUILDER_INCLUDEPATH += ipc
146+ OBJECTBUILDER_DEPENDPATH += ipc
147+ OBJECTBUILDER_HEADERS += ipc/qmetaobjectbuilder_p.h
148+ OBJECTBUILDER_SOURCES += ipc/qmetaobjectbuilder.cpp
149+}
150diff --git a/src/serviceframework/ipc/qmetaobjectbuilder.cpp b/src/serviceframework/ipc/qmetaobjectbuilder.cpp
151index b19eb1a..6ffaa20 100644
152--- a/src/serviceframework/ipc/qmetaobjectbuilder.cpp
153+++ b/src/serviceframework/ipc/qmetaobjectbuilder.cpp
154@@ -117,6 +117,8 @@ enum PropertyFlags {
155 EnumOrFlag = 0x00000008,
156 StdCppSet = 0x00000100,
157 // Override = 0x00000200,
158+ Constant = 0x00000400,
159+ Final = 0x00000800,
160 Designable = 0x00001000,
161 ResolveDesignable = 0x00002000,
162 Scriptable = 0x00004000,
163@@ -128,7 +130,7 @@ enum PropertyFlags {
164 User = 0x00100000,
165 ResolveUser = 0x00200000,
166 Notify = 0x00400000,
167- Dynamic = 0x00800000
168+ Revisioned = 0x00800000
169 };
170
171 enum MethodFlags {
172@@ -145,7 +147,8 @@ enum MethodFlags {
173
174 MethodCompatibility = 0x10,
175 MethodCloned = 0x20,
176- MethodScriptable = 0x40
177+ MethodScriptable = 0x40,
178+ MethodRevisioned = 0x80
179 };
180
181 struct QMetaObjectPrivate
182@@ -623,6 +626,8 @@ QMetaPropertyBuilder QMetaObjectBuilder::addProperty(const QMetaProperty& protot
183 property.setUser(prototype.isUser());
184 property.setStdCppSet(prototype.hasStdCppSet());
185 property.setEnumOrFlag(prototype.isEnumType());
186+ property.setConstant(prototype.isConstant());
187+ property.setFinal(prototype.isFinal());
188 if (prototype.hasNotifySignal()) {
189 // Find an existing method for the notify signal, or add a new one.
190 QMetaMethod method = prototype.notifySignal();
191@@ -796,7 +801,7 @@ void QMetaObjectBuilder::addMetaObject
192 }
193
194 if ((members & StaticMetacall) != 0) {
195- if (priv(prototype->d.data)->revision >= 2) {
196+ if (priv(prototype->d.data)->revision >= 6) {
197 const QMetaObjectExtraData *extra =
198 (const QMetaObjectExtraData *)(prototype->d.extradata);
199 if (extra && extra->static_metacall)
200@@ -1266,8 +1271,8 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
201 char *str = reinterpret_cast<char *>(buf + size);
202 if (buf) {
203 if (relocatable) {
204- meta->d.stringdata = reinterpret_cast<const char *>((intptr_t)size);
205- meta->d.data = reinterpret_cast<uint *>((intptr_t)pmetaSize);
206+ meta->d.stringdata = reinterpret_cast<const char *>((quintptr)size);
207+ meta->d.data = reinterpret_cast<uint *>((quintptr)pmetaSize);
208 } else {
209 meta->d.stringdata = str;
210 meta->d.data = reinterpret_cast<uint *>(data);
211@@ -1504,8 +1509,8 @@ void QMetaObjectBuilder::fromRelocatableData(QMetaObject *output,
212 const char *buf = data.constData();
213 const QMetaObject *dataMo = reinterpret_cast<const QMetaObject *>(buf);
214
215- intptr_t stringdataOffset = (intptr_t)dataMo->d.stringdata;
216- intptr_t dataOffset = (intptr_t)dataMo->d.data;
217+ quintptr stringdataOffset = (quintptr)dataMo->d.stringdata;
218+ quintptr dataOffset = (quintptr)dataMo->d.data;
219
220 output->d.superdata = superclass;
221 output->d.stringdata = buf + stringdataOffset;
222@@ -2289,16 +2294,27 @@ bool QMetaPropertyBuilder::isEnumOrFlag() const
223 }
224
225 /*!
226- Returns true if the property has the dynamic flag set;
227- otherwise returns false. The default value is false.
228+ Returns true if the property is constant; otherwise returns false.
229+ The default value is false.
230+*/
231+bool QMetaPropertyBuilder::isConstant() const
232+{
233+ QMetaPropertyBuilderPrivate *d = d_func();
234+ if (d)
235+ return d->flag(Constant);
236+ else
237+ return false;
238+}
239
240- \sa setDynamic()
241+/*!
242+ Returns true if the property is final; otherwise returns false.
243+ The default value is false.
244 */
245-bool QMetaPropertyBuilder::isDynamic() const
246+bool QMetaPropertyBuilder::isFinal() const
247 {
248 QMetaPropertyBuilderPrivate *d = d_func();
249 if (d)
250- return d->flag(Dynamic);
251+ return d->flag(Final);
252 else
253 return false;
254 }
255@@ -2427,16 +2443,27 @@ void QMetaPropertyBuilder::setEnumOrFlag(bool value)
256 }
257
258 /*!
259- Sets this property to have the dynamic flag if \a value is
260- true.
261+ Sets the \c CONSTANT flag on this property to \a value.
262+
263+ \sa isConstant()
264+*/
265+void QMetaPropertyBuilder::setConstant(bool value)
266+{
267+ QMetaPropertyBuilderPrivate *d = d_func();
268+ if (d)
269+ d->setFlag(Constant, value);
270+}
271+
272+/*!
273+ Sets the \c FINAL flag on this property to \a value.
274
275- \sa isDynamic()
276+ \sa isFinal()
277 */
278-void QMetaPropertyBuilder::setDynamic(bool value)
279+void QMetaPropertyBuilder::setFinal(bool value)
280 {
281 QMetaPropertyBuilderPrivate *d = d_func();
282 if (d)
283- d->setFlag(Dynamic, value);
284+ d->setFlag(Final, value);
285 }
286
287 /*!
288diff --git a/src/serviceframework/ipc/qmetaobjectbuilder_47.cpp b/src/serviceframework/ipc/qmetaobjectbuilder_47.cpp
289new file mode 100644
290index 0000000..509d6c6
291--- /dev/null
292+++ b/src/serviceframework/ipc/qmetaobjectbuilder_47.cpp
293@@ -0,0 +1,2583 @@
294+/****************************************************************************
295+**
296+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
297+** All rights reserved.
298+** Contact: Nokia Corporation (qt-info@nokia.com)
299+**
300+** This file is part of the QtDeclarative module of the Qt Toolkit.
301+**
302+** $QT_BEGIN_LICENSE:LGPL$
303+** No Commercial Usage
304+** This file contains pre-release code and may not be distributed.
305+** You may use this file in accordance with the terms and conditions
306+** contained in the Technology Preview License Agreement accompanying
307+** this package.
308+**
309+** GNU Lesser General Public License Usage
310+** Alternatively, this file may be used under the terms of the GNU Lesser
311+** General Public License version 2.1 as published by the Free Software
312+** Foundation and appearing in the file LICENSE.LGPL included in the
313+** packaging of this file. Please review the following information to
314+** ensure the GNU Lesser General Public License version 2.1 requirements
315+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
316+**
317+** In addition, as a special exception, Nokia gives you certain additional
318+** rights. These rights are described in the Nokia Qt LGPL Exception
319+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
320+**
321+** If you have questions regarding the use of this file, please contact
322+** Nokia at qt-info@nokia.com.
323+**
324+**
325+**
326+**
327+**
328+**
329+**
330+**
331+** $QT_END_LICENSE$
332+**
333+****************************************************************************/
334+
335+#include "qmetaobjectbuilder_47_p.h"
336+#include <QDebug>
337+
338+#ifndef Q_OS_WIN
339+#include <stdint.h>
340+#endif
341+
342+QTM_BEGIN_NAMESPACE
343+
344+/*!
345+ \class QMetaObjectBuilder
346+ \internal
347+ \brief The QMetaObjectBuilder class supports building QMetaObject objects at runtime.
348+ \since 1.1
349+
350+*/
351+
352+/*!
353+ \enum QMetaObjectBuilder::AddMember
354+ This enum defines which members of QMetaObject should be copied by QMetaObjectBuilder::addMetaObject()
355+
356+ \value ClassName Add the class name.
357+ \value SuperClass Add the super class.
358+ \value Methods Add methods that aren't signals or slots.
359+ \value Signals Add signals.
360+ \value Slots Add slots.
361+ \value Constructors Add constructors.
362+ \value Properties Add properties.
363+ \value Enumerators Add enumerators.
364+ \value ClassInfos Add items of class information.
365+ \value RelatedMetaObjects Add related meta objects.
366+ \value StaticMetacall Add the static metacall function.
367+ \value PublicMethods Add public methods (ignored for signals).
368+ \value ProtectedMethods Add protected methods (ignored for signals).
369+ \value PrivateMethods All private methods (ignored for signals).
370+ \value AllMembers Add all members.
371+ \value AllPrimaryMembers Add everything except the class name, super class, and static metacall function.
372+*/
373+
374+// copied from moc's generator.cpp
375+uint qvariant_nameToType(const char* name)
376+{
377+ if (!name)
378+ return 0;
379+
380+ if (strcmp(name, "QVariant") == 0)
381+ return 0xffffffff;
382+ if (strcmp(name, "QCString") == 0)
383+ return QMetaType::QByteArray;
384+ if (strcmp(name, "Q_LLONG") == 0)
385+ return QMetaType::LongLong;
386+ if (strcmp(name, "Q_ULLONG") == 0)
387+ return QMetaType::ULongLong;
388+ if (strcmp(name, "QIconSet") == 0)
389+ return QMetaType::QIcon;
390+
391+ uint tp = QMetaType::type(name);
392+ return tp < QMetaType::User ? tp : 0;
393+}
394+
395+/*
396+ Returns true if the type is a QVariant types.
397+*/
398+bool isVariantType(const char* type)
399+{
400+ return qvariant_nameToType(type) != 0;
401+}
402+
403+// copied from qmetaobject.cpp
404+// do not touch without touching the moc as well
405+enum PropertyFlags {
406+ Invalid = 0x00000000,
407+ Readable = 0x00000001,
408+ Writable = 0x00000002,
409+ Resettable = 0x00000004,
410+ EnumOrFlag = 0x00000008,
411+ StdCppSet = 0x00000100,
412+// Override = 0x00000200,
413+ Designable = 0x00001000,
414+ ResolveDesignable = 0x00002000,
415+ Scriptable = 0x00004000,
416+ ResolveScriptable = 0x00008000,
417+ Stored = 0x00010000,
418+ ResolveStored = 0x00020000,
419+ Editable = 0x00040000,
420+ ResolveEditable = 0x00080000,
421+ User = 0x00100000,
422+ ResolveUser = 0x00200000,
423+ Notify = 0x00400000,
424+ Dynamic = 0x00800000
425+};
426+
427+enum MethodFlags {
428+ AccessPrivate = 0x00,
429+ AccessProtected = 0x01,
430+ AccessPublic = 0x02,
431+ AccessMask = 0x03, //mask
432+
433+ MethodMethod = 0x00,
434+ MethodSignal = 0x04,
435+ MethodSlot = 0x08,
436+ MethodConstructor = 0x0c,
437+ MethodTypeMask = 0x0c,
438+
439+ MethodCompatibility = 0x10,
440+ MethodCloned = 0x20,
441+ MethodScriptable = 0x40
442+};
443+
444+struct QMetaObjectPrivate
445+{
446+ int revision;
447+ int className;
448+ int classInfoCount, classInfoData;
449+ int methodCount, methodData;
450+ int propertyCount, propertyData;
451+ int enumeratorCount, enumeratorData;
452+ int constructorCount, constructorData;
453+ int flags;
454+};
455+
456+static inline const QMetaObjectPrivate *priv(const uint* data)
457+{ return reinterpret_cast<const QMetaObjectPrivate*>(data); }
458+// end of copied lines from qmetaobject.cpp
459+
460+class QMetaMethodBuilderPrivate
461+{
462+public:
463+ QMetaMethodBuilderPrivate
464+ (QMetaMethod::MethodType _methodType,
465+ const QByteArray& _signature,
466+ const QByteArray& _returnType = QByteArray(),
467+ QMetaMethod::Access _access = QMetaMethod::Public)
468+ : signature(QMetaObject::normalizedSignature(_signature.constData())),
469+ returnType(QMetaObject::normalizedType(_returnType)),
470+ attributes(((int)_access) | (((int)_methodType) << 2))
471+ {
472+ }
473+
474+ QByteArray signature;
475+ QByteArray returnType;
476+ QList<QByteArray> parameterNames;
477+ QByteArray tag;
478+ int attributes;
479+
480+ QMetaMethod::MethodType methodType() const
481+ {
482+ return (QMetaMethod::MethodType)((attributes & MethodTypeMask) >> 2);
483+ }
484+
485+ QMetaMethod::Access access() const
486+ {
487+ return (QMetaMethod::Access)(attributes & AccessMask);
488+ }
489+
490+ void setAccess(QMetaMethod::Access value)
491+ {
492+ attributes = ((attributes & ~AccessMask) | (int)value);
493+ }
494+};
495+
496+class QMetaPropertyBuilderPrivate
497+{
498+public:
499+ QMetaPropertyBuilderPrivate
500+ (const QByteArray& _name, const QByteArray& _type, int notifierIdx=-1)
501+ : name(_name),
502+ type(QMetaObject::normalizedType(_type.constData())),
503+ flags(Readable | Writable | Scriptable), notifySignal(-1)
504+ {
505+ if (notifierIdx >= 0) {
506+ flags |= Notify;
507+ notifySignal = notifierIdx;
508+ }
509+ }
510+
511+ QByteArray name;
512+ QByteArray type;
513+ int flags;
514+ int notifySignal;
515+
516+ bool flag(int f) const
517+ {
518+ return ((flags & f) != 0);
519+ }
520+
521+ void setFlag(int f, bool value)
522+ {
523+ if (value)
524+ flags |= f;
525+ else
526+ flags &= ~f;
527+ }
528+};
529+
530+class QMetaEnumBuilderPrivate
531+{
532+public:
533+ QMetaEnumBuilderPrivate(const QByteArray& _name)
534+ : name(_name), isFlag(false)
535+ {
536+ }
537+
538+ QByteArray name;
539+ bool isFlag;
540+ QList<QByteArray> keys;
541+ QList<int> values;
542+};
543+
544+class QMetaObjectBuilderPrivate
545+{
546+public:
547+ QMetaObjectBuilderPrivate()
548+ : flags(0)
549+ {
550+ superClass = &QObject::staticMetaObject;
551+ staticMetacallFunction = 0;
552+ }
553+
554+ QByteArray className;
555+ const QMetaObject *superClass;
556+ QMetaObjectBuilder::StaticMetacallFunction staticMetacallFunction;
557+ QList<QMetaMethodBuilderPrivate> methods;
558+ QList<QMetaMethodBuilderPrivate> constructors;
559+ QList<QMetaPropertyBuilderPrivate> properties;
560+ QList<QByteArray> classInfoNames;
561+ QList<QByteArray> classInfoValues;
562+ QList<QMetaEnumBuilderPrivate> enumerators;
563+#ifdef Q_NO_DATA_RELOCATION
564+ QList<QMetaObjectAccessor> relatedMetaObjects;
565+#else
566+ QList<const QMetaObject *> relatedMetaObjects;
567+#endif
568+ int flags;
569+};
570+
571+/*!
572+ Constructs a new QMetaObjectBuilder.
573+*/
574+QMetaObjectBuilder::QMetaObjectBuilder()
575+{
576+ d = new QMetaObjectBuilderPrivate();
577+}
578+
579+/*!
580+ Constructs a new QMetaObjectBuilder which is a copy of the
581+ meta object information in \a prototype. Note: the super class
582+ contents for \a prototype are not copied, only the immediate
583+ class that is defined by \a prototype.
584+
585+ The \a members parameter indicates which members of \a prototype
586+ should be added. The default is AllMembers.
587+
588+ \sa addMetaObject()
589+*/
590+QMetaObjectBuilder::QMetaObjectBuilder
591+ (const QMetaObject *prototype, QMetaObjectBuilder::AddMembers members)
592+{
593+ d = new QMetaObjectBuilderPrivate();
594+ addMetaObject(prototype, members);
595+}
596+
597+/*!
598+ Destroys this meta object builder.
599+*/
600+QMetaObjectBuilder::~QMetaObjectBuilder()
601+{
602+ delete d;
603+}
604+
605+/*!
606+ Returns the name of the class being constructed by this
607+ meta object builder. The default value is an empty QByteArray.
608+
609+ \sa setClassName(), superClass()
610+*/
611+QByteArray QMetaObjectBuilder::className() const
612+{
613+ return d->className;
614+}
615+
616+/*!
617+ Sets the \a name of the class being constructed by this
618+ meta object builder.
619+
620+ \sa className(), setSuperClass()
621+*/
622+void QMetaObjectBuilder::setClassName(const QByteArray& name)
623+{
624+ d->className = name;
625+}
626+
627+/*!
628+ Returns the superclass meta object of the class being constructed
629+ by this meta object builder. The default value is the meta object
630+ for QObject.
631+
632+ \sa setSuperClass(), className()
633+*/
634+const QMetaObject *QMetaObjectBuilder::superClass() const
635+{
636+ return d->superClass;
637+}
638+
639+/*!
640+ Sets the superclass meta object of the class being constructed
641+ by this meta object builder to \a meta. The \a meta parameter
642+ must not be null.
643+
644+ \sa superClass(), setClassName()
645+*/
646+void QMetaObjectBuilder::setSuperClass(const QMetaObject *meta)
647+{
648+ Q_ASSERT(meta);
649+ d->superClass = meta;
650+}
651+
652+/*!
653+ Returns the flags of the class being constructed by this meta object
654+ builder.
655+
656+ \sa setFlags()
657+*/
658+QMetaObjectBuilder::MetaObjectFlags QMetaObjectBuilder::flags() const
659+{
660+ return (QMetaObjectBuilder::MetaObjectFlags)d->flags;
661+}
662+
663+/*!
664+ Sets the \a flags of the class being constructed by this meta object
665+ builder.
666+
667+ \sa flags()
668+*/
669+void QMetaObjectBuilder::setFlags(MetaObjectFlags flags)
670+{
671+ d->flags = flags;
672+}
673+
674+/*!
675+ Returns the number of methods in this class, excluding the number
676+ of methods in the base class. These include signals and slots
677+ as well as normal member functions.
678+
679+ \sa addMethod(), method(), removeMethod(), indexOfMethod()
680+*/
681+int QMetaObjectBuilder::methodCount() const
682+{
683+ return d->methods.size();
684+}
685+
686+/*!
687+ Returns the number of constructors in this class.
688+
689+ \sa addConstructor(), constructor(), removeConstructor(), indexOfConstructor()
690+*/
691+int QMetaObjectBuilder::constructorCount() const
692+{
693+ return d->constructors.size();
694+}
695+
696+/*!
697+ Returns the number of properties in this class, excluding the number
698+ of properties in the base class.
699+
700+ \sa addProperty(), property(), removeProperty(), indexOfProperty()
701+*/
702+int QMetaObjectBuilder::propertyCount() const
703+{
704+ return d->properties.size();
705+}
706+
707+/*!
708+ Returns the number of enumerators in this class, excluding the
709+ number of enumerators in the base class.
710+
711+ \sa addEnumerator(), enumerator(), removeEnumerator()
712+ \sa indexOfEnumerator()
713+*/
714+int QMetaObjectBuilder::enumeratorCount() const
715+{
716+ return d->enumerators.size();
717+}
718+
719+/*!
720+ Returns the number of items of class information in this class,
721+ exclusing the number of items of class information in the base class.
722+
723+ \sa addClassInfo(), classInfoName(), classInfoValue(), removeClassInfo()
724+ \sa indexOfClassInfo()
725+*/
726+int QMetaObjectBuilder::classInfoCount() const
727+{
728+ return d->classInfoNames.size();
729+}
730+
731+/*!
732+ Returns the number of related meta objects that are associated
733+ with this class.
734+
735+ Related meta objects are used when resolving the enumerated type
736+ associated with a property, where the enumerated type is in a
737+ different class from the property.
738+
739+ \sa addRelatedMetaObject(), relatedMetaObject()
740+ \sa removeRelatedMetaObject()
741+*/
742+int QMetaObjectBuilder::relatedMetaObjectCount() const
743+{
744+ return d->relatedMetaObjects.size();
745+}
746+
747+/*!
748+ Adds a new public method to this class with the specified \a signature.
749+ Returns an object that can be used to adjust the other attributes
750+ of the method. The \a signature will be normalized before it is
751+ added to the class.
752+
753+ \sa method(), methodCount(), removeMethod(), indexOfMethod()
754+*/
755+QMetaMethodBuilder QMetaObjectBuilder::addMethod(const QByteArray& signature)
756+{
757+ int index = d->methods.size();
758+ d->methods.append(QMetaMethodBuilderPrivate(QMetaMethod::Method, signature));
759+ return QMetaMethodBuilder(this, index);
760+}
761+
762+/*!
763+ Adds a new public method to this class with the specified
764+ \a signature and \a returnType. Returns an object that can be
765+ used to adjust the other attributes of the method. The \a signature
766+ and \a returnType will be normalized before they are added to
767+ the class. If \a returnType is empty, then it indicates that
768+ the method has \c{void} as its return type.
769+
770+ \sa method(), methodCount(), removeMethod(), indexOfMethod()
771+*/
772+QMetaMethodBuilder QMetaObjectBuilder::addMethod
773+ (const QByteArray& signature, const QByteArray& returnType)
774+{
775+ int index = d->methods.size();
776+ d->methods.append(QMetaMethodBuilderPrivate
777+ (QMetaMethod::Method, signature, returnType));
778+ return QMetaMethodBuilder(this, index);
779+}
780+
781+/*!
782+ Adds a new public method to this class that has the same information as
783+ \a prototype. This is used to clone the methods of an existing
784+ QMetaObject. Returns an object that can be used to adjust the
785+ attributes of the method.
786+
787+ This function will detect if \a prototype is an ordinary method,
788+ signal, slot, or constructor and act accordingly.
789+
790+ \sa method(), methodCount(), removeMethod(), indexOfMethod()
791+*/
792+QMetaMethodBuilder QMetaObjectBuilder::addMethod(const QMetaMethod& prototype)
793+{
794+ QMetaMethodBuilder method;
795+ if (prototype.methodType() == QMetaMethod::Method)
796+ method = addMethod(prototype.signature());
797+ else if (prototype.methodType() == QMetaMethod::Signal)
798+ method = addSignal(prototype.signature());
799+ else if (prototype.methodType() == QMetaMethod::Slot)
800+ method = addSlot(prototype.signature());
801+ else if (prototype.methodType() == QMetaMethod::Constructor)
802+ method = addConstructor(prototype.signature());
803+ method.setReturnType(prototype.typeName());
804+ method.setParameterNames(prototype.parameterNames());
805+ method.setTag(prototype.tag());
806+ method.setAccess(prototype.access());
807+ method.setAttributes(prototype.attributes());
808+ return method;
809+}
810+
811+/*!
812+ Adds a new public slot to this class with the specified \a signature.
813+ Returns an object that can be used to adjust the other attributes
814+ of the slot. The \a signature will be normalized before it is
815+ added to the class.
816+
817+ \sa addMethod(), addSignal(), indexOfSlot()
818+*/
819+QMetaMethodBuilder QMetaObjectBuilder::addSlot(const QByteArray& signature)
820+{
821+ int index = d->methods.size();
822+ d->methods.append(QMetaMethodBuilderPrivate(QMetaMethod::Slot, signature));
823+ return QMetaMethodBuilder(this, index);
824+}
825+
826+/*!
827+ Adds a new signal to this class with the specified \a signature.
828+ Returns an object that can be used to adjust the other attributes
829+ of the signal. The \a signature will be normalized before it is
830+ added to the class.
831+
832+ \sa addMethod(), addSlot(), indexOfSignal()
833+*/
834+QMetaMethodBuilder QMetaObjectBuilder::addSignal(const QByteArray& signature)
835+{
836+ int index = d->methods.size();
837+ d->methods.append(QMetaMethodBuilderPrivate
838+ (QMetaMethod::Signal, signature, QByteArray(), QMetaMethod::Protected));
839+ return QMetaMethodBuilder(this, index);
840+}
841+
842+/*!
843+ Adds a new constructor to this class with the specified \a signature.
844+ Returns an object that can be used to adjust the other attributes
845+ of the constructor. The \a signature will be normalized before it is
846+ added to the class.
847+
848+ \sa constructor(), constructorCount(), removeConstructor()
849+ \sa indexOfConstructor()
850+*/
851+QMetaMethodBuilder QMetaObjectBuilder::addConstructor(const QByteArray& signature)
852+{
853+ int index = d->constructors.size();
854+ d->constructors.append(QMetaMethodBuilderPrivate(QMetaMethod::Constructor, signature));
855+ return QMetaMethodBuilder(this, -(index + 1));
856+}
857+
858+/*!
859+ Adds a new constructor to this class that has the same information as
860+ \a prototype. This is used to clone the constructors of an existing
861+ QMetaObject. Returns an object that can be used to adjust the
862+ attributes of the constructor.
863+
864+ This function requires that \a prototype be a constructor.
865+
866+ \sa constructor(), constructorCount(), removeConstructor()
867+ \sa indexOfConstructor()
868+*/
869+QMetaMethodBuilder QMetaObjectBuilder::addConstructor(const QMetaMethod& prototype)
870+{
871+ Q_ASSERT(prototype.methodType() == QMetaMethod::Constructor);
872+ QMetaMethodBuilder ctor = addConstructor(prototype.signature());
873+ ctor.setReturnType(prototype.typeName());
874+ ctor.setParameterNames(prototype.parameterNames());
875+ ctor.setTag(prototype.tag());
876+ ctor.setAccess(prototype.access());
877+ ctor.setAttributes(prototype.attributes());
878+ return ctor;
879+}
880+
881+/*!
882+ Adds a new readable/writable property to this class with the
883+ specified \a name and \a type. Returns an object that can be used
884+ to adjust the other attributes of the property. The \a type will
885+ be normalized before it is added to the class. \a notifierId will
886+ be registered as the property's \e notify signal.
887+
888+ \sa property(), propertyCount(), removeProperty(), indexOfProperty()
889+*/
890+QMetaPropertyBuilder QMetaObjectBuilder::addProperty
891+ (const QByteArray& name, const QByteArray& type, int notifierId)
892+{
893+ int index = d->properties.size();
894+ d->properties.append(QMetaPropertyBuilderPrivate(name, type, notifierId));
895+ return QMetaPropertyBuilder(this, index);
896+}
897+
898+/*!
899+ Adds a new property to this class that has the same information as
900+ \a prototype. This is used to clone the properties of an existing
901+ QMetaObject. Returns an object that can be used to adjust the
902+ attributes of the property.
903+
904+ \sa property(), propertyCount(), removeProperty(), indexOfProperty()
905+*/
906+QMetaPropertyBuilder QMetaObjectBuilder::addProperty(const QMetaProperty& prototype)
907+{
908+ QMetaPropertyBuilder property = addProperty(prototype.name(), prototype.typeName());
909+ property.setReadable(prototype.isReadable());
910+ property.setWritable(prototype.isWritable());
911+ property.setResettable(prototype.isResettable());
912+ property.setDesignable(prototype.isDesignable());
913+ property.setScriptable(prototype.isScriptable());
914+ property.setStored(prototype.isStored());
915+ property.setEditable(prototype.isEditable());
916+ property.setUser(prototype.isUser());
917+ property.setStdCppSet(prototype.hasStdCppSet());
918+ property.setEnumOrFlag(prototype.isEnumType());
919+ if (prototype.hasNotifySignal()) {
920+ // Find an existing method for the notify signal, or add a new one.
921+ QMetaMethod method = prototype.notifySignal();
922+ int index = indexOfMethod(method.signature());
923+ if (index == -1)
924+ index = addMethod(method).index();
925+ d->properties[property._index].notifySignal = index;
926+ d->properties[property._index].setFlag(Notify, true);
927+ }
928+ return property;
929+}
930+
931+/*!
932+ Adds a new enumerator to this class with the specified
933+ \a name. Returns an object that can be used to adjust
934+ the other attributes of the enumerator.
935+
936+ \sa enumerator(), enumeratorCount(), removeEnumerator(),
937+ \sa indexOfEnumerator()
938+*/
939+QMetaEnumBuilder QMetaObjectBuilder::addEnumerator(const QByteArray& name)
940+{
941+ int index = d->enumerators.size();
942+ d->enumerators.append(QMetaEnumBuilderPrivate(name));
943+ return QMetaEnumBuilder(this, index);
944+}
945+
946+/*!
947+ Adds a new enumerator to this class that has the same information as
948+ \a prototype. This is used to clone the enumerators of an existing
949+ QMetaObject. Returns an object that can be used to adjust the
950+ attributes of the enumerator.
951+
952+ \sa enumerator(), enumeratorCount(), removeEnumerator(),
953+ \sa indexOfEnumerator()
954+*/
955+QMetaEnumBuilder QMetaObjectBuilder::addEnumerator(const QMetaEnum& prototype)
956+{
957+ QMetaEnumBuilder en = addEnumerator(prototype.name());
958+ en.setIsFlag(prototype.isFlag());
959+ int count = prototype.keyCount();
960+ for (int index = 0; index < count; ++index)
961+ en.addKey(prototype.key(index), prototype.value(index));
962+ return en;
963+}
964+
965+/*!
966+ Adds \a name and \a value as an item of class information to this class.
967+ Returns the index of the new item of class information.
968+
969+ \sa classInfoCount(), classInfoName(), classInfoValue(), removeClassInfo()
970+ \sa indexOfClassInfo()
971+*/
972+int QMetaObjectBuilder::addClassInfo(const QByteArray& name, const QByteArray& value)
973+{
974+ int index = d->classInfoNames.size();
975+ d->classInfoNames += name;
976+ d->classInfoValues += value;
977+ return index;
978+}
979+
980+/*!
981+ Adds \a meta to this class as a related meta object. Returns
982+ the index of the new related meta object entry.
983+
984+ Related meta objects are used when resolving the enumerated type
985+ associated with a property, where the enumerated type is in a
986+ different class from the property.
987+
988+ \sa relatedMetaObjectCount(), relatedMetaObject()
989+ \sa removeRelatedMetaObject()
990+*/
991+#ifdef Q_NO_DATA_RELOCATION
992+int QMetaObjectBuilder::addRelatedMetaObject(const QMetaObjectAccessor &meta)
993+#else
994+int QMetaObjectBuilder::addRelatedMetaObject(const QMetaObject *meta)
995+#endif
996+{
997+ Q_ASSERT(meta);
998+ int index = d->relatedMetaObjects.size();
999+ d->relatedMetaObjects.append(meta);
1000+ return index;
1001+}
1002+
1003+/*!
1004+ Adds the contents of \a prototype to this meta object builder.
1005+ This function is useful for cloning the contents of an existing QMetaObject.
1006+
1007+ The \a members parameter indicates which members of \a prototype
1008+ should be added. The default is AllMembers.
1009+*/
1010+void QMetaObjectBuilder::addMetaObject
1011+ (const QMetaObject *prototype, QMetaObjectBuilder::AddMembers members)
1012+{
1013+ Q_ASSERT(prototype);
1014+ int index;
1015+
1016+ if ((members & ClassName) != 0)
1017+ d->className = prototype->className();
1018+
1019+ if ((members & SuperClass) != 0)
1020+ d->superClass = prototype->superClass();
1021+
1022+ if ((members & (Methods | Signals | Slots)) != 0) {
1023+ for (index = prototype->methodOffset(); index < prototype->methodCount(); ++index) {
1024+ QMetaMethod method = prototype->method(index);
1025+ if (method.methodType() != QMetaMethod::Signal) {
1026+ if (method.access() == QMetaMethod::Public && (members & PublicMethods) == 0)
1027+ continue;
1028+ if (method.access() == QMetaMethod::Private && (members & PrivateMethods) == 0)
1029+ continue;
1030+ if (method.access() == QMetaMethod::Protected && (members & ProtectedMethods) == 0)
1031+ continue;
1032+ }
1033+ if (method.methodType() == QMetaMethod::Method && (members & Methods) != 0) {
1034+ addMethod(method);
1035+ } else if (method.methodType() == QMetaMethod::Signal &&
1036+ (members & Signals) != 0) {
1037+ addMethod(method);
1038+ } else if (method.methodType() == QMetaMethod::Slot &&
1039+ (members & Slots) != 0) {
1040+ addMethod(method);
1041+ }
1042+ }
1043+ }
1044+
1045+ if ((members & Constructors) != 0) {
1046+ for (index = 0; index < prototype->constructorCount(); ++index)
1047+ addConstructor(prototype->constructor(index));
1048+ }
1049+
1050+ if ((members & Properties) != 0) {
1051+ for (index = prototype->propertyOffset(); index < prototype->propertyCount(); ++index)
1052+ addProperty(prototype->property(index));
1053+ }
1054+
1055+ if ((members & Enumerators) != 0) {
1056+ for (index = prototype->enumeratorOffset(); index < prototype->enumeratorCount(); ++index)
1057+ addEnumerator(prototype->enumerator(index));
1058+ }
1059+
1060+ if ((members & ClassInfos) != 0) {
1061+ for (index = prototype->classInfoOffset(); index < prototype->classInfoCount(); ++index) {
1062+ QMetaClassInfo ci = prototype->classInfo(index);
1063+ addClassInfo(ci.name(), ci.value());
1064+ }
1065+ }
1066+
1067+ if ((members & RelatedMetaObjects) != 0) {
1068+#ifdef Q_NO_DATA_RELOCATION
1069+ const QMetaObjectAccessor *objects = 0;
1070+#else
1071+ const QMetaObject **objects;
1072+ if (priv(prototype->d.data)->revision < 2) {
1073+ objects = (const QMetaObject **)(prototype->d.extradata);
1074+ } else
1075+#endif
1076+ {
1077+ const QMetaObjectExtraData *extra = (const QMetaObjectExtraData *)(prototype->d.extradata);
1078+ if (extra)
1079+ objects = extra->objects;
1080+ else
1081+ objects = 0;
1082+ }
1083+ if (objects) {
1084+ while (*objects != 0) {
1085+ addRelatedMetaObject(*objects);
1086+ ++objects;
1087+ }
1088+ }
1089+ }
1090+
1091+ if ((members & StaticMetacall) != 0) {
1092+ if (priv(prototype->d.data)->revision >= 2) {
1093+ const QMetaObjectExtraData *extra =
1094+ (const QMetaObjectExtraData *)(prototype->d.extradata);
1095+ if (extra && extra->static_metacall)
1096+ setStaticMetacallFunction(extra->static_metacall);
1097+ }
1098+ }
1099+}
1100+
1101+/*!
1102+ Returns the method at \a index in this class.
1103+
1104+ \sa methodCount(), addMethod(), removeMethod(), indexOfMethod()
1105+*/
1106+QMetaMethodBuilder QMetaObjectBuilder::method(int index) const
1107+{
1108+ if (index >= 0 && index < d->methods.size())
1109+ return QMetaMethodBuilder(this, index);
1110+ else
1111+ return QMetaMethodBuilder();
1112+}
1113+
1114+/*!
1115+ Returns the constructor at \a index in this class.
1116+
1117+ \sa methodCount(), addMethod(), removeMethod(), indexOfConstructor()
1118+*/
1119+QMetaMethodBuilder QMetaObjectBuilder::constructor(int index) const
1120+{
1121+ if (index >= 0 && index < d->constructors.size())
1122+ return QMetaMethodBuilder(this, -(index + 1));
1123+ else
1124+ return QMetaMethodBuilder();
1125+}
1126+
1127+/*!
1128+ Returns the property at \a index in this class.
1129+
1130+ \sa methodCount(), addMethod(), removeMethod(), indexOfProperty()
1131+*/
1132+QMetaPropertyBuilder QMetaObjectBuilder::property(int index) const
1133+{
1134+ if (index >= 0 && index < d->properties.size())
1135+ return QMetaPropertyBuilder(this, index);
1136+ else
1137+ return QMetaPropertyBuilder();
1138+}
1139+
1140+/*!
1141+ Returns the enumerator at \a index in this class.
1142+
1143+ \sa enumeratorCount(), addEnumerator(), removeEnumerator()
1144+ \sa indexOfEnumerator()
1145+*/
1146+QMetaEnumBuilder QMetaObjectBuilder::enumerator(int index) const
1147+{
1148+ if (index >= 0 && index < d->enumerators.size())
1149+ return QMetaEnumBuilder(this, index);
1150+ else
1151+ return QMetaEnumBuilder();
1152+}
1153+
1154+/*!
1155+ Returns the related meta object at \a index in this class.
1156+
1157+ Related meta objects are used when resolving the enumerated type
1158+ associated with a property, where the enumerated type is in a
1159+ different class from the property.
1160+
1161+ \sa relatedMetaObjectCount(), addRelatedMetaObject()
1162+ \sa removeRelatedMetaObject()
1163+*/
1164+const QMetaObject *QMetaObjectBuilder::relatedMetaObject(int index) const
1165+{
1166+ if (index >= 0 && index < d->relatedMetaObjects.size())
1167+#ifdef Q_NO_DATA_RELOCATION
1168+ return &((*(d->relatedMetaObjects[index]))());
1169+#else
1170+ return d->relatedMetaObjects[index];
1171+#endif
1172+ else
1173+ return 0;
1174+}
1175+
1176+/*!
1177+ Returns the name of the item of class information at \a index
1178+ in this class.
1179+
1180+ \sa classInfoCount(), addClassInfo(), classInfoValue(), removeClassInfo()
1181+ \sa indexOfClassInfo()
1182+*/
1183+QByteArray QMetaObjectBuilder::classInfoName(int index) const
1184+{
1185+ if (index >= 0 && index < d->classInfoNames.size())
1186+ return d->classInfoNames[index];
1187+ else
1188+ return QByteArray();
1189+}
1190+
1191+/*!
1192+ Returns the value of the item of class information at \a index
1193+ in this class.
1194+
1195+ \sa classInfoCount(), addClassInfo(), classInfoName(), removeClassInfo()
1196+ \sa indexOfClassInfo()
1197+*/
1198+QByteArray QMetaObjectBuilder::classInfoValue(int index) const
1199+{
1200+ if (index >= 0 && index < d->classInfoValues.size())
1201+ return d->classInfoValues[index];
1202+ else
1203+ return QByteArray();
1204+}
1205+
1206+/*!
1207+ Removes the method at \a index from this class. The indices of
1208+ all following methods will be adjusted downwards by 1. If the
1209+ method is registered as a notify signal on a property, then the
1210+ notify signal will be removed from the property.
1211+
1212+ \sa methodCount(), addMethod(), method(), indexOfMethod()
1213+*/
1214+void QMetaObjectBuilder::removeMethod(int index)
1215+{
1216+ if (index >= 0 && index < d->methods.size()) {
1217+ d->methods.removeAt(index);
1218+ for (int prop = 0; prop < d->properties.size(); ++prop) {
1219+ // Adjust the indices of property notify signal references.
1220+ if (d->properties[prop].notifySignal == index) {
1221+ d->properties[prop].notifySignal = -1;
1222+ d->properties[prop].setFlag(Notify, false);
1223+ } else if (d->properties[prop].notifySignal > index)
1224+ (d->properties[prop].notifySignal)--;
1225+ }
1226+ }
1227+}
1228+
1229+/*!
1230+ Removes the constructor at \a index from this class. The indices of
1231+ all following constructors will be adjusted downwards by 1.
1232+
1233+ \sa constructorCount(), addConstructor(), constructor()
1234+ \sa indexOfConstructor()
1235+*/
1236+void QMetaObjectBuilder::removeConstructor(int index)
1237+{
1238+ if (index >= 0 && index < d->constructors.size())
1239+ d->constructors.removeAt(index);
1240+}
1241+
1242+/*!
1243+ Removes the property at \a index from this class. The indices of
1244+ all following properties will be adjusted downwards by 1.
1245+
1246+ \sa propertyCount(), addProperty(), property(), indexOfProperty()
1247+*/
1248+void QMetaObjectBuilder::removeProperty(int index)
1249+{
1250+ if (index >= 0 && index < d->properties.size())
1251+ d->properties.removeAt(index);
1252+}
1253+
1254+/*!
1255+ Removes the enumerator at \a index from this class. The indices of
1256+ all following enumerators will be adjusted downwards by 1.
1257+
1258+ \sa enumertorCount(), addEnumerator(), enumerator()
1259+ \sa indexOfEnumerator()
1260+*/
1261+void QMetaObjectBuilder::removeEnumerator(int index)
1262+{
1263+ if (index >= 0 && index < d->enumerators.size())
1264+ d->enumerators.removeAt(index);
1265+}
1266+
1267+/*!
1268+ Removes the item of class information at \a index from this class.
1269+ The indices of all following items will be adjusted downwards by 1.
1270+
1271+ \sa classInfoCount(), addClassInfo(), classInfoName(), classInfoValue()
1272+ \sa indexOfClassInfo()
1273+*/
1274+void QMetaObjectBuilder::removeClassInfo(int index)
1275+{
1276+ if (index >= 0 && index < d->classInfoNames.size()) {
1277+ d->classInfoNames.removeAt(index);
1278+ d->classInfoValues.removeAt(index);
1279+ }
1280+}
1281+
1282+/*!
1283+ Removes the related meta object at \a index from this class.
1284+ The indices of all following related meta objects will be adjusted
1285+ downwards by 1.
1286+
1287+ Related meta objects are used when resolving the enumerated type
1288+ associated with a property, where the enumerated type is in a
1289+ different class from the property.
1290+
1291+ \sa relatedMetaObjectCount(), addRelatedMetaObject()
1292+ \sa relatedMetaObject()
1293+*/
1294+void QMetaObjectBuilder::removeRelatedMetaObject(int index)
1295+{
1296+ if (index >= 0 && index < d->relatedMetaObjects.size())
1297+ d->relatedMetaObjects.removeAt(index);
1298+}
1299+
1300+/*!
1301+ Finds a method with the specified \a signature and returns its index;
1302+ otherwise returns -1. The \a signature will be normalized by this method.
1303+
1304+ \sa method(), methodCount(), addMethod(), removeMethod()
1305+*/
1306+int QMetaObjectBuilder::indexOfMethod(const QByteArray& signature)
1307+{
1308+ QByteArray sig = QMetaObject::normalizedSignature(signature);
1309+ for (int index = 0; index < d->methods.size(); ++index) {
1310+ if (sig == d->methods[index].signature)
1311+ return index;
1312+ }
1313+ return -1;
1314+}
1315+
1316+/*!
1317+ Finds a signal with the specified \a signature and returns its index;
1318+ otherwise returns -1. The \a signature will be normalized by this method.
1319+
1320+ \sa indexOfMethod(), indexOfSlot()
1321+*/
1322+int QMetaObjectBuilder::indexOfSignal(const QByteArray& signature)
1323+{
1324+ QByteArray sig = QMetaObject::normalizedSignature(signature);
1325+ for (int index = 0; index < d->methods.size(); ++index) {
1326+ if (sig == d->methods[index].signature &&
1327+ d->methods[index].methodType() == QMetaMethod::Signal)
1328+ return index;
1329+ }
1330+ return -1;
1331+}
1332+
1333+/*!
1334+ Finds a slot with the specified \a signature and returns its index;
1335+ otherwise returns -1. The \a signature will be normalized by this method.
1336+
1337+ \sa indexOfMethod(), indexOfSignal()
1338+*/
1339+int QMetaObjectBuilder::indexOfSlot(const QByteArray& signature)
1340+{
1341+ QByteArray sig = QMetaObject::normalizedSignature(signature);
1342+ for (int index = 0; index < d->methods.size(); ++index) {
1343+ if (sig == d->methods[index].signature &&
1344+ d->methods[index].methodType() == QMetaMethod::Slot)
1345+ return index;
1346+ }
1347+ return -1;
1348+}
1349+
1350+/*!
1351+ Finds a constructor with the specified \a signature and returns its index;
1352+ otherwise returns -1. The \a signature will be normalized by this method.
1353+
1354+ \sa constructor(), constructorCount(), addConstructor(), removeConstructor()
1355+*/
1356+int QMetaObjectBuilder::indexOfConstructor(const QByteArray& signature)
1357+{
1358+ QByteArray sig = QMetaObject::normalizedSignature(signature);
1359+ for (int index = 0; index < d->constructors.size(); ++index) {
1360+ if (sig == d->constructors[index].signature)
1361+ return index;
1362+ }
1363+ return -1;
1364+}
1365+
1366+/*!
1367+ Finds a property with the specified \a name and returns its index;
1368+ otherwise returns -1.
1369+
1370+ \sa property(), propertyCount(), addProperty(), removeProperty()
1371+*/
1372+int QMetaObjectBuilder::indexOfProperty(const QByteArray& name)
1373+{
1374+ for (int index = 0; index < d->properties.size(); ++index) {
1375+ if (name == d->properties[index].name)
1376+ return index;
1377+ }
1378+ return -1;
1379+}
1380+
1381+/*!
1382+ Finds an enumerator with the specified \a name and returns its index;
1383+ otherwise returns -1.
1384+
1385+ \sa enumertor(), enumeratorCount(), addEnumerator(), removeEnumerator()
1386+*/
1387+int QMetaObjectBuilder::indexOfEnumerator(const QByteArray& name)
1388+{
1389+ for (int index = 0; index < d->enumerators.size(); ++index) {
1390+ if (name == d->enumerators[index].name)
1391+ return index;
1392+ }
1393+ return -1;
1394+}
1395+
1396+/*!
1397+ Finds an item of class information with the specified \a name and
1398+ returns its index; otherwise returns -1.
1399+
1400+ \sa classInfoName(), classInfoValue(), classInfoCount(), addClassInfo()
1401+ \sa removeClassInfo()
1402+*/
1403+int QMetaObjectBuilder::indexOfClassInfo(const QByteArray& name)
1404+{
1405+ for (int index = 0; index < d->classInfoNames.size(); ++index) {
1406+ if (name == d->classInfoNames[index])
1407+ return index;
1408+ }
1409+ return -1;
1410+}
1411+
1412+// Align on a specific type boundary.
1413+#define ALIGN(size,type) \
1414+ (size) = ((size) + sizeof(type) - 1) & ~(sizeof(type) - 1)
1415+
1416+// Build a string into a QMetaObject representation. Returns the
1417+// position in the string table where the string was placed.
1418+static int buildString
1419+ (char *buf, char *str, int *offset, const QByteArray& value, int empty)
1420+{
1421+ if (value.size() == 0 && empty >= 0)
1422+ return empty;
1423+ if (buf) {
1424+ memcpy(str + *offset, value.constData(), value.size());
1425+ str[*offset + value.size()] = '\0';
1426+ }
1427+ int posn = *offset;
1428+ *offset += value.size() + 1;
1429+ return posn;
1430+}
1431+
1432+// Build the parameter array string for a method.
1433+static QByteArray buildParameterNames
1434+ (const QByteArray& signature, const QList<QByteArray>& parameterNames)
1435+{
1436+ // If the parameter name list is specified, then concatenate them.
1437+ if (!parameterNames.isEmpty()) {
1438+ QByteArray names;
1439+ bool first = true;
1440+ foreach (const QByteArray &name, parameterNames) {
1441+ if (first)
1442+ first = false;
1443+ else
1444+ names += (char)',';
1445+ names += name;
1446+ }
1447+ return names;
1448+ }
1449+
1450+ // Count commas in the signature, excluding those inside template arguments.
1451+ int index = signature.indexOf('(');
1452+ if (index < 0)
1453+ return QByteArray();
1454+ ++index;
1455+ if (index >= signature.size())
1456+ return QByteArray();
1457+ if (signature[index] == ')')
1458+ return QByteArray();
1459+ int count = 1;
1460+ int brackets = 0;
1461+ while (index < signature.size() && signature[index] != ',') {
1462+ char ch = signature[index++];
1463+ if (ch == '<')
1464+ ++brackets;
1465+ else if (ch == '>')
1466+ --brackets;
1467+ else if (ch == ',' && brackets <= 0)
1468+ ++count;
1469+ }
1470+ return QByteArray(count - 1, ',');
1471+}
1472+
1473+// Build a QMetaObject in "buf" based on the information in "d".
1474+// If "buf" is null, then return the number of bytes needed to
1475+// build the QMetaObject. Returns -1 if the metaobject if
1476+// relocatable is set, but the metaobject contains extradata.
1477+static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
1478+ bool relocatable)
1479+{
1480+ int size = 0;
1481+ int dataIndex;
1482+ int enumIndex;
1483+ int index;
1484+ bool hasNotifySignals = false;
1485+
1486+ if (relocatable &&
1487+ (d->relatedMetaObjects.size() > 0 || d->staticMetacallFunction))
1488+ return -1;
1489+
1490+ // Create the main QMetaObject structure at the start of the buffer.
1491+ QMetaObject *meta = reinterpret_cast<QMetaObject *>(buf);
1492+ size += sizeof(QMetaObject);
1493+ ALIGN(size, int);
1494+ if (buf) {
1495+ if (!relocatable) meta->d.superdata = d->superClass;
1496+ meta->d.extradata = 0;
1497+ }
1498+
1499+ // Populate the QMetaObjectPrivate structure.
1500+ QMetaObjectPrivate *pmeta
1501+ = reinterpret_cast<QMetaObjectPrivate *>(buf + size);
1502+ int pmetaSize = size;
1503+ dataIndex = 13; // Number of fields in the QMetaObjectPrivate.
1504+ for (index = 0; index < d->properties.size(); ++index) {
1505+ if (d->properties[index].notifySignal != -1) {
1506+ hasNotifySignals = true;
1507+ break;
1508+ }
1509+ }
1510+ if (buf) {
1511+ pmeta->revision = 3;
1512+ pmeta->flags = d->flags;
1513+ pmeta->className = 0; // Class name is always the first string.
1514+
1515+ pmeta->classInfoCount = d->classInfoNames.size();
1516+ pmeta->classInfoData = dataIndex;
1517+ dataIndex += 2 * d->classInfoNames.size();
1518+
1519+ pmeta->methodCount = d->methods.size();
1520+ pmeta->methodData = dataIndex;
1521+ dataIndex += 5 * d->methods.size();
1522+
1523+ pmeta->propertyCount = d->properties.size();
1524+ pmeta->propertyData = dataIndex;
1525+ dataIndex += 3 * d->properties.size();
1526+ if (hasNotifySignals)
1527+ dataIndex += d->properties.size();
1528+
1529+ pmeta->enumeratorCount = d->enumerators.size();
1530+ pmeta->enumeratorData = dataIndex;
1531+ dataIndex += 4 * d->enumerators.size();
1532+
1533+ pmeta->constructorCount = d->constructors.size();
1534+ pmeta->constructorData = dataIndex;
1535+ dataIndex += 5 * d->constructors.size();
1536+ } else {
1537+ dataIndex += 2 * d->classInfoNames.size();
1538+ dataIndex += 5 * d->methods.size();
1539+ dataIndex += 3 * d->properties.size();
1540+ if (hasNotifySignals)
1541+ dataIndex += d->properties.size();
1542+ dataIndex += 4 * d->enumerators.size();
1543+ dataIndex += 5 * d->constructors.size();
1544+ }
1545+
1546+ // Allocate space for the enumerator key names and values.
1547+ enumIndex = dataIndex;
1548+ for (index = 0; index < d->enumerators.size(); ++index) {
1549+ QMetaEnumBuilderPrivate *enumerator = &(d->enumerators[index]);
1550+ dataIndex += 2 * enumerator->keys.size();
1551+ }
1552+
1553+ // Zero terminator at the end of the data offset table.
1554+ ++dataIndex;
1555+
1556+ // Find the start of the data and string tables.
1557+ int *data = reinterpret_cast<int *>(pmeta);
1558+ size += dataIndex * sizeof(int);
1559+ char *str = reinterpret_cast<char *>(buf + size);
1560+ if (buf) {
1561+ if (relocatable) {
1562+ meta->d.stringdata = reinterpret_cast<const char *>((intptr_t)size);
1563+ meta->d.data = reinterpret_cast<uint *>((intptr_t)pmetaSize);
1564+ } else {
1565+ meta->d.stringdata = str;
1566+ meta->d.data = reinterpret_cast<uint *>(data);
1567+ }
1568+ }
1569+
1570+ // Reset the current data position to just past the QMetaObjectPrivate.
1571+ dataIndex = 13;
1572+
1573+ // Add the class name to the string table.
1574+ int offset = 0;
1575+ buildString(buf, str, &offset, d->className, -1);
1576+
1577+ // Add a common empty string, which is used to indicate "void"
1578+ // method returns, empty tag strings, etc.
1579+ int empty = buildString(buf, str, &offset, QByteArray(), -1);
1580+
1581+ // Output the class infos,
1582+ for (index = 0; index < d->classInfoNames.size(); ++index) {
1583+ int name = buildString(buf, str, &offset, d->classInfoNames[index], empty);
1584+ int value = buildString(buf, str, &offset, d->classInfoValues[index], empty);
1585+ if (buf) {
1586+ data[dataIndex] = name;
1587+ data[dataIndex + 1] = value;
1588+ }
1589+ dataIndex += 2;
1590+ }
1591+
1592+ // Output the methods in the class.
1593+ for (index = 0; index < d->methods.size(); ++index) {
1594+ QMetaMethodBuilderPrivate *method = &(d->methods[index]);
1595+ int sig = buildString(buf, str, &offset, method->signature, empty);
1596+ int params;
1597+ QByteArray names = buildParameterNames
1598+ (method->signature, method->parameterNames);
1599+ params = buildString(buf, str, &offset, names, empty);
1600+ int ret = buildString(buf, str, &offset, method->returnType, empty);
1601+ int tag = buildString(buf, str, &offset, method->tag, empty);
1602+ int attrs = method->attributes;
1603+ if (buf) {
1604+ data[dataIndex] = sig;
1605+ data[dataIndex + 1] = params;
1606+ data[dataIndex + 2] = ret;
1607+ data[dataIndex + 3] = tag;
1608+ data[dataIndex + 4] = attrs;
1609+ }
1610+ dataIndex += 5;
1611+ }
1612+
1613+ // Output the properties in the class.
1614+ for (index = 0; index < d->properties.size(); ++index) {
1615+ QMetaPropertyBuilderPrivate *prop = &(d->properties[index]);
1616+ int name = buildString(buf, str, &offset, prop->name, empty);
1617+ int type = buildString(buf, str, &offset, prop->type, empty);
1618+ int flags = prop->flags;
1619+
1620+ if (!isVariantType(prop->type)) {
1621+ flags |= EnumOrFlag;
1622+ } else {
1623+ flags |= qvariant_nameToType(prop->type) << 24;
1624+ }
1625+
1626+ if (buf) {
1627+ data[dataIndex] = name;
1628+ data[dataIndex + 1] = type;
1629+ data[dataIndex + 2] = flags;
1630+ }
1631+ dataIndex += 3;
1632+ }
1633+ if (hasNotifySignals) {
1634+ for (index = 0; index < d->properties.size(); ++index) {
1635+ QMetaPropertyBuilderPrivate *prop = &(d->properties[index]);
1636+ if (buf) {
1637+ if (prop->notifySignal != -1)
1638+ data[dataIndex] = prop->notifySignal;
1639+ else
1640+ data[dataIndex] = 0;
1641+ }
1642+ ++dataIndex;
1643+ }
1644+ }
1645+
1646+ // Output the enumerators in the class.
1647+ for (index = 0; index < d->enumerators.size(); ++index) {
1648+ QMetaEnumBuilderPrivate *enumerator = &(d->enumerators[index]);
1649+ int name = buildString(buf, str, &offset, enumerator->name, empty);
1650+ int isFlag = (int)(enumerator->isFlag);
1651+ int count = enumerator->keys.size();
1652+ int enumOffset = enumIndex;
1653+ if (buf) {
1654+ data[dataIndex] = name;
1655+ data[dataIndex + 1] = isFlag;
1656+ data[dataIndex + 2] = count;
1657+ data[dataIndex + 3] = enumOffset;
1658+ }
1659+ for (int key = 0; key < count; ++key) {
1660+ int keyIndex = buildString(buf, str, &offset, enumerator->keys[key], empty);
1661+ if (buf) {
1662+ data[enumOffset++] = keyIndex;
1663+ data[enumOffset++] = enumerator->values[key];
1664+ }
1665+ }
1666+ dataIndex += 4;
1667+ enumIndex += 2 * count;
1668+ }
1669+
1670+ // Output the constructors in the class.
1671+ for (index = 0; index < d->constructors.size(); ++index) {
1672+ QMetaMethodBuilderPrivate *method = &(d->constructors[index]);
1673+ int sig = buildString(buf, str, &offset, method->signature, empty);
1674+ int params;
1675+ QByteArray names = buildParameterNames
1676+ (method->signature, method->parameterNames);
1677+ params = buildString(buf, str, &offset, names, empty);
1678+ int ret = buildString(buf, str, &offset, method->returnType, empty);
1679+ int tag = buildString(buf, str, &offset, method->tag, empty);
1680+ int attrs = method->attributes;
1681+ if (buf) {
1682+ data[dataIndex] = sig;
1683+ data[dataIndex + 1] = params;
1684+ data[dataIndex + 2] = ret;
1685+ data[dataIndex + 3] = tag;
1686+ data[dataIndex + 4] = attrs;
1687+ }
1688+ dataIndex += 5;
1689+ }
1690+
1691+ // One more empty string to act as a terminator.
1692+ buildString(buf, str, &offset, QByteArray(), -1);
1693+ size += offset;
1694+
1695+ // Output the zero terminator in the data array.
1696+ if (buf)
1697+ data[enumIndex] = 0;
1698+
1699+ // Create the extradata block if we need one.
1700+ if (d->relatedMetaObjects.size() > 0 || d->staticMetacallFunction) {
1701+ ALIGN(size, QMetaObject **);
1702+ ALIGN(size, QMetaObjectBuilder::StaticMetacallFunction);
1703+ QMetaObjectExtraData *extra =
1704+ reinterpret_cast<QMetaObjectExtraData *>(buf + size);
1705+ size += sizeof(QMetaObjectExtraData);
1706+ ALIGN(size, QMetaObject *);
1707+#ifdef Q_NO_DATA_RELOCATION
1708+ QMetaObjectAccessor *objects =
1709+ reinterpret_cast<QMetaObjectAccessor *>(buf + size);
1710+#else
1711+ const QMetaObject **objects =
1712+ reinterpret_cast<const QMetaObject **>(buf + size);
1713+#endif
1714+ if (buf) {
1715+ if (d->relatedMetaObjects.size() > 0) {
1716+ extra->objects = objects;
1717+ for (index = 0; index < d->relatedMetaObjects.size(); ++index)
1718+ objects[index] = d->relatedMetaObjects[index];
1719+ objects[index] = 0;
1720+ } else {
1721+ extra->objects = 0;
1722+ }
1723+ extra->static_metacall = d->staticMetacallFunction;
1724+ meta->d.extradata = reinterpret_cast<void *>(extra);
1725+ }
1726+ if (d->relatedMetaObjects.size() > 0)
1727+ size += sizeof(QMetaObject *) * (d->relatedMetaObjects.size() + 1);
1728+ }
1729+
1730+ // Align the final size and return it.
1731+ ALIGN(size, void *);
1732+ return size;
1733+}
1734+
1735+/*!
1736+ Converts this meta object builder into a concrete QMetaObject.
1737+ The return value should be deallocated using qFree() once it
1738+ is no longer needed.
1739+
1740+ The returned meta object is a snapshot of the state of the
1741+ QMetaObjectBuilder. Any further modifications to the QMetaObjectBuilder
1742+ will not be reflected in previous meta objects returned by
1743+ this method.
1744+*/
1745+QMetaObject *QMetaObjectBuilder::toMetaObject() const
1746+{
1747+ int size = buildMetaObject(d, 0, false);
1748+ char *buf = reinterpret_cast<char *>(qMalloc(size));
1749+ buildMetaObject(d, buf, false);
1750+ return reinterpret_cast<QMetaObject *>(buf);
1751+}
1752+
1753+/*
1754+ \internal
1755+
1756+ Converts this meta object builder into relocatable data. This data can
1757+ be stored, copied and later passed to fromRelocatableData() to create a
1758+ concrete QMetaObject.
1759+
1760+ The data is specific to the architecture on which it was created, but is not
1761+ specific to the process that created it. Not all meta object builder's can
1762+ be converted to data in this way. If \a ok is provided, it will be set to
1763+ true if the conversion succeeds, and false otherwise. If a
1764+ staticMetacallFunction() or any relatedMetaObject()'s are specified the
1765+ conversion to relocatable data will fail.
1766+*/
1767+QByteArray QMetaObjectBuilder::toRelocatableData(bool *ok) const
1768+{
1769+ int size = buildMetaObject(d, 0, true);
1770+ if (size == -1) {
1771+ if (ok) *ok = false;
1772+ return QByteArray();
1773+ }
1774+
1775+ QByteArray data;
1776+ data.resize(size);
1777+ char *buf = data.data();
1778+ buildMetaObject(d, buf, true);
1779+ if (ok) *ok = true;
1780+ return data;
1781+}
1782+
1783+/*
1784+ \internal
1785+
1786+ Sets the \a data returned from toRelocatableData() onto a concrete
1787+ QMetaObject instance, \a output. As the meta object's super class is not
1788+ saved in the relocatable data, it must be passed as \a superClass.
1789+*/
1790+void QMetaObjectBuilder::fromRelocatableData(QMetaObject *output,
1791+ const QMetaObject *superclass,
1792+ const QByteArray &data)
1793+{
1794+ if (!output)
1795+ return;
1796+
1797+ const char *buf = data.constData();
1798+ const QMetaObject *dataMo = reinterpret_cast<const QMetaObject *>(buf);
1799+
1800+ intptr_t stringdataOffset = (intptr_t)dataMo->d.stringdata;
1801+ intptr_t dataOffset = (intptr_t)dataMo->d.data;
1802+
1803+ output->d.superdata = superclass;
1804+ output->d.stringdata = buf + stringdataOffset;
1805+ output->d.data = reinterpret_cast<const uint *>(buf + dataOffset);
1806+}
1807+
1808+/*!
1809+ \typedef QMetaObjectBuilder::StaticMetacallFunction
1810+
1811+ Typedef for static metacall functions. The three parameters are
1812+ the call type value, the constructor index, and the
1813+ array of parameters.
1814+*/
1815+
1816+/*!
1817+ Returns the static metacall function to use to construct objects
1818+ of this class. The default value is null.
1819+
1820+ \sa setStaticMetacallFunction()
1821+*/
1822+QMetaObjectBuilder::StaticMetacallFunction QMetaObjectBuilder::staticMetacallFunction() const
1823+{
1824+ return d->staticMetacallFunction;
1825+}
1826+
1827+/*!
1828+ Sets the static metacall function to use to construct objects
1829+ of this class to \a value. The default value is null.
1830+
1831+ \sa staticMetacallFunction()
1832+*/
1833+void QMetaObjectBuilder::setStaticMetacallFunction
1834+ (QMetaObjectBuilder::StaticMetacallFunction value)
1835+{
1836+ d->staticMetacallFunction = value;
1837+}
1838+
1839+#ifndef QT_NO_DATASTREAM
1840+
1841+/*!
1842+ Serializes the contents of the meta object builder onto \a stream.
1843+
1844+ \sa deserialize()
1845+*/
1846+void QMetaObjectBuilder::serialize(QDataStream& stream) const
1847+{
1848+ int index;
1849+
1850+ // Write the class and super class names.
1851+ stream << d->className;
1852+ if (d->superClass)
1853+ stream << QByteArray(d->superClass->className());
1854+ else
1855+ stream << QByteArray();
1856+
1857+ // Write the counts for each type of class member.
1858+ stream << d->classInfoNames.size();
1859+ stream << d->methods.size();
1860+ stream << d->properties.size();
1861+ stream << d->enumerators.size();
1862+ stream << d->constructors.size();
1863+ stream << d->relatedMetaObjects.size();
1864+
1865+ // Write the items of class information.
1866+ for (index = 0; index < d->classInfoNames.size(); ++index) {
1867+ stream << d->classInfoNames[index];
1868+ stream << d->classInfoValues[index];
1869+ }
1870+
1871+ // Write the methods.
1872+ for (index = 0; index < d->methods.size(); ++index) {
1873+ const QMetaMethodBuilderPrivate *method = &(d->methods[index]);
1874+ stream << method->signature;
1875+ stream << method->returnType;
1876+ stream << method->parameterNames;
1877+ stream << method->tag;
1878+ stream << method->attributes;
1879+ }
1880+
1881+ // Write the properties.
1882+ for (index = 0; index < d->properties.size(); ++index) {
1883+ const QMetaPropertyBuilderPrivate *property = &(d->properties[index]);
1884+ stream << property->name;
1885+ stream << property->type;
1886+ stream << property->flags;
1887+ stream << property->notifySignal;
1888+ }
1889+
1890+ // Write the enumerators.
1891+ for (index = 0; index < d->enumerators.size(); ++index) {
1892+ const QMetaEnumBuilderPrivate *enumerator = &(d->enumerators[index]);
1893+ stream << enumerator->name;
1894+ stream << enumerator->isFlag;
1895+ stream << enumerator->keys;
1896+ stream << enumerator->values;
1897+ }
1898+
1899+ // Write the constructors.
1900+ for (index = 0; index < d->constructors.size(); ++index) {
1901+ const QMetaMethodBuilderPrivate *method = &(d->constructors[index]);
1902+ stream << method->signature;
1903+ stream << method->returnType;
1904+ stream << method->parameterNames;
1905+ stream << method->tag;
1906+ stream << method->attributes;
1907+ }
1908+
1909+ // Write the related meta objects.
1910+#ifdef Q_NO_DATA_RELOCATION
1911+ //the related meta objects will be function pointers
1912+ //which you have to add to the builder manually.
1913+ //e.g.
1914+ //builder2.addRelatedMetaObject(QLocale::getStaticMetaObject);
1915+#else
1916+ for (index = 0; index < d->relatedMetaObjects.size(); ++index) {
1917+ const QMetaObject *meta = d->relatedMetaObjects[index];
1918+ stream << QByteArray(meta->className());
1919+ }
1920+#endif
1921+
1922+ // Add an extra empty QByteArray for additional data in future versions.
1923+ // This should help maintain backwards compatibility, allowing older
1924+ // versions to read newer data.
1925+ stream << QByteArray();
1926+}
1927+
1928+// Resolve a class name using the name reference map.
1929+static const QMetaObject *resolveClassName
1930+ (const QMap<QByteArray, const QMetaObject *>& references,
1931+ const QByteArray& name)
1932+{
1933+ if (name == QByteArray("QObject"))
1934+ return &QObject::staticMetaObject;
1935+ else
1936+ return references.value(name, 0);
1937+}
1938+
1939+/*!
1940+ Deserializes a meta object builder from \a stream into
1941+ this meta object builder.
1942+
1943+ The \a references parameter specifies a mapping from class names
1944+ to QMetaObject instances for resolving the super class name and
1945+ related meta objects in the object that is deserialized.
1946+ The meta object for QObject is implicitly added to \a references
1947+ and does not need to be supplied.
1948+
1949+ The QDataStream::status() value on \a stream will be set to
1950+ QDataStream::ReadCorruptData if the input data is corrupt.
1951+ The status will be set to QDataStream::ReadPastEnd if the
1952+ input was exhausted before the full meta object was read.
1953+
1954+ \sa serialize()
1955+*/
1956+void QMetaObjectBuilder::deserialize
1957+ (QDataStream& stream,
1958+ const QMap<QByteArray, const QMetaObject *>& references)
1959+{
1960+ QByteArray name;
1961+ const QMetaObject *cl;
1962+ int index;
1963+
1964+ // Clear all members in the builder to their default states.
1965+ d->className.clear();
1966+ d->superClass = &QObject::staticMetaObject;
1967+ d->classInfoNames.clear();
1968+ d->classInfoValues.clear();
1969+ d->methods.clear();
1970+ d->properties.clear();
1971+ d->enumerators.clear();
1972+ d->constructors.clear();
1973+ d->relatedMetaObjects.clear();
1974+ d->staticMetacallFunction = 0;
1975+
1976+ // Read the class and super class names.
1977+ stream >> d->className;
1978+ stream >> name;
1979+ if (name.isEmpty()) {
1980+ d->superClass = 0;
1981+ } else if ((cl = resolveClassName(references, name)) != 0) {
1982+ d->superClass = cl;
1983+ } else {
1984+ stream.setStatus(QDataStream::ReadCorruptData);
1985+ return;
1986+ }
1987+
1988+ // Read the counts for each type of class member.
1989+ int classInfoCount, methodCount, propertyCount;
1990+ int enumeratorCount, constructorCount, relatedMetaObjectCount;
1991+ stream >> classInfoCount;
1992+ stream >> methodCount;
1993+ stream >> propertyCount;
1994+ stream >> enumeratorCount;
1995+ stream >> constructorCount;
1996+ stream >> relatedMetaObjectCount;
1997+ if (classInfoCount < 0 || methodCount < 0 ||
1998+ propertyCount < 0 || enumeratorCount < 0 ||
1999+ constructorCount < 0 || relatedMetaObjectCount < 0) {
2000+ stream.setStatus(QDataStream::ReadCorruptData);
2001+ return;
2002+ }
2003+
2004+ // Read the items of class information.
2005+ for (index = 0; index < classInfoCount; ++index) {
2006+ if (stream.status() != QDataStream::Ok)
2007+ return;
2008+ QByteArray value;
2009+ stream >> name;
2010+ stream >> value;
2011+ addClassInfo(name, value);
2012+ }
2013+
2014+ // Read the member methods.
2015+ for (index = 0; index < methodCount; ++index) {
2016+ if (stream.status() != QDataStream::Ok)
2017+ return;
2018+ stream >> name;
2019+ addMethod(name);
2020+ QMetaMethodBuilderPrivate *method = &(d->methods[index]);
2021+ stream >> method->returnType;
2022+ stream >> method->parameterNames;
2023+ stream >> method->tag;
2024+ stream >> method->attributes;
2025+ if (method->methodType() == QMetaMethod::Constructor) {
2026+ // Cannot add a constructor in this set of methods.
2027+ stream.setStatus(QDataStream::ReadCorruptData);
2028+ return;
2029+ }
2030+ }
2031+
2032+ // Read the properties.
2033+ for (index = 0; index < propertyCount; ++index) {
2034+ if (stream.status() != QDataStream::Ok)
2035+ return;
2036+ QByteArray type;
2037+ stream >> name;
2038+ stream >> type;
2039+ addProperty(name, type);
2040+ QMetaPropertyBuilderPrivate *property = &(d->properties[index]);
2041+ stream >> property->flags;
2042+ stream >> property->notifySignal;
2043+ if (property->notifySignal < -1 ||
2044+ property->notifySignal >= d->methods.size()) {
2045+ // Notify signal method index is out of range.
2046+ stream.setStatus(QDataStream::ReadCorruptData);
2047+ return;
2048+ }
2049+ if (property->notifySignal >= 0 &&
2050+ d->methods[property->notifySignal].methodType() != QMetaMethod::Signal) {
2051+ // Notify signal method index does not refer to a signal.
2052+ stream.setStatus(QDataStream::ReadCorruptData);
2053+ return;
2054+ }
2055+ }
2056+
2057+ // Read the enumerators.
2058+ for (index = 0; index < enumeratorCount; ++index) {
2059+ if (stream.status() != QDataStream::Ok)
2060+ return;
2061+ stream >> name;
2062+ addEnumerator(name);
2063+ QMetaEnumBuilderPrivate *enumerator = &(d->enumerators[index]);
2064+ stream >> enumerator->isFlag;
2065+ stream >> enumerator->keys;
2066+ stream >> enumerator->values;
2067+ if (enumerator->keys.size() != enumerator->values.size()) {
2068+ // Mismatch between number of keys and number of values.
2069+ stream.setStatus(QDataStream::ReadCorruptData);
2070+ return;
2071+ }
2072+ }
2073+
2074+ // Read the constructor methods.
2075+ for (index = 0; index < constructorCount; ++index) {
2076+ if (stream.status() != QDataStream::Ok)
2077+ return;
2078+ stream >> name;
2079+ addConstructor(name);
2080+ QMetaMethodBuilderPrivate *method = &(d->constructors[index]);
2081+ stream >> method->returnType;
2082+ stream >> method->parameterNames;
2083+ stream >> method->tag;
2084+ stream >> method->attributes;
2085+ if (method->methodType() != QMetaMethod::Constructor) {
2086+ // The type must be Constructor.
2087+ stream.setStatus(QDataStream::ReadCorruptData);
2088+ return;
2089+ }
2090+ }
2091+
2092+ // Read the related meta objects.
2093+#ifdef Q_NO_DATA_RELOCATION
2094+ //the related meta objects will be function pointers
2095+ //which you have to add to the builder manually.
2096+ //e.g.
2097+ //builder2.addRelatedMetaObject(QLocale::getStaticMetaObject);
2098+#else
2099+ for (index = 0; index < relatedMetaObjectCount; ++index) {
2100+ if (stream.status() != QDataStream::Ok)
2101+ return;
2102+ stream >> name;
2103+ cl = resolveClassName(references, name);
2104+ if (!cl) {
2105+ stream.setStatus(QDataStream::ReadCorruptData);
2106+ return;
2107+ }
2108+ addRelatedMetaObject(cl);
2109+ }
2110+#endif
2111+
2112+ // Read the extra data block, which is reserved for future use.
2113+ stream >> name;
2114+}
2115+
2116+#endif // !QT_NO_DATASTREAM
2117+
2118+/*!
2119+ \class QMetaMethodBuilder
2120+ \internal
2121+ \brief The QMetaMethodBuilder class enables modifications to a method definition on a meta object builder.
2122+*/
2123+
2124+QMetaMethodBuilderPrivate *QMetaMethodBuilder::d_func() const
2125+{
2126+ // Positive indices indicate methods, negative indices indicate constructors.
2127+ if (_mobj && _index >= 0 && _index < _mobj->d->methods.size())
2128+ return &(_mobj->d->methods[_index]);
2129+ else if (_mobj && -_index >= 1 && -_index <= _mobj->d->constructors.size())
2130+ return &(_mobj->d->constructors[(-_index) - 1]);
2131+ else
2132+ return 0;
2133+}
2134+
2135+/*!
2136+ \fn QMetaMethodBuilder::QMetaMethodBuilder()
2137+ \internal
2138+*/
2139+
2140+/*!
2141+ Returns the index of this method within its QMetaObjectBuilder.
2142+*/
2143+int QMetaMethodBuilder::index() const
2144+{
2145+ if (_index >= 0)
2146+ return _index; // Method, signal, or slot
2147+ else
2148+ return (-_index) - 1; // Constructor
2149+}
2150+
2151+/*!
2152+ Returns the type of this method (signal, slot, method, or constructor).
2153+*/
2154+QMetaMethod::MethodType QMetaMethodBuilder::methodType() const
2155+{
2156+ QMetaMethodBuilderPrivate *d = d_func();
2157+ if (d)
2158+ return d->methodType();
2159+ else
2160+ return QMetaMethod::Method;
2161+}
2162+
2163+/*!
2164+ Returns the signature of this method.
2165+
2166+ \sa parameterNames(), returnType()
2167+*/
2168+QByteArray QMetaMethodBuilder::signature() const
2169+{
2170+ QMetaMethodBuilderPrivate *d = d_func();
2171+ if (d)
2172+ return d->signature;
2173+ else
2174+ return QByteArray();
2175+}
2176+
2177+/*!
2178+ Returns the return type for this method; empty if the method's
2179+ return type is \c{void}.
2180+
2181+ \sa setReturnType(), signature()
2182+*/
2183+QByteArray QMetaMethodBuilder::returnType() const
2184+{
2185+ QMetaMethodBuilderPrivate *d = d_func();
2186+ if (d)
2187+ return d->returnType;
2188+ else
2189+ return QByteArray();
2190+}
2191+
2192+/*!
2193+ Sets the return type for this method to \a value. If \a value
2194+ is empty, then the method's return type is \c{void}. The \a value
2195+ will be normalized before it is added to the method.
2196+
2197+ \sa returnType(), signature()
2198+*/
2199+void QMetaMethodBuilder::setReturnType(const QByteArray& value)
2200+{
2201+ QMetaMethodBuilderPrivate *d = d_func();
2202+ if (d)
2203+ d->returnType = QMetaObject::normalizedType(value);
2204+}
2205+
2206+/*!
2207+ Returns the list of parameter names for this method.
2208+
2209+ \sa setParameterNames()
2210+*/
2211+QList<QByteArray> QMetaMethodBuilder::parameterNames() const
2212+{
2213+ QMetaMethodBuilderPrivate *d = d_func();
2214+ if (d)
2215+ return d->parameterNames;
2216+ else
2217+ return QList<QByteArray>();
2218+}
2219+
2220+/*!
2221+ Sets the list of parameter names for this method to \a value.
2222+
2223+ \sa parameterNames()
2224+*/
2225+void QMetaMethodBuilder::setParameterNames(const QList<QByteArray>& value)
2226+{
2227+ QMetaMethodBuilderPrivate *d = d_func();
2228+ if (d)
2229+ d->parameterNames = value;
2230+}
2231+
2232+/*!
2233+ Returns the tag associated with this method.
2234+
2235+ \sa setTag()
2236+*/
2237+QByteArray QMetaMethodBuilder::tag() const
2238+{
2239+ QMetaMethodBuilderPrivate *d = d_func();
2240+ if (d)
2241+ return d->tag;
2242+ else
2243+ return QByteArray();
2244+}
2245+
2246+/*!
2247+ Sets the tag associated with this method to \a value.
2248+
2249+ \sa setTag()
2250+*/
2251+void QMetaMethodBuilder::setTag(const QByteArray& value)
2252+{
2253+ QMetaMethodBuilderPrivate *d = d_func();
2254+ if (d)
2255+ d->tag = value;
2256+}
2257+
2258+/*!
2259+ Returns the access specification of this method (private, protected,
2260+ or public). The default value is QMetaMethod::Public for methods,
2261+ slots, and constructors. The default value is QMetaMethod::Protected
2262+ for signals.
2263+
2264+ \sa setAccess()
2265+*/
2266+QMetaMethod::Access QMetaMethodBuilder::access() const
2267+{
2268+ QMetaMethodBuilderPrivate *d = d_func();
2269+ if (d)
2270+ return d->access();
2271+ else
2272+ return QMetaMethod::Public;
2273+}
2274+
2275+/*!
2276+ Sets the access specification of this method (private, protected,
2277+ or public) to \a value. If the method is a signal, this function
2278+ will be ignored.
2279+
2280+ \sa access()
2281+*/
2282+void QMetaMethodBuilder::setAccess(QMetaMethod::Access value)
2283+{
2284+ QMetaMethodBuilderPrivate *d = d_func();
2285+ if (d && d->methodType() != QMetaMethod::Signal)
2286+ d->setAccess(value);
2287+}
2288+
2289+/*!
2290+ Returns the additional attributes for this method.
2291+
2292+ \sa setAttributes()
2293+*/
2294+int QMetaMethodBuilder::attributes() const
2295+{
2296+ QMetaMethodBuilderPrivate *d = d_func();
2297+ if (d)
2298+ return (d->attributes >> 4);
2299+ else
2300+ return 0;
2301+}
2302+
2303+/*!
2304+ Sets the additional attributes for this method to \a value.
2305+
2306+ \sa attributes()
2307+*/
2308+void QMetaMethodBuilder::setAttributes(int value)
2309+{
2310+ QMetaMethodBuilderPrivate *d = d_func();
2311+ if (d)
2312+ d->attributes = ((d->attributes & 0x0f) | (value << 4));
2313+}
2314+
2315+/*!
2316+ \class QMetaPropertyBuilder
2317+ \internal
2318+ \brief The QMetaPropertyBuilder class enables modifications to a property definition on a meta object builder.
2319+*/
2320+
2321+QMetaPropertyBuilderPrivate *QMetaPropertyBuilder::d_func() const
2322+{
2323+ if (_mobj && _index >= 0 && _index < _mobj->d->properties.size())
2324+ return &(_mobj->d->properties[_index]);
2325+ else
2326+ return 0;
2327+}
2328+
2329+/*!
2330+ \fn QMetaPropertyBuilder::QMetaPropertyBuilder()
2331+ \internal
2332+*/
2333+
2334+/*!
2335+ \fn int QMetaPropertyBuilder::index() const
2336+
2337+ Returns the index of this property within its QMetaObjectBuilder.
2338+*/
2339+
2340+/*!
2341+ Returns the name associated with this property.
2342+
2343+ \sa type()
2344+*/
2345+QByteArray QMetaPropertyBuilder::name() const
2346+{
2347+ QMetaPropertyBuilderPrivate *d = d_func();
2348+ if (d)
2349+ return d->name;
2350+ else
2351+ return QByteArray();
2352+}
2353+
2354+/*!
2355+ Returns the type associated with this property.
2356+
2357+ \sa name()
2358+*/
2359+QByteArray QMetaPropertyBuilder::type() const
2360+{
2361+ QMetaPropertyBuilderPrivate *d = d_func();
2362+ if (d)
2363+ return d->type;
2364+ else
2365+ return QByteArray();
2366+}
2367+
2368+/*!
2369+ Returns true if this property has a notify signal; false otherwise.
2370+
2371+ \sa notifySignal(), setNotifySignal(), removeNotifySignal()
2372+*/
2373+bool QMetaPropertyBuilder::hasNotifySignal() const
2374+{
2375+ QMetaPropertyBuilderPrivate *d = d_func();
2376+ if (d)
2377+ return d->flag(Notify);
2378+ else
2379+ return false;
2380+}
2381+
2382+/*!
2383+ Returns the notify signal associated with this property.
2384+
2385+ \sa hasNotifySignal(), setNotifySignal(), removeNotifySignal()
2386+*/
2387+QMetaMethodBuilder QMetaPropertyBuilder::notifySignal() const
2388+{
2389+ QMetaPropertyBuilderPrivate *d = d_func();
2390+ if (d && d->notifySignal >= 0)
2391+ return QMetaMethodBuilder(_mobj, d->notifySignal);
2392+ else
2393+ return QMetaMethodBuilder();
2394+}
2395+
2396+/*!
2397+ Sets the notify signal associated with this property to \a value.
2398+
2399+ \sa hasNotifySignal(), notifySignal(), removeNotifySignal()
2400+*/
2401+void QMetaPropertyBuilder::setNotifySignal(const QMetaMethodBuilder& value)
2402+{
2403+ QMetaPropertyBuilderPrivate *d = d_func();
2404+ if (d) {
2405+ if (value._mobj) {
2406+ d->notifySignal = value._index;
2407+ d->setFlag(Notify, true);
2408+ } else {
2409+ d->notifySignal = -1;
2410+ d->setFlag(Notify, false);
2411+ }
2412+ }
2413+}
2414+
2415+/*!
2416+ Removes the notify signal from this property.
2417+
2418+ \sa hasNotifySignal(), notifySignal(), setNotifySignal()
2419+*/
2420+void QMetaPropertyBuilder::removeNotifySignal()
2421+{
2422+ QMetaPropertyBuilderPrivate *d = d_func();
2423+ if (d) {
2424+ d->notifySignal = -1;
2425+ d->setFlag(Notify, false);
2426+ }
2427+}
2428+
2429+/*!
2430+ Returns true if this property is readable; otherwise returns false.
2431+ The default value is true.
2432+
2433+ \sa setReadable(), isWritable()
2434+*/
2435+bool QMetaPropertyBuilder::isReadable() const
2436+{
2437+ QMetaPropertyBuilderPrivate *d = d_func();
2438+ if (d)
2439+ return d->flag(Readable);
2440+ else
2441+ return false;
2442+}
2443+
2444+/*!
2445+ Returns true if this property is writable; otherwise returns false.
2446+ The default value is true.
2447+
2448+ \sa setWritable(), isReadable()
2449+*/
2450+bool QMetaPropertyBuilder::isWritable() const
2451+{
2452+ QMetaPropertyBuilderPrivate *d = d_func();
2453+ if (d)
2454+ return d->flag(Writable);
2455+ else
2456+ return false;
2457+}
2458+
2459+/*!
2460+ Returns true if this property can be reset to a default value; otherwise
2461+ returns false. The default value is false.
2462+
2463+ \sa setResettable()
2464+*/
2465+bool QMetaPropertyBuilder::isResettable() const
2466+{
2467+ QMetaPropertyBuilderPrivate *d = d_func();
2468+ if (d)
2469+ return d->flag(Resettable);
2470+ else
2471+ return false;
2472+}
2473+
2474+/*!
2475+ Returns true if this property is designable; otherwise returns false.
2476+ This default value is false.
2477+
2478+ \sa setDesignable(), isScriptable(), isStored()
2479+*/
2480+bool QMetaPropertyBuilder::isDesignable() const
2481+{
2482+ QMetaPropertyBuilderPrivate *d = d_func();
2483+ if (d)
2484+ return d->flag(Designable);
2485+ else
2486+ return false;
2487+}
2488+
2489+/*!
2490+ Returns true if the property is scriptable; otherwise returns false.
2491+ This default value is true.
2492+
2493+ \sa setScriptable(), isDesignable(), isStored()
2494+*/
2495+bool QMetaPropertyBuilder::isScriptable() const
2496+{
2497+ QMetaPropertyBuilderPrivate *d = d_func();
2498+ if (d)
2499+ return d->flag(Scriptable);
2500+ else
2501+ return false;
2502+}
2503+
2504+/*!
2505+ Returns true if the property is stored; otherwise returns false.
2506+ This default value is false.
2507+
2508+ \sa setStored(), isDesignable(), isScriptable()
2509+*/
2510+bool QMetaPropertyBuilder::isStored() const
2511+{
2512+ QMetaPropertyBuilderPrivate *d = d_func();
2513+ if (d)
2514+ return d->flag(Stored);
2515+ else
2516+ return false;
2517+}
2518+
2519+/*!
2520+ Returns true if the property is editable; otherwise returns false.
2521+ This default value is false.
2522+
2523+ \sa setEditable(), isDesignable(), isScriptable(), isStored()
2524+*/
2525+bool QMetaPropertyBuilder::isEditable() const
2526+{
2527+ QMetaPropertyBuilderPrivate *d = d_func();
2528+ if (d)
2529+ return d->flag(Editable);
2530+ else
2531+ return false;
2532+}
2533+
2534+/*!
2535+ Returns true if this property is designated as the \c USER
2536+ property, i.e., the one that the user can edit or that is
2537+ significant in some other way. Otherwise it returns
2538+ false. This default value is false.
2539+
2540+ \sa setUser(), isDesignable(), isScriptable()
2541+*/
2542+bool QMetaPropertyBuilder::isUser() const
2543+{
2544+ QMetaPropertyBuilderPrivate *d = d_func();
2545+ if (d)
2546+ return d->flag(User);
2547+ else
2548+ return false;
2549+}
2550+
2551+/*!
2552+ Returns true if the property has a C++ setter function that
2553+ follows Qt's standard "name" / "setName" pattern. Designer and uic
2554+ query hasStdCppSet() in order to avoid expensive
2555+ QObject::setProperty() calls. All properties in Qt [should] follow
2556+ this pattern. The default value is false.
2557+
2558+ \sa setStdCppSet()
2559+*/
2560+bool QMetaPropertyBuilder::hasStdCppSet() const
2561+{
2562+ QMetaPropertyBuilderPrivate *d = d_func();
2563+ if (d)
2564+ return d->flag(StdCppSet);
2565+ else
2566+ return false;
2567+}
2568+
2569+/*!
2570+ Returns true if the property is an enumerator or flag type;
2571+ otherwise returns false. This default value is false.
2572+
2573+ \sa setEnumOrFlag()
2574+*/
2575+bool QMetaPropertyBuilder::isEnumOrFlag() const
2576+{
2577+ QMetaPropertyBuilderPrivate *d = d_func();
2578+ if (d)
2579+ return d->flag(EnumOrFlag);
2580+ else
2581+ return false;
2582+}
2583+
2584+/*!
2585+ Returns true if the property has the dynamic flag set;
2586+ otherwise returns false. The default value is false.
2587+
2588+ \sa setDynamic()
2589+*/
2590+bool QMetaPropertyBuilder::isDynamic() const
2591+{
2592+ QMetaPropertyBuilderPrivate *d = d_func();
2593+ if (d)
2594+ return d->flag(Dynamic);
2595+ else
2596+ return false;
2597+}
2598+
2599+/*!
2600+ Sets this property to readable if \a value is true.
2601+
2602+ \sa isReadable(), setWritable()
2603+*/
2604+void QMetaPropertyBuilder::setReadable(bool value)
2605+{
2606+ QMetaPropertyBuilderPrivate *d = d_func();
2607+ if (d)
2608+ d->setFlag(Readable, value);
2609+}
2610+
2611+/*!
2612+ Sets this property to writable if \a value is true.
2613+
2614+ \sa isWritable(), setReadable()
2615+*/
2616+void QMetaPropertyBuilder::setWritable(bool value)
2617+{
2618+ QMetaPropertyBuilderPrivate *d = d_func();
2619+ if (d)
2620+ d->setFlag(Writable, value);
2621+}
2622+
2623+/*!
2624+ Sets this property to resettable if \a value is true.
2625+
2626+ \sa isResettable()
2627+*/
2628+void QMetaPropertyBuilder::setResettable(bool value)
2629+{
2630+ QMetaPropertyBuilderPrivate *d = d_func();
2631+ if (d)
2632+ d->setFlag(Resettable, value);
2633+}
2634+
2635+/*!
2636+ Sets this property to designable if \a value is true.
2637+
2638+ \sa isDesignable(), setScriptable(), setStored()
2639+*/
2640+void QMetaPropertyBuilder::setDesignable(bool value)
2641+{
2642+ QMetaPropertyBuilderPrivate *d = d_func();
2643+ if (d)
2644+ d->setFlag(Designable, value);
2645+}
2646+
2647+/*!
2648+ Sets this property to scriptable if \a value is true.
2649+
2650+ \sa isScriptable(), setDesignable(), setStored()
2651+*/
2652+void QMetaPropertyBuilder::setScriptable(bool value)
2653+{
2654+ QMetaPropertyBuilderPrivate *d = d_func();
2655+ if (d)
2656+ d->setFlag(Scriptable, value);
2657+}
2658+
2659+/*!
2660+ Sets this property to storable if \a value is true.
2661+
2662+ \sa isStored(), setDesignable(), setScriptable()
2663+*/
2664+void QMetaPropertyBuilder::setStored(bool value)
2665+{
2666+ QMetaPropertyBuilderPrivate *d = d_func();
2667+ if (d)
2668+ d->setFlag(Stored, value);
2669+}
2670+
2671+/*!
2672+ Sets this property to editable if \a value is true.
2673+
2674+ \sa isEditable(), setDesignable(), setScriptable(), setStored()
2675+*/
2676+void QMetaPropertyBuilder::setEditable(bool value)
2677+{
2678+ QMetaPropertyBuilderPrivate *d = d_func();
2679+ if (d)
2680+ d->setFlag(Editable, value);
2681+}
2682+
2683+/*!
2684+ Sets the \c USER flag on this property to \a value.
2685+
2686+ \sa isUser(), setDesignable(), setScriptable()
2687+*/
2688+void QMetaPropertyBuilder::setUser(bool value)
2689+{
2690+ QMetaPropertyBuilderPrivate *d = d_func();
2691+ if (d)
2692+ d->setFlag(User, value);
2693+}
2694+
2695+/*!
2696+ Sets the C++ setter flag on this property to \a value, which is
2697+ true if the property has a C++ setter function that follows Qt's
2698+ standard "name" / "setName" pattern.
2699+
2700+ \sa hasStdCppSet()
2701+*/
2702+void QMetaPropertyBuilder::setStdCppSet(bool value)
2703+{
2704+ QMetaPropertyBuilderPrivate *d = d_func();
2705+ if (d)
2706+ d->setFlag(StdCppSet, value);
2707+}
2708+
2709+/*!
2710+ Sets this property to be of an enumerator or flag type if
2711+ \a value is true.
2712+
2713+ \sa isEnumOrFlag()
2714+*/
2715+void QMetaPropertyBuilder::setEnumOrFlag(bool value)
2716+{
2717+ QMetaPropertyBuilderPrivate *d = d_func();
2718+ if (d)
2719+ d->setFlag(EnumOrFlag, value);
2720+}
2721+
2722+/*!
2723+ Sets this property to have the dynamic flag if \a value is
2724+ true.
2725+
2726+ \sa isDynamic()
2727+*/
2728+void QMetaPropertyBuilder::setDynamic(bool value)
2729+{
2730+ QMetaPropertyBuilderPrivate *d = d_func();
2731+ if (d)
2732+ d->setFlag(Dynamic, value);
2733+}
2734+
2735+/*!
2736+ \class QMetaEnumBuilder
2737+ \internal
2738+ \brief The QMetaEnumBuilder class enables modifications to an enumerator definition on a meta object builder.
2739+*/
2740+
2741+QMetaEnumBuilderPrivate *QMetaEnumBuilder::d_func() const
2742+{
2743+ if (_mobj && _index >= 0 && _index < _mobj->d->enumerators.size())
2744+ return &(_mobj->d->enumerators[_index]);
2745+ else
2746+ return 0;
2747+}
2748+
2749+/*!
2750+ \fn QMetaEnumBuilder::QMetaEnumBuilder()
2751+ \internal
2752+*/
2753+
2754+/*!
2755+ \fn int QMetaEnumBuilder::index() const
2756+
2757+ Returns the index of this enumerator within its QMetaObjectBuilder.
2758+*/
2759+
2760+/*!
2761+ Returns the name of the enumerator (without the scope).
2762+*/
2763+QByteArray QMetaEnumBuilder::name() const
2764+{
2765+ QMetaEnumBuilderPrivate *d = d_func();
2766+ if (d)
2767+ return d->name;
2768+ else
2769+ return QByteArray();
2770+}
2771+
2772+/*!
2773+ Returns true if this enumerator is used as a flag; otherwise returns
2774+ false.
2775+
2776+ \sa setIsFlag()
2777+*/
2778+bool QMetaEnumBuilder::isFlag() const
2779+{
2780+ QMetaEnumBuilderPrivate *d = d_func();
2781+ if (d)
2782+ return d->isFlag;
2783+ else
2784+ return false;
2785+}
2786+
2787+/*!
2788+ Sets this enumerator to be used as a flag if \a value is true.
2789+
2790+ \sa isFlag()
2791+*/
2792+void QMetaEnumBuilder::setIsFlag(bool value)
2793+{
2794+ QMetaEnumBuilderPrivate *d = d_func();
2795+ if (d)
2796+ d->isFlag = value;
2797+}
2798+
2799+/*!
2800+ Returns the number of keys.
2801+
2802+ \sa key(), addKey()
2803+*/
2804+int QMetaEnumBuilder::keyCount() const
2805+{
2806+ QMetaEnumBuilderPrivate *d = d_func();
2807+ if (d)
2808+ return d->keys.size();
2809+ else
2810+ return 0;
2811+}
2812+
2813+/*!
2814+ Returns the key with the given \a index, or an empty QByteArray
2815+ if no such key exists.
2816+
2817+ \sa keyCount(), addKey(), value()
2818+*/
2819+QByteArray QMetaEnumBuilder::key(int index) const
2820+{
2821+ QMetaEnumBuilderPrivate *d = d_func();
2822+ if (d && index >= 0 && index < d->keys.size())
2823+ return d->keys[index];
2824+ else
2825+ return QByteArray();
2826+}
2827+
2828+/*!
2829+ Returns the value with the given \a index; or returns -1 if there
2830+ is no such value.
2831+
2832+ \sa keyCount(), addKey(), key()
2833+*/
2834+int QMetaEnumBuilder::value(int index) const
2835+{
2836+ QMetaEnumBuilderPrivate *d = d_func();
2837+ if (d && index >= 0 && index < d->keys.size())
2838+ return d->values[index];
2839+ else
2840+ return -1;
2841+}
2842+
2843+/*!
2844+ Adds a new key called \a name to this enumerator, associated
2845+ with \a value. Returns the index of the new key.
2846+
2847+ \sa keyCount(), key(), value(), removeKey()
2848+*/
2849+int QMetaEnumBuilder::addKey(const QByteArray& name, int value)
2850+{
2851+ QMetaEnumBuilderPrivate *d = d_func();
2852+ if (d) {
2853+ int index = d->keys.size();
2854+ d->keys += name;
2855+ d->values += value;
2856+ return index;
2857+ } else {
2858+ return -1;
2859+ }
2860+}
2861+
2862+/*!
2863+ Removes the key at \a index from this enumerator.
2864+
2865+ \sa addKey()
2866+*/
2867+void QMetaEnumBuilder::removeKey(int index)
2868+{
2869+ QMetaEnumBuilderPrivate *d = d_func();
2870+ if (d && index >= 0 && index < d->keys.size()) {
2871+ d->keys.removeAt(index);
2872+ d->values.removeAt(index);
2873+ }
2874+}
2875+
2876+QTM_END_NAMESPACE
2877diff --git a/src/serviceframework/ipc/qmetaobjectbuilder_47_p.h b/src/serviceframework/ipc/qmetaobjectbuilder_47_p.h
2878new file mode 100644
2879index 0000000..5f25e0f
2880--- /dev/null
2881+++ b/src/serviceframework/ipc/qmetaobjectbuilder_47_p.h
2882@@ -0,0 +1,338 @@
2883+/****************************************************************************
2884+**
2885+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
2886+** All rights reserved.
2887+** Contact: Nokia Corporation (qt-info@nokia.com)
2888+**
2889+** This file is part of the Qt Mobility Components.
2890+**
2891+** $QT_BEGIN_LICENSE:LGPL$
2892+** No Commercial Usage
2893+** This file contains pre-release code and may not be distributed.
2894+** You may use this file in accordance with the terms and conditions
2895+** contained in the Technology Preview License Agreement accompanying
2896+** this package.
2897+**
2898+** GNU Lesser General Public License Usage
2899+** Alternatively, this file may be used under the terms of the GNU Lesser
2900+** General Public License version 2.1 as published by the Free Software
2901+** Foundation and appearing in the file LICENSE.LGPL included in the
2902+** packaging of this file. Please review the following information to
2903+** ensure the GNU Lesser General Public License version 2.1 requirements
2904+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
2905+**
2906+** In addition, as a special exception, Nokia gives you certain additional
2907+** rights. These rights are described in the Nokia Qt LGPL Exception
2908+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
2909+**
2910+** If you have questions regarding the use of this file, please contact
2911+** Nokia at qt-info@nokia.com.
2912+**
2913+**
2914+**
2915+**
2916+**
2917+**
2918+**
2919+**
2920+** $QT_END_LICENSE$
2921+**
2922+****************************************************************************/
2923+
2924+#ifndef QMETAOBJECTBUILDER_H
2925+#define QMETAOBJECTBUILDER_H
2926+
2927+//
2928+// W A R N I N G
2929+// -------------
2930+//
2931+// This file is not part of the Qt API. It exists for the convenience
2932+// of moc. This header file may change from version to version without notice,
2933+// or even be removed.
2934+//
2935+// We mean it.
2936+//
2937+
2938+#include <qmobilityglobal.h>
2939+#include <QtCore/qobject.h>
2940+#include <QtCore/qmetaobject.h>
2941+#include <QtCore/qdatastream.h>
2942+#include <QtCore/qmap.h>
2943+
2944+QTM_BEGIN_NAMESPACE
2945+
2946+class QMetaObjectBuilderPrivate;
2947+class QMetaMethodBuilder;
2948+class QMetaMethodBuilderPrivate;
2949+class QMetaPropertyBuilder;
2950+class QMetaPropertyBuilderPrivate;
2951+class QMetaEnumBuilder;
2952+class QMetaEnumBuilderPrivate;
2953+
2954+#ifdef IGNORE_METAOBJECTBUILDER_EXPORT
2955+ class QMetaObjectBuilder
2956+#else
2957+ class QM_AUTOTEST_EXPORT QMetaObjectBuilder
2958+#endif
2959+{
2960+public:
2961+ enum AddMember
2962+ {
2963+ ClassName = 0x00000001,
2964+ SuperClass = 0x00000002,
2965+ Methods = 0x00000004,
2966+ Signals = 0x00000008,
2967+ Slots = 0x00000010,
2968+ Constructors = 0x00000020,
2969+ Properties = 0x00000040,
2970+ Enumerators = 0x00000080,
2971+ ClassInfos = 0x00000100,
2972+ RelatedMetaObjects = 0x00000200,
2973+ StaticMetacall = 0x00000400,
2974+ PublicMethods = 0x00000800,
2975+ ProtectedMethods = 0x00001000,
2976+ PrivateMethods = 0x00002000,
2977+ AllMembers = 0x7FFFFFFF,
2978+ AllPrimaryMembers = 0x7FFFFBFC
2979+ };
2980+ Q_DECLARE_FLAGS(AddMembers, AddMember)
2981+
2982+ enum MetaObjectFlag {
2983+ DynamicMetaObject = 0x01
2984+ };
2985+ Q_DECLARE_FLAGS(MetaObjectFlags, MetaObjectFlag)
2986+
2987+ QMetaObjectBuilder();
2988+ explicit QMetaObjectBuilder(const QMetaObject *prototype, QMetaObjectBuilder::AddMembers members = AllMembers);
2989+ virtual ~QMetaObjectBuilder();
2990+
2991+ QByteArray className() const;
2992+ void setClassName(const QByteArray& name);
2993+
2994+ const QMetaObject *superClass() const;
2995+ void setSuperClass(const QMetaObject *meta);
2996+
2997+ MetaObjectFlags flags() const;
2998+ void setFlags(MetaObjectFlags);
2999+
3000+ int methodCount() const;
3001+ int constructorCount() const;
3002+ int propertyCount() const;
3003+ int enumeratorCount() const;
3004+ int classInfoCount() const;
3005+ int relatedMetaObjectCount() const;
3006+
3007+ QMetaMethodBuilder addMethod(const QByteArray& signature);
3008+ QMetaMethodBuilder addMethod(const QByteArray& signature, const QByteArray& returnType);
3009+ QMetaMethodBuilder addMethod(const QMetaMethod& prototype);
3010+
3011+ QMetaMethodBuilder addSlot(const QByteArray& signature);
3012+ QMetaMethodBuilder addSignal(const QByteArray& signature);
3013+
3014+ QMetaMethodBuilder addConstructor(const QByteArray& signature);
3015+ QMetaMethodBuilder addConstructor(const QMetaMethod& prototype);
3016+
3017+ QMetaPropertyBuilder addProperty(const QByteArray& name, const QByteArray& type, int notifierId=-1);
3018+ QMetaPropertyBuilder addProperty(const QMetaProperty& prototype);
3019+
3020+ QMetaEnumBuilder addEnumerator(const QByteArray& name);
3021+ QMetaEnumBuilder addEnumerator(const QMetaEnum& prototype);
3022+
3023+ int addClassInfo(const QByteArray& name, const QByteArray& value);
3024+
3025+#ifdef Q_NO_DATA_RELOCATION
3026+ int addRelatedMetaObject(const QMetaObjectAccessor &meta);
3027+#else
3028+ int addRelatedMetaObject(const QMetaObject *meta);
3029+#endif
3030+
3031+ void addMetaObject(const QMetaObject *prototype, QMetaObjectBuilder::AddMembers members = AllMembers);
3032+
3033+ QMetaMethodBuilder method(int index) const;
3034+ QMetaMethodBuilder constructor(int index) const;
3035+ QMetaPropertyBuilder property(int index) const;
3036+ QMetaEnumBuilder enumerator(int index) const;
3037+ const QMetaObject *relatedMetaObject(int index) const;
3038+
3039+ QByteArray classInfoName(int index) const;
3040+ QByteArray classInfoValue(int index) const;
3041+
3042+ void removeMethod(int index);
3043+ void removeConstructor(int index);
3044+ void removeProperty(int index);
3045+ void removeEnumerator(int index);
3046+ void removeClassInfo(int index);
3047+ void removeRelatedMetaObject(int index);
3048+
3049+ int indexOfMethod(const QByteArray& signature);
3050+ int indexOfSignal(const QByteArray& signature);
3051+ int indexOfSlot(const QByteArray& signature);
3052+ int indexOfConstructor(const QByteArray& signature);
3053+ int indexOfProperty(const QByteArray& name);
3054+ int indexOfEnumerator(const QByteArray& name);
3055+ int indexOfClassInfo(const QByteArray& name);
3056+
3057+ typedef int (*StaticMetacallFunction)(QMetaObject::Call, int, void **);
3058+
3059+ QMetaObjectBuilder::StaticMetacallFunction staticMetacallFunction() const;
3060+ void setStaticMetacallFunction(QMetaObjectBuilder::StaticMetacallFunction value);
3061+
3062+ QMetaObject *toMetaObject() const;
3063+ QByteArray toRelocatableData(bool * = 0) const;
3064+ static void fromRelocatableData(QMetaObject *, const QMetaObject *, const QByteArray &);
3065+
3066+#ifndef QT_NO_DATASTREAM
3067+ void serialize(QDataStream& stream) const;
3068+ void deserialize
3069+ (QDataStream& stream,
3070+ const QMap<QByteArray, const QMetaObject *>& references);
3071+#endif
3072+
3073+private:
3074+ Q_DISABLE_COPY(QMetaObjectBuilder)
3075+
3076+ QMetaObjectBuilderPrivate *d;
3077+
3078+ friend class QMetaMethodBuilder;
3079+ friend class QMetaPropertyBuilder;
3080+ friend class QMetaEnumBuilder;
3081+};
3082+
3083+#ifdef IGNORE_METAOBJECTBUILDER_EXPORT
3084+ class QMetaMethodBuilder
3085+#else
3086+ class QM_AUTOTEST_EXPORT QMetaMethodBuilder
3087+#endif
3088+{
3089+public:
3090+ QMetaMethodBuilder() : _mobj(0), _index(0) {}
3091+
3092+ int index() const;
3093+
3094+ QMetaMethod::MethodType methodType() const;
3095+ QByteArray signature() const;
3096+
3097+ QByteArray returnType() const;
3098+ void setReturnType(const QByteArray& value);
3099+
3100+ QList<QByteArray> parameterNames() const;
3101+ void setParameterNames(const QList<QByteArray>& value);
3102+
3103+ QByteArray tag() const;
3104+ void setTag(const QByteArray& value);
3105+
3106+ QMetaMethod::Access access() const;
3107+ void setAccess(QMetaMethod::Access value);
3108+
3109+ int attributes() const;
3110+ void setAttributes(int value);
3111+
3112+private:
3113+ const QMetaObjectBuilder *_mobj;
3114+ int _index;
3115+
3116+ friend class QMetaObjectBuilder;
3117+ friend class QMetaPropertyBuilder;
3118+
3119+ QMetaMethodBuilder(const QMetaObjectBuilder *mobj, int index)
3120+ : _mobj(mobj), _index(index) {}
3121+
3122+ QMetaMethodBuilderPrivate *d_func() const;
3123+};
3124+
3125+#ifdef IGNORE_METAOBJECTBUILDER_EXPORT
3126+ class QMetaPropertyBuilder
3127+#else
3128+ class QM_AUTOTEST_EXPORT QMetaPropertyBuilder
3129+#endif
3130+{
3131+public:
3132+ QMetaPropertyBuilder() : _mobj(0), _index(0) {}
3133+
3134+ int index() const { return _index; }
3135+
3136+ QByteArray name() const;
3137+ QByteArray type() const;
3138+
3139+ bool hasNotifySignal() const;
3140+ QMetaMethodBuilder notifySignal() const;
3141+ void setNotifySignal(const QMetaMethodBuilder& value);
3142+ void removeNotifySignal();
3143+
3144+ bool isReadable() const;
3145+ bool isWritable() const;
3146+ bool isResettable() const;
3147+ bool isDesignable() const;
3148+ bool isScriptable() const;
3149+ bool isStored() const;
3150+ bool isEditable() const;
3151+ bool isUser() const;
3152+ bool hasStdCppSet() const;
3153+ bool isEnumOrFlag() const;
3154+ bool isDynamic() const;
3155+
3156+ void setReadable(bool value);
3157+ void setWritable(bool value);
3158+ void setResettable(bool value);
3159+ void setDesignable(bool value);
3160+ void setScriptable(bool value);
3161+ void setStored(bool value);
3162+ void setEditable(bool value);
3163+ void setUser(bool value);
3164+ void setStdCppSet(bool value);
3165+ void setEnumOrFlag(bool value);
3166+ void setDynamic(bool value);
3167+
3168+private:
3169+ const QMetaObjectBuilder *_mobj;
3170+ int _index;
3171+
3172+ friend class QMetaObjectBuilder;
3173+
3174+ QMetaPropertyBuilder(const QMetaObjectBuilder *mobj, int index)
3175+ : _mobj(mobj), _index(index) {}
3176+
3177+ QMetaPropertyBuilderPrivate *d_func() const;
3178+};
3179+
3180+#ifdef IGNORE_METAOBJECTBUILDER_EXPORT
3181+ class QMetaEnumBuilder
3182+#else
3183+ class QM_AUTOTEST_EXPORT QMetaEnumBuilder
3184+#endif
3185+{
3186+public:
3187+ QMetaEnumBuilder() : _mobj(0), _index(0) {}
3188+
3189+ int index() const { return _index; }
3190+
3191+ QByteArray name() const;
3192+
3193+ bool isFlag() const;
3194+ void setIsFlag(bool value);
3195+
3196+ int keyCount() const;
3197+ QByteArray key(int index) const;
3198+ int value(int index) const;
3199+
3200+ int addKey(const QByteArray& name, int value);
3201+ void removeKey(int index);
3202+
3203+private:
3204+ const QMetaObjectBuilder *_mobj;
3205+ int _index;
3206+
3207+ friend class QMetaObjectBuilder;
3208+
3209+ QMetaEnumBuilder(const QMetaObjectBuilder *mobj, int index)
3210+ : _mobj(mobj), _index(index) {}
3211+
3212+ QMetaEnumBuilderPrivate *d_func() const;
3213+};
3214+
3215+Q_DECLARE_OPERATORS_FOR_FLAGS(QMetaObjectBuilder::AddMembers)
3216+Q_DECLARE_OPERATORS_FOR_FLAGS(QMetaObjectBuilder::MetaObjectFlags)
3217+
3218+QTM_END_NAMESPACE
3219+
3220+#endif
3221diff --git a/src/serviceframework/ipc/qmetaobjectbuilder_p.h b/src/serviceframework/ipc/qmetaobjectbuilder_p.h
3222index 5f25e0f..7f29ddc 100644
3223--- a/src/serviceframework/ipc/qmetaobjectbuilder_p.h
3224+++ b/src/serviceframework/ipc/qmetaobjectbuilder_p.h
3225@@ -69,6 +69,8 @@ class QMetaPropertyBuilderPrivate;
3226 class QMetaEnumBuilder;
3227 class QMetaEnumBuilderPrivate;
3228
3229+typedef const QMetaObject& (*QMetaObjectAccessor)();
3230+
3231 #ifdef IGNORE_METAOBJECTBUILDER_EXPORT
3232 class QMetaObjectBuilder
3233 #else
3234@@ -172,7 +174,7 @@ public:
3235 int indexOfEnumerator(const QByteArray& name);
3236 int indexOfClassInfo(const QByteArray& name);
3237
3238- typedef int (*StaticMetacallFunction)(QMetaObject::Call, int, void **);
3239+ typedef QMetaObjectExtraData::StaticMetacallFunction StaticMetacallFunction;
3240
3241 QMetaObjectBuilder::StaticMetacallFunction staticMetacallFunction() const;
3242 void setStaticMetacallFunction(QMetaObjectBuilder::StaticMetacallFunction value);
3243@@ -269,7 +271,8 @@ public:
3244 bool isUser() const;
3245 bool hasStdCppSet() const;
3246 bool isEnumOrFlag() const;
3247- bool isDynamic() const;
3248+ bool isConstant() const;
3249+ bool isFinal() const;
3250
3251 void setReadable(bool value);
3252 void setWritable(bool value);
3253@@ -281,7 +284,8 @@ public:
3254 void setUser(bool value);
3255 void setStdCppSet(bool value);
3256 void setEnumOrFlag(bool value);
3257- void setDynamic(bool value);
3258+ void setConstant(bool value);
3259+ void setFinal(bool value);
3260
3261 private:
3262 const QMetaObjectBuilder *_mobj;
3263diff --git a/tests/auto/qmetaobjectbuilder/qmetaobjectbuilder.pro b/tests/auto/qmetaobjectbuilder/qmetaobjectbuilder.pro
3264index 4cbc03a..fa6123b 100644
3265--- a/tests/auto/qmetaobjectbuilder/qmetaobjectbuilder.pro
3266+++ b/tests/auto/qmetaobjectbuilder/qmetaobjectbuilder.pro
3267@@ -9,7 +9,11 @@ QT = core
3268 include(../../../common.pri)
3269
3270 # Input
3271-SOURCES += tst_qmetaobjectbuilder.cpp
3272+contains(QT_MAJOR_VERSION, 4):lessThan(QT_MINOR_VERSION, 8) {
3273+ SOURCES += tst_qmetaobjectbuilder_47.cpp
3274+} else {
3275+ SOURCES += tst_qmetaobjectbuilder.cpp
3276+}
3277
3278 CONFIG += mobility
3279 MOBILITY = serviceframework
3280diff --git a/tests/auto/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp b/tests/auto/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp
3281index 48ba43c..470d9e5 100644
3282--- a/tests/auto/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp
3283+++ b/tests/auto/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp
3284@@ -149,9 +149,9 @@ void tst_QMetaObjectBuilder::mocVersionCheck()
3285 // whenenver moc changes. Once QMetaObjectBuilder has been
3286 // updated, this test can be changed to check for the next version.
3287 int version = int(QObject::staticMetaObject.d.data[0]);
3288- QVERIFY(version == 4 || version == 5);
3289+ QVERIFY(version == 4 || version == 5 || version == 6);
3290 version = int(staticMetaObject.d.data[0]);
3291- QVERIFY(version == 4 || version == 5);
3292+ QVERIFY(version == 4 || version == 5 || version == 6);
3293 }
3294
3295 void tst_QMetaObjectBuilder::create()
3296@@ -555,7 +555,8 @@ void tst_QMetaObjectBuilder::property()
3297 QVERIFY(!nullProp.isUser());
3298 QVERIFY(!nullProp.hasStdCppSet());
3299 QVERIFY(!nullProp.isEnumOrFlag());
3300- QVERIFY(!nullProp.isDynamic());
3301+ QVERIFY(!nullProp.isConstant());
3302+ QVERIFY(!nullProp.isFinal());
3303 QCOMPARE(nullProp.index(), 0);
3304
3305 // Add a property and check its attributes.
3306@@ -573,7 +574,8 @@ void tst_QMetaObjectBuilder::property()
3307 QVERIFY(!prop1.isUser());
3308 QVERIFY(!prop1.hasStdCppSet());
3309 QVERIFY(!prop1.isEnumOrFlag());
3310- QVERIFY(!prop1.isDynamic());
3311+ QVERIFY(!prop1.isConstant());
3312+ QVERIFY(!prop1.isFinal());
3313 QCOMPARE(prop1.index(), 0);
3314 QCOMPARE(builder.propertyCount(), 1);
3315
3316@@ -592,7 +594,8 @@ void tst_QMetaObjectBuilder::property()
3317 QVERIFY(!prop2.isUser());
3318 QVERIFY(!prop2.hasStdCppSet());
3319 QVERIFY(!prop2.isEnumOrFlag());
3320- QVERIFY(!prop2.isDynamic());
3321+ QVERIFY(!prop2.isConstant());
3322+ QVERIFY(!prop2.isFinal());
3323 QCOMPARE(prop2.index(), 1);
3324 QCOMPARE(builder.propertyCount(), 2);
3325
3326@@ -614,7 +617,8 @@ void tst_QMetaObjectBuilder::property()
3327 prop1.setUser(true);
3328 prop1.setStdCppSet(true);
3329 prop1.setEnumOrFlag(true);
3330- prop1.setDynamic(true);
3331+ prop1.setConstant(true);
3332+ prop1.setFinal(true);
3333
3334 // Check that prop1 is changed, but prop2 is not.
3335 QCOMPARE(prop1.name(), QByteArray("foo"));
3336@@ -629,7 +633,8 @@ void tst_QMetaObjectBuilder::property()
3337 QVERIFY(prop1.isUser());
3338 QVERIFY(prop1.hasStdCppSet());
3339 QVERIFY(prop1.isEnumOrFlag());
3340- QVERIFY(prop1.isDynamic());
3341+ QVERIFY(prop1.isConstant());
3342+ QVERIFY(prop1.isFinal());
3343 QVERIFY(prop2.isReadable());
3344 QVERIFY(prop2.isWritable());
3345 QCOMPARE(prop2.name(), QByteArray("bar"));
3346@@ -642,7 +647,8 @@ void tst_QMetaObjectBuilder::property()
3347 QVERIFY(!prop2.isUser());
3348 QVERIFY(!prop2.hasStdCppSet());
3349 QVERIFY(!prop2.isEnumOrFlag());
3350- QVERIFY(!prop2.isDynamic());
3351+ QVERIFY(!prop2.isConstant());
3352+ QVERIFY(!prop2.isFinal());
3353
3354 // Remove prop1 and check that prop2 becomes index 0.
3355 builder.removeProperty(0);
3356@@ -658,7 +664,8 @@ void tst_QMetaObjectBuilder::property()
3357 QVERIFY(!prop2.isUser());
3358 QVERIFY(!prop2.hasStdCppSet());
3359 QVERIFY(!prop2.isEnumOrFlag());
3360- QVERIFY(!prop2.isDynamic());
3361+ QVERIFY(!prop2.isConstant());
3362+ QVERIFY(!prop2.isFinal());
3363 QCOMPARE(prop2.index(), 0);
3364
3365 // Perform index-based lookup again.
3366@@ -682,7 +689,8 @@ void tst_QMetaObjectBuilder::property()
3367 prop2.setUser(false); \
3368 prop2.setStdCppSet(false); \
3369 prop2.setEnumOrFlag(false); \
3370- prop2.setDynamic(false); \
3371+ prop2.setConstant(false); \
3372+ prop2.setFinal(false); \
3373 } while (0)
3374 #define COUNT_FLAGS() \
3375 ((prop2.isReadable() ? 1 : 0) + \
3376@@ -695,7 +703,8 @@ void tst_QMetaObjectBuilder::property()
3377 (prop2.isUser() ? 1 : 0) + \
3378 (prop2.hasStdCppSet() ? 1 : 0) + \
3379 (prop2.isEnumOrFlag() ? 1 : 0) + \
3380- (prop2.isDynamic() ? 1 : 0))
3381+ (prop2.isConstant() ? 1 : 0) + \
3382+ (prop2.isFinal() ? 1 : 0))
3383 #define CHECK_FLAG(setFunc,isFunc) \
3384 do { \
3385 CLEAR_FLAGS(); \
3386@@ -714,7 +723,8 @@ void tst_QMetaObjectBuilder::property()
3387 CHECK_FLAG(setUser, isUser);
3388 CHECK_FLAG(setStdCppSet, hasStdCppSet);
3389 CHECK_FLAG(setEnumOrFlag, isEnumOrFlag);
3390- CHECK_FLAG(setDynamic, isDynamic);
3391+ CHECK_FLAG(setConstant, isConstant);
3392+ CHECK_FLAG(setFinal, isFinal);
3393
3394 // Check that nothing else changed.
3395 QVERIFY(checkForSideEffects(builder, QMetaObjectBuilder::Properties));
3396@@ -958,9 +968,9 @@ void tst_QMetaObjectBuilder::relatedMetaObject()
3397 QVERIFY(checkForSideEffects(builder, QMetaObjectBuilder::RelatedMetaObjects));
3398 }
3399
3400-static int smetacall(QMetaObject::Call, int, void **)
3401+static void smetacall(QObject *, QMetaObject::Call, int, void **)
3402 {
3403- return 0;
3404+ return;
3405 }
3406
3407 void tst_QMetaObjectBuilder::staticMetacall()
3408@@ -1263,8 +1273,8 @@ bool tst_QMetaObjectBuilder::sameMetaObject
3409 if (extra1 && extra2) {
3410 if (extra1->static_metacall != extra2->static_metacall)
3411 return false;
3412- //objects1 = extra1->objects;
3413- //objects2 = extra1->objects;
3414+ objects1 = extra1->objects;
3415+ objects2 = extra1->objects;
3416 }
3417 } else if (meta1->d.data[0] == meta2->d.data[0] && meta1->d.data[0] == 1) {
3418 objects1 = (const QMetaObject **)(meta1->d.extradata);
3419diff --git a/tests/auto/qmetaobjectbuilder/tst_qmetaobjectbuilder_47.cpp b/tests/auto/qmetaobjectbuilder/tst_qmetaobjectbuilder_47.cpp
3420new file mode 100644
3421index 0000000..96a7eca
3422--- /dev/null
3423+++ b/tests/auto/qmetaobjectbuilder/tst_qmetaobjectbuilder_47.cpp
3424@@ -0,0 +1,1283 @@
3425+/****************************************************************************
3426+**
3427+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
3428+** All rights reserved.
3429+** Contact: Nokia Corporation (qt-info@nokia.com)
3430+**
3431+** This file is part of the test suite of the Qt Toolkit.
3432+**
3433+** $QT_BEGIN_LICENSE:LGPL$
3434+** No Commercial Usage
3435+** This file contains pre-release code and may not be distributed.
3436+** You may use this file in accordance with the terms and conditions
3437+** contained in the Technology Preview License Agreement accompanying
3438+** this package.
3439+**
3440+** GNU Lesser General Public License Usage
3441+** Alternatively, this file may be used under the terms of the GNU Lesser
3442+** General Public License version 2.1 as published by the Free Software
3443+** Foundation and appearing in the file LICENSE.LGPL included in the
3444+** packaging of this file. Please review the following information to
3445+** ensure the GNU Lesser General Public License version 2.1 requirements
3446+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
3447+**
3448+** In addition, as a special exception, Nokia gives you certain additional
3449+** rights. These rights are described in the Nokia Qt LGPL Exception
3450+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
3451+**
3452+** If you have questions regarding the use of this file, please contact
3453+** Nokia at qt-info@nokia.com.
3454+**
3455+**
3456+**
3457+**
3458+**
3459+**
3460+**
3461+**
3462+** $QT_END_LICENSE$
3463+**
3464+****************************************************************************/
3465+
3466+//TESTED_COMPONENT=src/serviceframework
3467+
3468+#include <qmobilityglobal.h>
3469+#include <QtTest/QtTest>
3470+#include <QtCore/qlocale.h>
3471+#include <qmetaobjectbuilder_47_p.h>
3472+
3473+QTM_USE_NAMESPACE
3474+
3475+class tst_QMetaObjectBuilder : public QObject
3476+{
3477+ Q_OBJECT
3478+public:
3479+ tst_QMetaObjectBuilder() {}
3480+ ~tst_QMetaObjectBuilder() {}
3481+
3482+private slots:
3483+ void mocVersionCheck();
3484+ void create();
3485+ void className();
3486+ void superClass();
3487+ void flags();
3488+ void method();
3489+ void slot();
3490+ void signal();
3491+ void constructor();
3492+ void property();
3493+ void notifySignal();
3494+ void enumerator();
3495+ void classInfo();
3496+ void relatedMetaObject();
3497+ void staticMetacall();
3498+ void copyMetaObject();
3499+ void serialize();
3500+ void removeNotifySignal();
3501+
3502+private:
3503+ static bool checkForSideEffects
3504+ (const QMetaObjectBuilder& builder,
3505+ QMetaObjectBuilder::AddMembers members);
3506+ static bool sameMetaObject
3507+ (const QMetaObject *meta1, const QMetaObject *meta2);
3508+};
3509+
3510+#ifdef Q_NO_DATA_RELOCATION
3511+const QMetaObject *meta;
3512+#endif
3513+
3514+// Dummy class that has something of every type of thing moc can generate.
3515+class SomethingOfEverything : public QObject
3516+{
3517+ Q_OBJECT
3518+ Q_CLASSINFO("ci_foo", "ABC")
3519+ Q_CLASSINFO("ci_bar", "DEF")
3520+ Q_PROPERTY(QString prop READ prop WRITE setProp NOTIFY propChanged)
3521+ Q_PROPERTY(QString prop2 READ prop WRITE setProp)
3522+ Q_PROPERTY(SomethingEnum eprop READ eprop)
3523+ Q_PROPERTY(SomethingFlagEnum fprop READ fprop)
3524+ Q_PROPERTY(QLocale::Language language READ language)
3525+ Q_ENUMS(SomethingEnum)
3526+ Q_FLAGS(SomethingFlagEnum)
3527+public:
3528+ Q_INVOKABLE SomethingOfEverything() {}
3529+ ~SomethingOfEverything() {}
3530+
3531+ enum SomethingEnum
3532+ {
3533+ GHI,
3534+ JKL = 10
3535+ };
3536+
3537+ enum SomethingFlagEnum
3538+ {
3539+ XYZ = 1,
3540+ UVW = 8
3541+ };
3542+
3543+ Q_INVOKABLE Q_SCRIPTABLE void method1() {}
3544+
3545+ QString prop() const { return QString(); }
3546+ void setProp(const QString& v) { Q_UNUSED(v); }
3547+
3548+ SomethingOfEverything::SomethingEnum eprop() const { return GHI; }
3549+ SomethingOfEverything::SomethingFlagEnum fprop() const { return XYZ; }
3550+ QLocale::Language language() const { return QLocale::English; }
3551+
3552+public slots:
3553+ void slot1(const QString&) {}
3554+ void slot2(int, const QString&) {}
3555+
3556+private slots:
3557+ void slot3() {}
3558+
3559+protected slots:
3560+ Q_SCRIPTABLE void slot4(int) {}
3561+ void slot5(int a, const QString& b) { Q_UNUSED(a); Q_UNUSED(b); }
3562+
3563+signals:
3564+ void sig1();
3565+ void sig2(int x, const QString& y);
3566+ void propChanged(const QString&);
3567+};
3568+
3569+void tst_QMetaObjectBuilder::mocVersionCheck()
3570+{
3571+ // This test will fail when the moc version number is changed.
3572+ // It is intended as a reminder to also update QMetaObjectBuilder
3573+ // whenenver moc changes. Once QMetaObjectBuilder has been
3574+ // updated, this test can be changed to check for the next version.
3575+ int version = int(QObject::staticMetaObject.d.data[0]);
3576+ QVERIFY(version == 4 || version == 5 || version == 6);
3577+ version = int(staticMetaObject.d.data[0]);
3578+ QVERIFY(version == 4 || version == 5 || version == 6);
3579+}
3580+
3581+void tst_QMetaObjectBuilder::create()
3582+{
3583+ QMetaObjectBuilder builder;
3584+ QVERIFY(builder.className().isEmpty());
3585+ QVERIFY(builder.superClass() == &QObject::staticMetaObject);
3586+ QCOMPARE(builder.methodCount(), 0);
3587+ QCOMPARE(builder.constructorCount(), 0);
3588+ QCOMPARE(builder.propertyCount(), 0);
3589+ QCOMPARE(builder.enumeratorCount(), 0);
3590+ QCOMPARE(builder.classInfoCount(), 0);
3591+ QCOMPARE(builder.relatedMetaObjectCount(), 0);
3592+ QVERIFY(builder.staticMetacallFunction() == 0);
3593+}
3594+
3595+void tst_QMetaObjectBuilder::className()
3596+{
3597+ QMetaObjectBuilder builder;
3598+
3599+ // Change the class name.
3600+ builder.setClassName("Foo");
3601+ QCOMPARE(builder.className(), QByteArray("Foo"));
3602+
3603+ // Change it again.
3604+ builder.setClassName("Bar");
3605+ QCOMPARE(builder.className(), QByteArray("Bar"));
3606+
3607+ // Clone the class name off a static QMetaObject.
3608+ builder.addMetaObject(&QObject::staticMetaObject, QMetaObjectBuilder::ClassName);
3609+ QCOMPARE(builder.className(), QByteArray("QObject"));
3610+
3611+ // Check that nothing else changed.
3612+ QVERIFY(checkForSideEffects(builder, QMetaObjectBuilder::ClassName));
3613+}
3614+
3615+void tst_QMetaObjectBuilder::superClass()
3616+{
3617+ QMetaObjectBuilder builder;
3618+
3619+ // Change the super class.
3620+ builder.setSuperClass(&QObject::staticMetaObject);
3621+ QVERIFY(builder.superClass() == &QObject::staticMetaObject);
3622+
3623+ // Change it again.
3624+ builder.setSuperClass(&staticMetaObject);
3625+ QVERIFY(builder.superClass() == &staticMetaObject);
3626+
3627+ // Clone the super class off a static QMetaObject.
3628+ builder.addMetaObject(&QObject::staticMetaObject, QMetaObjectBuilder::SuperClass);
3629+ QVERIFY(builder.superClass() == 0);
3630+ builder.addMetaObject(&staticMetaObject, QMetaObjectBuilder::SuperClass);
3631+ QVERIFY(builder.superClass() == staticMetaObject.superClass());
3632+
3633+ // Check that nothing else changed.
3634+ QVERIFY(checkForSideEffects(builder, QMetaObjectBuilder::SuperClass));
3635+}
3636+
3637+void tst_QMetaObjectBuilder::flags()
3638+{
3639+ QMetaObjectBuilder builder;
3640+
3641+ // Check default
3642+ QVERIFY(builder.flags() == 0);
3643+
3644+ // Set flags
3645+ builder.setFlags(QMetaObjectBuilder::DynamicMetaObject);
3646+ QVERIFY(builder.flags() == QMetaObjectBuilder::DynamicMetaObject);
3647+}
3648+
3649+void tst_QMetaObjectBuilder::method()
3650+{
3651+ QMetaObjectBuilder builder;
3652+
3653+ // Check null method
3654+ QMetaMethodBuilder nullMethod;
3655+ QCOMPARE(nullMethod.signature(), QByteArray());
3656+ QVERIFY(nullMethod.methodType() == QMetaMethod::Method);
3657+ QVERIFY(nullMethod.returnType().isEmpty());
3658+ QVERIFY(nullMethod.parameterNames().isEmpty());
3659+ QVERIFY(nullMethod.tag().isEmpty());
3660+ QVERIFY(nullMethod.access() == QMetaMethod::Public);
3661+ QCOMPARE(nullMethod.attributes(), 0);
3662+ QCOMPARE(nullMethod.index(), 0);
3663+
3664+ // Add a method and check its attributes.
3665+ QMetaMethodBuilder method1 = builder.addMethod("foo(const QString&, int)");
3666+ QCOMPARE(method1.signature(), QByteArray("foo(QString,int)"));
3667+ QVERIFY(method1.methodType() == QMetaMethod::Method);
3668+ QVERIFY(method1.returnType().isEmpty());
3669+ QVERIFY(method1.parameterNames().isEmpty());
3670+ QVERIFY(method1.tag().isEmpty());
3671+ QVERIFY(method1.access() == QMetaMethod::Public);
3672+ QCOMPARE(method1.attributes(), 0);
3673+ QCOMPARE(method1.index(), 0);
3674+ QCOMPARE(builder.methodCount(), 1);
3675+
3676+ // Add another method and check again.
3677+ QMetaMethodBuilder method2 = builder.addMethod("bar(QString)", "int");
3678+ QCOMPARE(method2.signature(), QByteArray("bar(QString)"));
3679+ QVERIFY(method2.methodType() == QMetaMethod::Method);
3680+ QCOMPARE(method2.returnType(), QByteArray("int"));
3681+ QVERIFY(method2.parameterNames().isEmpty());
3682+ QVERIFY(method2.tag().isEmpty());
3683+ QVERIFY(method2.access() == QMetaMethod::Public);
3684+ QCOMPARE(method2.attributes(), 0);
3685+ QCOMPARE(method2.index(), 1);
3686+ QCOMPARE(builder.methodCount(), 2);
3687+
3688+ // Perform index-based lookup.
3689+ QCOMPARE(builder.indexOfMethod("foo(const QString&, int)"), 0);
3690+ QCOMPARE(builder.indexOfMethod("bar(QString)"), 1);
3691+ QCOMPARE(builder.indexOfMethod("baz()"), -1);
3692+
3693+ // Modify the attributes on method1.
3694+ method1.setReturnType("int");
3695+ method1.setParameterNames(QList<QByteArray>() << "a" << "b");
3696+ method1.setTag("tag");
3697+ method1.setAccess(QMetaMethod::Private);
3698+ method1.setAttributes(42);
3699+
3700+ // Check that method1 is changed, but method2 is not.
3701+ QCOMPARE(method1.signature(), QByteArray("foo(QString,int)"));
3702+ QVERIFY(method1.methodType() == QMetaMethod::Method);
3703+ QCOMPARE(method1.returnType(), QByteArray("int"));
3704+ QCOMPARE(method1.parameterNames(), QList<QByteArray>() << "a" << "b");
3705+ QCOMPARE(method1.tag(), QByteArray("tag"));
3706+ QVERIFY(method1.access() == QMetaMethod::Private);
3707+ QCOMPARE(method1.attributes(), 42);
3708+ QCOMPARE(method1.index(), 0);
3709+ QCOMPARE(method2.signature(), QByteArray("bar(QString)"));
3710+ QVERIFY(method2.methodType() == QMetaMethod::Method);
3711+ QCOMPARE(method2.returnType(), QByteArray("int"));
3712+ QVERIFY(method2.parameterNames().isEmpty());
3713+ QVERIFY(method2.tag().isEmpty());
3714+ QVERIFY(method2.access() == QMetaMethod::Public);
3715+ QCOMPARE(method2.attributes(), 0);
3716+ QCOMPARE(method2.index(), 1);
3717+ QCOMPARE(builder.methodCount(), 2);
3718+
3719+ // Modify the attributes on method2.
3720+ method2.setReturnType("QString");
3721+ method2.setParameterNames(QList<QByteArray>() << "c");
3722+ method2.setTag("Q_FOO");
3723+ method2.setAccess(QMetaMethod::Protected);
3724+ method2.setAttributes(24);
3725+
3726+ // This time check that only method2 changed.
3727+ QCOMPARE(method1.signature(), QByteArray("foo(QString,int)"));
3728+ QVERIFY(method1.methodType() == QMetaMethod::Method);
3729+ QCOMPARE(method1.returnType(), QByteArray("int"));
3730+ QCOMPARE(method1.parameterNames(), QList<QByteArray>() << "a" << "b");
3731+ QCOMPARE(method1.tag(), QByteArray("tag"));
3732+ QVERIFY(method1.access() == QMetaMethod::Private);
3733+ QCOMPARE(method1.attributes(), 42);
3734+ QCOMPARE(method1.index(), 0);
3735+ QCOMPARE(method2.signature(), QByteArray("bar(QString)"));
3736+ QVERIFY(method2.methodType() == QMetaMethod::Method);
3737+ QCOMPARE(method2.returnType(), QByteArray("QString"));
3738+ QCOMPARE(method2.parameterNames(), QList<QByteArray>() << "c");
3739+ QCOMPARE(method2.tag(), QByteArray("Q_FOO"));
3740+ QVERIFY(method2.access() == QMetaMethod::Protected);
3741+ QCOMPARE(method2.attributes(), 24);
3742+ QCOMPARE(method2.index(), 1);
3743+ QCOMPARE(builder.methodCount(), 2);
3744+
3745+ // Remove method1 and check that method2 becomes index 0.
3746+ builder.removeMethod(0);
3747+ QCOMPARE(builder.methodCount(), 1);
3748+ method2 = builder.method(0);
3749+ QCOMPARE(method2.signature(), QByteArray("bar(QString)"));
3750+ QVERIFY(method2.methodType() == QMetaMethod::Method);
3751+ QCOMPARE(method2.returnType(), QByteArray("QString"));
3752+ QCOMPARE(method2.parameterNames(), QList<QByteArray>() << "c");
3753+ QCOMPARE(method2.tag(), QByteArray("Q_FOO"));
3754+ QVERIFY(method2.access() == QMetaMethod::Protected);
3755+ QCOMPARE(method2.attributes(), 24);
3756+ QCOMPARE(method2.index(), 0);
3757+
3758+ // Perform index-based lookup again.
3759+ QCOMPARE(builder.indexOfMethod("foo(const QString&, int)"), -1);
3760+ QCOMPARE(builder.indexOfMethod("bar(QString)"), 0);
3761+ QCOMPARE(builder.indexOfMethod("baz()"), -1);
3762+ QCOMPARE(builder.method(0).signature(), QByteArray("bar(QString)"));
3763+ QCOMPARE(builder.method(9).signature(), QByteArray());
3764+
3765+ // Check that nothing else changed.
3766+ QVERIFY(checkForSideEffects(builder, QMetaObjectBuilder::Methods));
3767+}
3768+
3769+void tst_QMetaObjectBuilder::slot()
3770+{
3771+ QMetaObjectBuilder builder;
3772+
3773+ // Add a slot and check its attributes.
3774+ QMetaMethodBuilder method1 = builder.addSlot("foo(const QString&, int)");
3775+ QCOMPARE(method1.signature(), QByteArray("foo(QString,int)"));
3776+ QVERIFY(method1.methodType() == QMetaMethod::Slot);
3777+ QVERIFY(method1.returnType().isEmpty());
3778+ QVERIFY(method1.parameterNames().isEmpty());
3779+ QVERIFY(method1.tag().isEmpty());
3780+ QVERIFY(method1.access() == QMetaMethod::Public);
3781+ QCOMPARE(method1.attributes(), 0);
3782+ QCOMPARE(method1.index(), 0);
3783+ QCOMPARE(builder.methodCount(), 1);
3784+
3785+ // Add another slot and check again.
3786+ QMetaMethodBuilder method2 = builder.addSlot("bar(QString)");
3787+ QCOMPARE(method2.signature(), QByteArray("bar(QString)"));
3788+ QVERIFY(method2.methodType() == QMetaMethod::Slot);
3789+ QVERIFY(method2.returnType().isEmpty());
3790+ QVERIFY(method2.parameterNames().isEmpty());
3791+ QVERIFY(method2.tag().isEmpty());
3792+ QVERIFY(method2.access() == QMetaMethod::Public);
3793+ QCOMPARE(method2.attributes(), 0);
3794+ QCOMPARE(method2.index(), 1);
3795+ QCOMPARE(builder.methodCount(), 2);
3796+
3797+ // Perform index-based lookup
3798+ QCOMPARE(builder.indexOfSlot("foo(const QString &, int)"), 0);
3799+ QCOMPARE(builder.indexOfSlot("bar(QString)"), 1);
3800+ QCOMPARE(builder.indexOfSlot("baz()"), -1);
3801+
3802+ // Check that nothing else changed.
3803+ QVERIFY(checkForSideEffects(builder, QMetaObjectBuilder::Methods));
3804+}
3805+
3806+void tst_QMetaObjectBuilder::signal()
3807+{
3808+ QMetaObjectBuilder builder;
3809+
3810+ // Add a signal and check its attributes.
3811+ QMetaMethodBuilder method1 = builder.addSignal("foo(const QString&, int)");
3812+ QCOMPARE(method1.signature(), QByteArray("foo(QString,int)"));
3813+ QVERIFY(method1.methodType() == QMetaMethod::Signal);
3814+ QVERIFY(method1.returnType().isEmpty());
3815+ QVERIFY(method1.parameterNames().isEmpty());
3816+ QVERIFY(method1.tag().isEmpty());
3817+ QVERIFY(method1.access() == QMetaMethod::Protected);
3818+ QCOMPARE(method1.attributes(), 0);
3819+ QCOMPARE(method1.index(), 0);
3820+ QCOMPARE(builder.methodCount(), 1);
3821+
3822+ // Add another signal and check again.
3823+ QMetaMethodBuilder method2 = builder.addSignal("bar(QString)");
3824+ QCOMPARE(method2.signature(), QByteArray("bar(QString)"));
3825+ QVERIFY(method2.methodType() == QMetaMethod::Signal);
3826+ QVERIFY(method2.returnType().isEmpty());
3827+ QVERIFY(method2.parameterNames().isEmpty());
3828+ QVERIFY(method2.tag().isEmpty());
3829+ QVERIFY(method2.access() == QMetaMethod::Protected);
3830+ QCOMPARE(method2.attributes(), 0);
3831+ QCOMPARE(method2.index(), 1);
3832+ QCOMPARE(builder.methodCount(), 2);
3833+
3834+ // Perform index-based lookup
3835+ QCOMPARE(builder.indexOfSignal("foo(const QString &, int)"), 0);
3836+ QCOMPARE(builder.indexOfSignal("bar(QString)"), 1);
3837+ QCOMPARE(builder.indexOfSignal("baz()"), -1);
3838+
3839+ // Check that nothing else changed.
3840+ QVERIFY(checkForSideEffects(builder, QMetaObjectBuilder::Methods));
3841+}
3842+
3843+void tst_QMetaObjectBuilder::constructor()
3844+{
3845+ QMetaObjectBuilder builder;
3846+
3847+ // Add a constructor and check its attributes.
3848+ QMetaMethodBuilder ctor1 = builder.addConstructor("foo(const QString&, int)");
3849+ QCOMPARE(ctor1.signature(), QByteArray("foo(QString,int)"));
3850+ QVERIFY(ctor1.methodType() == QMetaMethod::Constructor);
3851+ QVERIFY(ctor1.returnType().isEmpty());
3852+ QVERIFY(ctor1.parameterNames().isEmpty());
3853+ QVERIFY(ctor1.tag().isEmpty());
3854+ QVERIFY(ctor1.access() == QMetaMethod::Public);
3855+ QCOMPARE(ctor1.attributes(), 0);
3856+ QCOMPARE(ctor1.index(), 0);
3857+ QCOMPARE(builder.constructorCount(), 1);
3858+
3859+ // Add another constructor and check again.
3860+ QMetaMethodBuilder ctor2 = builder.addConstructor("bar(QString)");
3861+ QCOMPARE(ctor2.signature(), QByteArray("bar(QString)"));
3862+ QVERIFY(ctor2.methodType() == QMetaMethod::Constructor);
3863+ QVERIFY(ctor2.returnType().isEmpty());
3864+ QVERIFY(ctor2.parameterNames().isEmpty());
3865+ QVERIFY(ctor2.tag().isEmpty());
3866+ QVERIFY(ctor2.access() == QMetaMethod::Public);
3867+ QCOMPARE(ctor2.attributes(), 0);
3868+ QCOMPARE(ctor2.index(), 1);
3869+ QCOMPARE(builder.constructorCount(), 2);
3870+
3871+ // Perform index-based lookup.
3872+ QCOMPARE(builder.indexOfConstructor("foo(const QString&, int)"), 0);
3873+ QCOMPARE(builder.indexOfConstructor("bar(QString)"), 1);
3874+ QCOMPARE(builder.indexOfConstructor("baz()"), -1);
3875+ QCOMPARE(builder.constructor(1).signature(), QByteArray("bar(QString)"));
3876+ QCOMPARE(builder.constructor(9).signature(), QByteArray());
3877+
3878+ // Modify the attributes on ctor1.
3879+ ctor1.setReturnType("int");
3880+ ctor1.setParameterNames(QList<QByteArray>() << "a" << "b");
3881+ ctor1.setTag("tag");
3882+ ctor1.setAccess(QMetaMethod::Private);
3883+ ctor1.setAttributes(42);
3884+
3885+ // Check that ctor1 is changed, but ctor2 is not.
3886+ QCOMPARE(ctor1.signature(), QByteArray("foo(QString,int)"));
3887+ QVERIFY(ctor1.methodType() == QMetaMethod::Constructor);
3888+ QCOMPARE(ctor1.returnType(), QByteArray("int"));
3889+ QCOMPARE(ctor1.parameterNames(), QList<QByteArray>() << "a" << "b");
3890+ QCOMPARE(ctor1.tag(), QByteArray("tag"));
3891+ QVERIFY(ctor1.access() == QMetaMethod::Private);
3892+ QCOMPARE(ctor1.attributes(), 42);
3893+ QCOMPARE(ctor1.index(), 0);
3894+ QCOMPARE(ctor2.signature(), QByteArray("bar(QString)"));
3895+ QVERIFY(ctor2.methodType() == QMetaMethod::Constructor);
3896+ QVERIFY(ctor2.returnType().isEmpty());
3897+ QVERIFY(ctor2.parameterNames().isEmpty());
3898+ QVERIFY(ctor2.tag().isEmpty());
3899+ QVERIFY(ctor2.access() == QMetaMethod::Public);
3900+ QCOMPARE(ctor2.attributes(), 0);
3901+ QCOMPARE(ctor2.index(), 1);
3902+ QCOMPARE(builder.constructorCount(), 2);
3903+
3904+ // Modify the attributes on ctor2.
3905+ ctor2.setReturnType("QString");
3906+ ctor2.setParameterNames(QList<QByteArray>() << "c");
3907+ ctor2.setTag("Q_FOO");
3908+ ctor2.setAccess(QMetaMethod::Protected);
3909+ ctor2.setAttributes(24);
3910+
3911+ // This time check that only ctor2 changed.
3912+ QCOMPARE(ctor1.signature(), QByteArray("foo(QString,int)"));
3913+ QVERIFY(ctor1.methodType() == QMetaMethod::Constructor);
3914+ QCOMPARE(ctor1.returnType(), QByteArray("int"));
3915+ QCOMPARE(ctor1.parameterNames(), QList<QByteArray>() << "a" << "b");
3916+ QCOMPARE(ctor1.tag(), QByteArray("tag"));
3917+ QVERIFY(ctor1.access() == QMetaMethod::Private);
3918+ QCOMPARE(ctor1.attributes(), 42);
3919+ QCOMPARE(ctor1.index(), 0);
3920+ QCOMPARE(ctor2.signature(), QByteArray("bar(QString)"));
3921+ QVERIFY(ctor2.methodType() == QMetaMethod::Constructor);
3922+ QCOMPARE(ctor2.returnType(), QByteArray("QString"));
3923+ QCOMPARE(ctor2.parameterNames(), QList<QByteArray>() << "c");
3924+ QCOMPARE(ctor2.tag(), QByteArray("Q_FOO"));
3925+ QVERIFY(ctor2.access() == QMetaMethod::Protected);
3926+ QCOMPARE(ctor2.attributes(), 24);
3927+ QCOMPARE(ctor2.index(), 1);
3928+ QCOMPARE(builder.constructorCount(), 2);
3929+
3930+ // Remove ctor1 and check that ctor2 becomes index 0.
3931+ builder.removeConstructor(0);
3932+ QCOMPARE(builder.constructorCount(), 1);
3933+ ctor2 = builder.constructor(0);
3934+ QCOMPARE(ctor2.signature(), QByteArray("bar(QString)"));
3935+ QVERIFY(ctor2.methodType() == QMetaMethod::Constructor);
3936+ QCOMPARE(ctor2.returnType(), QByteArray("QString"));
3937+ QCOMPARE(ctor2.parameterNames(), QList<QByteArray>() << "c");
3938+ QCOMPARE(ctor2.tag(), QByteArray("Q_FOO"));
3939+ QVERIFY(ctor2.access() == QMetaMethod::Protected);
3940+ QCOMPARE(ctor2.attributes(), 24);
3941+ QCOMPARE(ctor2.index(), 0);
3942+
3943+ // Perform index-based lookup again.
3944+ QCOMPARE(builder.indexOfConstructor("foo(const QString&, int)"), -1);
3945+ QCOMPARE(builder.indexOfConstructor("bar(QString)"), 0);
3946+ QCOMPARE(builder.indexOfConstructor("baz()"), -1);
3947+
3948+ // Add constructor from prototype
3949+ QMetaMethod prototype = SomethingOfEverything::staticMetaObject.constructor(0);
3950+ QMetaMethodBuilder prototypeConstructor = builder.addMethod(prototype);
3951+ QCOMPARE(builder.constructorCount(), 2);
3952+
3953+ QCOMPARE(prototypeConstructor.signature(), QByteArray("SomethingOfEverything()"));
3954+ QVERIFY(prototypeConstructor.methodType() == QMetaMethod::Constructor);
3955+ QCOMPARE(prototypeConstructor.returnType(), QByteArray());
3956+ QVERIFY(prototypeConstructor.access() == QMetaMethod::Public);
3957+ QCOMPARE(prototypeConstructor.index(), 1);
3958+
3959+ // Check that nothing else changed.
3960+ QVERIFY(checkForSideEffects(builder, QMetaObjectBuilder::Constructors));
3961+}
3962+
3963+void tst_QMetaObjectBuilder::property()
3964+{
3965+ QMetaObjectBuilder builder;
3966+
3967+ // Null property builder
3968+ QMetaPropertyBuilder nullProp;
3969+ QCOMPARE(nullProp.name(), QByteArray());
3970+ QCOMPARE(nullProp.type(), QByteArray());
3971+ QVERIFY(!nullProp.hasNotifySignal());
3972+ QVERIFY(!nullProp.isReadable());
3973+ QVERIFY(!nullProp.isWritable());
3974+ QVERIFY(!nullProp.isResettable());
3975+ QVERIFY(!nullProp.isDesignable());
3976+ QVERIFY(!nullProp.isScriptable());
3977+ QVERIFY(!nullProp.isStored());
3978+ QVERIFY(!nullProp.isEditable());
3979+ QVERIFY(!nullProp.isUser());
3980+ QVERIFY(!nullProp.hasStdCppSet());
3981+ QVERIFY(!nullProp.isEnumOrFlag());
3982+ QCOMPARE(nullProp.index(), 0);
3983+
3984+ // Add a property and check its attributes.
3985+ QMetaPropertyBuilder prop1 = builder.addProperty("foo", "const QString &");
3986+ QCOMPARE(prop1.name(), QByteArray("foo"));
3987+ QCOMPARE(prop1.type(), QByteArray("QString"));
3988+ QVERIFY(!prop1.hasNotifySignal());
3989+ QVERIFY(prop1.isReadable());
3990+ QVERIFY(prop1.isWritable());
3991+ QVERIFY(!prop1.isResettable());
3992+ QVERIFY(!prop1.isDesignable());
3993+ QVERIFY(prop1.isScriptable());
3994+ QVERIFY(!prop1.isStored());
3995+ QVERIFY(!prop1.isEditable());
3996+ QVERIFY(!prop1.isUser());
3997+ QVERIFY(!prop1.hasStdCppSet());
3998+ QVERIFY(!prop1.isEnumOrFlag());
3999+
4000+ QCOMPARE(prop1.index(), 0);
4001+ QCOMPARE(builder.propertyCount(), 1);
4002+
4003+ // Add another property and check again.
4004+ QMetaPropertyBuilder prop2 = builder.addProperty("bar", "int");
4005+ QCOMPARE(prop2.name(), QByteArray("bar"));
4006+ QCOMPARE(prop2.type(), QByteArray("int"));
4007+ QVERIFY(!prop2.hasNotifySignal());
4008+ QVERIFY(prop2.isReadable());
4009+ QVERIFY(prop2.isWritable());
4010+ QVERIFY(!prop2.isResettable());
4011+ QVERIFY(!prop2.isDesignable());
4012+ QVERIFY(prop2.isScriptable());
4013+ QVERIFY(!prop2.isStored());
4014+ QVERIFY(!prop2.isEditable());
4015+ QVERIFY(!prop2.isUser());
4016+ QVERIFY(!prop2.hasStdCppSet());
4017+ QVERIFY(!prop2.isEnumOrFlag());
4018+
4019+ QCOMPARE(prop2.index(), 1);
4020+ QCOMPARE(builder.propertyCount(), 2);
4021+
4022+ // Perform index-based lookup.
4023+ QCOMPARE(builder.indexOfProperty("foo"), 0);
4024+ QCOMPARE(builder.indexOfProperty("bar"), 1);
4025+ QCOMPARE(builder.indexOfProperty("baz"), -1);
4026+ QCOMPARE(builder.property(1).name(), QByteArray("bar"));
4027+ QCOMPARE(builder.property(9).name(), QByteArray());
4028+
4029+ // Modify the attributes on prop1.
4030+ prop1.setReadable(false);
4031+ prop1.setWritable(false);
4032+ prop1.setResettable(true);
4033+ prop1.setDesignable(true);
4034+ prop1.setScriptable(false);
4035+ prop1.setStored(true);
4036+ prop1.setEditable(true);
4037+ prop1.setUser(true);
4038+ prop1.setStdCppSet(true);
4039+ prop1.setEnumOrFlag(true);
4040+
4041+ // Check that prop1 is changed, but prop2 is not.
4042+ QCOMPARE(prop1.name(), QByteArray("foo"));
4043+ QCOMPARE(prop1.type(), QByteArray("QString"));
4044+ QVERIFY(!prop1.isReadable());
4045+ QVERIFY(!prop1.isWritable());
4046+ QVERIFY(prop1.isResettable());
4047+ QVERIFY(prop1.isDesignable());
4048+ QVERIFY(!prop1.isScriptable());
4049+ QVERIFY(prop1.isStored());
4050+ QVERIFY(prop1.isEditable());
4051+ QVERIFY(prop1.isUser());
4052+ QVERIFY(prop1.hasStdCppSet());
4053+ QVERIFY(prop1.isEnumOrFlag());
4054+ QVERIFY(prop2.isReadable());
4055+ QVERIFY(prop2.isWritable());
4056+ QCOMPARE(prop2.name(), QByteArray("bar"));
4057+ QCOMPARE(prop2.type(), QByteArray("int"));
4058+ QVERIFY(!prop2.isResettable());
4059+ QVERIFY(!prop2.isDesignable());
4060+ QVERIFY(prop2.isScriptable());
4061+ QVERIFY(!prop2.isStored());
4062+ QVERIFY(!prop2.isEditable());
4063+ QVERIFY(!prop2.isUser());
4064+ QVERIFY(!prop2.hasStdCppSet());
4065+ QVERIFY(!prop2.isEnumOrFlag());
4066+
4067+ // Remove prop1 and check that prop2 becomes index 0.
4068+ builder.removeProperty(0);
4069+ QCOMPARE(builder.propertyCount(), 1);
4070+ prop2 = builder.property(0);
4071+ QCOMPARE(prop2.name(), QByteArray("bar"));
4072+ QCOMPARE(prop2.type(), QByteArray("int"));
4073+ QVERIFY(!prop2.isResettable());
4074+ QVERIFY(!prop2.isDesignable());
4075+ QVERIFY(prop2.isScriptable());
4076+ QVERIFY(!prop2.isStored());
4077+ QVERIFY(!prop2.isEditable());
4078+ QVERIFY(!prop2.isUser());
4079+ QVERIFY(!prop2.hasStdCppSet());
4080+ QVERIFY(!prop2.isEnumOrFlag());
4081+ QCOMPARE(prop2.index(), 0);
4082+
4083+ // Perform index-based lookup again.
4084+ QCOMPARE(builder.indexOfProperty("foo"), -1);
4085+ QCOMPARE(builder.indexOfProperty("bar"), 0);
4086+ QCOMPARE(builder.indexOfProperty("baz"), -1);
4087+
4088+ // Check for side-effects between the flags on prop2.
4089+ // Setting a flag to true shouldn't set any of the others to true.
4090+ // This checks for cut-and-paste bugs in the implementation where
4091+ // the flag code was pasted but the flag name was not changed.
4092+#define CLEAR_FLAGS() \
4093+ do { \
4094+ prop2.setReadable(false); \
4095+ prop2.setWritable(false); \
4096+ prop2.setResettable(false); \
4097+ prop2.setDesignable(false); \
4098+ prop2.setScriptable(false); \
4099+ prop2.setStored(false); \
4100+ prop2.setEditable(false); \
4101+ prop2.setUser(false); \
4102+ prop2.setStdCppSet(false); \
4103+ prop2.setEnumOrFlag(false); \
4104+ } while (0)
4105+#define COUNT_FLAGS() \
4106+ ((prop2.isReadable() ? 1 : 0) + \
4107+ (prop2.isWritable() ? 1 : 0) + \
4108+ (prop2.isResettable() ? 1 : 0) + \
4109+ (prop2.isDesignable() ? 1 : 0) + \
4110+ (prop2.isScriptable() ? 1 : 0) + \
4111+ (prop2.isStored() ? 1 : 0) + \
4112+ (prop2.isEditable() ? 1 : 0) + \
4113+ (prop2.isUser() ? 1 : 0) + \
4114+ (prop2.hasStdCppSet() ? 1 : 0) + \
4115+ (prop2.isEnumOrFlag() ? 1 : 0))
4116+#define CHECK_FLAG(setFunc,isFunc) \
4117+ do { \
4118+ CLEAR_FLAGS(); \
4119+ QCOMPARE(COUNT_FLAGS(), 0); \
4120+ prop2.setFunc(true); \
4121+ QVERIFY(prop2.isFunc()); \
4122+ QCOMPARE(COUNT_FLAGS(), 1); \
4123+ } while (0)
4124+ CHECK_FLAG(setReadable, isReadable);
4125+ CHECK_FLAG(setWritable, isWritable);
4126+ CHECK_FLAG(setResettable, isResettable);
4127+ CHECK_FLAG(setDesignable, isDesignable);
4128+ CHECK_FLAG(setScriptable, isScriptable);
4129+ CHECK_FLAG(setStored, isStored);
4130+ CHECK_FLAG(setEditable, isEditable);
4131+ CHECK_FLAG(setUser, isUser);
4132+ CHECK_FLAG(setStdCppSet, hasStdCppSet);
4133+ CHECK_FLAG(setEnumOrFlag, isEnumOrFlag);
4134+
4135+ // Check that nothing else changed.
4136+ QVERIFY(checkForSideEffects(builder, QMetaObjectBuilder::Properties));
4137+
4138+ // Add property from prototype
4139+ QMetaProperty prototype = SomethingOfEverything::staticMetaObject.property(1);
4140+ QVERIFY(prototype.name() == QByteArray("prop"));
4141+ QMetaPropertyBuilder prototypeProp = builder.addProperty(prototype);
4142+ QCOMPARE(prototypeProp.name(), QByteArray("prop"));
4143+ QVERIFY(prototypeProp.hasNotifySignal());
4144+ QCOMPARE(prototypeProp.notifySignal().signature(), QByteArray("propChanged(QString)"));
4145+ QCOMPARE(builder.methodCount(), 1);
4146+ QCOMPARE(builder.method(0).signature(), QByteArray("propChanged(QString)"));
4147+}
4148+
4149+void tst_QMetaObjectBuilder::notifySignal()
4150+{
4151+ QMetaObjectBuilder builder;
4152+
4153+ QMetaPropertyBuilder prop = builder.addProperty("foo", "const QString &");
4154+ builder.addSlot("setFoo(QString)");
4155+ QMetaMethodBuilder notify = builder.addSignal("fooChanged(QString)");
4156+
4157+ QVERIFY(!prop.hasNotifySignal());
4158+ QCOMPARE(prop.notifySignal().index(), 0);
4159+
4160+ prop.setNotifySignal(notify);
4161+ QVERIFY(prop.hasNotifySignal());
4162+ QCOMPARE(prop.notifySignal().index(), 1);
4163+
4164+ prop.setNotifySignal(QMetaMethodBuilder());
4165+ QVERIFY(!prop.hasNotifySignal());
4166+ QCOMPARE(prop.notifySignal().index(), 0);
4167+
4168+ prop.setNotifySignal(notify);
4169+ prop.removeNotifySignal();
4170+ QVERIFY(!prop.hasNotifySignal());
4171+ QCOMPARE(prop.notifySignal().index(), 0);
4172+
4173+ QCOMPARE(builder.methodCount(), 2);
4174+ QCOMPARE(builder.propertyCount(), 1);
4175+
4176+ // Check that nothing else changed except methods and properties.
4177+ QVERIFY(checkForSideEffects
4178+ (builder, QMetaObjectBuilder::Methods | QMetaObjectBuilder::Properties));
4179+}
4180+
4181+void tst_QMetaObjectBuilder::enumerator()
4182+{
4183+ QMetaObjectBuilder builder;
4184+
4185+ // Add an enumerator and check its attributes.
4186+ QMetaEnumBuilder enum1 = builder.addEnumerator("foo");
4187+ QCOMPARE(enum1.name(), QByteArray("foo"));
4188+ QVERIFY(!enum1.isFlag());
4189+ QCOMPARE(enum1.keyCount(), 0);
4190+ QCOMPARE(enum1.index(), 0);
4191+ QCOMPARE(builder.enumeratorCount(), 1);
4192+
4193+ // Add another enumerator and check again.
4194+ QMetaEnumBuilder enum2 = builder.addEnumerator("bar");
4195+ QCOMPARE(enum2.name(), QByteArray("bar"));
4196+ QVERIFY(!enum2.isFlag());
4197+ QCOMPARE(enum2.keyCount(), 0);
4198+ QCOMPARE(enum2.index(), 1);
4199+ QCOMPARE(builder.enumeratorCount(), 2);
4200+
4201+ // Perform index-based lookup.
4202+ QCOMPARE(builder.indexOfEnumerator("foo"), 0);
4203+ QCOMPARE(builder.indexOfEnumerator("bar"), 1);
4204+ QCOMPARE(builder.indexOfEnumerator("baz"), -1);
4205+ QCOMPARE(builder.enumerator(1).name(), QByteArray("bar"));
4206+ QCOMPARE(builder.enumerator(9).name(), QByteArray());
4207+
4208+ // Modify the attributes on enum1.
4209+ enum1.setIsFlag(true);
4210+ QCOMPARE(enum1.addKey("ABC", 0), 0);
4211+ QCOMPARE(enum1.addKey("DEF", 1), 1);
4212+ QCOMPARE(enum1.addKey("GHI", -1), 2);
4213+
4214+ // Check that enum1 is changed, but enum2 is not.
4215+ QCOMPARE(enum1.name(), QByteArray("foo"));
4216+ QVERIFY(enum1.isFlag());
4217+ QCOMPARE(enum1.keyCount(), 3);
4218+ QCOMPARE(enum1.index(), 0);
4219+ QCOMPARE(enum1.key(0), QByteArray("ABC"));
4220+ QCOMPARE(enum1.key(1), QByteArray("DEF"));
4221+ QCOMPARE(enum1.key(2), QByteArray("GHI"));
4222+ QCOMPARE(enum1.key(3), QByteArray());
4223+ QCOMPARE(enum1.value(0), 0);
4224+ QCOMPARE(enum1.value(1), 1);
4225+ QCOMPARE(enum1.value(2), -1);
4226+ QCOMPARE(enum2.name(), QByteArray("bar"));
4227+ QVERIFY(!enum2.isFlag());
4228+ QCOMPARE(enum2.keyCount(), 0);
4229+ QCOMPARE(enum2.index(), 1);
4230+
4231+ // Modify the attributes on enum2.
4232+ enum2.setIsFlag(true);
4233+ QCOMPARE(enum2.addKey("XYZ", 10), 0);
4234+ QCOMPARE(enum2.addKey("UVW", 19), 1);
4235+
4236+ // This time check that only method2 changed.
4237+ QCOMPARE(enum1.name(), QByteArray("foo"));
4238+ QVERIFY(enum1.isFlag());
4239+ QCOMPARE(enum1.keyCount(), 3);
4240+ QCOMPARE(enum1.index(), 0);
4241+ QCOMPARE(enum1.key(0), QByteArray("ABC"));
4242+ QCOMPARE(enum1.key(1), QByteArray("DEF"));
4243+ QCOMPARE(enum1.key(2), QByteArray("GHI"));
4244+ QCOMPARE(enum1.key(3), QByteArray());
4245+ QCOMPARE(enum1.value(0), 0);
4246+ QCOMPARE(enum1.value(1), 1);
4247+ QCOMPARE(enum1.value(2), -1);
4248+ QCOMPARE(enum2.name(), QByteArray("bar"));
4249+ QVERIFY(enum2.isFlag());
4250+ QCOMPARE(enum2.keyCount(), 2);
4251+ QCOMPARE(enum2.index(), 1);
4252+ QCOMPARE(enum2.key(0), QByteArray("XYZ"));
4253+ QCOMPARE(enum2.key(1), QByteArray("UVW"));
4254+ QCOMPARE(enum2.key(2), QByteArray());
4255+ QCOMPARE(enum2.value(0), 10);
4256+ QCOMPARE(enum2.value(1), 19);
4257+
4258+ // Remove enum1 key
4259+ enum1.removeKey(2);
4260+ QCOMPARE(enum1.name(), QByteArray("foo"));
4261+ QVERIFY(enum1.isFlag());
4262+ QCOMPARE(enum1.keyCount(), 2);
4263+ QCOMPARE(enum1.index(), 0);
4264+ QCOMPARE(enum1.key(0), QByteArray("ABC"));
4265+ QCOMPARE(enum1.key(1), QByteArray("DEF"));
4266+ QCOMPARE(enum1.key(2), QByteArray());
4267+ QCOMPARE(enum1.value(0), 0);
4268+ QCOMPARE(enum1.value(1), 1);
4269+ QCOMPARE(enum1.value(2), -1);
4270+ QCOMPARE(enum2.name(), QByteArray("bar"));
4271+ QVERIFY(enum2.isFlag());
4272+ QCOMPARE(enum2.keyCount(), 2);
4273+ QCOMPARE(enum2.index(), 1);
4274+ QCOMPARE(enum2.key(0), QByteArray("XYZ"));
4275+ QCOMPARE(enum2.key(1), QByteArray("UVW"));
4276+ QCOMPARE(enum2.key(2), QByteArray());
4277+ QCOMPARE(enum2.value(0), 10);
4278+ QCOMPARE(enum2.value(1), 19);
4279+
4280+ // Remove enum1 and check that enum2 becomes index 0.
4281+ builder.removeEnumerator(0);
4282+ QCOMPARE(builder.enumeratorCount(), 1);
4283+ enum2 = builder.enumerator(0);
4284+ QCOMPARE(enum2.name(), QByteArray("bar"));
4285+ QVERIFY(enum2.isFlag());
4286+ QCOMPARE(enum2.keyCount(), 2);
4287+ QCOMPARE(enum2.index(), 0);
4288+ QCOMPARE(enum2.key(0), QByteArray("XYZ"));
4289+ QCOMPARE(enum2.key(1), QByteArray("UVW"));
4290+ QCOMPARE(enum2.key(2), QByteArray());
4291+ QCOMPARE(enum2.value(0), 10);
4292+ QCOMPARE(enum2.value(1), 19);
4293+
4294+ // Perform index-based lookup again.
4295+ QCOMPARE(builder.indexOfEnumerator("foo"), -1);
4296+ QCOMPARE(builder.indexOfEnumerator("bar"), 0);
4297+ QCOMPARE(builder.indexOfEnumerator("baz"), -1);
4298+
4299+ // Check that nothing else changed.
4300+ QVERIFY(checkForSideEffects(builder, QMetaObjectBuilder::Enumerators));
4301+}
4302+
4303+void tst_QMetaObjectBuilder::classInfo()
4304+{
4305+ QMetaObjectBuilder builder;
4306+
4307+ // Add two items of class information and check their attributes.
4308+ QCOMPARE(builder.addClassInfo("foo", "value1"), 0);
4309+ QCOMPARE(builder.addClassInfo("bar", "value2"), 1);
4310+ QCOMPARE(builder.classInfoName(0), QByteArray("foo"));
4311+ QCOMPARE(builder.classInfoValue(0), QByteArray("value1"));
4312+ QCOMPARE(builder.classInfoName(1), QByteArray("bar"));
4313+ QCOMPARE(builder.classInfoValue(1), QByteArray("value2"));
4314+ QCOMPARE(builder.classInfoName(9), QByteArray());
4315+ QCOMPARE(builder.classInfoValue(9), QByteArray());
4316+ QCOMPARE(builder.classInfoCount(), 2);
4317+
4318+ // Perform index-based lookup.
4319+ QCOMPARE(builder.indexOfClassInfo("foo"), 0);
4320+ QCOMPARE(builder.indexOfClassInfo("bar"), 1);
4321+ QCOMPARE(builder.indexOfClassInfo("baz"), -1);
4322+
4323+ // Remove the first one and check again.
4324+ builder.removeClassInfo(0);
4325+ QCOMPARE(builder.classInfoName(0), QByteArray("bar"));
4326+ QCOMPARE(builder.classInfoValue(0), QByteArray("value2"));
4327+ QCOMPARE(builder.classInfoCount(), 1);
4328+
4329+ // Perform index-based lookup again.
4330+ QCOMPARE(builder.indexOfClassInfo("foo"), -1);
4331+ QCOMPARE(builder.indexOfClassInfo("bar"), 0);
4332+ QCOMPARE(builder.indexOfClassInfo("baz"), -1);
4333+
4334+ // Check that nothing else changed.
4335+ QVERIFY(checkForSideEffects(builder, QMetaObjectBuilder::ClassInfos));
4336+}
4337+
4338+#ifdef Q_NO_DATA_RELOCATION
4339+const QMetaObject& staticMetaObjectGlobal()
4340+{
4341+ return QObject::staticMetaObject;
4342+}
4343+
4344+const QMetaObject& staticMetaObjectLocal()
4345+{
4346+ return *meta;
4347+}
4348+#endif
4349+
4350+
4351+void tst_QMetaObjectBuilder::relatedMetaObject()
4352+{
4353+ QMetaObjectBuilder builder;
4354+
4355+ // Add two related meta objects and check their attributes.
4356+#ifdef Q_NO_DATA_RELOCATION
4357+ meta = &staticMetaObject;
4358+ QCOMPARE(builder.addRelatedMetaObject(&staticMetaObjectGlobal), 0);
4359+ QCOMPARE(builder.addRelatedMetaObject(&staticMetaObjectLocal), 1);
4360+#else
4361+ QCOMPARE(builder.addRelatedMetaObject(&QObject::staticMetaObject), 0);
4362+ QCOMPARE(builder.addRelatedMetaObject(&staticMetaObject), 1);
4363+#endif
4364+ QVERIFY(builder.relatedMetaObject(0) == &QObject::staticMetaObject);
4365+ QVERIFY(builder.relatedMetaObject(1) == &staticMetaObject);
4366+ QCOMPARE(builder.relatedMetaObjectCount(), 2);
4367+
4368+ // Remove the first one and check again.
4369+ builder.removeRelatedMetaObject(0);
4370+ QVERIFY(builder.relatedMetaObject(0) == &staticMetaObject);
4371+ QCOMPARE(builder.relatedMetaObjectCount(), 1);
4372+
4373+ // Check that nothing else changed.
4374+ QVERIFY(checkForSideEffects(builder, QMetaObjectBuilder::RelatedMetaObjects));
4375+}
4376+
4377+static int smetacall(QMetaObject::Call, int, void **)
4378+{
4379+ return 0;
4380+}
4381+
4382+void tst_QMetaObjectBuilder::staticMetacall()
4383+{
4384+ QMetaObjectBuilder builder;
4385+ QVERIFY(!builder.staticMetacallFunction());
4386+ builder.setStaticMetacallFunction(smetacall);
4387+ QVERIFY(builder.staticMetacallFunction() == smetacall);
4388+ QVERIFY(checkForSideEffects(builder, QMetaObjectBuilder::StaticMetacall));
4389+}
4390+
4391+// Copy the entire contents of a static QMetaObject and then check
4392+// that QMetaObjectBuilder will produce an exact copy as output.
4393+void tst_QMetaObjectBuilder::copyMetaObject()
4394+{
4395+ QMetaObjectBuilder builder(&QObject::staticMetaObject);
4396+ QMetaObject *meta = builder.toMetaObject();
4397+ QVERIFY(sameMetaObject(meta, &QObject::staticMetaObject));
4398+ qFree(meta);
4399+
4400+ QMetaObjectBuilder builder2(&staticMetaObject);
4401+ meta = builder2.toMetaObject();
4402+ QVERIFY(sameMetaObject(meta, &staticMetaObject));
4403+ qFree(meta);
4404+
4405+ QMetaObjectBuilder builder3(&SomethingOfEverything::staticMetaObject);
4406+ meta = builder3.toMetaObject();
4407+ QVERIFY(sameMetaObject(meta, &SomethingOfEverything::staticMetaObject));
4408+ qFree(meta);
4409+}
4410+
4411+// Serialize and deserialize a meta object and check that
4412+// it round-trips to the exact same value.
4413+void tst_QMetaObjectBuilder::serialize()
4414+{
4415+ // Full QMetaObjectBuilder
4416+ {
4417+ QMetaObjectBuilder builder(&SomethingOfEverything::staticMetaObject);
4418+ QMetaObject *meta = builder.toMetaObject();
4419+
4420+ QByteArray data;
4421+ QDataStream stream(&data, QIODevice::WriteOnly | QIODevice::Append);
4422+ builder.serialize(stream);
4423+
4424+ QMetaObjectBuilder builder2;
4425+ QDataStream stream2(data);
4426+ QMap<QByteArray, const QMetaObject *> references;
4427+ references.insert(QByteArray("QLocale"), &QLocale::staticMetaObject);
4428+ builder2.deserialize(stream2, references);
4429+#ifdef Q_NO_DATA_RELOCATION
4430+ //the related meta objects will be function pointers
4431+ //which you have to add to the builder manually.
4432+ builder2.addRelatedMetaObject(QLocale::getStaticMetaObject);
4433+#endif
4434+ builder2.setStaticMetacallFunction(builder.staticMetacallFunction());
4435+ QMetaObject *meta2 = builder2.toMetaObject();
4436+
4437+ QVERIFY(sameMetaObject(meta, meta2));
4438+ qFree(meta);
4439+ qFree(meta2);
4440+ }
4441+
4442+ // Partial QMetaObjectBuilder
4443+ {
4444+ QMetaObjectBuilder builder;
4445+ builder.setClassName("Test");
4446+ builder.addProperty("foo", "int");
4447+
4448+ QByteArray data;
4449+ QDataStream stream(&data, QIODevice::WriteOnly | QIODevice::Append);
4450+ builder.serialize(stream);
4451+
4452+ QMetaObjectBuilder builder2;
4453+ QDataStream stream2(data);
4454+ builder2.deserialize(stream2, QMap<QByteArray, const QMetaObject *>());
4455+
4456+ QCOMPARE(builder.superClass(), builder2.superClass());
4457+ QCOMPARE(builder.className(), builder2.className());
4458+ QCOMPARE(builder.propertyCount(), builder2.propertyCount());
4459+ QCOMPARE(builder.property(0).name(), builder2.property(0).name());
4460+ QCOMPARE(builder.property(0).type(), builder2.property(0).type());
4461+ }
4462+}
4463+
4464+// Check that removing a method updates notify signals appropriately
4465+void tst_QMetaObjectBuilder::removeNotifySignal()
4466+{
4467+ QMetaObjectBuilder builder;
4468+
4469+ QMetaMethodBuilder method1 = builder.addSignal("foo(const QString&, int)");
4470+ QMetaMethodBuilder method2 = builder.addSignal("bar(QString)");
4471+
4472+ // Setup property
4473+ QMetaPropertyBuilder prop = builder.addProperty("prop", "const QString &");
4474+ prop.setNotifySignal(method2);
4475+ QVERIFY(prop.hasNotifySignal());
4476+ QCOMPARE(prop.notifySignal().index(), 1);
4477+
4478+ // Remove non-notify signal
4479+ builder.removeMethod(0);
4480+ QVERIFY(prop.hasNotifySignal());
4481+ QCOMPARE(prop.notifySignal().index(), 0);
4482+
4483+ // Remove notify signal
4484+ builder.removeMethod(0);
4485+ QVERIFY(!prop.hasNotifySignal());
4486+}
4487+
4488+// Check that the only changes to a "builder" relative to the default
4489+// state is specified by "members".
4490+bool tst_QMetaObjectBuilder::checkForSideEffects
4491+ (const QMetaObjectBuilder& builder,
4492+ QMetaObjectBuilder::AddMembers members)
4493+{
4494+ if ((members & QMetaObjectBuilder::ClassName) == 0) {
4495+ if (!builder.className().isEmpty())
4496+ return false;
4497+ }
4498+
4499+ if ((members & QMetaObjectBuilder::SuperClass) == 0) {
4500+ if (builder.superClass() != &QObject::staticMetaObject)
4501+ return false;
4502+ }
4503+
4504+ if ((members & QMetaObjectBuilder::Methods) == 0) {
4505+ if (builder.methodCount() != 0)
4506+ return false;
4507+ }
4508+
4509+ if ((members & QMetaObjectBuilder::Constructors) == 0) {
4510+ if (builder.constructorCount() != 0)
4511+ return false;
4512+ }
4513+
4514+ if ((members & QMetaObjectBuilder::Properties) == 0) {
4515+ if (builder.propertyCount() != 0)
4516+ return false;
4517+ }
4518+
4519+ if ((members & QMetaObjectBuilder::Enumerators) == 0) {
4520+ if (builder.enumeratorCount() != 0)
4521+ return false;
4522+ }
4523+
4524+ if ((members & QMetaObjectBuilder::ClassInfos) == 0) {
4525+ if (builder.classInfoCount() != 0)
4526+ return false;
4527+ }
4528+
4529+ if ((members & QMetaObjectBuilder::RelatedMetaObjects) == 0) {
4530+ if (builder.relatedMetaObjectCount() != 0)
4531+ return false;
4532+ }
4533+
4534+ if ((members & QMetaObjectBuilder::StaticMetacall) == 0) {
4535+ if (builder.staticMetacallFunction() != 0)
4536+ return false;
4537+ }
4538+
4539+ return true;
4540+}
4541+
4542+static bool sameMethod(const QMetaMethod& method1, const QMetaMethod& method2)
4543+{
4544+ if (QByteArray(method1.signature()) != QByteArray(method2.signature()))
4545+ return false;
4546+
4547+ if (QByteArray(method1.typeName()) != QByteArray(method2.typeName()))
4548+ return false;
4549+
4550+ if (method1.parameterNames() != method2.parameterNames())
4551+ return false;
4552+
4553+ if (QByteArray(method1.tag()) != QByteArray(method2.tag()))
4554+ return false;
4555+
4556+ if (method1.access() != method2.access())
4557+ return false;
4558+
4559+ if (method1.methodType() != method2.methodType())
4560+ return false;
4561+
4562+ if (method1.attributes() != method2.attributes())
4563+ return false;
4564+
4565+ return true;
4566+}
4567+
4568+static bool sameProperty(const QMetaProperty& prop1, const QMetaProperty& prop2)
4569+{
4570+ if (QByteArray(prop1.name()) != QByteArray(prop2.name()))
4571+ return false;
4572+
4573+ if (QByteArray(prop1.typeName()) != QByteArray(prop2.typeName()))
4574+ return false;
4575+
4576+ if (prop1.isReadable() != prop2.isReadable() ||
4577+ prop1.isWritable() != prop2.isWritable() ||
4578+ prop1.isResettable() != prop2.isResettable() ||
4579+ prop1.isDesignable() != prop2.isDesignable() ||
4580+ prop1.isScriptable() != prop2.isScriptable() ||
4581+ prop1.isStored() != prop2.isStored() ||
4582+ prop1.isEditable() != prop2.isEditable() ||
4583+ prop1.isUser() != prop2.isUser() ||
4584+ prop1.isFlagType() != prop2.isFlagType() ||
4585+ prop1.isEnumType() != prop2.isEnumType() ||
4586+ prop1.hasNotifySignal() != prop2.hasNotifySignal() ||
4587+ prop1.hasStdCppSet() != prop2.hasStdCppSet())
4588+ return false;
4589+
4590+ if (prop1.hasNotifySignal()) {
4591+ if (prop1.notifySignalIndex() != prop2.notifySignalIndex())
4592+ return false;
4593+ }
4594+
4595+ return true;
4596+}
4597+
4598+static bool sameEnumerator(const QMetaEnum& enum1, const QMetaEnum& enum2)
4599+{
4600+ if (QByteArray(enum1.name()) != QByteArray(enum2.name()))
4601+ return false;
4602+
4603+ if (enum1.isFlag() != enum2.isFlag())
4604+ return false;
4605+
4606+ if (enum1.keyCount() != enum2.keyCount())
4607+ return false;
4608+
4609+ for (int index = 0; index < enum1.keyCount(); ++index) {
4610+ if (QByteArray(enum1.key(index)) != QByteArray(enum2.key(index)))
4611+ return false;
4612+ if (enum1.value(index) != enum2.value(index))
4613+ return false;
4614+ }
4615+
4616+ if (QByteArray(enum1.scope()) != QByteArray(enum2.scope()))
4617+ return false;
4618+
4619+ return true;
4620+}
4621+
4622+// Determine if two meta objects are identical.
4623+bool tst_QMetaObjectBuilder::sameMetaObject
4624+ (const QMetaObject *meta1, const QMetaObject *meta2)
4625+{
4626+ int index;
4627+
4628+ if (strcmp(meta1->className(), meta2->className()) != 0)
4629+ return false;
4630+
4631+ if (meta1->superClass() != meta2->superClass())
4632+ return false;
4633+
4634+ if (meta1->constructorCount() != meta2->constructorCount() ||
4635+ meta1->methodCount() != meta2->methodCount() ||
4636+ meta1->enumeratorCount() != meta2->enumeratorCount() ||
4637+ meta1->propertyCount() != meta2->propertyCount() ||
4638+ meta1->classInfoCount() != meta2->classInfoCount())
4639+ return false;
4640+
4641+ for (index = 0; index < meta1->constructorCount(); ++index) {
4642+ if (!sameMethod(meta1->constructor(index), meta2->constructor(index)))
4643+ return false;
4644+ }
4645+
4646+ for (index = 0; index < meta1->methodCount(); ++index) {
4647+ if (!sameMethod(meta1->method(index), meta2->method(index)))
4648+ return false;
4649+ }
4650+
4651+ for (index = 0; index < meta1->propertyCount(); ++index) {
4652+ if (!sameProperty(meta1->property(index), meta2->property(index)))
4653+ return false;
4654+ }
4655+
4656+ for (index = 0; index < meta1->enumeratorCount(); ++index) {
4657+ if (!sameEnumerator(meta1->enumerator(index), meta2->enumerator(index)))
4658+ return false;
4659+ }
4660+
4661+ for (index = 0; index < meta1->classInfoCount(); ++index) {
4662+ if (QByteArray(meta1->classInfo(index).name()) !=
4663+ QByteArray(meta2->classInfo(index).name()))
4664+ return false;
4665+ if (QByteArray(meta1->classInfo(index).value()) !=
4666+ QByteArray(meta2->classInfo(index).value()))
4667+ return false;
4668+ }
4669+
4670+ const QMetaObject **objects1 = 0;
4671+ const QMetaObject **objects2 = 0;
4672+ if (meta1->d.data[0] == meta2->d.data[0] && meta1->d.data[0] >= 2) {
4673+ QMetaObjectExtraData *extra1 = (QMetaObjectExtraData *)(meta1->d.extradata);
4674+ QMetaObjectExtraData *extra2 = (QMetaObjectExtraData *)(meta2->d.extradata);
4675+ if (extra1 && !extra2)
4676+ return false;
4677+ if (extra2 && !extra1)
4678+ return false;
4679+ if (extra1 && extra2) {
4680+ if (extra1->static_metacall != extra2->static_metacall)
4681+ return false;
4682+ //objects1 = extra1->objects;
4683+ //objects2 = extra1->objects;
4684+ }
4685+ } else if (meta1->d.data[0] == meta2->d.data[0] && meta1->d.data[0] == 1) {
4686+ objects1 = (const QMetaObject **)(meta1->d.extradata);
4687+ objects2 = (const QMetaObject **)(meta2->d.extradata);
4688+ }
4689+ if (objects1 && !objects2)
4690+ return false;
4691+ if (objects2 && !objects1)
4692+ return false;
4693+ if (objects1 && objects2) {
4694+ while (*objects1 != 0 && *objects2 != 0) {
4695+ if (*objects1 != *objects2)
4696+ return false;
4697+ ++objects1;
4698+ ++objects2;
4699+ }
4700+ }
4701+
4702+ return true;
4703+}
4704+
4705+QTEST_MAIN(tst_QMetaObjectBuilder)
4706+
4707+#include "tst_qmetaobjectbuilder_47.moc"
diff --git a/meta/recipes-qt/qt4/qt-mobility-1.2.0/gcc-scope.patch b/meta/recipes-qt/qt4/qt-mobility-1.2.0/gcc-scope.patch
deleted file mode 100644
index f01ee9f4df..0000000000
--- a/meta/recipes-qt/qt4/qt-mobility-1.2.0/gcc-scope.patch
+++ /dev/null
@@ -1,48 +0,0 @@
1
2Fixes issues like below
3
4| qaudiooutput_pulse.cpp: In member function 'bool QPulseAudioOutput::open()':
5| qaudiooutput_pulse.cpp:255:75: error: '::getpid' has not been declared
6| make[3]: *** [../../../build/Debug/qtmedia_pulse/qaudiooutput_pulse.o] Error 1
7
8Signed-off-by: Khem Raj <raj.khem@gmail.com>
9
10Upstream-Status: Pending
11
12Index: qt-mobility-opensource-src-1.2.0/plugins/multimedia/pulseaudio/qaudiooutput_pulse.cpp
13===================================================================
14--- qt-mobility-opensource-src-1.2.0.orig/plugins/multimedia/pulseaudio/qaudiooutput_pulse.cpp 2012-03-31 07:26:24.457018348 -0700
15+++ qt-mobility-opensource-src-1.2.0/plugins/multimedia/pulseaudio/qaudiooutput_pulse.cpp 2012-03-31 07:27:53.309022654 -0700
16@@ -46,7 +46,7 @@
17 #include "qaudiodeviceinfo_pulse.h"
18 #include "qpulseaudioengine.h"
19 #include "qpulsehelpers.h"
20-
21+#include <unistd.h>
22 QT_BEGIN_NAMESPACE
23
24 const int PeriodTimeMs = 20;
25Index: qt-mobility-opensource-src-1.2.0/plugins/multimedia/pulseaudio/qaudioinput_pulse.cpp
26===================================================================
27--- qt-mobility-opensource-src-1.2.0.orig/plugins/multimedia/pulseaudio/qaudioinput_pulse.cpp 2012-03-31 07:29:19.997026831 -0700
28+++ qt-mobility-opensource-src-1.2.0/plugins/multimedia/pulseaudio/qaudioinput_pulse.cpp 2012-03-31 07:29:39.541027625 -0700
29@@ -46,6 +46,7 @@
30 #include "qaudiodeviceinfo_pulse.h"
31 #include "qpulseaudioengine.h"
32 #include "qpulsehelpers.h"
33+#include <unistd.h>
34
35 QT_BEGIN_NAMESPACE
36
37Index: qt-mobility-opensource-src-1.2.0/plugins/multimedia/pulseaudio/qpulseaudioengine.cpp
38===================================================================
39--- qt-mobility-opensource-src-1.2.0.orig/plugins/multimedia/pulseaudio/qpulseaudioengine.cpp 2012-03-31 07:33:24.805038719 -0700
40+++ qt-mobility-opensource-src-1.2.0/plugins/multimedia/pulseaudio/qpulseaudioengine.cpp 2012-03-31 07:33:46.889039783 -0700
41@@ -46,6 +46,7 @@
42 #include "qaudiodeviceinfo_pulse.h"
43 #include "qaudiooutput_pulse.h"
44 #include "qpulsehelpers.h"
45+#include <unistd.h>
46
47 QT_BEGIN_NAMESPACE
48
diff --git a/meta/recipes-qt/qt4/qt-mobility-1.2.0/qt-mobility-configure.patch b/meta/recipes-qt/qt4/qt-mobility-1.2.0/qt-mobility-configure.patch
deleted file mode 100644
index d61ec03341..0000000000
--- a/meta/recipes-qt/qt4/qt-mobility-1.2.0/qt-mobility-configure.patch
+++ /dev/null
@@ -1,17 +0,0 @@
1When building qt-mobility, the qa_configure stage failed because the catalogue /usr/lib
2is used in some Makefiles within configure tests. We manually removed this catalogue.
3
4Upstream-Status: Inappropriate [embedded]
5Signed-off-by: Dmitry Cherukhin <dima_ch@emcraft.com>
6
7--- qt-mobility-opensource-src-1.2.0/configure.orig 2011-05-10 10:06:01.000000000 +0200
8+++ qt-mobility-opensource-src-1.2.0/configure 2011-11-08 12:34:56.347645968 +0100
9@@ -583,6 +583,8 @@
10 fi
11
12 $QMAKE_EXEC $QMKSPEC "$relpath/config.tests/$2/$2.pro" 2>> "$CONFIG_LOG" >> "$CONFIG_LOG"
13+ cp Makefile Makefile.old
14+ sed -e 's@-L/usr/lib@@' <Makefile.old >Makefile
15 printf " ."
16 "$MAKE" clean >> "$CONFIG_LOG"
17 printf "."
diff --git a/meta/recipes-qt/qt4/qt-mobility-1.2.0/qt-mobility-no-opengl.patch b/meta/recipes-qt/qt4/qt-mobility-1.2.0/qt-mobility-no-opengl.patch
deleted file mode 100644
index 1724995072..0000000000
--- a/meta/recipes-qt/qt4/qt-mobility-1.2.0/qt-mobility-no-opengl.patch
+++ /dev/null
@@ -1,38 +0,0 @@
1Upstream-Status: Inappropriate [configuration]
2
3diff --git a/examples/declarative-camera/declarative-camera.pro b/examples/declarative-camera/declarative-camera.pro
4index 8164fbc..54fd8ad 100644
5--- a/examples/declarative-camera/declarative-camera.pro
6+++ b/examples/declarative-camera/declarative-camera.pro
7@@ -5,10 +5,10 @@ TEMPLATE=app
8
9 QT += declarative network
10
11-!maemo5 {
12- contains(QT_CONFIG, opengl) {
13- QT += opengl
14- }
15+contains(QT_CONFIG, opengl): !maemo5 {
16+ QT += opengl
17+} else {
18+ DEFINES += QT_NO_OPENGL
19 }
20
21 win32 {
22diff --git a/examples/videographicsitem/videographicsitem.pro b/examples/videographicsitem/videographicsitem.pro
23index 8461beb..eedee2f 100644
24--- a/examples/videographicsitem/videographicsitem.pro
25+++ b/examples/videographicsitem/videographicsitem.pro
26@@ -9,7 +9,11 @@ MOBILITY = multimedia
27
28 QMAKE_RPATHDIR += $$DESTDIR
29
30-!symbian:contains(QT_CONFIG, opengl): QT += opengl
31+contains(QT_CONFIG, opengl): !symbian {
32+ QT += opengl
33+} else {
34+ DEFINES += QT_NO_OPENGL
35+}
36
37 HEADERS += videoplayer.h \
38 videoitem.h
diff --git a/meta/recipes-qt/qt4/qt-mobility-1.2.0/qt-mobility-no-xvideo.patch b/meta/recipes-qt/qt4/qt-mobility-1.2.0/qt-mobility-no-xvideo.patch
deleted file mode 100644
index 6046752aa7..0000000000
--- a/meta/recipes-qt/qt4/qt-mobility-1.2.0/qt-mobility-no-xvideo.patch
+++ /dev/null
@@ -1,26 +0,0 @@
1QMake pro files don't explicitly define QT_NO_XVIDEO if the
2configuration lacks xvideo, but plugins code relies on this define.
3
4Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
5Upstream-Status: Inappropriate [configuration]
6---
7 plugins/multimedia/gstreamer/gstreamer.pro | 4 ++++
8 1 file changed, 4 insertions(+)
9
10diff --git a/plugins/multimedia/gstreamer/gstreamer.pro b/plugins/multimedia/gstreamer/gstreamer.pro
11--- a/plugins/multimedia/gstreamer/gstreamer.pro
12+++ b/plugins/multimedia/gstreamer/gstreamer.pro
13@@ -19,6 +19,10 @@ LIBS += \
14 -lasound
15 }
16
17+unix:!contains(QT_CONFIG, xvideo) {
18+ DEFINES += QT_NO_XVIDEO
19+}
20+
21 CONFIG += link_pkgconfig
22
23 PKGCONFIG += \
24--
251.8.1.2
26
diff --git a/meta/recipes-qt/qt4/qt-mobility-embedded_1.2.0.bb b/meta/recipes-qt/qt4/qt-mobility-embedded_1.2.0.bb
deleted file mode 100644
index 998de2a055..0000000000
--- a/meta/recipes-qt/qt4/qt-mobility-embedded_1.2.0.bb
+++ /dev/null
@@ -1,11 +0,0 @@
1SUMMARY = "Mobile device API extensions for Qt/Embedded 4.x"
2DEPENDS = "qt4-embedded"
3SECTION = "libs"
4qtm_embedded := "embedded"
5qtm_dir = "qtopia"
6qtm_glflags := "-=opengl"
7qtm_extra_config := "gstreamer-photography_enabled = no"
8
9inherit qt4e
10require qt-mobility_${PV}.inc
11
diff --git a/meta/recipes-qt/qt4/qt-mobility-x11_1.2.0.bb b/meta/recipes-qt/qt4/qt-mobility-x11_1.2.0.bb
deleted file mode 100644
index e7e4b3c62a..0000000000
--- a/meta/recipes-qt/qt4/qt-mobility-x11_1.2.0.bb
+++ /dev/null
@@ -1,10 +0,0 @@
1SUMMARY = "Mobile device API extensions for Qt/X11 4.x"
2DEPENDS = "qt4-x11-free"
3SECTION = "x11/libs"
4qtm_embedded := ""
5qtm_dir = "qt4"
6qtm_glflags := "${@bb.utils.contains('DISTRO_FEATURES', 'opengl', '+=opengl', '-=opengl', d)} "
7qtm_extra_config := ""
8
9inherit qt4x11
10require qt-mobility_${PV}.inc
diff --git a/meta/recipes-qt/qt4/qt-mobility_1.2.0.inc b/meta/recipes-qt/qt4/qt-mobility_1.2.0.inc
deleted file mode 100644
index 56631bb05c..0000000000
--- a/meta/recipes-qt/qt4/qt-mobility_1.2.0.inc
+++ /dev/null
@@ -1,112 +0,0 @@
1HOMEPAGE = "http://qt-project.org/"
2DEPENDS = "gstreamer util-linux"
3
4inherit bluetooth
5
6PACKAGECONFIG ??= "${@bb.utils.contains('DISTRO_FEATURES', 'pulseaudio', 'pulseaudio', '', d)} \
7 ${@bb.utils.contains('DISTRO_FEATURES', 'bluetooth', '${BLUEZ}', '', d)}"
8PACKAGECONFIG[bluez4] = ",,bluez4"
9PACKAGECONFIG[pulseaudio] = ",,pulseaudio"
10
11LICENSE = "LGPLv2.1"
12LIC_FILES_CHKSUM = "file://LICENSE.LGPL;md5=fbc093901857fcd118f065f900982c24 \
13 file://LGPL_EXCEPTION.txt;md5=411080a56ff917a5a1aa08c98acae354"
14
15FILESEXTRAPATHS =. "${FILE_DIRNAME}/qt-mobility-${PV}:"
16SRC_URI = "http://pkgs.fedoraproject.org/repo/pkgs/qt-mobility/qt-mobility-opensource-src-${PV}.tar.gz/ea5db5a8d3dd4709c2926dceda646bd8/qt-mobility-opensource-src-${PV}.tar.gz \
17 file://qt-mobility-configure.patch \
18 file://0001-gstvideoconnector-fixed-buffers-allocation.patch \
19 file://0002-Remove-unnecessary-rpaths-from-qml_device-example.patch \
20 file://qt-mobility-no-opengl.patch \
21 file://gcc-scope.patch \
22 file://qt-mobility-no-xvideo.patch \
23 file://fix_metaobjectbuilder_build_err.patch \
24 file://0001-fix-embedded-usage-doesn-t-work-outside-of-Qt.patch \
25 file://fix-compile-error-no-bluez.patch \
26 "
27
28SRC_URI[md5sum]="ea5db5a8d3dd4709c2926dceda646bd8"
29SRC_URI[sha256sum]="ee3c88975e04139ac9589f76d4be646d44fcbc4c8c1cf2db621abc154cf0ba44"
30
31PR = "r8"
32
33S = "${WORKDIR}/qt-mobility-opensource-src-${PV}"
34
35qtm_bin := "/usr/bin/${qtm_dir}"
36qtm_lib := "/usr/lib"
37qtm_include := "/usr/include/${qtm_dir}"
38qtm_examples := "/usr/bin/${qtm_dir}/examples/QtMobility"
39qtm_demos := "/usr/bin/${qtm_dir}/demos/QtMobility"
40qtm_plugins := "/usr/lib/${qtm_dir}/plugins/QtMobility"
41qtm_data := "/usr/share/${qtm_dir}"
42qtm_imports := "/usr/lib/${qtm_dir}/imports"
43
44QTM_MODULES_LIST ?= "bearer contacts gallery location publishsubscribe messaging multimedia \
45systeminfo serviceframework sensors versit organizer feedback connectivity"
46
47do_configure_prepend() {
48 cp qtmobility.pro qtmobility.pro.old
49 sed -e 's@...QT_INSTALL_DATA.@${qtm_data}@' <qtmobility.pro.old >qtmobility.pro
50 for NAME in plugins/declarative/*/*.pro
51 do
52 cp $NAME $NAME.old
53 sed -e 's@...QT_INSTALL_IMPORTS.@${qtm_imports}@' <$NAME.old >$NAME
54 done
55 cp staticconfig.pri staticconfig.pri.old
56 echo "include(${STAGING_DATADIR}/${qtm_dir}/mkspecs/qconfig.pri)" >staticconfig.pri
57 cat staticconfig.pri.old >>staticconfig.pri
58
59 cat > features/platformconfig/oe.pri <<EOF
60qmf_enabled = no
61networkmanager_enabled = no
62corewlan_enabled = no
63immersion_enabled = no
64meegotouchfeedback_enabled = no
65maemo-icd_enabled = no
66maemo-icd-network-wlan_enabled = no
67maemo5-contacts_enabled = no
68maemo5-calendar_enabled = no
69maemo6-landmarks_enabled = no
70bme_enabled = no
71bluez_enabled = ${@bb.utils.contains('PACKAGECONFIG', 'bluez4', 'yes', 'no', d)}
72proj_enabled = no
73gstreamer-photography_enabled = no
74gstreamer-appsrc_enabled = yes
75blkid_enabled = yes
76pulseaudio_enabled = ${@bb.utils.contains('PACKAGECONFIG', 'pulseaudio', 'yes', 'no', d)}
77udev_enabled = yes
78iphb_enabled = no
79nfc_symbian_enabled = no
80sensord_enabled = no
81geoclue-master_enabled = no
82gypsy_enabled = no
83${qtm_extra_config}
84EOF
85
86 ./configure -qmake-exec qmake2 -prefix /usr -staticconfig oe -examples -demos -modules "${QTM_MODULES_LIST}"
87 echo QT_MOBILITY_BIN = ${qtm_bin} >>./config.pri
88 echo QT_MOBILITY_LIB = ${qtm_lib} >>./config.pri
89 echo QT_MOBILITY_INCLUDE = ${qtm_include} >>./config.pri
90 echo QT_MOBILITY_PLUGINS = ${qtm_plugins} >>./config.pri
91 echo QT_MOBILITY_EXAMPLES = ${qtm_examples} >>./config.pri
92 echo QT_MOBILITY_DEMOS = ${qtm_demos} >>./config.pri
93 echo QT_CONFIG ${qtm_glflags} >>./config.pri
94 echo CONFIG += ${qtm_embedded} >>./config.pri
95}
96
97do_install() {
98 for NAME in */*.prf
99 do
100 cp $NAME $NAME.old
101 sed -e 's@/usr@${STAGING_BINDIR}/..@' <$NAME.old >$NAME
102 done
103 oe_runmake install INSTALL_ROOT=${D}
104}
105
106PACKAGES = "${PN}-dbg ${PN} ${PN}-dev"
107
108FILES_${PN}-dbg = "${qtm_bin}/.debug ${qtm_examples}/.debug ${qtm_demos}/.debug \
109 ${qtm_lib}/.debug ${qtm_plugins}/*/.debug ${qtm_imports}/*/.debug \
110 ${qtm_imports}/*/*/.debug ${bindir}/.debug /usr/src/debug"
111FILES_${PN} = "${qtm_bin} ${qtm_examples} ${qtm_demos} ${qtm_lib}/*.so.1* ${qtm_plugins} ${qtm_imports}"
112FILES_${PN}-dev = "${exec_prefix}"