Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/kernel/qmetaobjectbuilder.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||||||||||||||
2 | ** | - | ||||||||||||||||||||||||
3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||||||||||||||
4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||||||||||||||
5 | ** | - | ||||||||||||||||||||||||
6 | ** This file is part of the QtCore module of the Qt Toolkit. | - | ||||||||||||||||||||||||
7 | ** | - | ||||||||||||||||||||||||
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||||||||||||||
9 | ** Commercial License Usage | - | ||||||||||||||||||||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||||||||
14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||||||||
15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||||||||||||||||||||
16 | ** | - | ||||||||||||||||||||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||||||||
19 | ** General Public License version 3 as published by the Free Software | - | ||||||||||||||||||||||||
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||||||||||||||
21 | ** packaging of this file. Please review the following information to | - | ||||||||||||||||||||||||
22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||||||||||||||
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||||||||||||||
24 | ** | - | ||||||||||||||||||||||||
25 | ** GNU General Public License Usage | - | ||||||||||||||||||||||||
26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||||||||||||||
27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||||||||||||||
28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||||||||||||||
29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||||||||||||||
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||||||||||||||
31 | ** included in the packaging of this file. Please review the following | - | ||||||||||||||||||||||||
32 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||||||||||||||
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||||||||||||||
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||||||||||||||
35 | ** | - | ||||||||||||||||||||||||
36 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||||||||
37 | ** | - | ||||||||||||||||||||||||
38 | ****************************************************************************/ | - | ||||||||||||||||||||||||
39 | - | |||||||||||||||||||||||||
40 | #include "qmetaobjectbuilder_p.h" | - | ||||||||||||||||||||||||
41 | - | |||||||||||||||||||||||||
42 | #include "qobject_p.h" | - | ||||||||||||||||||||||||
43 | #include "qmetaobject_p.h" | - | ||||||||||||||||||||||||
44 | - | |||||||||||||||||||||||||
45 | #include <vector> | - | ||||||||||||||||||||||||
46 | #include <stdlib.h> | - | ||||||||||||||||||||||||
47 | - | |||||||||||||||||||||||||
48 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||
49 | - | |||||||||||||||||||||||||
50 | /*! | - | ||||||||||||||||||||||||
51 | \class QMetaObjectBuilder | - | ||||||||||||||||||||||||
52 | \inmodule QtCore | - | ||||||||||||||||||||||||
53 | \internal | - | ||||||||||||||||||||||||
54 | \brief The QMetaObjectBuilder class supports building QMetaObject objects at runtime. | - | ||||||||||||||||||||||||
55 | - | |||||||||||||||||||||||||
56 | */ | - | ||||||||||||||||||||||||
57 | - | |||||||||||||||||||||||||
58 | /*! | - | ||||||||||||||||||||||||
59 | \enum QMetaObjectBuilder::AddMember | - | ||||||||||||||||||||||||
60 | This enum defines which members of QMetaObject should be copied by QMetaObjectBuilder::addMetaObject() | - | ||||||||||||||||||||||||
61 | - | |||||||||||||||||||||||||
62 | \value ClassName Add the class name. | - | ||||||||||||||||||||||||
63 | \value SuperClass Add the super class. | - | ||||||||||||||||||||||||
64 | \value Methods Add methods that aren't signals or slots. | - | ||||||||||||||||||||||||
65 | \value Signals Add signals. | - | ||||||||||||||||||||||||
66 | \value Slots Add slots. | - | ||||||||||||||||||||||||
67 | \value Constructors Add constructors. | - | ||||||||||||||||||||||||
68 | \value Properties Add properties. | - | ||||||||||||||||||||||||
69 | \value Enumerators Add enumerators. | - | ||||||||||||||||||||||||
70 | \value ClassInfos Add items of class information. | - | ||||||||||||||||||||||||
71 | \value RelatedMetaObjects Add related meta objects. | - | ||||||||||||||||||||||||
72 | \value StaticMetacall Add the static metacall function. | - | ||||||||||||||||||||||||
73 | \value PublicMethods Add public methods (ignored for signals). | - | ||||||||||||||||||||||||
74 | \value ProtectedMethods Add protected methods (ignored for signals). | - | ||||||||||||||||||||||||
75 | \value PrivateMethods All private methods (ignored for signals). | - | ||||||||||||||||||||||||
76 | \value AllMembers Add all members. | - | ||||||||||||||||||||||||
77 | \value AllPrimaryMembers Add everything except the class name, super class, and static metacall function. | - | ||||||||||||||||||||||||
78 | */ | - | ||||||||||||||||||||||||
79 | - | |||||||||||||||||||||||||
80 | // copied from moc's generator.cpp | - | ||||||||||||||||||||||||
81 | namespace QtPrivate { | - | ||||||||||||||||||||||||
82 | Q_CORE_EXPORT bool isBuiltinType(const QByteArray &type) | - | ||||||||||||||||||||||||
83 | { | - | ||||||||||||||||||||||||
84 | int id = QMetaType::type(type); | - | ||||||||||||||||||||||||
85 | if (!id && !type.isEmpty() && type != "void") | - | ||||||||||||||||||||||||
86 | return false; | - | ||||||||||||||||||||||||
87 | return (id < QMetaType::User); | - | ||||||||||||||||||||||||
88 | } | - | ||||||||||||||||||||||||
89 | } // namespace QtPrivate | - | ||||||||||||||||||||||||
90 | - | |||||||||||||||||||||||||
91 | // copied from qmetaobject.cpp | - | ||||||||||||||||||||||||
92 | static inline Q_DECL_UNUSED const QMetaObjectPrivate *priv(const uint* data) | - | ||||||||||||||||||||||||
93 | { return reinterpret_cast<const QMetaObjectPrivate*>(data); } | - | ||||||||||||||||||||||||
94 | - | |||||||||||||||||||||||||
95 | class QMetaMethodBuilderPrivate | - | ||||||||||||||||||||||||
96 | { | - | ||||||||||||||||||||||||
97 | public: | - | ||||||||||||||||||||||||
98 | QMetaMethodBuilderPrivate() {} QMetaMethodBuilderPrivate | - | ||||||||||||||||||||||||
99 | (QMetaMethod::MethodType _methodType, | - | ||||||||||||||||||||||||
100 | const QByteArray& _signature, | - | ||||||||||||||||||||||||
101 | const QByteArray& _returnType = QByteArray("void"), | - | ||||||||||||||||||||||||
102 | QMetaMethod::Access _access = QMetaMethod::Public, | - | ||||||||||||||||||||||||
103 | int _revision = 0) | - | ||||||||||||||||||||||||
104 | : signature(QMetaObject::normalizedSignature(_signature.constData())), | - | ||||||||||||||||||||||||
105 | returnType(QMetaObject::normalizedType(_returnType)), | - | ||||||||||||||||||||||||
106 | attributes(((int)_access) | (((int)_methodType) << 2)), | - | ||||||||||||||||||||||||
107 | revision(_revision) | - | ||||||||||||||||||||||||
108 | { | - | ||||||||||||||||||||||||
109 | Q_ASSERT((_methodType == QMetaMethod::Constructor) == returnType.isNull()); | - | ||||||||||||||||||||||||
110 | } | - | ||||||||||||||||||||||||
111 | - | |||||||||||||||||||||||||
112 | QByteArray signature; | - | ||||||||||||||||||||||||
113 | QByteArray returnType; | - | ||||||||||||||||||||||||
114 | QList<QByteArray> parameterNames; | - | ||||||||||||||||||||||||
115 | QByteArray tag; | - | ||||||||||||||||||||||||
116 | int attributes; | - | ||||||||||||||||||||||||
117 | int revision; | - | ||||||||||||||||||||||||
118 | - | |||||||||||||||||||||||||
119 | QMetaMethod::MethodType methodType() const | - | ||||||||||||||||||||||||
120 | { | - | ||||||||||||||||||||||||
121 | return (QMetaMethod::MethodType)((attributes & MethodTypeMask) >> 2); | - | ||||||||||||||||||||||||
122 | } | - | ||||||||||||||||||||||||
123 | - | |||||||||||||||||||||||||
124 | QMetaMethod::Access access() const | - | ||||||||||||||||||||||||
125 | { | - | ||||||||||||||||||||||||
126 | return (QMetaMethod::Access)(attributes & AccessMask); | - | ||||||||||||||||||||||||
127 | } | - | ||||||||||||||||||||||||
128 | - | |||||||||||||||||||||||||
129 | void setAccess(QMetaMethod::Access value) | - | ||||||||||||||||||||||||
130 | { | - | ||||||||||||||||||||||||
131 | attributes = ((attributes & ~AccessMask) | (int)value); | - | ||||||||||||||||||||||||
132 | } | - | ||||||||||||||||||||||||
133 | - | |||||||||||||||||||||||||
134 | QList<QByteArray> parameterTypes() const | - | ||||||||||||||||||||||||
135 | { | - | ||||||||||||||||||||||||
136 | return QMetaObjectPrivate::parameterTypeNamesFromSignature(signature); | - | ||||||||||||||||||||||||
137 | } | - | ||||||||||||||||||||||||
138 | - | |||||||||||||||||||||||||
139 | int parameterCount() const | - | ||||||||||||||||||||||||
140 | { | - | ||||||||||||||||||||||||
141 | return parameterTypes().size(); | - | ||||||||||||||||||||||||
142 | } | - | ||||||||||||||||||||||||
143 | - | |||||||||||||||||||||||||
144 | QByteArray name() const | - | ||||||||||||||||||||||||
145 | { | - | ||||||||||||||||||||||||
146 | return signature.left(qMax(signature.indexOf('('), 0)); | - | ||||||||||||||||||||||||
147 | } | - | ||||||||||||||||||||||||
148 | }; | - | ||||||||||||||||||||||||
149 | Q_DECLARE_TYPEINFO(QMetaMethodBuilderPrivate, Q_MOVABLE_TYPE); | - | ||||||||||||||||||||||||
150 | - | |||||||||||||||||||||||||
151 | class QMetaPropertyBuilderPrivate | - | ||||||||||||||||||||||||
152 | { | - | ||||||||||||||||||||||||
153 | public: | - | ||||||||||||||||||||||||
154 | QMetaPropertyBuilderPrivate() {} QMetaPropertyBuilderPrivate | - | ||||||||||||||||||||||||
155 | (const QByteArray& _name, const QByteArray& _type, int notifierIdx=-1, | - | ||||||||||||||||||||||||
156 | int _revision = 0) | - | ||||||||||||||||||||||||
157 | : name(_name), | - | ||||||||||||||||||||||||
158 | type(QMetaObject::normalizedType(_type.constData())), | - | ||||||||||||||||||||||||
159 | flags(Readable | Writable | Scriptable), notifySignal(-1), | - | ||||||||||||||||||||||||
160 | revision(_revision) | - | ||||||||||||||||||||||||
161 | { | - | ||||||||||||||||||||||||
162 | if (notifierIdx >= 0) { | - | ||||||||||||||||||||||||
163 | flags |= Notify; | - | ||||||||||||||||||||||||
164 | notifySignal = notifierIdx; | - | ||||||||||||||||||||||||
165 | } | - | ||||||||||||||||||||||||
166 | } | - | ||||||||||||||||||||||||
167 | - | |||||||||||||||||||||||||
168 | QByteArray name; | - | ||||||||||||||||||||||||
169 | QByteArray type; | - | ||||||||||||||||||||||||
170 | int flags; | - | ||||||||||||||||||||||||
171 | int notifySignal; | - | ||||||||||||||||||||||||
172 | int revision; | - | ||||||||||||||||||||||||
173 | - | |||||||||||||||||||||||||
174 | bool flag(int f) const | - | ||||||||||||||||||||||||
175 | { | - | ||||||||||||||||||||||||
176 | return ((flags & f) != 0); | - | ||||||||||||||||||||||||
177 | } | - | ||||||||||||||||||||||||
178 | - | |||||||||||||||||||||||||
179 | void setFlag(int f, bool value) | - | ||||||||||||||||||||||||
180 | { | - | ||||||||||||||||||||||||
181 | if (value) | - | ||||||||||||||||||||||||
182 | flags |= f; | - | ||||||||||||||||||||||||
183 | else | - | ||||||||||||||||||||||||
184 | flags &= ~f; | - | ||||||||||||||||||||||||
185 | } | - | ||||||||||||||||||||||||
186 | }; | - | ||||||||||||||||||||||||
187 | Q_DECLARE_TYPEINFO(QMetaPropertyBuilderPrivate, Q_MOVABLE_TYPE); | - | ||||||||||||||||||||||||
188 | - | |||||||||||||||||||||||||
189 | class QMetaEnumBuilderPrivate | - | ||||||||||||||||||||||||
190 | { | - | ||||||||||||||||||||||||
191 | public: | - | ||||||||||||||||||||||||
192 | QMetaEnumBuilderPrivate() {} QMetaEnumBuilderPrivate(const QByteArray& _name) | - | ||||||||||||||||||||||||
193 | : name(_name), isFlag(false) | - | ||||||||||||||||||||||||
194 | { | - | ||||||||||||||||||||||||
195 | } | - | ||||||||||||||||||||||||
196 | - | |||||||||||||||||||||||||
197 | QByteArray name; | - | ||||||||||||||||||||||||
198 | bool isFlag; | - | ||||||||||||||||||||||||
199 | QList<QByteArray> keys; | - | ||||||||||||||||||||||||
200 | QVector<int> values; | - | ||||||||||||||||||||||||
201 | }; | - | ||||||||||||||||||||||||
202 | Q_DECLARE_TYPEINFO(QMetaEnumBuilderPrivate, Q_MOVABLE_TYPE); | - | ||||||||||||||||||||||||
203 | - | |||||||||||||||||||||||||
204 | class QMetaObjectBuilderPrivate | - | ||||||||||||||||||||||||
205 | { | - | ||||||||||||||||||||||||
206 | public: | - | ||||||||||||||||||||||||
207 | QMetaObjectBuilderPrivate() | - | ||||||||||||||||||||||||
208 | : flags(0) | - | ||||||||||||||||||||||||
209 | { | - | ||||||||||||||||||||||||
210 | superClass = &QObject::staticMetaObject; | - | ||||||||||||||||||||||||
211 | staticMetacallFunction = 0; | - | ||||||||||||||||||||||||
212 | } | - | ||||||||||||||||||||||||
213 | - | |||||||||||||||||||||||||
214 | bool hasRevisionedProperties() const; | - | ||||||||||||||||||||||||
215 | bool hasRevisionedMethods() const; | - | ||||||||||||||||||||||||
216 | - | |||||||||||||||||||||||||
217 | QByteArray className; | - | ||||||||||||||||||||||||
218 | const QMetaObject *superClass; | - | ||||||||||||||||||||||||
219 | QMetaObjectBuilder::StaticMetacallFunction staticMetacallFunction; | - | ||||||||||||||||||||||||
220 | QVectorstd::vector<QMetaMethodBuilderPrivate> methods; | - | ||||||||||||||||||||||||
221 | QVectorstd::vector<QMetaMethodBuilderPrivate> constructors; | - | ||||||||||||||||||||||||
222 | QVectorstd::vector<QMetaPropertyBuilderPrivate> properties; | - | ||||||||||||||||||||||||
223 | QList<QByteArray> classInfoNames; | - | ||||||||||||||||||||||||
224 | QList<QByteArray> classInfoValues; | - | ||||||||||||||||||||||||
225 | QVectorstd::vector<QMetaEnumBuilderPrivate> enumerators; | - | ||||||||||||||||||||||||
226 | QList<const QMetaObject *> relatedMetaObjects; | - | ||||||||||||||||||||||||
227 | int flags; | - | ||||||||||||||||||||||||
228 | }; | - | ||||||||||||||||||||||||
229 | - | |||||||||||||||||||||||||
230 | bool QMetaObjectBuilderPrivate::hasRevisionedProperties() const | - | ||||||||||||||||||||||||
231 | { | - | ||||||||||||||||||||||||
232 | for (int i = 0; i <const auto &property : properties.size(); ++i) { | - | ||||||||||||||||||||||||
233 | if (propertiesproperty.at(i).revision)
| 8-42 | ||||||||||||||||||||||||
234 | return true; executed 8 times by 1 test: return true; Executed by:
| 8 | ||||||||||||||||||||||||
235 | } executed 42 times by 1 test: end of block Executed by:
| 42 | ||||||||||||||||||||||||
236 | return false; executed 28 times by 1 test: return false; Executed by:
| 28 | ||||||||||||||||||||||||
237 | } | - | ||||||||||||||||||||||||
238 | - | |||||||||||||||||||||||||
239 | bool QMetaObjectBuilderPrivate::hasRevisionedMethods() const | - | ||||||||||||||||||||||||
240 | { | - | ||||||||||||||||||||||||
241 | for (int i = 0; i <const auto &method : methods.size(); ++i) { | - | ||||||||||||||||||||||||
242 | if (methodsmethod.at(i).revision)
| 8-170 | ||||||||||||||||||||||||
243 | return true; executed 8 times by 1 test: return true; Executed by:
| 8 | ||||||||||||||||||||||||
244 | } executed 170 times by 1 test: end of block Executed by:
| 170 | ||||||||||||||||||||||||
245 | return false; executed 28 times by 1 test: return false; Executed by:
| 28 | ||||||||||||||||||||||||
246 | } | - | ||||||||||||||||||||||||
247 | - | |||||||||||||||||||||||||
248 | /*! | - | ||||||||||||||||||||||||
249 | Constructs a new QMetaObjectBuilder. | - | ||||||||||||||||||||||||
250 | */ | - | ||||||||||||||||||||||||
251 | QMetaObjectBuilder::QMetaObjectBuilder() | - | ||||||||||||||||||||||||
252 | { | - | ||||||||||||||||||||||||
253 | d = new QMetaObjectBuilderPrivate(); | - | ||||||||||||||||||||||||
254 | } | - | ||||||||||||||||||||||||
255 | - | |||||||||||||||||||||||||
256 | /*! | - | ||||||||||||||||||||||||
257 | Constructs a new QMetaObjectBuilder which is a copy of the | - | ||||||||||||||||||||||||
258 | meta object information in \a prototype. Note: the super class | - | ||||||||||||||||||||||||
259 | contents for \a prototype are not copied, only the immediate | - | ||||||||||||||||||||||||
260 | class that is defined by \a prototype. | - | ||||||||||||||||||||||||
261 | - | |||||||||||||||||||||||||
262 | The \a members parameter indicates which members of \a prototype | - | ||||||||||||||||||||||||
263 | should be added. The default is AllMembers. | - | ||||||||||||||||||||||||
264 | - | |||||||||||||||||||||||||
265 | \sa addMetaObject() | - | ||||||||||||||||||||||||
266 | */ | - | ||||||||||||||||||||||||
267 | QMetaObjectBuilder::QMetaObjectBuilder | - | ||||||||||||||||||||||||
268 | (const QMetaObject *prototype, QMetaObjectBuilder::AddMembers members) | - | ||||||||||||||||||||||||
269 | { | - | ||||||||||||||||||||||||
270 | d = new QMetaObjectBuilderPrivate(); | - | ||||||||||||||||||||||||
271 | addMetaObject(prototype, members); | - | ||||||||||||||||||||||||
272 | } | - | ||||||||||||||||||||||||
273 | - | |||||||||||||||||||||||||
274 | /*! | - | ||||||||||||||||||||||||
275 | Destroys this meta object builder. | - | ||||||||||||||||||||||||
276 | */ | - | ||||||||||||||||||||||||
277 | QMetaObjectBuilder::~QMetaObjectBuilder() | - | ||||||||||||||||||||||||
278 | { | - | ||||||||||||||||||||||||
279 | delete d; | - | ||||||||||||||||||||||||
280 | } | - | ||||||||||||||||||||||||
281 | - | |||||||||||||||||||||||||
282 | /*! | - | ||||||||||||||||||||||||
283 | Returns the name of the class being constructed by this | - | ||||||||||||||||||||||||
284 | meta object builder. The default value is an empty QByteArray. | - | ||||||||||||||||||||||||
285 | - | |||||||||||||||||||||||||
286 | \sa setClassName(), superClass() | - | ||||||||||||||||||||||||
287 | */ | - | ||||||||||||||||||||||||
288 | QByteArray QMetaObjectBuilder::className() const | - | ||||||||||||||||||||||||
289 | { | - | ||||||||||||||||||||||||
290 | return d->className; | - | ||||||||||||||||||||||||
291 | } | - | ||||||||||||||||||||||||
292 | - | |||||||||||||||||||||||||
293 | /*! | - | ||||||||||||||||||||||||
294 | Sets the \a name of the class being constructed by this | - | ||||||||||||||||||||||||
295 | meta object builder. | - | ||||||||||||||||||||||||
296 | - | |||||||||||||||||||||||||
297 | \sa className(), setSuperClass() | - | ||||||||||||||||||||||||
298 | */ | - | ||||||||||||||||||||||||
299 | void QMetaObjectBuilder::setClassName(const QByteArray& name) | - | ||||||||||||||||||||||||
300 | { | - | ||||||||||||||||||||||||
301 | d->className = name; | - | ||||||||||||||||||||||||
302 | } | - | ||||||||||||||||||||||||
303 | - | |||||||||||||||||||||||||
304 | /*! | - | ||||||||||||||||||||||||
305 | Returns the superclass meta object of the class being constructed | - | ||||||||||||||||||||||||
306 | by this meta object builder. The default value is the meta object | - | ||||||||||||||||||||||||
307 | for QObject. | - | ||||||||||||||||||||||||
308 | - | |||||||||||||||||||||||||
309 | \sa setSuperClass(), className() | - | ||||||||||||||||||||||||
310 | */ | - | ||||||||||||||||||||||||
311 | const QMetaObject *QMetaObjectBuilder::superClass() const | - | ||||||||||||||||||||||||
312 | { | - | ||||||||||||||||||||||||
313 | return d->superClass; | - | ||||||||||||||||||||||||
314 | } | - | ||||||||||||||||||||||||
315 | - | |||||||||||||||||||||||||
316 | /*! | - | ||||||||||||||||||||||||
317 | Sets the superclass meta object of the class being constructed | - | ||||||||||||||||||||||||
318 | by this meta object builder to \a meta. The \a meta parameter | - | ||||||||||||||||||||||||
319 | must not be null. | - | ||||||||||||||||||||||||
320 | - | |||||||||||||||||||||||||
321 | \sa superClass(), setClassName() | - | ||||||||||||||||||||||||
322 | */ | - | ||||||||||||||||||||||||
323 | void QMetaObjectBuilder::setSuperClass(const QMetaObject *meta) | - | ||||||||||||||||||||||||
324 | { | - | ||||||||||||||||||||||||
325 | Q_ASSERT(meta); | - | ||||||||||||||||||||||||
326 | d->superClass = meta; | - | ||||||||||||||||||||||||
327 | } | - | ||||||||||||||||||||||||
328 | - | |||||||||||||||||||||||||
329 | /*! | - | ||||||||||||||||||||||||
330 | Returns the flags of the class being constructed by this meta object | - | ||||||||||||||||||||||||
331 | builder. | - | ||||||||||||||||||||||||
332 | - | |||||||||||||||||||||||||
333 | \sa setFlags() | - | ||||||||||||||||||||||||
334 | */ | - | ||||||||||||||||||||||||
335 | QMetaObjectBuilder::MetaObjectFlags QMetaObjectBuilder::flags() const | - | ||||||||||||||||||||||||
336 | { | - | ||||||||||||||||||||||||
337 | return (QMetaObjectBuilder::MetaObjectFlags)d->flags; | - | ||||||||||||||||||||||||
338 | } | - | ||||||||||||||||||||||||
339 | - | |||||||||||||||||||||||||
340 | /*! | - | ||||||||||||||||||||||||
341 | Sets the \a flags of the class being constructed by this meta object | - | ||||||||||||||||||||||||
342 | builder. | - | ||||||||||||||||||||||||
343 | - | |||||||||||||||||||||||||
344 | \sa flags() | - | ||||||||||||||||||||||||
345 | */ | - | ||||||||||||||||||||||||
346 | void QMetaObjectBuilder::setFlags(MetaObjectFlags flags) | - | ||||||||||||||||||||||||
347 | { | - | ||||||||||||||||||||||||
348 | d->flags = flags; | - | ||||||||||||||||||||||||
349 | } | - | ||||||||||||||||||||||||
350 | - | |||||||||||||||||||||||||
351 | /*! | - | ||||||||||||||||||||||||
352 | Returns the number of methods in this class, excluding the number | - | ||||||||||||||||||||||||
353 | of methods in the base class. These include signals and slots | - | ||||||||||||||||||||||||
354 | as well as normal member functions. | - | ||||||||||||||||||||||||
355 | - | |||||||||||||||||||||||||
356 | \sa addMethod(), method(), removeMethod(), indexOfMethod() | - | ||||||||||||||||||||||||
357 | */ | - | ||||||||||||||||||||||||
358 | int QMetaObjectBuilder::methodCount() const | - | ||||||||||||||||||||||||
359 | { | - | ||||||||||||||||||||||||
360 | return int(d->methods.size();()); executed 20 times by 1 test: return int(d->methods.size()); Executed by:
| 20 | ||||||||||||||||||||||||
361 | } | - | ||||||||||||||||||||||||
362 | - | |||||||||||||||||||||||||
363 | /*! | - | ||||||||||||||||||||||||
364 | Returns the number of constructors in this class. | - | ||||||||||||||||||||||||
365 | - | |||||||||||||||||||||||||
366 | \sa addConstructor(), constructor(), removeConstructor(), indexOfConstructor() | - | ||||||||||||||||||||||||
367 | */ | - | ||||||||||||||||||||||||
368 | int QMetaObjectBuilder::constructorCount() const | - | ||||||||||||||||||||||||
369 | { | - | ||||||||||||||||||||||||
370 | return int(d->constructors.size();()); executed 18 times by 1 test: return int(d->constructors.size()); Executed by:
| 18 | ||||||||||||||||||||||||
371 | } | - | ||||||||||||||||||||||||
372 | - | |||||||||||||||||||||||||
373 | /*! | - | ||||||||||||||||||||||||
374 | Returns the number of properties in this class, excluding the number | - | ||||||||||||||||||||||||
375 | of properties in the base class. | - | ||||||||||||||||||||||||
376 | - | |||||||||||||||||||||||||
377 | \sa addProperty(), property(), removeProperty(), indexOfProperty() | - | ||||||||||||||||||||||||
378 | */ | - | ||||||||||||||||||||||||
379 | int QMetaObjectBuilder::propertyCount() const | - | ||||||||||||||||||||||||
380 | { | - | ||||||||||||||||||||||||
381 | return int(d->properties.size();()); executed 17 times by 1 test: return int(d->properties.size()); Executed by:
| 17 | ||||||||||||||||||||||||
382 | } | - | ||||||||||||||||||||||||
383 | - | |||||||||||||||||||||||||
384 | /*! | - | ||||||||||||||||||||||||
385 | Returns the number of enumerators in this class, excluding the | - | ||||||||||||||||||||||||
386 | number of enumerators in the base class. | - | ||||||||||||||||||||||||
387 | - | |||||||||||||||||||||||||
388 | \sa addEnumerator(), enumerator(), removeEnumerator() | - | ||||||||||||||||||||||||
389 | \sa indexOfEnumerator() | - | ||||||||||||||||||||||||
390 | */ | - | ||||||||||||||||||||||||
391 | int QMetaObjectBuilder::enumeratorCount() const | - | ||||||||||||||||||||||||
392 | { | - | ||||||||||||||||||||||||
393 | return int(d->enumerators.size();()); executed 15 times by 1 test: return int(d->enumerators.size()); Executed by:
| 15 | ||||||||||||||||||||||||
394 | } | - | ||||||||||||||||||||||||
395 | - | |||||||||||||||||||||||||
396 | /*! | - | ||||||||||||||||||||||||
397 | Returns the number of items of class information in this class, | - | ||||||||||||||||||||||||
398 | exclusing the number of items of class information in the base class. | - | ||||||||||||||||||||||||
399 | - | |||||||||||||||||||||||||
400 | \sa addClassInfo(), classInfoName(), classInfoValue(), removeClassInfo() | - | ||||||||||||||||||||||||
401 | \sa indexOfClassInfo() | - | ||||||||||||||||||||||||
402 | */ | - | ||||||||||||||||||||||||
403 | int QMetaObjectBuilder::classInfoCount() const | - | ||||||||||||||||||||||||
404 | { | - | ||||||||||||||||||||||||
405 | return d->classInfoNames.size(); | - | ||||||||||||||||||||||||
406 | } | - | ||||||||||||||||||||||||
407 | - | |||||||||||||||||||||||||
408 | /*! | - | ||||||||||||||||||||||||
409 | Returns the number of related meta objects that are associated | - | ||||||||||||||||||||||||
410 | with this class. | - | ||||||||||||||||||||||||
411 | - | |||||||||||||||||||||||||
412 | Related meta objects are used when resolving the enumerated type | - | ||||||||||||||||||||||||
413 | associated with a property, where the enumerated type is in a | - | ||||||||||||||||||||||||
414 | different class from the property. | - | ||||||||||||||||||||||||
415 | - | |||||||||||||||||||||||||
416 | \sa addRelatedMetaObject(), relatedMetaObject() | - | ||||||||||||||||||||||||
417 | \sa removeRelatedMetaObject() | - | ||||||||||||||||||||||||
418 | */ | - | ||||||||||||||||||||||||
419 | int QMetaObjectBuilder::relatedMetaObjectCount() const | - | ||||||||||||||||||||||||
420 | { | - | ||||||||||||||||||||||||
421 | return d->relatedMetaObjects.size(); | - | ||||||||||||||||||||||||
422 | } | - | ||||||||||||||||||||||||
423 | - | |||||||||||||||||||||||||
424 | /*! | - | ||||||||||||||||||||||||
425 | Adds a new public method to this class with the specified \a signature. | - | ||||||||||||||||||||||||
426 | Returns an object that can be used to adjust the other attributes | - | ||||||||||||||||||||||||
427 | of the method. The \a signature will be normalized before it is | - | ||||||||||||||||||||||||
428 | added to the class. | - | ||||||||||||||||||||||||
429 | - | |||||||||||||||||||||||||
430 | \sa method(), methodCount(), removeMethod(), indexOfMethod() | - | ||||||||||||||||||||||||
431 | */ | - | ||||||||||||||||||||||||
432 | QMetaMethodBuilder QMetaObjectBuilder::addMethod(const QByteArray& signature) | - | ||||||||||||||||||||||||
433 | { | - | ||||||||||||||||||||||||
434 | int index = int(d->methods.size();()); | - | ||||||||||||||||||||||||
435 | d->methods.appendpush_back(QMetaMethodBuilderPrivate(QMetaMethod::Method, signature)); | - | ||||||||||||||||||||||||
436 | return QMetaMethodBuilder(this, index); executed 24 times by 1 test: return QMetaMethodBuilder(this, index); Executed by:
| 24 | ||||||||||||||||||||||||
437 | } | - | ||||||||||||||||||||||||
438 | - | |||||||||||||||||||||||||
439 | /*! | - | ||||||||||||||||||||||||
440 | Adds a new public method to this class with the specified | - | ||||||||||||||||||||||||
441 | \a signature and \a returnType. Returns an object that can be | - | ||||||||||||||||||||||||
442 | used to adjust the other attributes of the method. The \a signature | - | ||||||||||||||||||||||||
443 | and \a returnType will be normalized before they are added to | - | ||||||||||||||||||||||||
444 | the class. | - | ||||||||||||||||||||||||
445 | - | |||||||||||||||||||||||||
446 | \sa method(), methodCount(), removeMethod(), indexOfMethod() | - | ||||||||||||||||||||||||
447 | */ | - | ||||||||||||||||||||||||
448 | QMetaMethodBuilder QMetaObjectBuilder::addMethod | - | ||||||||||||||||||||||||
449 | (const QByteArray& signature, const QByteArray& returnType) | - | ||||||||||||||||||||||||
450 | { | - | ||||||||||||||||||||||||
451 | int index = int(d->methods.size();()); | - | ||||||||||||||||||||||||
452 | d->methods.appendpush_back(QMetaMethodBuilderPrivate | - | ||||||||||||||||||||||||
453 | (QMetaMethod::Method, signature, returnType)); | - | ||||||||||||||||||||||||
454 | return QMetaMethodBuilder(this, index); executed 1 time by 1 test: return QMetaMethodBuilder(this, index); Executed by:
| 1 | ||||||||||||||||||||||||
455 | } | - | ||||||||||||||||||||||||
456 | - | |||||||||||||||||||||||||
457 | /*! | - | ||||||||||||||||||||||||
458 | Adds a new public method to this class that has the same information as | - | ||||||||||||||||||||||||
459 | \a prototype. This is used to clone the methods of an existing | - | ||||||||||||||||||||||||
460 | QMetaObject. Returns an object that can be used to adjust the | - | ||||||||||||||||||||||||
461 | attributes of the method. | - | ||||||||||||||||||||||||
462 | - | |||||||||||||||||||||||||
463 | This function will detect if \a prototype is an ordinary method, | - | ||||||||||||||||||||||||
464 | signal, slot, or constructor and act accordingly. | - | ||||||||||||||||||||||||
465 | - | |||||||||||||||||||||||||
466 | \sa method(), methodCount(), removeMethod(), indexOfMethod() | - | ||||||||||||||||||||||||
467 | */ | - | ||||||||||||||||||||||||
468 | QMetaMethodBuilder QMetaObjectBuilder::addMethod(const QMetaMethod& prototype) | - | ||||||||||||||||||||||||
469 | { | - | ||||||||||||||||||||||||
470 | QMetaMethodBuilder method; | - | ||||||||||||||||||||||||
471 | if (prototype.methodType() == QMetaMethod::Method) | - | ||||||||||||||||||||||||
472 | method = addMethod(prototype.methodSignature()); | - | ||||||||||||||||||||||||
473 | else if (prototype.methodType() == QMetaMethod::Signal) | - | ||||||||||||||||||||||||
474 | method = addSignal(prototype.methodSignature()); | - | ||||||||||||||||||||||||
475 | else if (prototype.methodType() == QMetaMethod::Slot) | - | ||||||||||||||||||||||||
476 | method = addSlot(prototype.methodSignature()); | - | ||||||||||||||||||||||||
477 | else if (prototype.methodType() == QMetaMethod::Constructor) | - | ||||||||||||||||||||||||
478 | method = addConstructor(prototype.methodSignature()); | - | ||||||||||||||||||||||||
479 | method.setReturnType(prototype.typeName()); | - | ||||||||||||||||||||||||
480 | method.setParameterNames(prototype.parameterNames()); | - | ||||||||||||||||||||||||
481 | method.setTag(prototype.tag()); | - | ||||||||||||||||||||||||
482 | method.setAccess(prototype.access()); | - | ||||||||||||||||||||||||
483 | method.setAttributes(prototype.attributes()); | - | ||||||||||||||||||||||||
484 | method.setRevision(prototype.revision()); | - | ||||||||||||||||||||||||
485 | return method; | - | ||||||||||||||||||||||||
486 | } | - | ||||||||||||||||||||||||
487 | - | |||||||||||||||||||||||||
488 | /*! | - | ||||||||||||||||||||||||
489 | Adds a new public slot to this class with the specified \a signature. | - | ||||||||||||||||||||||||
490 | Returns an object that can be used to adjust the other attributes | - | ||||||||||||||||||||||||
491 | of the slot. The \a signature will be normalized before it is | - | ||||||||||||||||||||||||
492 | added to the class. | - | ||||||||||||||||||||||||
493 | - | |||||||||||||||||||||||||
494 | \sa addMethod(), addSignal(), indexOfSlot() | - | ||||||||||||||||||||||||
495 | */ | - | ||||||||||||||||||||||||
496 | QMetaMethodBuilder QMetaObjectBuilder::addSlot(const QByteArray& signature) | - | ||||||||||||||||||||||||
497 | { | - | ||||||||||||||||||||||||
498 | int index = int(d->methods.size();()); | - | ||||||||||||||||||||||||
499 | d->methods.appendpush_back(QMetaMethodBuilderPrivate(QMetaMethod::Slot, signature)); | - | ||||||||||||||||||||||||
500 | return QMetaMethodBuilder(this, index); executed 60 times by 1 test: return QMetaMethodBuilder(this, index); Executed by:
| 60 | ||||||||||||||||||||||||
501 | } | - | ||||||||||||||||||||||||
502 | - | |||||||||||||||||||||||||
503 | /*! | - | ||||||||||||||||||||||||
504 | Adds a new signal to this class with the specified \a signature. | - | ||||||||||||||||||||||||
505 | Returns an object that can be used to adjust the other attributes | - | ||||||||||||||||||||||||
506 | of the signal. The \a signature will be normalized before it is | - | ||||||||||||||||||||||||
507 | added to the class. | - | ||||||||||||||||||||||||
508 | - | |||||||||||||||||||||||||
509 | \sa addMethod(), addSlot(), indexOfSignal() | - | ||||||||||||||||||||||||
510 | */ | - | ||||||||||||||||||||||||
511 | QMetaMethodBuilder QMetaObjectBuilder::addSignal(const QByteArray& signature) | - | ||||||||||||||||||||||||
512 | { | - | ||||||||||||||||||||||||
513 | int index = int(d->methods.size();()); | - | ||||||||||||||||||||||||
514 | d->methods.appendpush_back(QMetaMethodBuilderPrivate | - | ||||||||||||||||||||||||
515 | (QMetaMethod::Signal, signature, QByteArray("void"), QMetaMethod::Public)); | - | ||||||||||||||||||||||||
516 | return QMetaMethodBuilder(this, index); executed 28 times by 1 test: return QMetaMethodBuilder(this, index); Executed by:
| 28 | ||||||||||||||||||||||||
517 | } | - | ||||||||||||||||||||||||
518 | - | |||||||||||||||||||||||||
519 | /*! | - | ||||||||||||||||||||||||
520 | Adds a new constructor to this class with the specified \a signature. | - | ||||||||||||||||||||||||
521 | Returns an object that can be used to adjust the other attributes | - | ||||||||||||||||||||||||
522 | of the constructor. The \a signature will be normalized before it is | - | ||||||||||||||||||||||||
523 | added to the class. | - | ||||||||||||||||||||||||
524 | - | |||||||||||||||||||||||||
525 | \sa constructor(), constructorCount(), removeConstructor() | - | ||||||||||||||||||||||||
526 | \sa indexOfConstructor() | - | ||||||||||||||||||||||||
527 | */ | - | ||||||||||||||||||||||||
528 | QMetaMethodBuilder QMetaObjectBuilder::addConstructor(const QByteArray& signature) | - | ||||||||||||||||||||||||
529 | { | - | ||||||||||||||||||||||||
530 | int index = int(d->constructors.size();()); | - | ||||||||||||||||||||||||
531 | d->constructors.appendpush_back(QMetaMethodBuilderPrivate(QMetaMethod::Constructor, signature, | - | ||||||||||||||||||||||||
532 | /*returnType=*/QByteArray())); | - | ||||||||||||||||||||||||
533 | return QMetaMethodBuilder(this, -(index + 1)); executed 27 times by 1 test: return QMetaMethodBuilder(this, -(index + 1)); Executed by:
| 27 | ||||||||||||||||||||||||
534 | } | - | ||||||||||||||||||||||||
535 | - | |||||||||||||||||||||||||
536 | /*! | - | ||||||||||||||||||||||||
537 | Adds a new constructor to this class that has the same information as | - | ||||||||||||||||||||||||
538 | \a prototype. This is used to clone the constructors of an existing | - | ||||||||||||||||||||||||
539 | QMetaObject. Returns an object that can be used to adjust the | - | ||||||||||||||||||||||||
540 | attributes of the constructor. | - | ||||||||||||||||||||||||
541 | - | |||||||||||||||||||||||||
542 | This function requires that \a prototype be a constructor. | - | ||||||||||||||||||||||||
543 | - | |||||||||||||||||||||||||
544 | \sa constructor(), constructorCount(), removeConstructor() | - | ||||||||||||||||||||||||
545 | \sa indexOfConstructor() | - | ||||||||||||||||||||||||
546 | */ | - | ||||||||||||||||||||||||
547 | QMetaMethodBuilder QMetaObjectBuilder::addConstructor(const QMetaMethod& prototype) | - | ||||||||||||||||||||||||
548 | { | - | ||||||||||||||||||||||||
549 | Q_ASSERT(prototype.methodType() == QMetaMethod::Constructor); | - | ||||||||||||||||||||||||
550 | QMetaMethodBuilder ctor = addConstructor(prototype.methodSignature()); | - | ||||||||||||||||||||||||
551 | ctor.setReturnType(prototype.typeName()); | - | ||||||||||||||||||||||||
552 | ctor.setParameterNames(prototype.parameterNames()); | - | ||||||||||||||||||||||||
553 | ctor.setTag(prototype.tag()); | - | ||||||||||||||||||||||||
554 | ctor.setAccess(prototype.access()); | - | ||||||||||||||||||||||||
555 | ctor.setAttributes(prototype.attributes()); | - | ||||||||||||||||||||||||
556 | return ctor; | - | ||||||||||||||||||||||||
557 | } | - | ||||||||||||||||||||||||
558 | - | |||||||||||||||||||||||||
559 | /*! | - | ||||||||||||||||||||||||
560 | Adds a new readable/writable property to this class with the | - | ||||||||||||||||||||||||
561 | specified \a name and \a type. Returns an object that can be used | - | ||||||||||||||||||||||||
562 | to adjust the other attributes of the property. The \a type will | - | ||||||||||||||||||||||||
563 | be normalized before it is added to the class. \a notifierId will | - | ||||||||||||||||||||||||
564 | be registered as the property's \e notify signal. | - | ||||||||||||||||||||||||
565 | - | |||||||||||||||||||||||||
566 | \sa property(), propertyCount(), removeProperty(), indexOfProperty() | - | ||||||||||||||||||||||||
567 | */ | - | ||||||||||||||||||||||||
568 | QMetaPropertyBuilder QMetaObjectBuilder::addProperty | - | ||||||||||||||||||||||||
569 | (const QByteArray& name, const QByteArray& type, int notifierId) | - | ||||||||||||||||||||||||
570 | { | - | ||||||||||||||||||||||||
571 | int index = int(d->properties.size();()); | - | ||||||||||||||||||||||||
572 | d->properties.appendpush_back(QMetaPropertyBuilderPrivate(name, type, notifierId)); | - | ||||||||||||||||||||||||
573 | return QMetaPropertyBuilder(this, index); executed 43 times by 1 test: return QMetaPropertyBuilder(this, index); Executed by:
| 43 | ||||||||||||||||||||||||
574 | } | - | ||||||||||||||||||||||||
575 | - | |||||||||||||||||||||||||
576 | /*! | - | ||||||||||||||||||||||||
577 | Adds a new property to this class that has the same information as | - | ||||||||||||||||||||||||
578 | \a prototype. This is used to clone the properties of an existing | - | ||||||||||||||||||||||||
579 | QMetaObject. Returns an object that can be used to adjust the | - | ||||||||||||||||||||||||
580 | attributes of the property. | - | ||||||||||||||||||||||||
581 | - | |||||||||||||||||||||||||
582 | \sa property(), propertyCount(), removeProperty(), indexOfProperty() | - | ||||||||||||||||||||||||
583 | */ | - | ||||||||||||||||||||||||
584 | QMetaPropertyBuilder QMetaObjectBuilder::addProperty(const QMetaProperty& prototype) | - | ||||||||||||||||||||||||
585 | { | - | ||||||||||||||||||||||||
586 | QMetaPropertyBuilder property = addProperty(prototype.name(), prototype.typeName()); | - | ||||||||||||||||||||||||
587 | property.setReadable(prototype.isReadable()); | - | ||||||||||||||||||||||||
588 | property.setWritable(prototype.isWritable()); | - | ||||||||||||||||||||||||
589 | property.setResettable(prototype.isResettable()); | - | ||||||||||||||||||||||||
590 | property.setDesignable(prototype.isDesignable()); | - | ||||||||||||||||||||||||
591 | property.setScriptable(prototype.isScriptable()); | - | ||||||||||||||||||||||||
592 | property.setStored(prototype.isStored()); | - | ||||||||||||||||||||||||
593 | property.setEditable(prototype.isEditable()); | - | ||||||||||||||||||||||||
594 | property.setUser(prototype.isUser()); | - | ||||||||||||||||||||||||
595 | property.setStdCppSet(prototype.hasStdCppSet()); | - | ||||||||||||||||||||||||
596 | property.setEnumOrFlag(prototype.isEnumType()); | - | ||||||||||||||||||||||||
597 | property.setConstant(prototype.isConstant()); | - | ||||||||||||||||||||||||
598 | property.setFinal(prototype.isFinal()); | - | ||||||||||||||||||||||||
599 | property.setRevision(prototype.revision()); | - | ||||||||||||||||||||||||
600 | if (prototype.hasNotifySignal()) { | - | ||||||||||||||||||||||||
601 | // Find an existing method for the notify signal, or add a new one. | - | ||||||||||||||||||||||||
602 | QMetaMethod method = prototype.notifySignal(); | - | ||||||||||||||||||||||||
603 | int index = indexOfMethod(method.methodSignature()); | - | ||||||||||||||||||||||||
604 | if (index == -1) | - | ||||||||||||||||||||||||
605 | index = addMethod(method).index(); | - | ||||||||||||||||||||||||
606 | d->properties[property._index].notifySignal = index; | - | ||||||||||||||||||||||||
607 | d->properties[property._index].setFlag(Notify, true); | - | ||||||||||||||||||||||||
608 | } | - | ||||||||||||||||||||||||
609 | return property; | - | ||||||||||||||||||||||||
610 | } | - | ||||||||||||||||||||||||
611 | - | |||||||||||||||||||||||||
612 | /*! | - | ||||||||||||||||||||||||
613 | Adds a new enumerator to this class with the specified | - | ||||||||||||||||||||||||
614 | \a name. Returns an object that can be used to adjust | - | ||||||||||||||||||||||||
615 | the other attributes of the enumerator. | - | ||||||||||||||||||||||||
616 | - | |||||||||||||||||||||||||
617 | \sa enumerator(), enumeratorCount(), removeEnumerator() | - | ||||||||||||||||||||||||
618 | \sa indexOfEnumerator() | - | ||||||||||||||||||||||||
619 | */ | - | ||||||||||||||||||||||||
620 | QMetaEnumBuilder QMetaObjectBuilder::addEnumerator(const QByteArray& name) | - | ||||||||||||||||||||||||
621 | { | - | ||||||||||||||||||||||||
622 | int index = int(d->enumerators.size();()); | - | ||||||||||||||||||||||||
623 | d->enumerators.appendpush_back(QMetaEnumBuilderPrivate(name)); | - | ||||||||||||||||||||||||
624 | return QMetaEnumBuilder(this, index); executed 10 times by 1 test: return QMetaEnumBuilder(this, index); Executed by:
| 10 | ||||||||||||||||||||||||
625 | } | - | ||||||||||||||||||||||||
626 | - | |||||||||||||||||||||||||
627 | /*! | - | ||||||||||||||||||||||||
628 | Adds a new enumerator to this class that has the same information as | - | ||||||||||||||||||||||||
629 | \a prototype. This is used to clone the enumerators of an existing | - | ||||||||||||||||||||||||
630 | QMetaObject. Returns an object that can be used to adjust the | - | ||||||||||||||||||||||||
631 | attributes of the enumerator. | - | ||||||||||||||||||||||||
632 | - | |||||||||||||||||||||||||
633 | \sa enumerator(), enumeratorCount(), removeEnumerator() | - | ||||||||||||||||||||||||
634 | \sa indexOfEnumerator() | - | ||||||||||||||||||||||||
635 | */ | - | ||||||||||||||||||||||||
636 | QMetaEnumBuilder QMetaObjectBuilder::addEnumerator(const QMetaEnum& prototype) | - | ||||||||||||||||||||||||
637 | { | - | ||||||||||||||||||||||||
638 | QMetaEnumBuilder en = addEnumerator(prototype.name()); | - | ||||||||||||||||||||||||
639 | en.setIsFlag(prototype.isFlag()); | - | ||||||||||||||||||||||||
640 | int count = prototype.keyCount(); | - | ||||||||||||||||||||||||
641 | for (int index = 0; index < count; ++index) | - | ||||||||||||||||||||||||
642 | en.addKey(prototype.key(index), prototype.value(index)); | - | ||||||||||||||||||||||||
643 | return en; | - | ||||||||||||||||||||||||
644 | } | - | ||||||||||||||||||||||||
645 | - | |||||||||||||||||||||||||
646 | /*! | - | ||||||||||||||||||||||||
647 | Adds \a name and \a value as an item of class information to this class. | - | ||||||||||||||||||||||||
648 | Returns the index of the new item of class information. | - | ||||||||||||||||||||||||
649 | - | |||||||||||||||||||||||||
650 | \sa classInfoCount(), classInfoName(), classInfoValue(), removeClassInfo() | - | ||||||||||||||||||||||||
651 | \sa indexOfClassInfo() | - | ||||||||||||||||||||||||
652 | */ | - | ||||||||||||||||||||||||
653 | int QMetaObjectBuilder::addClassInfo(const QByteArray& name, const QByteArray& value) | - | ||||||||||||||||||||||||
654 | { | - | ||||||||||||||||||||||||
655 | int index = d->classInfoNames.size(); | - | ||||||||||||||||||||||||
656 | d->classInfoNames += name; | - | ||||||||||||||||||||||||
657 | d->classInfoValues += value; | - | ||||||||||||||||||||||||
658 | return index; | - | ||||||||||||||||||||||||
659 | } | - | ||||||||||||||||||||||||
660 | - | |||||||||||||||||||||||||
661 | /*! | - | ||||||||||||||||||||||||
662 | Adds \a meta to this class as a related meta object. Returns | - | ||||||||||||||||||||||||
663 | the index of the new related meta object entry. | - | ||||||||||||||||||||||||
664 | - | |||||||||||||||||||||||||
665 | Related meta objects are used when resolving the enumerated type | - | ||||||||||||||||||||||||
666 | associated with a property, where the enumerated type is in a | - | ||||||||||||||||||||||||
667 | different class from the property. | - | ||||||||||||||||||||||||
668 | - | |||||||||||||||||||||||||
669 | \sa relatedMetaObjectCount(), relatedMetaObject() | - | ||||||||||||||||||||||||
670 | \sa removeRelatedMetaObject() | - | ||||||||||||||||||||||||
671 | */ | - | ||||||||||||||||||||||||
672 | int QMetaObjectBuilder::addRelatedMetaObject(const QMetaObject *meta) | - | ||||||||||||||||||||||||
673 | { | - | ||||||||||||||||||||||||
674 | Q_ASSERT(meta); | - | ||||||||||||||||||||||||
675 | int index = d->relatedMetaObjects.size(); | - | ||||||||||||||||||||||||
676 | d->relatedMetaObjects.append(meta); | - | ||||||||||||||||||||||||
677 | return index; | - | ||||||||||||||||||||||||
678 | } | - | ||||||||||||||||||||||||
679 | - | |||||||||||||||||||||||||
680 | /*! | - | ||||||||||||||||||||||||
681 | Adds the contents of \a prototype to this meta object builder. | - | ||||||||||||||||||||||||
682 | This function is useful for cloning the contents of an existing QMetaObject. | - | ||||||||||||||||||||||||
683 | - | |||||||||||||||||||||||||
684 | The \a members parameter indicates which members of \a prototype | - | ||||||||||||||||||||||||
685 | should be added. The default is AllMembers. | - | ||||||||||||||||||||||||
686 | */ | - | ||||||||||||||||||||||||
687 | void QMetaObjectBuilder::addMetaObject | - | ||||||||||||||||||||||||
688 | (const QMetaObject *prototype, QMetaObjectBuilder::AddMembers members) | - | ||||||||||||||||||||||||
689 | { | - | ||||||||||||||||||||||||
690 | Q_ASSERT(prototype); | - | ||||||||||||||||||||||||
691 | int index; | - | ||||||||||||||||||||||||
692 | - | |||||||||||||||||||||||||
693 | if ((members & ClassName) != 0) | - | ||||||||||||||||||||||||
694 | d->className = prototype->className(); | - | ||||||||||||||||||||||||
695 | - | |||||||||||||||||||||||||
696 | if ((members & SuperClass) != 0) | - | ||||||||||||||||||||||||
697 | d->superClass = prototype->superClass(); | - | ||||||||||||||||||||||||
698 | - | |||||||||||||||||||||||||
699 | if ((members & (Methods | Signals | Slots)) != 0) { | - | ||||||||||||||||||||||||
700 | for (index = prototype->methodOffset(); index < prototype->methodCount(); ++index) { | - | ||||||||||||||||||||||||
701 | QMetaMethod method = prototype->method(index); | - | ||||||||||||||||||||||||
702 | if (method.methodType() != QMetaMethod::Signal) { | - | ||||||||||||||||||||||||
703 | if (method.access() == QMetaMethod::Public && (members & PublicMethods) == 0) | - | ||||||||||||||||||||||||
704 | continue; | - | ||||||||||||||||||||||||
705 | if (method.access() == QMetaMethod::Private && (members & PrivateMethods) == 0) | - | ||||||||||||||||||||||||
706 | continue; | - | ||||||||||||||||||||||||
707 | if (method.access() == QMetaMethod::Protected && (members & ProtectedMethods) == 0) | - | ||||||||||||||||||||||||
708 | continue; | - | ||||||||||||||||||||||||
709 | } | - | ||||||||||||||||||||||||
710 | if (method.methodType() == QMetaMethod::Method && (members & Methods) != 0) { | - | ||||||||||||||||||||||||
711 | addMethod(method); | - | ||||||||||||||||||||||||
712 | } else if (method.methodType() == QMetaMethod::Signal && | - | ||||||||||||||||||||||||
713 | (members & Signals) != 0) { | - | ||||||||||||||||||||||||
714 | addMethod(method); | - | ||||||||||||||||||||||||
715 | } else if (method.methodType() == QMetaMethod::Slot && | - | ||||||||||||||||||||||||
716 | (members & Slots) != 0) { | - | ||||||||||||||||||||||||
717 | addMethod(method); | - | ||||||||||||||||||||||||
718 | } | - | ||||||||||||||||||||||||
719 | } | - | ||||||||||||||||||||||||
720 | } | - | ||||||||||||||||||||||||
721 | - | |||||||||||||||||||||||||
722 | if ((members & Constructors) != 0) { | - | ||||||||||||||||||||||||
723 | for (index = 0; index < prototype->constructorCount(); ++index) | - | ||||||||||||||||||||||||
724 | addConstructor(prototype->constructor(index)); | - | ||||||||||||||||||||||||
725 | } | - | ||||||||||||||||||||||||
726 | - | |||||||||||||||||||||||||
727 | if ((members & Properties) != 0) { | - | ||||||||||||||||||||||||
728 | for (index = prototype->propertyOffset(); index < prototype->propertyCount(); ++index) | - | ||||||||||||||||||||||||
729 | addProperty(prototype->property(index)); | - | ||||||||||||||||||||||||
730 | } | - | ||||||||||||||||||||||||
731 | - | |||||||||||||||||||||||||
732 | if ((members & Enumerators) != 0) { | - | ||||||||||||||||||||||||
733 | for (index = prototype->enumeratorOffset(); index < prototype->enumeratorCount(); ++index) | - | ||||||||||||||||||||||||
734 | addEnumerator(prototype->enumerator(index)); | - | ||||||||||||||||||||||||
735 | } | - | ||||||||||||||||||||||||
736 | - | |||||||||||||||||||||||||
737 | if ((members & ClassInfos) != 0) { | - | ||||||||||||||||||||||||
738 | for (index = prototype->classInfoOffset(); index < prototype->classInfoCount(); ++index) { | - | ||||||||||||||||||||||||
739 | QMetaClassInfo ci = prototype->classInfo(index); | - | ||||||||||||||||||||||||
740 | addClassInfo(ci.name(), ci.value()); | - | ||||||||||||||||||||||||
741 | } | - | ||||||||||||||||||||||||
742 | } | - | ||||||||||||||||||||||||
743 | - | |||||||||||||||||||||||||
744 | if ((members & RelatedMetaObjects) != 0) { | - | ||||||||||||||||||||||||
745 | Q_ASSERT(priv(prototype->d.data)->revision >= 2); | - | ||||||||||||||||||||||||
746 | const QMetaObject * const *objects = prototype->d.relatedMetaObjects; | - | ||||||||||||||||||||||||
747 | if (objects) { | - | ||||||||||||||||||||||||
748 | while (*objects != 0) { | - | ||||||||||||||||||||||||
749 | addRelatedMetaObject(*objects); | - | ||||||||||||||||||||||||
750 | ++objects; | - | ||||||||||||||||||||||||
751 | } | - | ||||||||||||||||||||||||
752 | } | - | ||||||||||||||||||||||||
753 | } | - | ||||||||||||||||||||||||
754 | - | |||||||||||||||||||||||||
755 | if ((members & StaticMetacall) != 0) { | - | ||||||||||||||||||||||||
756 | Q_ASSERT(priv(prototype->d.data)->revision >= 6); | - | ||||||||||||||||||||||||
757 | if (prototype->d.static_metacall) | - | ||||||||||||||||||||||||
758 | setStaticMetacallFunction(prototype->d.static_metacall); | - | ||||||||||||||||||||||||
759 | } | - | ||||||||||||||||||||||||
760 | } | - | ||||||||||||||||||||||||
761 | - | |||||||||||||||||||||||||
762 | /*! | - | ||||||||||||||||||||||||
763 | Returns the method at \a index in this class. | - | ||||||||||||||||||||||||
764 | - | |||||||||||||||||||||||||
765 | \sa methodCount(), addMethod(), removeMethod(), indexOfMethod() | - | ||||||||||||||||||||||||
766 | */ | - | ||||||||||||||||||||||||
767 | QMetaMethodBuilder QMetaObjectBuilder::method(int index) const | - | ||||||||||||||||||||||||
768 | { | - | ||||||||||||||||||||||||
769 | if (index >= 0 &&uint(index) < d->methods.size())
| 1-3 | ||||||||||||||||||||||||
770 | return QMetaMethodBuilder(this, index); executed 3 times by 1 test: return QMetaMethodBuilder(this, index); Executed by:
| 3 | ||||||||||||||||||||||||
771 | else | - | ||||||||||||||||||||||||
772 | return QMetaMethodBuilder(); executed 1 time by 1 test: return QMetaMethodBuilder(); Executed by:
| 1 | ||||||||||||||||||||||||
773 | } | - | ||||||||||||||||||||||||
774 | - | |||||||||||||||||||||||||
775 | /*! | - | ||||||||||||||||||||||||
776 | Returns the constructor at \a index in this class. | - | ||||||||||||||||||||||||
777 | - | |||||||||||||||||||||||||
778 | \sa methodCount(), addMethod(), removeMethod(), indexOfConstructor() | - | ||||||||||||||||||||||||
779 | */ | - | ||||||||||||||||||||||||
780 | QMetaMethodBuilder QMetaObjectBuilder::constructor(int index) const | - | ||||||||||||||||||||||||
781 | { | - | ||||||||||||||||||||||||
782 | if (index >= 0 &&uint(index) < d->constructors.size())
| 1-2 | ||||||||||||||||||||||||
783 | return QMetaMethodBuilder(this, -(index + 1)); executed 2 times by 1 test: return QMetaMethodBuilder(this, -(index + 1)); Executed by:
| 2 | ||||||||||||||||||||||||
784 | else | - | ||||||||||||||||||||||||
785 | return QMetaMethodBuilder(); executed 1 time by 1 test: return QMetaMethodBuilder(); Executed by:
| 1 | ||||||||||||||||||||||||
786 | } | - | ||||||||||||||||||||||||
787 | - | |||||||||||||||||||||||||
788 | /*! | - | ||||||||||||||||||||||||
789 | Returns the property at \a index in this class. | - | ||||||||||||||||||||||||
790 | - | |||||||||||||||||||||||||
791 | \sa methodCount(), addMethod(), removeMethod(), indexOfProperty() | - | ||||||||||||||||||||||||
792 | */ | - | ||||||||||||||||||||||||
793 | QMetaPropertyBuilder QMetaObjectBuilder::property(int index) const | - | ||||||||||||||||||||||||
794 | { | - | ||||||||||||||||||||||||
795 | if (index >= 0 &&uint(index) < d->properties.size())
| 1-6 | ||||||||||||||||||||||||
796 | return QMetaPropertyBuilder(this, index); executed 6 times by 1 test: return QMetaPropertyBuilder(this, index); Executed by:
| 6 | ||||||||||||||||||||||||
797 | else | - | ||||||||||||||||||||||||
798 | return QMetaPropertyBuilder(); executed 1 time by 1 test: return QMetaPropertyBuilder(); Executed by:
| 1 | ||||||||||||||||||||||||
799 | } | - | ||||||||||||||||||||||||
800 | - | |||||||||||||||||||||||||
801 | /*! | - | ||||||||||||||||||||||||
802 | Returns the enumerator at \a index in this class. | - | ||||||||||||||||||||||||
803 | - | |||||||||||||||||||||||||
804 | \sa enumeratorCount(), addEnumerator(), removeEnumerator() | - | ||||||||||||||||||||||||
805 | \sa indexOfEnumerator() | - | ||||||||||||||||||||||||
806 | */ | - | ||||||||||||||||||||||||
807 | QMetaEnumBuilder QMetaObjectBuilder::enumerator(int index) const | - | ||||||||||||||||||||||||
808 | { | - | ||||||||||||||||||||||||
809 | if (index >= 0 &&uint(index) < d->enumerators.size())
| 1-2 | ||||||||||||||||||||||||
810 | return QMetaEnumBuilder(this, index); executed 2 times by 1 test: return QMetaEnumBuilder(this, index); Executed by:
| 2 | ||||||||||||||||||||||||
811 | else | - | ||||||||||||||||||||||||
812 | return QMetaEnumBuilder(); executed 1 time by 1 test: return QMetaEnumBuilder(); Executed by:
| 1 | ||||||||||||||||||||||||
813 | } | - | ||||||||||||||||||||||||
814 | - | |||||||||||||||||||||||||
815 | /*! | - | ||||||||||||||||||||||||
816 | Returns the related meta object at \a index in this class. | - | ||||||||||||||||||||||||
817 | - | |||||||||||||||||||||||||
818 | Related meta objects are used when resolving the enumerated type | - | ||||||||||||||||||||||||
819 | associated with a property, where the enumerated type is in a | - | ||||||||||||||||||||||||
820 | different class from the property. | - | ||||||||||||||||||||||||
821 | - | |||||||||||||||||||||||||
822 | \sa relatedMetaObjectCount(), addRelatedMetaObject() | - | ||||||||||||||||||||||||
823 | \sa removeRelatedMetaObject() | - | ||||||||||||||||||||||||
824 | */ | - | ||||||||||||||||||||||||
825 | const QMetaObject *QMetaObjectBuilder::relatedMetaObject(int index) const | - | ||||||||||||||||||||||||
826 | { | - | ||||||||||||||||||||||||
827 | if (index >= 0 && index < d->relatedMetaObjects.size()) | - | ||||||||||||||||||||||||
828 | return d->relatedMetaObjects[index]; | - | ||||||||||||||||||||||||
829 | else | - | ||||||||||||||||||||||||
830 | return 0; | - | ||||||||||||||||||||||||
831 | } | - | ||||||||||||||||||||||||
832 | - | |||||||||||||||||||||||||
833 | /*! | - | ||||||||||||||||||||||||
834 | Returns the name of the item of class information at \a index | - | ||||||||||||||||||||||||
835 | in this class. | - | ||||||||||||||||||||||||
836 | - | |||||||||||||||||||||||||
837 | \sa classInfoCount(), addClassInfo(), classInfoValue(), removeClassInfo() | - | ||||||||||||||||||||||||
838 | \sa indexOfClassInfo() | - | ||||||||||||||||||||||||
839 | */ | - | ||||||||||||||||||||||||
840 | QByteArray QMetaObjectBuilder::classInfoName(int index) const | - | ||||||||||||||||||||||||
841 | { | - | ||||||||||||||||||||||||
842 | if (index >= 0 && index < d->classInfoNames.size()) | - | ||||||||||||||||||||||||
843 | return d->classInfoNames[index]; | - | ||||||||||||||||||||||||
844 | else | - | ||||||||||||||||||||||||
845 | return QByteArray(); | - | ||||||||||||||||||||||||
846 | } | - | ||||||||||||||||||||||||
847 | - | |||||||||||||||||||||||||
848 | /*! | - | ||||||||||||||||||||||||
849 | Returns the value of the item of class information at \a index | - | ||||||||||||||||||||||||
850 | in this class. | - | ||||||||||||||||||||||||
851 | - | |||||||||||||||||||||||||
852 | \sa classInfoCount(), addClassInfo(), classInfoName(), removeClassInfo() | - | ||||||||||||||||||||||||
853 | \sa indexOfClassInfo() | - | ||||||||||||||||||||||||
854 | */ | - | ||||||||||||||||||||||||
855 | QByteArray QMetaObjectBuilder::classInfoValue(int index) const | - | ||||||||||||||||||||||||
856 | { | - | ||||||||||||||||||||||||
857 | if (index >= 0 && index < d->classInfoValues.size()) | - | ||||||||||||||||||||||||
858 | return d->classInfoValues[index]; | - | ||||||||||||||||||||||||
859 | else | - | ||||||||||||||||||||||||
860 | return QByteArray(); | - | ||||||||||||||||||||||||
861 | } | - | ||||||||||||||||||||||||
862 | - | |||||||||||||||||||||||||
863 | /*! | - | ||||||||||||||||||||||||
864 | Removes the method at \a index from this class. The indices of | - | ||||||||||||||||||||||||
865 | all following methods will be adjusted downwards by 1. If the | - | ||||||||||||||||||||||||
866 | method is registered as a notify signal on a property, then the | - | ||||||||||||||||||||||||
867 | notify signal will be removed from the property. | - | ||||||||||||||||||||||||
868 | - | |||||||||||||||||||||||||
869 | \sa methodCount(), addMethod(), method(), indexOfMethod() | - | ||||||||||||||||||||||||
870 | */ | - | ||||||||||||||||||||||||
871 | void QMetaObjectBuilder::removeMethod(int index) | - | ||||||||||||||||||||||||
872 | { | - | ||||||||||||||||||||||||
873 | if (index >= 0 &&uint(index) < d->methods.size()) {
| 0-3 | ||||||||||||||||||||||||
874 | d->methods.removeAterase(d->methods.begin() + index); | - | ||||||||||||||||||||||||
875 | for (int prop = 0; prop <auto &property : d->properties.size(); ++prop) { | - | ||||||||||||||||||||||||
876 | // Adjust the indices of property notify signal references. | - | ||||||||||||||||||||||||
877 | if (d->properties[prop].property.notifySignal == index) {
| 1 | ||||||||||||||||||||||||
878 | d->properties[prop].property.notifySignal = -1; | - | ||||||||||||||||||||||||
879 | d->properties[prop].property.setFlag(Notify, false); | - | ||||||||||||||||||||||||
880 | } else if (d->properties[prop].property.notifySignal > index) executed 1 time by 1 test: end of block Executed by:
| 0-1 | ||||||||||||||||||||||||
881 | (d->properties[prop].property.notifySignal)--;--; executed 1 time by 1 test: property.notifySignal--; Executed by:
| 1 | ||||||||||||||||||||||||
882 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
883 | } executed 3 times by 1 test: end of block Executed by:
| 3 | ||||||||||||||||||||||||
884 | } executed 3 times by 1 test: end of block Executed by:
| 3 | ||||||||||||||||||||||||
885 | - | |||||||||||||||||||||||||
886 | /*! | - | ||||||||||||||||||||||||
887 | Removes the constructor at \a index from this class. The indices of | - | ||||||||||||||||||||||||
888 | all following constructors will be adjusted downwards by 1. | - | ||||||||||||||||||||||||
889 | - | |||||||||||||||||||||||||
890 | \sa constructorCount(), addConstructor(), constructor() | - | ||||||||||||||||||||||||
891 | \sa indexOfConstructor() | - | ||||||||||||||||||||||||
892 | */ | - | ||||||||||||||||||||||||
893 | void QMetaObjectBuilder::removeConstructor(int index) | - | ||||||||||||||||||||||||
894 | { | - | ||||||||||||||||||||||||
895 | if (index >= 0 &&uint(index) < d->constructors.size())
| 0-1 | ||||||||||||||||||||||||
896 | d->constructors.removeAterase(d->constructors.begin() + index); executed 1 time by 1 test: d->constructors.erase(d->constructors.begin() + index); Executed by:
| 1 | ||||||||||||||||||||||||
897 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||||||||
898 | - | |||||||||||||||||||||||||
899 | /*! | - | ||||||||||||||||||||||||
900 | Removes the property at \a index from this class. The indices of | - | ||||||||||||||||||||||||
901 | all following properties will be adjusted downwards by 1. | - | ||||||||||||||||||||||||
902 | - | |||||||||||||||||||||||||
903 | \sa propertyCount(), addProperty(), property(), indexOfProperty() | - | ||||||||||||||||||||||||
904 | */ | - | ||||||||||||||||||||||||
905 | void QMetaObjectBuilder::removeProperty(int index) | - | ||||||||||||||||||||||||
906 | { | - | ||||||||||||||||||||||||
907 | if (index >= 0 &&uint(index) < d->properties.size())
| 0-1 | ||||||||||||||||||||||||
908 | d->properties.removeAterase(d->properties.begin() + index); executed 1 time by 1 test: d->properties.erase(d->properties.begin() + index); Executed by:
| 1 | ||||||||||||||||||||||||
909 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||||||||
910 | - | |||||||||||||||||||||||||
911 | /*! | - | ||||||||||||||||||||||||
912 | Removes the enumerator at \a index from this class. The indices of | - | ||||||||||||||||||||||||
913 | all following enumerators will be adjusted downwards by 1. | - | ||||||||||||||||||||||||
914 | - | |||||||||||||||||||||||||
915 | \sa enumertorCount(), addEnumerator(), enumerator() | - | ||||||||||||||||||||||||
916 | \sa indexOfEnumerator() | - | ||||||||||||||||||||||||
917 | */ | - | ||||||||||||||||||||||||
918 | void QMetaObjectBuilder::removeEnumerator(int index) | - | ||||||||||||||||||||||||
919 | { | - | ||||||||||||||||||||||||
920 | if (index >= 0 &&uint(index) < d->enumerators.size())
| 0-1 | ||||||||||||||||||||||||
921 | d->enumerators.removeAterase(d->enumerators.begin() + index); executed 1 time by 1 test: d->enumerators.erase(d->enumerators.begin() + index); Executed by:
| 1 | ||||||||||||||||||||||||
922 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||||||||
923 | - | |||||||||||||||||||||||||
924 | /*! | - | ||||||||||||||||||||||||
925 | Removes the item of class information at \a index from this class. | - | ||||||||||||||||||||||||
926 | The indices of all following items will be adjusted downwards by 1. | - | ||||||||||||||||||||||||
927 | - | |||||||||||||||||||||||||
928 | \sa classInfoCount(), addClassInfo(), classInfoName(), classInfoValue() | - | ||||||||||||||||||||||||
929 | \sa indexOfClassInfo() | - | ||||||||||||||||||||||||
930 | */ | - | ||||||||||||||||||||||||
931 | void QMetaObjectBuilder::removeClassInfo(int index) | - | ||||||||||||||||||||||||
932 | { | - | ||||||||||||||||||||||||
933 | if (index >= 0 && index < d->classInfoNames.size()) { | - | ||||||||||||||||||||||||
934 | d->classInfoNames.removeAt(index); | - | ||||||||||||||||||||||||
935 | d->classInfoValues.removeAt(index); | - | ||||||||||||||||||||||||
936 | } | - | ||||||||||||||||||||||||
937 | } | - | ||||||||||||||||||||||||
938 | - | |||||||||||||||||||||||||
939 | /*! | - | ||||||||||||||||||||||||
940 | Removes the related meta object at \a index from this class. | - | ||||||||||||||||||||||||
941 | The indices of all following related meta objects will be adjusted | - | ||||||||||||||||||||||||
942 | downwards by 1. | - | ||||||||||||||||||||||||
943 | - | |||||||||||||||||||||||||
944 | Related meta objects are used when resolving the enumerated type | - | ||||||||||||||||||||||||
945 | associated with a property, where the enumerated type is in a | - | ||||||||||||||||||||||||
946 | different class from the property. | - | ||||||||||||||||||||||||
947 | - | |||||||||||||||||||||||||
948 | \sa relatedMetaObjectCount(), addRelatedMetaObject() | - | ||||||||||||||||||||||||
949 | \sa relatedMetaObject() | - | ||||||||||||||||||||||||
950 | */ | - | ||||||||||||||||||||||||
951 | void QMetaObjectBuilder::removeRelatedMetaObject(int index) | - | ||||||||||||||||||||||||
952 | { | - | ||||||||||||||||||||||||
953 | if (index >= 0 && index < d->relatedMetaObjects.size()) | - | ||||||||||||||||||||||||
954 | d->relatedMetaObjects.removeAt(index); | - | ||||||||||||||||||||||||
955 | } | - | ||||||||||||||||||||||||
956 | - | |||||||||||||||||||||||||
957 | /*! | - | ||||||||||||||||||||||||
958 | Finds a method with the specified \a signature and returns its index; | - | ||||||||||||||||||||||||
959 | otherwise returns -1. The \a signature will be normalized by this method. | - | ||||||||||||||||||||||||
960 | - | |||||||||||||||||||||||||
961 | \sa method(), methodCount(), addMethod(), removeMethod() | - | ||||||||||||||||||||||||
962 | */ | - | ||||||||||||||||||||||||
963 | int QMetaObjectBuilder::indexOfMethod(const QByteArray& signature) | - | ||||||||||||||||||||||||
964 | { | - | ||||||||||||||||||||||||
965 | QByteArray sig = QMetaObject::normalizedSignature(signature); | - | ||||||||||||||||||||||||
966 | for (int index = 0; index <const auto &method : d->methods.size(); ++index) { | - | ||||||||||||||||||||||||
967 | if (sig == d->methods[index].method.signature)
| 7-13 | ||||||||||||||||||||||||
968 | return index;int(&method - &d->methods.front()); executed 7 times by 1 test: return int(&method - &d->methods.front()); Executed by:
| 7 | ||||||||||||||||||||||||
969 | } executed 13 times by 1 test: end of block Executed by:
| 13 | ||||||||||||||||||||||||
970 | return -1; executed 4 times by 1 test: return -1; Executed by:
| 4 | ||||||||||||||||||||||||
971 | } | - | ||||||||||||||||||||||||
972 | - | |||||||||||||||||||||||||
973 | /*! | - | ||||||||||||||||||||||||
974 | Finds a signal with the specified \a signature and returns its index; | - | ||||||||||||||||||||||||
975 | otherwise returns -1. The \a signature will be normalized by this method. | - | ||||||||||||||||||||||||
976 | - | |||||||||||||||||||||||||
977 | \sa indexOfMethod(), indexOfSlot() | - | ||||||||||||||||||||||||
978 | */ | - | ||||||||||||||||||||||||
979 | int QMetaObjectBuilder::indexOfSignal(const QByteArray& signature) | - | ||||||||||||||||||||||||
980 | { | - | ||||||||||||||||||||||||
981 | QByteArray sig = QMetaObject::normalizedSignature(signature); | - | ||||||||||||||||||||||||
982 | for (int index = 0; index <const auto &method : d->methods.size(); ++index) { | - | ||||||||||||||||||||||||
983 | if (sig == d->methods[index].signature &&
| 0-5 | ||||||||||||||||||||||||
d->methods[index].
| ||||||||||||||||||||||||||
984 | return index;int(&method - &d->methods.front()); executed 2 times by 1 test: return int(&method - &d->methods.front()); Executed by:
| 2 | ||||||||||||||||||||||||
985 | } executed 3 times by 1 test: end of block Executed by:
| 3 | ||||||||||||||||||||||||
986 | return -1; executed 1 time by 1 test: return -1; Executed by:
| 1 | ||||||||||||||||||||||||
987 | } | - | ||||||||||||||||||||||||
988 | - | |||||||||||||||||||||||||
989 | /*! | - | ||||||||||||||||||||||||
990 | Finds a slot with the specified \a signature and returns its index; | - | ||||||||||||||||||||||||
991 | otherwise returns -1. The \a signature will be normalized by this method. | - | ||||||||||||||||||||||||
992 | - | |||||||||||||||||||||||||
993 | \sa indexOfMethod(), indexOfSignal() | - | ||||||||||||||||||||||||
994 | */ | - | ||||||||||||||||||||||||
995 | int QMetaObjectBuilder::indexOfSlot(const QByteArray& signature) | - | ||||||||||||||||||||||||
996 | { | - | ||||||||||||||||||||||||
997 | QByteArray sig = QMetaObject::normalizedSignature(signature); | - | ||||||||||||||||||||||||
998 | for (int index = 0; index <const auto &method : d->methods.size(); ++index) { | - | ||||||||||||||||||||||||
999 | if (sig == d->methods[index].signature &&
| 0-5 | ||||||||||||||||||||||||
d->methods[index].
| ||||||||||||||||||||||||||
1000 | return index;int(&method - &d->methods.front()); executed 2 times by 1 test: return int(&method - &d->methods.front()); Executed by:
| 2 | ||||||||||||||||||||||||
1001 | } executed 3 times by 1 test: end of block Executed by:
| 3 | ||||||||||||||||||||||||
1002 | return -1; executed 1 time by 1 test: return -1; Executed by:
| 1 | ||||||||||||||||||||||||
1003 | } | - | ||||||||||||||||||||||||
1004 | - | |||||||||||||||||||||||||
1005 | /*! | - | ||||||||||||||||||||||||
1006 | Finds a constructor with the specified \a signature and returns its index; | - | ||||||||||||||||||||||||
1007 | otherwise returns -1. The \a signature will be normalized by this method. | - | ||||||||||||||||||||||||
1008 | - | |||||||||||||||||||||||||
1009 | \sa constructor(), constructorCount(), addConstructor(), removeConstructor() | - | ||||||||||||||||||||||||
1010 | */ | - | ||||||||||||||||||||||||
1011 | int QMetaObjectBuilder::indexOfConstructor(const QByteArray& signature) | - | ||||||||||||||||||||||||
1012 | { | - | ||||||||||||||||||||||||
1013 | QByteArray sig = QMetaObject::normalizedSignature(signature); | - | ||||||||||||||||||||||||
1014 | for (int index = 0; index <const auto &constructor : d->constructors.size(); ++index) { | - | ||||||||||||||||||||||||
1015 | if (sig == d->constructors[index].constructor.signature)
| 3-5 | ||||||||||||||||||||||||
1016 | return index;int(&constructor - &d->constructors.front()); executed 3 times by 1 test: return int(&constructor - &d->constructors.front()); Executed by:
| 3 | ||||||||||||||||||||||||
1017 | } executed 5 times by 1 test: end of block Executed by:
| 5 | ||||||||||||||||||||||||
1018 | return -1; executed 3 times by 1 test: return -1; Executed by:
| 3 | ||||||||||||||||||||||||
1019 | } | - | ||||||||||||||||||||||||
1020 | - | |||||||||||||||||||||||||
1021 | /*! | - | ||||||||||||||||||||||||
1022 | Finds a property with the specified \a name and returns its index; | - | ||||||||||||||||||||||||
1023 | otherwise returns -1. | - | ||||||||||||||||||||||||
1024 | - | |||||||||||||||||||||||||
1025 | \sa property(), propertyCount(), addProperty(), removeProperty() | - | ||||||||||||||||||||||||
1026 | */ | - | ||||||||||||||||||||||||
1027 | int QMetaObjectBuilder::indexOfProperty(const QByteArray& name) | - | ||||||||||||||||||||||||
1028 | { | - | ||||||||||||||||||||||||
1029 | for (int index = 0; index <const auto &property : d->properties.size(); ++index) { | - | ||||||||||||||||||||||||
1030 | if (name == d->properties[index].property.name)
| 3-5 | ||||||||||||||||||||||||
1031 | return index;int(&property - &d->properties.front()); executed 3 times by 1 test: return int(&property - &d->properties.front()); Executed by:
| 3 | ||||||||||||||||||||||||
1032 | } executed 5 times by 1 test: end of block Executed by:
| 5 | ||||||||||||||||||||||||
1033 | return -1; executed 3 times by 1 test: return -1; Executed by:
| 3 | ||||||||||||||||||||||||
1034 | } | - | ||||||||||||||||||||||||
1035 | - | |||||||||||||||||||||||||
1036 | /*! | - | ||||||||||||||||||||||||
1037 | Finds an enumerator with the specified \a name and returns its index; | - | ||||||||||||||||||||||||
1038 | otherwise returns -1. | - | ||||||||||||||||||||||||
1039 | - | |||||||||||||||||||||||||
1040 | \sa enumertor(), enumeratorCount(), addEnumerator(), removeEnumerator() | - | ||||||||||||||||||||||||
1041 | */ | - | ||||||||||||||||||||||||
1042 | int QMetaObjectBuilder::indexOfEnumerator(const QByteArray& name) | - | ||||||||||||||||||||||||
1043 | { | - | ||||||||||||||||||||||||
1044 | for (int index = 0; index <const auto &enumerator : d->enumerators.size(); ++index) { | - | ||||||||||||||||||||||||
1045 | if (name == d->enumerators[index].enumerator.name)
| 3-5 | ||||||||||||||||||||||||
1046 | return index;int(&enumerator - &d->enumerators.front()); executed 3 times by 1 test: return int(&enumerator - &d->enumerators.front()); Executed by:
| 3 | ||||||||||||||||||||||||
1047 | } executed 5 times by 1 test: end of block Executed by:
| 5 | ||||||||||||||||||||||||
1048 | return -1; executed 3 times by 1 test: return -1; Executed by:
| 3 | ||||||||||||||||||||||||
1049 | } | - | ||||||||||||||||||||||||
1050 | - | |||||||||||||||||||||||||
1051 | /*! | - | ||||||||||||||||||||||||
1052 | Finds an item of class information with the specified \a name and | - | ||||||||||||||||||||||||
1053 | returns its index; otherwise returns -1. | - | ||||||||||||||||||||||||
1054 | - | |||||||||||||||||||||||||
1055 | \sa classInfoName(), classInfoValue(), classInfoCount(), addClassInfo() | - | ||||||||||||||||||||||||
1056 | \sa removeClassInfo() | - | ||||||||||||||||||||||||
1057 | */ | - | ||||||||||||||||||||||||
1058 | int QMetaObjectBuilder::indexOfClassInfo(const QByteArray& name) | - | ||||||||||||||||||||||||
1059 | { | - | ||||||||||||||||||||||||
1060 | for (int index = 0; index < d->classInfoNames.size(); ++index) { | - | ||||||||||||||||||||||||
1061 | if (name == d->classInfoNames[index]) | - | ||||||||||||||||||||||||
1062 | return index; | - | ||||||||||||||||||||||||
1063 | } | - | ||||||||||||||||||||||||
1064 | return -1; | - | ||||||||||||||||||||||||
1065 | } | - | ||||||||||||||||||||||||
1066 | - | |||||||||||||||||||||||||
1067 | // Align on a specific type boundary. | - | ||||||||||||||||||||||||
1068 | #define ALIGN(size,type) \ | - | ||||||||||||||||||||||||
1069 | (size) = ((size) + sizeof(type) - 1) & ~(sizeof(type) - 1) | - | ||||||||||||||||||||||||
1070 | - | |||||||||||||||||||||||||
1071 | /*! | - | ||||||||||||||||||||||||
1072 | \class QMetaStringTable | - | ||||||||||||||||||||||||
1073 | \inmodule QtCore | - | ||||||||||||||||||||||||
1074 | \internal | - | ||||||||||||||||||||||||
1075 | \brief The QMetaStringTable class can generate a meta-object string table at runtime. | - | ||||||||||||||||||||||||
1076 | */ | - | ||||||||||||||||||||||||
1077 | - | |||||||||||||||||||||||||
1078 | QMetaStringTable::QMetaStringTable(const QByteArray &className) | - | ||||||||||||||||||||||||
1079 | : m_index(0) | - | ||||||||||||||||||||||||
1080 | , m_className(className) | - | ||||||||||||||||||||||||
1081 | { | - | ||||||||||||||||||||||||
1082 | const int index = enter(m_className); | - | ||||||||||||||||||||||||
1083 | Q_ASSERT(index == 0); | - | ||||||||||||||||||||||||
1084 | Q_UNUSED(index); | - | ||||||||||||||||||||||||
1085 | } | - | ||||||||||||||||||||||||
1086 | - | |||||||||||||||||||||||||
1087 | // Enters the given value into the string table (if it hasn't already been | - | ||||||||||||||||||||||||
1088 | // entered). Returns the index of the string. | - | ||||||||||||||||||||||||
1089 | int QMetaStringTable::enter(const QByteArray &value) | - | ||||||||||||||||||||||||
1090 | { | - | ||||||||||||||||||||||||
1091 | Entries::iterator it = m_entries.find(value); | - | ||||||||||||||||||||||||
1092 | if (it != m_entries.end()) | - | ||||||||||||||||||||||||
1093 | return it.value(); | - | ||||||||||||||||||||||||
1094 | int pos = m_index; | - | ||||||||||||||||||||||||
1095 | m_entries.insert(value, pos); | - | ||||||||||||||||||||||||
1096 | ++m_index; | - | ||||||||||||||||||||||||
1097 | return pos; | - | ||||||||||||||||||||||||
1098 | } | - | ||||||||||||||||||||||||
1099 | - | |||||||||||||||||||||||||
1100 | int QMetaStringTable::preferredAlignment() | - | ||||||||||||||||||||||||
1101 | { | - | ||||||||||||||||||||||||
1102 | return Q_ALIGNOF(QByteArrayData); | - | ||||||||||||||||||||||||
1103 | } | - | ||||||||||||||||||||||||
1104 | - | |||||||||||||||||||||||||
1105 | // Returns the size (in bytes) required for serializing this string table. | - | ||||||||||||||||||||||||
1106 | int QMetaStringTable::blobSize() const | - | ||||||||||||||||||||||||
1107 | { | - | ||||||||||||||||||||||||
1108 | int size = m_entries.size() * sizeof(QByteArrayData); | - | ||||||||||||||||||||||||
1109 | Entries::const_iterator it; | - | ||||||||||||||||||||||||
1110 | for (it = m_entries.constBegin(); it != m_entries.constEnd(); ++it) | - | ||||||||||||||||||||||||
1111 | size += it.key().size() + 1; | - | ||||||||||||||||||||||||
1112 | return size; | - | ||||||||||||||||||||||||
1113 | } | - | ||||||||||||||||||||||||
1114 | - | |||||||||||||||||||||||||
1115 | static void writeString(char *out, int i, const QByteArray &str, | - | ||||||||||||||||||||||||
1116 | const int offsetOfStringdataMember, int &stringdataOffset) | - | ||||||||||||||||||||||||
1117 | { | - | ||||||||||||||||||||||||
1118 | int size = str.size(); | - | ||||||||||||||||||||||||
1119 | qptrdiff offset = offsetOfStringdataMember + stringdataOffset | - | ||||||||||||||||||||||||
1120 | - i * sizeof(QByteArrayData); | - | ||||||||||||||||||||||||
1121 | const QByteArrayData data = | - | ||||||||||||||||||||||||
1122 | Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(size, offset); | - | ||||||||||||||||||||||||
1123 | - | |||||||||||||||||||||||||
1124 | memcpy(out + i * sizeof(QByteArrayData), &data, sizeof(QByteArrayData)); | - | ||||||||||||||||||||||||
1125 | - | |||||||||||||||||||||||||
1126 | memcpy(out + offsetOfStringdataMember + stringdataOffset, str.constData(), size); | - | ||||||||||||||||||||||||
1127 | out[offsetOfStringdataMember + stringdataOffset + size] = '\0'; | - | ||||||||||||||||||||||||
1128 | - | |||||||||||||||||||||||||
1129 | stringdataOffset += size + 1; | - | ||||||||||||||||||||||||
1130 | } | - | ||||||||||||||||||||||||
1131 | - | |||||||||||||||||||||||||
1132 | // Writes strings to string data struct. | - | ||||||||||||||||||||||||
1133 | // The struct consists of an array of QByteArrayData, followed by a char array | - | ||||||||||||||||||||||||
1134 | // containing the actual strings. This format must match the one produced by | - | ||||||||||||||||||||||||
1135 | // moc (see generator.cpp). | - | ||||||||||||||||||||||||
1136 | void QMetaStringTable::writeBlob(char *out) const | - | ||||||||||||||||||||||||
1137 | { | - | ||||||||||||||||||||||||
1138 | Q_ASSERT(!(reinterpret_cast<quintptr>(out) & (preferredAlignment()-1))); | - | ||||||||||||||||||||||||
1139 | - | |||||||||||||||||||||||||
1140 | int offsetOfStringdataMember = m_entries.size() * sizeof(QByteArrayData); | - | ||||||||||||||||||||||||
1141 | int stringdataOffset = 0; | - | ||||||||||||||||||||||||
1142 | - | |||||||||||||||||||||||||
1143 | // qt_metacast expects the first string in the string table to be the class name. | - | ||||||||||||||||||||||||
1144 | writeString(out, /*index*/0, m_className, offsetOfStringdataMember, stringdataOffset); | - | ||||||||||||||||||||||||
1145 | - | |||||||||||||||||||||||||
1146 | for (Entries::ConstIterator it = m_entries.constBegin(), end = m_entries.constEnd(); | - | ||||||||||||||||||||||||
1147 | it != end; ++it) { | - | ||||||||||||||||||||||||
1148 | const int i = it.value(); | - | ||||||||||||||||||||||||
1149 | if (i == 0) | - | ||||||||||||||||||||||||
1150 | continue; | - | ||||||||||||||||||||||||
1151 | const QByteArray &str = it.key(); | - | ||||||||||||||||||||||||
1152 | - | |||||||||||||||||||||||||
1153 | writeString(out, i, str, offsetOfStringdataMember, stringdataOffset); | - | ||||||||||||||||||||||||
1154 | } | - | ||||||||||||||||||||||||
1155 | } | - | ||||||||||||||||||||||||
1156 | - | |||||||||||||||||||||||||
1157 | // Returns the sum of all parameters (including return type) for the given | - | ||||||||||||||||||||||||
1158 | // \a methods. This is needed for calculating the size of the methods' | - | ||||||||||||||||||||||||
1159 | // parameter type/name meta-data. | - | ||||||||||||||||||||||||
1160 | static int aggregateParameterCount(const QVectorstd::vector<QMetaMethodBuilderPrivate> &methods) | - | ||||||||||||||||||||||||
1161 | { | - | ||||||||||||||||||||||||
1162 | int sum = 0; | - | ||||||||||||||||||||||||
1163 | for (int i = 0; i <const auto &method : methods.size(); ++i) | - | ||||||||||||||||||||||||
1164 | sum += methodsmethod.at(i).parameterCount() + 1; // +1 for return type executed 258 times by 1 test: sum += method.parameterCount() + 1; Executed by:
| 258 | ||||||||||||||||||||||||
1165 | return sum; executed 72 times by 1 test: return sum; Executed by:
| 72 | ||||||||||||||||||||||||
1166 | } | - | ||||||||||||||||||||||||
1167 | - | |||||||||||||||||||||||||
1168 | // Build a QMetaObject in "buf" based on the information in "d". | - | ||||||||||||||||||||||||
1169 | // If "buf" is null, then return the number of bytes needed to | - | ||||||||||||||||||||||||
1170 | // build the QMetaObject. Returns -1 if the metaobject if | - | ||||||||||||||||||||||||
1171 | // relocatable is set, but the metaobject contains relatedMetaObjects. | - | ||||||||||||||||||||||||
1172 | static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf, | - | ||||||||||||||||||||||||
1173 | int expectedSize, bool relocatable) | - | ||||||||||||||||||||||||
1174 | { | - | ||||||||||||||||||||||||
1175 | Q_UNUSED(expectedSize); // Avoid warning in release mode | - | ||||||||||||||||||||||||
1176 | int size = 0; | - | ||||||||||||||||||||||||
1177 | int dataIndex; | - | ||||||||||||||||||||||||
1178 | int paramsIndex; | - | ||||||||||||||||||||||||
1179 | int enumIndex; | - | ||||||||||||||||||||||||
1180 | int index; | - | ||||||||||||||||||||||||
1181 | bool hasRevisionedMethods = d->hasRevisionedMethods(); | - | ||||||||||||||||||||||||
1182 | bool hasRevisionedProperties = d->hasRevisionedProperties(); | - | ||||||||||||||||||||||||
1183 | bool hasNotifySignals = false; | - | ||||||||||||||||||||||||
1184 | - | |||||||||||||||||||||||||
1185 | if (relocatable &&
| 2-34 | ||||||||||||||||||||||||
1186 | (d->relatedMetaObjects.size() > 0 || d->staticMetacallFunction))
| 0-2 | ||||||||||||||||||||||||
1187 | return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||
1188 | - | |||||||||||||||||||||||||
1189 | // Create the main QMetaObject structure at the start of the buffer. | - | ||||||||||||||||||||||||
1190 | QMetaObject *meta = reinterpret_cast<QMetaObject *>(buf); | - | ||||||||||||||||||||||||
1191 | size += sizeof(QMetaObject); | - | ||||||||||||||||||||||||
1192 | ALIGN(size, int); | - | ||||||||||||||||||||||||
1193 | if (buf) {
| 18 | ||||||||||||||||||||||||
1194 | if (!relocatable) meta->d.superdata = d->superClass; executed 17 times by 1 test: meta->d.superdata = d->superClass; Executed by:
| 1-17 | ||||||||||||||||||||||||
1195 | meta->d.relatedMetaObjects = 0; | - | ||||||||||||||||||||||||
1196 | meta->d.extradata = 0; | - | ||||||||||||||||||||||||
1197 | meta->d.static_metacall = d->staticMetacallFunction; | - | ||||||||||||||||||||||||
1198 | } executed 18 times by 1 test: end of block Executed by:
| 18 | ||||||||||||||||||||||||
1199 | - | |||||||||||||||||||||||||
1200 | // Populate the QMetaObjectPrivate structure. | - | ||||||||||||||||||||||||
1201 | QMetaObjectPrivate *pmeta | - | ||||||||||||||||||||||||
1202 | = reinterpret_cast<QMetaObjectPrivate *>(buf + size); | - | ||||||||||||||||||||||||
1203 | int pmetaSize = size; | - | ||||||||||||||||||||||||
1204 | dataIndex = MetaObjectPrivateFieldCount; | - | ||||||||||||||||||||||||
1205 | for (index = 0; index <const auto &property : d->properties.size(); ++index) { | - | ||||||||||||||||||||||||
1206 | if (d->properties[index].property.notifySignal != -1) {
| 2-32 | ||||||||||||||||||||||||
1207 | hasNotifySignals = true; | - | ||||||||||||||||||||||||
1208 | break; executed 32 times by 1 test: break; Executed by:
| 32 | ||||||||||||||||||||||||
1209 | } | - | ||||||||||||||||||||||||
1210 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
1211 | int methodParametersDataSize = | - | ||||||||||||||||||||||||
1212 | ((aggregateParameterCount(d->methods) | - | ||||||||||||||||||||||||
1213 | + aggregateParameterCount(d->constructors)) * 2) // types and parameter names | - | ||||||||||||||||||||||||
1214 | - int(d->methods.size()()) // return "parameters" don't have names | - | ||||||||||||||||||||||||
1215 | - int(d->constructors.size();()); // "this" parameters don't have names | - | ||||||||||||||||||||||||
1216 | if (buf) {
| 18 | ||||||||||||||||||||||||
1217 | Q_STATIC_ASSERT_X(QMetaObjectPrivate::OutputRevision == 7, "QMetaObjectBuilder should generate the same version as moc"); | - | ||||||||||||||||||||||||
1218 | pmeta->revision = QMetaObjectPrivate::OutputRevision; | - | ||||||||||||||||||||||||
1219 | pmeta->flags = d->flags; | - | ||||||||||||||||||||||||
1220 | pmeta->className = 0; // Class name is always the first string. | - | ||||||||||||||||||||||||
1221 | //pmeta->signalCount is handled in the "output method loop" as an optimization. | - | ||||||||||||||||||||||||
1222 | - | |||||||||||||||||||||||||
1223 | pmeta->classInfoCount = d->classInfoNames.size(); | - | ||||||||||||||||||||||||
1224 | pmeta->classInfoData = dataIndex; | - | ||||||||||||||||||||||||
1225 | dataIndex += 2 * d->classInfoNames.size(); | - | ||||||||||||||||||||||||
1226 | - | |||||||||||||||||||||||||
1227 | pmeta->methodCount = int(d->methods.size();()); | - | ||||||||||||||||||||||||
1228 | pmeta->methodData = dataIndex; | - | ||||||||||||||||||||||||
1229 | dataIndex += 5 * int(d->methods.size();()); | - | ||||||||||||||||||||||||
1230 | if (hasRevisionedMethods)
| 4-14 | ||||||||||||||||||||||||
1231 | dataIndex += int(d->methods.size();()); executed 4 times by 1 test: dataIndex += int(d->methods.size()); Executed by:
| 4 | ||||||||||||||||||||||||
1232 | paramsIndex = dataIndex; | - | ||||||||||||||||||||||||
1233 | dataIndex += methodParametersDataSize; | - | ||||||||||||||||||||||||
1234 | - | |||||||||||||||||||||||||
1235 | pmeta->propertyCount = int(d->properties.size();()); | - | ||||||||||||||||||||||||
1236 | pmeta->propertyData = dataIndex; | - | ||||||||||||||||||||||||
1237 | dataIndex += 3 * int(d->properties.size();()); | - | ||||||||||||||||||||||||
1238 | if (hasNotifySignals)
| 2-16 | ||||||||||||||||||||||||
1239 | dataIndex += int(d->properties.size();()); executed 16 times by 1 test: dataIndex += int(d->properties.size()); Executed by:
| 16 | ||||||||||||||||||||||||
1240 | if (hasRevisionedProperties)
| 4-14 | ||||||||||||||||||||||||
1241 | dataIndex += int(d->properties.size();()); executed 4 times by 1 test: dataIndex += int(d->properties.size()); Executed by:
| 4 | ||||||||||||||||||||||||
1242 | - | |||||||||||||||||||||||||
1243 | pmeta->enumeratorCount = int(d->enumerators.size();()); | - | ||||||||||||||||||||||||
1244 | pmeta->enumeratorData = dataIndex; | - | ||||||||||||||||||||||||
1245 | dataIndex += 4 * int(d->enumerators.size();()); | - | ||||||||||||||||||||||||
1246 | - | |||||||||||||||||||||||||
1247 | pmeta->constructorCount = int(d->constructors.size();()); | - | ||||||||||||||||||||||||
1248 | pmeta->constructorData = dataIndex; | - | ||||||||||||||||||||||||
1249 | dataIndex += 5 * int(d->constructors.size();()); | - | ||||||||||||||||||||||||
1250 | } else { executed 18 times by 1 test: end of block Executed by:
| 18 | ||||||||||||||||||||||||
1251 | dataIndex += 2 * int(d->classInfoNames.size();()); | - | ||||||||||||||||||||||||
1252 | dataIndex += 5 * int(d->methods.size();()); | - | ||||||||||||||||||||||||
1253 | if (hasRevisionedMethods)
| 4-14 | ||||||||||||||||||||||||
1254 | dataIndex += int(d->methods.size();()); executed 4 times by 1 test: dataIndex += int(d->methods.size()); Executed by:
| 4 | ||||||||||||||||||||||||
1255 | paramsIndex = dataIndex; | - | ||||||||||||||||||||||||
1256 | dataIndex += methodParametersDataSize; | - | ||||||||||||||||||||||||
1257 | dataIndex += 3 * int(d->properties.size();()); | - | ||||||||||||||||||||||||
1258 | if (hasNotifySignals)
| 2-16 | ||||||||||||||||||||||||
1259 | dataIndex += int(d->properties.size();()); executed 16 times by 1 test: dataIndex += int(d->properties.size()); Executed by:
| 16 | ||||||||||||||||||||||||
1260 | if (hasRevisionedProperties)
| 4-14 | ||||||||||||||||||||||||
1261 | dataIndex += int(d->properties.size();()); executed 4 times by 1 test: dataIndex += int(d->properties.size()); Executed by:
| 4 | ||||||||||||||||||||||||
1262 | dataIndex += 4 * int(d->enumerators.size();()); | - | ||||||||||||||||||||||||
1263 | dataIndex += 5 * int(d->constructors.size();()); | - | ||||||||||||||||||||||||
1264 | } executed 18 times by 1 test: end of block Executed by:
| 18 | ||||||||||||||||||||||||
1265 | - | |||||||||||||||||||||||||
1266 | // Allocate space for the enumerator key names and values. | - | ||||||||||||||||||||||||
1267 | enumIndex = dataIndex; | - | ||||||||||||||||||||||||
1268 | for (index = 0; index <const auto &enumerator : d->enumerators.size(); ++index) | - | ||||||||||||||||||||||||
1269 | { executed 16 times by 1 test: dataIndex += 2 * enumerator.keys.size(); Executed by:
| 16 | ||||||||||||||||||||||||
QMetaEnumBuilderPrivate *enumerator = &(d->enumerators[index]); executed 16 times by 1 test: dataIndex += 2 * enumerator->.keys.size();dataIndex += 2 * enumerator.keys.size(); Executed by:
executed 16 times by 1 test: dataIndex += 2 * enumerator.keys.size(); Executed by:
| ||||||||||||||||||||||||||
1270 | - | |||||||||||||||||||||||||
1271 | }// Zero terminator at the end of the data offset table. | - | ||||||||||||||||||||||||
1272 | ++dataIndex; | - | ||||||||||||||||||||||||
1273 | - | |||||||||||||||||||||||||
1274 | // Find the start of the data and string tables. | - | ||||||||||||||||||||||||
1275 | int *data = reinterpret_cast<int *>(pmeta); | - | ||||||||||||||||||||||||
1276 | size += dataIndex * sizeof(int); | - | ||||||||||||||||||||||||
1277 | ALIGN(size, void *); | - | ||||||||||||||||||||||||
1278 | char *str = reinterpret_cast<char *>(buf + size); | - | ||||||||||||||||||||||||
1279 | if (buf) {
| 18 | ||||||||||||||||||||||||
1280 | if (relocatable) {
| 1-17 | ||||||||||||||||||||||||
1281 | meta->d.stringdata = reinterpret_cast<const QByteArrayData *>((quintptr)size); | - | ||||||||||||||||||||||||
1282 | meta->d.data = reinterpret_cast<uint *>((quintptr)pmetaSize); | - | ||||||||||||||||||||||||
1283 | } else { executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||||||||
1284 | meta->d.stringdata = reinterpret_cast<const QByteArrayData *>(str); | - | ||||||||||||||||||||||||
1285 | meta->d.data = reinterpret_cast<uint *>(data); | - | ||||||||||||||||||||||||
1286 | } executed 17 times by 1 test: end of block Executed by:
| 17 | ||||||||||||||||||||||||
1287 | } | - | ||||||||||||||||||||||||
1288 | - | |||||||||||||||||||||||||
1289 | // Reset the current data position to just past the QMetaObjectPrivate. | - | ||||||||||||||||||||||||
1290 | dataIndex = MetaObjectPrivateFieldCount; | - | ||||||||||||||||||||||||
1291 | - | |||||||||||||||||||||||||
1292 | QMetaStringTable strings(d->className); | - | ||||||||||||||||||||||||
1293 | - | |||||||||||||||||||||||||
1294 | // Output the class infos, | - | ||||||||||||||||||||||||
1295 | Q_ASSERT(!buf || dataIndex == pmeta->classInfoData); | - | ||||||||||||||||||||||||
1296 | for (index = 0; index < d->classInfoNames.size(); ++index) {
| 16-36 | ||||||||||||||||||||||||
1297 | int name = strings.enter(d->classInfoNames[index]); | - | ||||||||||||||||||||||||
1298 | int value = strings.enter(d->classInfoValues[index]); | - | ||||||||||||||||||||||||
1299 | if (buf) {
| 8 | ||||||||||||||||||||||||
1300 | data[dataIndex] = name; | - | ||||||||||||||||||||||||
1301 | data[dataIndex + 1] = value; | - | ||||||||||||||||||||||||
1302 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||||||||
1303 | dataIndex += 2; | - | ||||||||||||||||||||||||
1304 | } executed 16 times by 1 test: end of block Executed by:
| 16 | ||||||||||||||||||||||||
1305 | - | |||||||||||||||||||||||||
1306 | // Output the methods in the class. | - | ||||||||||||||||||||||||
1307 | Q_ASSERT(!buf || dataIndex == pmeta->methodData); | - | ||||||||||||||||||||||||
1308 | for (index = 0; index <const auto &method : d->methods.size(); ++index) { | - | ||||||||||||||||||||||||
1309 | QMetaMethodBuilderPrivate *method = &(d->methods[index]);int name = strings.enter(method->.name()); | - | ||||||||||||||||||||||||
1310 | int argc = method->.parameterCount(); | - | ||||||||||||||||||||||||
1311 | int tag = strings.enter(method->.tag); | - | ||||||||||||||||||||||||
1312 | int attrs = method->.attributes; | - | ||||||||||||||||||||||||
1313 | if (buf) {
| 105 | ||||||||||||||||||||||||
1314 | data[dataIndex] = name; | - | ||||||||||||||||||||||||
1315 | data[dataIndex + 1] = argc; | - | ||||||||||||||||||||||||
1316 | data[dataIndex + 2] = paramsIndex; | - | ||||||||||||||||||||||||
1317 | data[dataIndex + 3] = tag; | - | ||||||||||||||||||||||||
1318 | data[dataIndex + 4] = attrs; | - | ||||||||||||||||||||||||
1319 | if (method->.methodType() == QMetaMethod::Signal)
| 26-79 | ||||||||||||||||||||||||
1320 | pmeta->signalCount++; executed 26 times by 1 test: pmeta->signalCount++; Executed by:
| 26 | ||||||||||||||||||||||||
1321 | } executed 105 times by 1 test: end of block Executed by:
| 105 | ||||||||||||||||||||||||
1322 | dataIndex += 5; | - | ||||||||||||||||||||||||
1323 | paramsIndex += 1 + argc * 2; | - | ||||||||||||||||||||||||
1324 | } executed 210 times by 1 test: end of block Executed by:
| 210 | ||||||||||||||||||||||||
1325 | if (hasRevisionedMethods) {
| 8-28 | ||||||||||||||||||||||||
1326 | for (index = 0; index <const auto &method : d->methods.size(); ++index) { | - | ||||||||||||||||||||||||
1327 | QMetaMethodBuilderPrivate *method = &(d->methods[index]);if (buf)
| 40 | ||||||||||||||||||||||||
1328 | data[dataIndex] = method->.revision; executed 40 times by 1 test: data[dataIndex] = method.revision; Executed by:
| 40 | ||||||||||||||||||||||||
1329 | ++dataIndex; | - | ||||||||||||||||||||||||
1330 | } executed 80 times by 1 test: end of block Executed by:
| 80 | ||||||||||||||||||||||||
1331 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||||||||
1332 | - | |||||||||||||||||||||||||
1333 | // Output the method parameters in the class. | - | ||||||||||||||||||||||||
1334 | Q_ASSERT(!buf || dataIndex == pmeta->methodData + int(d->methods.size()()) * 5 | - | ||||||||||||||||||||||||
1335 | + (hasRevisionedMethods ? int(d->methods.size()()) : 0)); | - | ||||||||||||||||||||||||
1336 | for (int x = 0; x < 2; ++x) {
| 36-72 | ||||||||||||||||||||||||
1337 | QVectorconst std::vector<QMetaMethodBuilderPrivate> &methods = (x == 0) ? d->methods : d->constructors;
| 36 | ||||||||||||||||||||||||
1338 | for (index = 0; index <const auto &method : methods.size(); ++index) { | - | ||||||||||||||||||||||||
1339 | QMetaMethodBuilderPrivate *method = &(methods[index]);const QList<QByteArray> paramTypeNames = method->.parameterTypes(); | - | ||||||||||||||||||||||||
1340 | int paramCount = paramTypeNames.size(); | - | ||||||||||||||||||||||||
1341 | for (int i = -1; i < paramCount; ++i) {
| 258-444 | ||||||||||||||||||||||||
1342 | const QByteArray &typeName = (i < 0) ? method->.returnType : paramTypeNames.at(i);
| 186-258 | ||||||||||||||||||||||||
1343 | int typeInfo; | - | ||||||||||||||||||||||||
1344 | if (QtPrivate::isBuiltinType(typeName))
| 0-444 | ||||||||||||||||||||||||
1345 | typeInfo = QMetaType::type(typeName); executed 444 times by 1 test: typeInfo = QMetaType::type(typeName); Executed by:
| 444 | ||||||||||||||||||||||||
1346 | else | - | ||||||||||||||||||||||||
1347 | typeInfo = IsUnresolvedType | strings.enter(typeName); never executed: typeInfo = IsUnresolvedType | strings.enter(typeName); | 0 | ||||||||||||||||||||||||
1348 | if (buf)
| 222 | ||||||||||||||||||||||||
1349 | data[dataIndex] = typeInfo; executed 222 times by 1 test: data[dataIndex] = typeInfo; Executed by:
| 222 | ||||||||||||||||||||||||
1350 | ++dataIndex; | - | ||||||||||||||||||||||||
1351 | } executed 444 times by 1 test: end of block Executed by:
| 444 | ||||||||||||||||||||||||
1352 | - | |||||||||||||||||||||||||
1353 | QList<QByteArray> paramNames = method->.parameterNames; | - | ||||||||||||||||||||||||
1354 | while (paramNames.size() < paramCount)
| 18-258 | ||||||||||||||||||||||||
1355 | paramNames.append(QByteArray()); executed 18 times by 1 test: paramNames.append(QByteArray()); Executed by:
| 18 | ||||||||||||||||||||||||
1356 | for (int i = 0; i < paramCount; ++i) {
| 186-258 | ||||||||||||||||||||||||
1357 | int stringIndex = strings.enter(paramNames.at(i)); | - | ||||||||||||||||||||||||
1358 | if (buf)
| 93 | ||||||||||||||||||||||||
1359 | data[dataIndex] = stringIndex; executed 93 times by 1 test: data[dataIndex] = stringIndex; Executed by:
| 93 | ||||||||||||||||||||||||
1360 | ++dataIndex; | - | ||||||||||||||||||||||||
1361 | } executed 186 times by 1 test: end of block Executed by:
| 186 | ||||||||||||||||||||||||
1362 | } executed 258 times by 1 test: end of block Executed by:
| 258 | ||||||||||||||||||||||||
1363 | } executed 72 times by 1 test: end of block Executed by:
| 72 | ||||||||||||||||||||||||
1364 | - | |||||||||||||||||||||||||
1365 | // Output the properties in the class. | - | ||||||||||||||||||||||||
1366 | Q_ASSERT(!buf || dataIndex == pmeta->propertyData); | - | ||||||||||||||||||||||||
1367 | for (index = 0; index <const auto &prop : d->properties.size(); ++index) { | - | ||||||||||||||||||||||||
1368 | QMetaPropertyBuilderPrivate *prop = &(d->properties[index]);int name = strings.enter(prop->.name); | - | ||||||||||||||||||||||||
1369 | - | |||||||||||||||||||||||||
1370 | int typeInfo; | - | ||||||||||||||||||||||||
1371 | if (QtPrivate::isBuiltinType(prop->.type))
| 24-50 | ||||||||||||||||||||||||
1372 | typeInfo = QMetaType::type(prop->.type); executed 50 times by 1 test: typeInfo = QMetaType::type(prop.type); Executed by:
| 50 | ||||||||||||||||||||||||
1373 | else | - | ||||||||||||||||||||||||
1374 | typeInfo = IsUnresolvedType | strings.enter(prop->.type); executed 24 times by 1 test: typeInfo = IsUnresolvedType | strings.enter(prop.type); Executed by:
| 24 | ||||||||||||||||||||||||
1375 | - | |||||||||||||||||||||||||
1376 | int flags = prop->.flags; | - | ||||||||||||||||||||||||
1377 | - | |||||||||||||||||||||||||
1378 | if (!QtPrivate::isBuiltinType(prop->.type))
| 24-50 | ||||||||||||||||||||||||
1379 | flags |= EnumOrFlag; executed 24 times by 1 test: flags |= EnumOrFlag; Executed by:
| 24 | ||||||||||||||||||||||||
1380 | - | |||||||||||||||||||||||||
1381 | if (buf) {
| 37 | ||||||||||||||||||||||||
1382 | data[dataIndex] = name; | - | ||||||||||||||||||||||||
1383 | data[dataIndex + 1] = typeInfo; | - | ||||||||||||||||||||||||
1384 | data[dataIndex + 2] = flags; | - | ||||||||||||||||||||||||
1385 | } executed 37 times by 1 test: end of block Executed by:
| 37 | ||||||||||||||||||||||||
1386 | dataIndex += 3; | - | ||||||||||||||||||||||||
1387 | } executed 74 times by 1 test: end of block Executed by:
| 74 | ||||||||||||||||||||||||
1388 | if (hasNotifySignals) {
| 4-32 | ||||||||||||||||||||||||
1389 | for (index = 0; index <const auto &prop : d->properties.size(); ++index) { | - | ||||||||||||||||||||||||
1390 | QMetaPropertyBuilderPrivate *prop = &(d->properties[index]);if (buf) {
| 36 | ||||||||||||||||||||||||
1391 | if (prop->.notifySignal != -1)
| 16-20 | ||||||||||||||||||||||||
1392 | data[dataIndex] = prop->.notifySignal; executed 16 times by 1 test: data[dataIndex] = prop.notifySignal; Executed by:
| 16 | ||||||||||||||||||||||||
1393 | else | - | ||||||||||||||||||||||||
1394 | data[dataIndex] = 0; executed 20 times by 1 test: data[dataIndex] = 0; Executed by:
| 20 | ||||||||||||||||||||||||
1395 | } | - | ||||||||||||||||||||||||
1396 | ++dataIndex; | - | ||||||||||||||||||||||||
1397 | } executed 72 times by 1 test: end of block Executed by:
| 72 | ||||||||||||||||||||||||
1398 | } executed 32 times by 1 test: end of block Executed by:
| 32 | ||||||||||||||||||||||||
1399 | if (hasRevisionedProperties) {
| 8-28 | ||||||||||||||||||||||||
1400 | for (index = 0; index <const auto &prop : d->properties.size(); ++index) { | - | ||||||||||||||||||||||||
1401 | QMetaPropertyBuilderPrivate *prop = &(d->properties[index]);if (buf)
| 24 | ||||||||||||||||||||||||
1402 | data[dataIndex] = prop->.revision; executed 24 times by 1 test: data[dataIndex] = prop.revision; Executed by:
| 24 | ||||||||||||||||||||||||
1403 | ++dataIndex; | - | ||||||||||||||||||||||||
1404 | } executed 48 times by 1 test: end of block Executed by:
| 48 | ||||||||||||||||||||||||
1405 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||||||||
1406 | - | |||||||||||||||||||||||||
1407 | // Output the enumerators in the class. | - | ||||||||||||||||||||||||
1408 | Q_ASSERT(!buf || dataIndex == pmeta->enumeratorData); | - | ||||||||||||||||||||||||
1409 | for (index = 0; index <const auto &enumerator : d->enumerators.size(); ++index) { | - | ||||||||||||||||||||||||
1410 | QMetaEnumBuilderPrivate *enumerator = &(d->enumerators[index]);int name = strings.enter(enumerator->.name); | - | ||||||||||||||||||||||||
1411 | int isFlag = (int)(enumerator->.isFlag); | - | ||||||||||||||||||||||||
1412 | int count = enumerator->.keys.size(); | - | ||||||||||||||||||||||||
1413 | int enumOffset = enumIndex; | - | ||||||||||||||||||||||||
1414 | if (buf) {
| 8 | ||||||||||||||||||||||||
1415 | data[dataIndex] = name; | - | ||||||||||||||||||||||||
1416 | data[dataIndex + 1] = isFlag; | - | ||||||||||||||||||||||||
1417 | data[dataIndex + 2] = count; | - | ||||||||||||||||||||||||
1418 | data[dataIndex + 3] = enumOffset; | - | ||||||||||||||||||||||||
1419 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||||||||
1420 | for (int key = 0; key < count; ++key) {
| 16-32 | ||||||||||||||||||||||||
1421 | int keyIndex = strings.enter(enumerator->.keys[key]); | - | ||||||||||||||||||||||||
1422 | if (buf) {
| 16 | ||||||||||||||||||||||||
1423 | data[enumOffset++] = keyIndex; | - | ||||||||||||||||||||||||
1424 | data[enumOffset++] = enumerator->.values[key]; | - | ||||||||||||||||||||||||
1425 | } executed 16 times by 1 test: end of block Executed by:
| 16 | ||||||||||||||||||||||||
1426 | } executed 32 times by 1 test: end of block Executed by:
| 32 | ||||||||||||||||||||||||
1427 | dataIndex += 4; | - | ||||||||||||||||||||||||
1428 | enumIndex += 2 * count; | - | ||||||||||||||||||||||||
1429 | } executed 16 times by 1 test: end of block Executed by:
| 16 | ||||||||||||||||||||||||
1430 | - | |||||||||||||||||||||||||
1431 | // Output the constructors in the class. | - | ||||||||||||||||||||||||
1432 | Q_ASSERT(!buf || dataIndex == pmeta->constructorData); | - | ||||||||||||||||||||||||
1433 | for (index = 0; index <const auto &ctor : d->constructors.size(); ++index) { | - | ||||||||||||||||||||||||
1434 | QMetaMethodBuilderPrivate *method = &(d->constructors[index]);int name = strings.enter(method->ctor.name()); | - | ||||||||||||||||||||||||
1435 | int argc = method->ctor.parameterCount(); | - | ||||||||||||||||||||||||
1436 | int tag = strings.enter(method->ctor.tag); | - | ||||||||||||||||||||||||
1437 | int attrs = method->ctor.attributes; | - | ||||||||||||||||||||||||
1438 | if (buf) {
| 24 | ||||||||||||||||||||||||
1439 | data[dataIndex] = name; | - | ||||||||||||||||||||||||
1440 | data[dataIndex + 1] = argc; | - | ||||||||||||||||||||||||
1441 | data[dataIndex + 2] = paramsIndex; | - | ||||||||||||||||||||||||
1442 | data[dataIndex + 3] = tag; | - | ||||||||||||||||||||||||
1443 | data[dataIndex + 4] = attrs; | - | ||||||||||||||||||||||||
1444 | } executed 24 times by 1 test: end of block Executed by:
| 24 | ||||||||||||||||||||||||
1445 | dataIndex += 5; | - | ||||||||||||||||||||||||
1446 | paramsIndex += 1 + argc * 2; | - | ||||||||||||||||||||||||
1447 | } executed 48 times by 1 test: end of block Executed by:
| 48 | ||||||||||||||||||||||||
1448 | - | |||||||||||||||||||||||||
1449 | size += strings.blobSize(); | - | ||||||||||||||||||||||||
1450 | - | |||||||||||||||||||||||||
1451 | if (buf)
| 18 | ||||||||||||||||||||||||
1452 | strings.writeBlob(str); executed 18 times by 1 test: strings.writeBlob(str); Executed by:
| 18 | ||||||||||||||||||||||||
1453 | - | |||||||||||||||||||||||||
1454 | // Output the zero terminator in the data array. | - | ||||||||||||||||||||||||
1455 | if (buf)
| 18 | ||||||||||||||||||||||||
1456 | data[enumIndex] = 0; executed 18 times by 1 test: data[enumIndex] = 0; Executed by:
| 18 | ||||||||||||||||||||||||
1457 | - | |||||||||||||||||||||||||
1458 | // Create the relatedMetaObjects block if we need one. | - | ||||||||||||||||||||||||
1459 | if (d->relatedMetaObjects.size() > 0) {
| 8-28 | ||||||||||||||||||||||||
1460 | ALIGN(size, QMetaObject *); | - | ||||||||||||||||||||||||
1461 | const QMetaObject **objects = | - | ||||||||||||||||||||||||
1462 | reinterpret_cast<const QMetaObject **>(buf + size); | - | ||||||||||||||||||||||||
1463 | if (buf) {
| 4 | ||||||||||||||||||||||||
1464 | meta->d.relatedMetaObjects = objects; | - | ||||||||||||||||||||||||
1465 | for (index = 0; index < d->relatedMetaObjects.size(); ++index)
| 4 | ||||||||||||||||||||||||
1466 | objects[index] = d->relatedMetaObjects[index]; executed 4 times by 1 test: objects[index] = d->relatedMetaObjects[index]; Executed by:
| 4 | ||||||||||||||||||||||||
1467 | objects[index] = 0; | - | ||||||||||||||||||||||||
1468 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
1469 | size += sizeof(QMetaObject *) * (d->relatedMetaObjects.size() + 1); | - | ||||||||||||||||||||||||
1470 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||||||||
1471 | - | |||||||||||||||||||||||||
1472 | // Align the final size and return it. | - | ||||||||||||||||||||||||
1473 | ALIGN(size, void *); | - | ||||||||||||||||||||||||
1474 | Q_ASSERT(!buf || size == expectedSize); | - | ||||||||||||||||||||||||
1475 | return size; executed 36 times by 1 test: return size; Executed by:
| 36 | ||||||||||||||||||||||||
1476 | } | - | ||||||||||||||||||||||||
1477 | - | |||||||||||||||||||||||||
1478 | /*! | - | ||||||||||||||||||||||||
1479 | Converts this meta object builder into a concrete QMetaObject. | - | ||||||||||||||||||||||||
1480 | The return value should be deallocated using free() once it | - | ||||||||||||||||||||||||
1481 | is no longer needed. | - | ||||||||||||||||||||||||
1482 | - | |||||||||||||||||||||||||
1483 | The returned meta object is a snapshot of the state of the | - | ||||||||||||||||||||||||
1484 | QMetaObjectBuilder. Any further modifications to the QMetaObjectBuilder | - | ||||||||||||||||||||||||
1485 | will not be reflected in previous meta objects returned by | - | ||||||||||||||||||||||||
1486 | this method. | - | ||||||||||||||||||||||||
1487 | */ | - | ||||||||||||||||||||||||
1488 | QMetaObject *QMetaObjectBuilder::toMetaObject() const | - | ||||||||||||||||||||||||
1489 | { | - | ||||||||||||||||||||||||
1490 | int size = buildMetaObject(d, 0, 0, false); | - | ||||||||||||||||||||||||
1491 | char *buf = reinterpret_cast<char *>(malloc(size)); | - | ||||||||||||||||||||||||
1492 | memset(buf, 0, size); | - | ||||||||||||||||||||||||
1493 | buildMetaObject(d, buf, size, false); | - | ||||||||||||||||||||||||
1494 | return reinterpret_cast<QMetaObject *>(buf); | - | ||||||||||||||||||||||||
1495 | } | - | ||||||||||||||||||||||||
1496 | - | |||||||||||||||||||||||||
1497 | /* | - | ||||||||||||||||||||||||
1498 | \internal | - | ||||||||||||||||||||||||
1499 | - | |||||||||||||||||||||||||
1500 | Converts this meta object builder into relocatable data. This data can | - | ||||||||||||||||||||||||
1501 | be stored, copied and later passed to fromRelocatableData() to create a | - | ||||||||||||||||||||||||
1502 | concrete QMetaObject. | - | ||||||||||||||||||||||||
1503 | - | |||||||||||||||||||||||||
1504 | The data is specific to the architecture on which it was created, but is not | - | ||||||||||||||||||||||||
1505 | specific to the process that created it. Not all meta object builder's can | - | ||||||||||||||||||||||||
1506 | be converted to data in this way. If \a ok is provided, it will be set to | - | ||||||||||||||||||||||||
1507 | true if the conversion succeeds, and false otherwise. If a | - | ||||||||||||||||||||||||
1508 | staticMetacallFunction() or any relatedMetaObject()'s are specified the | - | ||||||||||||||||||||||||
1509 | conversion to relocatable data will fail. | - | ||||||||||||||||||||||||
1510 | */ | - | ||||||||||||||||||||||||
1511 | QByteArray QMetaObjectBuilder::toRelocatableData(bool *ok) const | - | ||||||||||||||||||||||||
1512 | { | - | ||||||||||||||||||||||||
1513 | int size = buildMetaObject(d, 0, 0, true); | - | ||||||||||||||||||||||||
1514 | if (size == -1) { | - | ||||||||||||||||||||||||
1515 | if (ok) *ok = false; | - | ||||||||||||||||||||||||
1516 | return QByteArray(); | - | ||||||||||||||||||||||||
1517 | } | - | ||||||||||||||||||||||||
1518 | - | |||||||||||||||||||||||||
1519 | QByteArray data; | - | ||||||||||||||||||||||||
1520 | data.resize(size); | - | ||||||||||||||||||||||||
1521 | char *buf = data.data(); | - | ||||||||||||||||||||||||
1522 | memset(buf, 0, size); | - | ||||||||||||||||||||||||
1523 | buildMetaObject(d, buf, size, true); | - | ||||||||||||||||||||||||
1524 | if (ok) *ok = true; | - | ||||||||||||||||||||||||
1525 | return data; | - | ||||||||||||||||||||||||
1526 | } | - | ||||||||||||||||||||||||
1527 | - | |||||||||||||||||||||||||
1528 | /* | - | ||||||||||||||||||||||||
1529 | \internal | - | ||||||||||||||||||||||||
1530 | - | |||||||||||||||||||||||||
1531 | Sets the \a data returned from toRelocatableData() onto a concrete | - | ||||||||||||||||||||||||
1532 | QMetaObject instance, \a output. As the meta object's super class is not | - | ||||||||||||||||||||||||
1533 | saved in the relocatable data, it must be passed as \a superClass. | - | ||||||||||||||||||||||||
1534 | */ | - | ||||||||||||||||||||||||
1535 | void QMetaObjectBuilder::fromRelocatableData(QMetaObject *output, | - | ||||||||||||||||||||||||
1536 | const QMetaObject *superclass, | - | ||||||||||||||||||||||||
1537 | const QByteArray &data) | - | ||||||||||||||||||||||||
1538 | { | - | ||||||||||||||||||||||||
1539 | if (!output) | - | ||||||||||||||||||||||||
1540 | return; | - | ||||||||||||||||||||||||
1541 | - | |||||||||||||||||||||||||
1542 | const char *buf = data.constData(); | - | ||||||||||||||||||||||||
1543 | const QMetaObject *dataMo = reinterpret_cast<const QMetaObject *>(buf); | - | ||||||||||||||||||||||||
1544 | - | |||||||||||||||||||||||||
1545 | quintptr stringdataOffset = (quintptr)dataMo->d.stringdata; | - | ||||||||||||||||||||||||
1546 | quintptr dataOffset = (quintptr)dataMo->d.data; | - | ||||||||||||||||||||||||
1547 | - | |||||||||||||||||||||||||
1548 | output->d.superdata = superclass; | - | ||||||||||||||||||||||||
1549 | output->d.stringdata = reinterpret_cast<const QByteArrayData *>(buf + stringdataOffset); | - | ||||||||||||||||||||||||
1550 | output->d.data = reinterpret_cast<const uint *>(buf + dataOffset); | - | ||||||||||||||||||||||||
1551 | output->d.extradata = 0; | - | ||||||||||||||||||||||||
1552 | output->d.relatedMetaObjects = 0; | - | ||||||||||||||||||||||||
1553 | output->d.static_metacall = 0; | - | ||||||||||||||||||||||||
1554 | } | - | ||||||||||||||||||||||||
1555 | - | |||||||||||||||||||||||||
1556 | /*! | - | ||||||||||||||||||||||||
1557 | \typedef QMetaObjectBuilder::StaticMetacallFunction | - | ||||||||||||||||||||||||
1558 | - | |||||||||||||||||||||||||
1559 | Typedef for static metacall functions. The three parameters are | - | ||||||||||||||||||||||||
1560 | the call type value, the constructor index, and the | - | ||||||||||||||||||||||||
1561 | array of parameters. | - | ||||||||||||||||||||||||
1562 | */ | - | ||||||||||||||||||||||||
1563 | - | |||||||||||||||||||||||||
1564 | /*! | - | ||||||||||||||||||||||||
1565 | Returns the static metacall function to use to construct objects | - | ||||||||||||||||||||||||
1566 | of this class. The default value is null. | - | ||||||||||||||||||||||||
1567 | - | |||||||||||||||||||||||||
1568 | \sa setStaticMetacallFunction() | - | ||||||||||||||||||||||||
1569 | */ | - | ||||||||||||||||||||||||
1570 | QMetaObjectBuilder::StaticMetacallFunction QMetaObjectBuilder::staticMetacallFunction() const | - | ||||||||||||||||||||||||
1571 | { | - | ||||||||||||||||||||||||
1572 | return d->staticMetacallFunction; | - | ||||||||||||||||||||||||
1573 | } | - | ||||||||||||||||||||||||
1574 | - | |||||||||||||||||||||||||
1575 | /*! | - | ||||||||||||||||||||||||
1576 | Sets the static metacall function to use to construct objects | - | ||||||||||||||||||||||||
1577 | of this class to \a value. The default value is null. | - | ||||||||||||||||||||||||
1578 | - | |||||||||||||||||||||||||
1579 | \sa staticMetacallFunction() | - | ||||||||||||||||||||||||
1580 | */ | - | ||||||||||||||||||||||||
1581 | void QMetaObjectBuilder::setStaticMetacallFunction | - | ||||||||||||||||||||||||
1582 | (QMetaObjectBuilder::StaticMetacallFunction value) | - | ||||||||||||||||||||||||
1583 | { | - | ||||||||||||||||||||||||
1584 | d->staticMetacallFunction = value; | - | ||||||||||||||||||||||||
1585 | } | - | ||||||||||||||||||||||||
1586 | - | |||||||||||||||||||||||||
1587 | #ifndef QT_NO_DATASTREAM | - | ||||||||||||||||||||||||
1588 | - | |||||||||||||||||||||||||
1589 | /*! | - | ||||||||||||||||||||||||
1590 | Serializes the contents of the meta object builder onto \a stream. | - | ||||||||||||||||||||||||
1591 | - | |||||||||||||||||||||||||
1592 | \sa deserialize() | - | ||||||||||||||||||||||||
1593 | */ | - | ||||||||||||||||||||||||
1594 | void QMetaObjectBuilder::serialize(QDataStream& stream) const | - | ||||||||||||||||||||||||
1595 | { | - | ||||||||||||||||||||||||
1596 | int index; | - | ||||||||||||||||||||||||
1597 | - | |||||||||||||||||||||||||
1598 | // Write the class and super class names. | - | ||||||||||||||||||||||||
1599 | stream << d->className; | - | ||||||||||||||||||||||||
1600 | if (d->superClass)
| 0-2 | ||||||||||||||||||||||||
1601 | stream << QByteArray(d->superClass->className()); executed 2 times by 1 test: stream << QByteArray(d->superClass->className()); Executed by:
| 2 | ||||||||||||||||||||||||
1602 | else | - | ||||||||||||||||||||||||
1603 | stream << QByteArray(); never executed: stream << QByteArray(); | 0 | ||||||||||||||||||||||||
1604 | - | |||||||||||||||||||||||||
1605 | // Write the counts for each type of class member. | - | ||||||||||||||||||||||||
1606 | stream << d->classInfoNames.size(); | - | ||||||||||||||||||||||||
1607 | stream << int(d->methods.size();()); | - | ||||||||||||||||||||||||
1608 | stream << int(d->properties.size();()); | - | ||||||||||||||||||||||||
1609 | stream << int(d->enumerators.size();()); | - | ||||||||||||||||||||||||
1610 | stream << int(d->constructors.size();()); | - | ||||||||||||||||||||||||
1611 | stream << d->relatedMetaObjects.size(); | - | ||||||||||||||||||||||||
1612 | - | |||||||||||||||||||||||||
1613 | // Write the items of class information. | - | ||||||||||||||||||||||||
1614 | for (index = 0; index < d->classInfoNames.size(); ++index) {
| 2 | ||||||||||||||||||||||||
1615 | stream << d->classInfoNames[index]; | - | ||||||||||||||||||||||||
1616 | stream << d->classInfoValues[index]; | - | ||||||||||||||||||||||||
1617 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
1618 | - | |||||||||||||||||||||||||
1619 | // Write the methods. | - | ||||||||||||||||||||||||
1620 | for (index = 0; index <const auto &method : d->methods.size(); ++index) { | - | ||||||||||||||||||||||||
1621 | const QMetaMethodBuilderPrivate *method = &(d->methods[index]);stream << method->.signature; | - | ||||||||||||||||||||||||
1622 | stream << method->.returnType; | - | ||||||||||||||||||||||||
1623 | stream << method->.parameterNames; | - | ||||||||||||||||||||||||
1624 | stream << method->.tag; | - | ||||||||||||||||||||||||
1625 | stream << method->.attributes; | - | ||||||||||||||||||||||||
1626 | if (method->.revision)
| 1-9 | ||||||||||||||||||||||||
1627 | stream << method->.revision; executed 1 time by 1 test: stream << method.revision; Executed by:
| 1 | ||||||||||||||||||||||||
1628 | } executed 10 times by 1 test: end of block Executed by:
| 10 | ||||||||||||||||||||||||
1629 | - | |||||||||||||||||||||||||
1630 | // Write the properties. | - | ||||||||||||||||||||||||
1631 | for (index = 0; index <const auto &property : d->properties.size(); ++index) { | - | ||||||||||||||||||||||||
1632 | const QMetaPropertyBuilderPrivate *property = &(d->properties[index]);stream << property->.name; | - | ||||||||||||||||||||||||
1633 | stream << property->.type; | - | ||||||||||||||||||||||||
1634 | stream << property->.flags; | - | ||||||||||||||||||||||||
1635 | stream << property->.notifySignal; | - | ||||||||||||||||||||||||
1636 | if (property->.revision)
| 1-6 | ||||||||||||||||||||||||
1637 | stream << property->.revision; executed 1 time by 1 test: stream << property.revision; Executed by:
| 1 | ||||||||||||||||||||||||
1638 | } executed 7 times by 1 test: end of block Executed by:
| 7 | ||||||||||||||||||||||||
1639 | - | |||||||||||||||||||||||||
1640 | // Write the enumerators. | - | ||||||||||||||||||||||||
1641 | for (index = 0; index <const auto &enumerator : d->enumerators.size(); ++index) { | - | ||||||||||||||||||||||||
1642 | const QMetaEnumBuilderPrivate *enumerator = &(d->enumerators[index]);stream << enumerator->.name; | - | ||||||||||||||||||||||||
1643 | stream << enumerator->.isFlag; | - | ||||||||||||||||||||||||
1644 | stream << enumerator->.keys; | - | ||||||||||||||||||||||||
1645 | stream << enumerator->.values; | - | ||||||||||||||||||||||||
1646 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
1647 | - | |||||||||||||||||||||||||
1648 | // Write the constructors. | - | ||||||||||||||||||||||||
1649 | for (index = 0; index <const auto &ctor : d->constructors.size(); ++index) { | - | ||||||||||||||||||||||||
1650 | const QMetaMethodBuilderPrivate *method = &(d->constructors[index]);stream << method->ctor.signature; | - | ||||||||||||||||||||||||
1651 | stream << method->ctor.returnType; | - | ||||||||||||||||||||||||
1652 | stream << method->ctor.parameterNames; | - | ||||||||||||||||||||||||
1653 | stream << method->ctor.tag; | - | ||||||||||||||||||||||||
1654 | stream << method->ctor.attributes; | - | ||||||||||||||||||||||||
1655 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||||||||
1656 | - | |||||||||||||||||||||||||
1657 | // Write the related meta objects. | - | ||||||||||||||||||||||||
1658 | for (index = 0; index < d->relatedMetaObjects.size(); ++index) {
| 1-2 | ||||||||||||||||||||||||
1659 | const QMetaObject *meta = d->relatedMetaObjects[index]; | - | ||||||||||||||||||||||||
1660 | stream << QByteArray(meta->className()); | - | ||||||||||||||||||||||||
1661 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||||||||
1662 | - | |||||||||||||||||||||||||
1663 | // Add an extra empty QByteArray for additional data in future versions. | - | ||||||||||||||||||||||||
1664 | // This should help maintain backwards compatibility, allowing older | - | ||||||||||||||||||||||||
1665 | // versions to read newer data. | - | ||||||||||||||||||||||||
1666 | stream << QByteArray(); | - | ||||||||||||||||||||||||
1667 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
1668 | - | |||||||||||||||||||||||||
1669 | // Resolve a class name using the name reference map. | - | ||||||||||||||||||||||||
1670 | static const QMetaObject *resolveClassName | - | ||||||||||||||||||||||||
1671 | (const QMap<QByteArray, const QMetaObject *>& references, | - | ||||||||||||||||||||||||
1672 | const QByteArray& name) | - | ||||||||||||||||||||||||
1673 | { | - | ||||||||||||||||||||||||
1674 | if (name == QByteArray("QObject")) | - | ||||||||||||||||||||||||
1675 | return &QObject::staticMetaObject; | - | ||||||||||||||||||||||||
1676 | else | - | ||||||||||||||||||||||||
1677 | return references.value(name, 0); | - | ||||||||||||||||||||||||
1678 | } | - | ||||||||||||||||||||||||
1679 | - | |||||||||||||||||||||||||
1680 | /*! | - | ||||||||||||||||||||||||
1681 | Deserializes a meta object builder from \a stream into | - | ||||||||||||||||||||||||
1682 | this meta object builder. | - | ||||||||||||||||||||||||
1683 | - | |||||||||||||||||||||||||
1684 | The \a references parameter specifies a mapping from class names | - | ||||||||||||||||||||||||
1685 | to QMetaObject instances for resolving the super class name and | - | ||||||||||||||||||||||||
1686 | related meta objects in the object that is deserialized. | - | ||||||||||||||||||||||||
1687 | The meta object for QObject is implicitly added to \a references | - | ||||||||||||||||||||||||
1688 | and does not need to be supplied. | - | ||||||||||||||||||||||||
1689 | - | |||||||||||||||||||||||||
1690 | The QDataStream::status() value on \a stream will be set to | - | ||||||||||||||||||||||||
1691 | QDataStream::ReadCorruptData if the input data is corrupt. | - | ||||||||||||||||||||||||
1692 | The status will be set to QDataStream::ReadPastEnd if the | - | ||||||||||||||||||||||||
1693 | input was exhausted before the full meta object was read. | - | ||||||||||||||||||||||||
1694 | - | |||||||||||||||||||||||||
1695 | \sa serialize() | - | ||||||||||||||||||||||||
1696 | */ | - | ||||||||||||||||||||||||
1697 | void QMetaObjectBuilder::deserialize | - | ||||||||||||||||||||||||
1698 | (QDataStream& stream, | - | ||||||||||||||||||||||||
1699 | const QMap<QByteArray, const QMetaObject *>& references) | - | ||||||||||||||||||||||||
1700 | { | - | ||||||||||||||||||||||||
1701 | QByteArray name; | - | ||||||||||||||||||||||||
1702 | const QMetaObject *cl; | - | ||||||||||||||||||||||||
1703 | int index; | - | ||||||||||||||||||||||||
1704 | - | |||||||||||||||||||||||||
1705 | // Clear all members in the builder to their default states. | - | ||||||||||||||||||||||||
1706 | d->className.clear(); | - | ||||||||||||||||||||||||
1707 | d->superClass = &QObject::staticMetaObject; | - | ||||||||||||||||||||||||
1708 | d->classInfoNames.clear(); | - | ||||||||||||||||||||||||
1709 | d->classInfoValues.clear(); | - | ||||||||||||||||||||||||
1710 | d->methods.clear(); | - | ||||||||||||||||||||||||
1711 | d->properties.clear(); | - | ||||||||||||||||||||||||
1712 | d->enumerators.clear(); | - | ||||||||||||||||||||||||
1713 | d->constructors.clear(); | - | ||||||||||||||||||||||||
1714 | d->relatedMetaObjects.clear(); | - | ||||||||||||||||||||||||
1715 | d->staticMetacallFunction = 0; | - | ||||||||||||||||||||||||
1716 | - | |||||||||||||||||||||||||
1717 | // Read the class and super class names. | - | ||||||||||||||||||||||||
1718 | stream >> d->className; | - | ||||||||||||||||||||||||
1719 | stream >> name; | - | ||||||||||||||||||||||||
1720 | if (name.isEmpty()) {
| 0-2 | ||||||||||||||||||||||||
1721 | d->superClass = 0; | - | ||||||||||||||||||||||||
1722 | } else if ((cl = resolveClassName(references, name)) != 0) { never executed: end of block
| 0-2 | ||||||||||||||||||||||||
1723 | d->superClass = cl; | - | ||||||||||||||||||||||||
1724 | } else { executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
1725 | stream.setStatus(QDataStream::ReadCorruptData); | - | ||||||||||||||||||||||||
1726 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1727 | } | - | ||||||||||||||||||||||||
1728 | - | |||||||||||||||||||||||||
1729 | // Read the counts for each type of class member. | - | ||||||||||||||||||||||||
1730 | int classInfoCount, methodCount, propertyCount; | - | ||||||||||||||||||||||||
1731 | int enumeratorCount, constructorCount, relatedMetaObjectCount; | - | ||||||||||||||||||||||||
1732 | stream >> classInfoCount; | - | ||||||||||||||||||||||||
1733 | stream >> methodCount; | - | ||||||||||||||||||||||||
1734 | stream >> propertyCount; | - | ||||||||||||||||||||||||
1735 | stream >> enumeratorCount; | - | ||||||||||||||||||||||||
1736 | stream >> constructorCount; | - | ||||||||||||||||||||||||
1737 | stream >> relatedMetaObjectCount; | - | ||||||||||||||||||||||||
1738 | if (classInfoCount < 0 || methodCount < 0 ||
| 0-2 | ||||||||||||||||||||||||
1739 | propertyCount < 0 || enumeratorCount < 0 ||
| 0-2 | ||||||||||||||||||||||||
1740 | constructorCount < 0 || relatedMetaObjectCount < 0) {
| 0-2 | ||||||||||||||||||||||||
1741 | stream.setStatus(QDataStream::ReadCorruptData); | - | ||||||||||||||||||||||||
1742 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1743 | } | - | ||||||||||||||||||||||||
1744 | - | |||||||||||||||||||||||||
1745 | // Read the items of class information. | - | ||||||||||||||||||||||||
1746 | for (index = 0; index < classInfoCount; ++index) {
| 2 | ||||||||||||||||||||||||
1747 | if (stream.status() != QDataStream::Ok)
| 0-2 | ||||||||||||||||||||||||
1748 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1749 | QByteArray value; | - | ||||||||||||||||||||||||
1750 | stream >> name; | - | ||||||||||||||||||||||||
1751 | stream >> value; | - | ||||||||||||||||||||||||
1752 | addClassInfo(name, value); | - | ||||||||||||||||||||||||
1753 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
1754 | - | |||||||||||||||||||||||||
1755 | // Read the member methods. | - | ||||||||||||||||||||||||
1756 | for (index = 0; index < methodCount; ++index) {
| 2-10 | ||||||||||||||||||||||||
1757 | if (stream.status() != QDataStream::Ok)
| 0-10 | ||||||||||||||||||||||||
1758 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1759 | stream >> name; | - | ||||||||||||||||||||||||
1760 | addMethod(name); | - | ||||||||||||||||||||||||
1761 | QMetaMethodBuilderPrivate *method&method = &(d->methods[index]);]; | - | ||||||||||||||||||||||||
1762 | stream >> method->.returnType; | - | ||||||||||||||||||||||||
1763 | stream >> method->.parameterNames; | - | ||||||||||||||||||||||||
1764 | stream >> method->.tag; | - | ||||||||||||||||||||||||
1765 | stream >> method->.attributes; | - | ||||||||||||||||||||||||
1766 | if (method->.attributes & MethodRevisioned)
| 1-9 | ||||||||||||||||||||||||
1767 | stream >> method->.revision; executed 1 time by 1 test: stream >> method.revision; Executed by:
| 1 | ||||||||||||||||||||||||
1768 | if (method->.methodType() == QMetaMethod::Constructor) {
| 0-10 | ||||||||||||||||||||||||
1769 | // Cannot add a constructor in this set of methods. | - | ||||||||||||||||||||||||
1770 | stream.setStatus(QDataStream::ReadCorruptData); | - | ||||||||||||||||||||||||
1771 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1772 | } | - | ||||||||||||||||||||||||
1773 | } executed 10 times by 1 test: end of block Executed by:
| 10 | ||||||||||||||||||||||||
1774 | - | |||||||||||||||||||||||||
1775 | // Read the properties. | - | ||||||||||||||||||||||||
1776 | for (index = 0; index < propertyCount; ++index) {
| 2-7 | ||||||||||||||||||||||||
1777 | if (stream.status() != QDataStream::Ok)
| 0-7 | ||||||||||||||||||||||||
1778 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1779 | QByteArray type; | - | ||||||||||||||||||||||||
1780 | stream >> name; | - | ||||||||||||||||||||||||
1781 | stream >> type; | - | ||||||||||||||||||||||||
1782 | addProperty(name, type); | - | ||||||||||||||||||||||||
1783 | QMetaPropertyBuilderPrivate *property&property = &(d->properties[index]);]; | - | ||||||||||||||||||||||||
1784 | stream >> property->.flags; | - | ||||||||||||||||||||||||
1785 | stream >> property->.notifySignal; | - | ||||||||||||||||||||||||
1786 | if (property->.notifySignal < -1 ||
| 0-7 | ||||||||||||||||||||||||
1787 | property->.notifySignal >= int(d->methods.size())())) {
| 0-7 | ||||||||||||||||||||||||
1788 | // Notify signal method index is out of range. | - | ||||||||||||||||||||||||
1789 | stream.setStatus(QDataStream::ReadCorruptData); | - | ||||||||||||||||||||||||
1790 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1791 | } | - | ||||||||||||||||||||||||
1792 | if (property->.notifySignal >= 0 &&
| 1-6 | ||||||||||||||||||||||||
1793 | d->methods[property->.notifySignal].methodType() != QMetaMethod::Signal) {
| 0-1 | ||||||||||||||||||||||||
1794 | // Notify signal method index does not refer to a signal. | - | ||||||||||||||||||||||||
1795 | stream.setStatus(QDataStream::ReadCorruptData); | - | ||||||||||||||||||||||||
1796 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1797 | } | - | ||||||||||||||||||||||||
1798 | if (property->.flags & Revisioned)
| 1-6 | ||||||||||||||||||||||||
1799 | stream >> property->.revision; executed 1 time by 1 test: stream >> property.revision; Executed by:
| 1 | ||||||||||||||||||||||||
1800 | } executed 7 times by 1 test: end of block Executed by:
| 7 | ||||||||||||||||||||||||
1801 | - | |||||||||||||||||||||||||
1802 | // Read the enumerators. | - | ||||||||||||||||||||||||
1803 | for (index = 0; index < enumeratorCount; ++index) {
| 2 | ||||||||||||||||||||||||
1804 | if (stream.status() != QDataStream::Ok)
| 0-2 | ||||||||||||||||||||||||
1805 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1806 | stream >> name; | - | ||||||||||||||||||||||||
1807 | addEnumerator(name); | - | ||||||||||||||||||||||||
1808 | QMetaEnumBuilderPrivate *enumerator&enumerator = &(d->enumerators[index]);]; | - | ||||||||||||||||||||||||
1809 | stream >> enumerator->.isFlag; | - | ||||||||||||||||||||||||
1810 | stream >> enumerator->.keys; | - | ||||||||||||||||||||||||
1811 | stream >> enumerator->.values; | - | ||||||||||||||||||||||||
1812 | if (enumerator->.keys.size() != enumerator->.values.size()) {
| 0-2 | ||||||||||||||||||||||||
1813 | // Mismatch between number of keys and number of values. | - | ||||||||||||||||||||||||
1814 | stream.setStatus(QDataStream::ReadCorruptData); | - | ||||||||||||||||||||||||
1815 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1816 | } | - | ||||||||||||||||||||||||
1817 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
1818 | - | |||||||||||||||||||||||||
1819 | // Read the constructor methods. | - | ||||||||||||||||||||||||
1820 | for (index = 0; index < constructorCount; ++index) {
| 1-2 | ||||||||||||||||||||||||
1821 | if (stream.status() != QDataStream::Ok)
| 0-1 | ||||||||||||||||||||||||
1822 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1823 | stream >> name; | - | ||||||||||||||||||||||||
1824 | addConstructor(name); | - | ||||||||||||||||||||||||
1825 | QMetaMethodBuilderPrivate *method&method = &(d->constructors[index]);]; | - | ||||||||||||||||||||||||
1826 | stream >> method->.returnType; | - | ||||||||||||||||||||||||
1827 | stream >> method->.parameterNames; | - | ||||||||||||||||||||||||
1828 | stream >> method->.tag; | - | ||||||||||||||||||||||||
1829 | stream >> method->.attributes; | - | ||||||||||||||||||||||||
1830 | if (method->.methodType() != QMetaMethod::Constructor) {
| 0-1 | ||||||||||||||||||||||||
1831 | // The type must be Constructor. | - | ||||||||||||||||||||||||
1832 | stream.setStatus(QDataStream::ReadCorruptData); | - | ||||||||||||||||||||||||
1833 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1834 | } | - | ||||||||||||||||||||||||
1835 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||||||||
1836 | - | |||||||||||||||||||||||||
1837 | // Read the related meta objects. | - | ||||||||||||||||||||||||
1838 | for (index = 0; index < relatedMetaObjectCount; ++index) {
| 1-2 | ||||||||||||||||||||||||
1839 | if (stream.status() != QDataStream::Ok)
| 0-1 | ||||||||||||||||||||||||
1840 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1841 | stream >> name; | - | ||||||||||||||||||||||||
1842 | cl = resolveClassName(references, name); | - | ||||||||||||||||||||||||
1843 | if (!cl) {
| 0-1 | ||||||||||||||||||||||||
1844 | stream.setStatus(QDataStream::ReadCorruptData); | - | ||||||||||||||||||||||||
1845 | return; never executed: return; | 0 | ||||||||||||||||||||||||
1846 | } | - | ||||||||||||||||||||||||
1847 | addRelatedMetaObject(cl); | - | ||||||||||||||||||||||||
1848 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||||||||
1849 | - | |||||||||||||||||||||||||
1850 | // Read the extra data block, which is reserved for future use. | - | ||||||||||||||||||||||||
1851 | stream >> name; | - | ||||||||||||||||||||||||
1852 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
1853 | - | |||||||||||||||||||||||||
1854 | #endif // !QT_NO_DATASTREAM | - | ||||||||||||||||||||||||
1855 | - | |||||||||||||||||||||||||
1856 | /*! | - | ||||||||||||||||||||||||
1857 | \class QMetaMethodBuilder | - | ||||||||||||||||||||||||
1858 | \inmodule QtCore | - | ||||||||||||||||||||||||
1859 | \internal | - | ||||||||||||||||||||||||
1860 | \brief The QMetaMethodBuilder class enables modifications to a method definition on a meta object builder. | - | ||||||||||||||||||||||||
1861 | */ | - | ||||||||||||||||||||||||
1862 | - | |||||||||||||||||||||||||
1863 | QMetaMethodBuilderPrivate *QMetaMethodBuilder::d_func() const | - | ||||||||||||||||||||||||
1864 | { | - | ||||||||||||||||||||||||
1865 | // Positive indices indicate methods, negative indices indicate constructors. | - | ||||||||||||||||||||||||
1866 | if (_mobj && _index >= 0 && _index < int(_mobj->d->methods.size())()))
| 0-631 | ||||||||||||||||||||||||
1867 | return &(_mobj->d->methods[_index]); executed 528 times by 1 test: return &(_mobj->d->methods[_index]); Executed by:
| 528 | ||||||||||||||||||||||||
1868 | else if (_mobj && -_index >= 1 && -_index <= int(_mobj->d->constructors.size())()))
| 0-103 | ||||||||||||||||||||||||
1869 | return &(_mobj->d->constructors[(-_index) - 1]); executed 103 times by 1 test: return &(_mobj->d->constructors[(-_index) - 1]); Executed by:
| 103 | ||||||||||||||||||||||||
1870 | else | - | ||||||||||||||||||||||||
1871 | return 0; executed 11 times by 1 test: return 0; Executed by:
| 11 | ||||||||||||||||||||||||
1872 | } | - | ||||||||||||||||||||||||
1873 | - | |||||||||||||||||||||||||
1874 | /*! | - | ||||||||||||||||||||||||
1875 | \fn QMetaMethodBuilder::QMetaMethodBuilder() | - | ||||||||||||||||||||||||
1876 | \internal | - | ||||||||||||||||||||||||
1877 | */ | - | ||||||||||||||||||||||||
1878 | - | |||||||||||||||||||||||||
1879 | /*! | - | ||||||||||||||||||||||||
1880 | Returns the index of this method within its QMetaObjectBuilder. | - | ||||||||||||||||||||||||
1881 | */ | - | ||||||||||||||||||||||||
1882 | int QMetaMethodBuilder::index() const | - | ||||||||||||||||||||||||
1883 | { | - | ||||||||||||||||||||||||
1884 | if (_index >= 0) | - | ||||||||||||||||||||||||
1885 | return _index; // Method, signal, or slot | - | ||||||||||||||||||||||||
1886 | else | - | ||||||||||||||||||||||||
1887 | return (-_index) - 1; // Constructor | - | ||||||||||||||||||||||||
1888 | } | - | ||||||||||||||||||||||||
1889 | - | |||||||||||||||||||||||||
1890 | /*! | - | ||||||||||||||||||||||||
1891 | Returns the type of this method (signal, slot, method, or constructor). | - | ||||||||||||||||||||||||
1892 | */ | - | ||||||||||||||||||||||||
1893 | QMetaMethod::MethodType QMetaMethodBuilder::methodType() const | - | ||||||||||||||||||||||||
1894 | { | - | ||||||||||||||||||||||||
1895 | QMetaMethodBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
1896 | if (d) | - | ||||||||||||||||||||||||
1897 | return d->methodType(); | - | ||||||||||||||||||||||||
1898 | else | - | ||||||||||||||||||||||||
1899 | return QMetaMethod::Method; | - | ||||||||||||||||||||||||
1900 | } | - | ||||||||||||||||||||||||
1901 | - | |||||||||||||||||||||||||
1902 | /*! | - | ||||||||||||||||||||||||
1903 | Returns the signature of this method. | - | ||||||||||||||||||||||||
1904 | - | |||||||||||||||||||||||||
1905 | \sa parameterNames(), returnType() | - | ||||||||||||||||||||||||
1906 | */ | - | ||||||||||||||||||||||||
1907 | QByteArray QMetaMethodBuilder::signature() const | - | ||||||||||||||||||||||||
1908 | { | - | ||||||||||||||||||||||||
1909 | QMetaMethodBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
1910 | if (d) | - | ||||||||||||||||||||||||
1911 | return d->signature; | - | ||||||||||||||||||||||||
1912 | else | - | ||||||||||||||||||||||||
1913 | return QByteArray(); | - | ||||||||||||||||||||||||
1914 | } | - | ||||||||||||||||||||||||
1915 | - | |||||||||||||||||||||||||
1916 | /*! | - | ||||||||||||||||||||||||
1917 | Returns the return type for this method; empty if the method's | - | ||||||||||||||||||||||||
1918 | return type is \c{void}. | - | ||||||||||||||||||||||||
1919 | - | |||||||||||||||||||||||||
1920 | \sa setReturnType(), signature() | - | ||||||||||||||||||||||||
1921 | */ | - | ||||||||||||||||||||||||
1922 | QByteArray QMetaMethodBuilder::returnType() const | - | ||||||||||||||||||||||||
1923 | { | - | ||||||||||||||||||||||||
1924 | QMetaMethodBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
1925 | if (d) | - | ||||||||||||||||||||||||
1926 | return d->returnType; | - | ||||||||||||||||||||||||
1927 | else | - | ||||||||||||||||||||||||
1928 | return QByteArray(); | - | ||||||||||||||||||||||||
1929 | } | - | ||||||||||||||||||||||||
1930 | - | |||||||||||||||||||||||||
1931 | /*! | - | ||||||||||||||||||||||||
1932 | Sets the return type for this method to \a value. If \a value | - | ||||||||||||||||||||||||
1933 | is empty, then the method's return type is \c{void}. The \a value | - | ||||||||||||||||||||||||
1934 | will be normalized before it is added to the method. | - | ||||||||||||||||||||||||
1935 | - | |||||||||||||||||||||||||
1936 | \sa returnType(), parameterTypes(), signature() | - | ||||||||||||||||||||||||
1937 | */ | - | ||||||||||||||||||||||||
1938 | void QMetaMethodBuilder::setReturnType(const QByteArray& value) | - | ||||||||||||||||||||||||
1939 | { | - | ||||||||||||||||||||||||
1940 | QMetaMethodBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
1941 | if (d) | - | ||||||||||||||||||||||||
1942 | d->returnType = QMetaObject::normalizedType(value); | - | ||||||||||||||||||||||||
1943 | } | - | ||||||||||||||||||||||||
1944 | - | |||||||||||||||||||||||||
1945 | /*! | - | ||||||||||||||||||||||||
1946 | Returns the list of parameter types for this method. | - | ||||||||||||||||||||||||
1947 | - | |||||||||||||||||||||||||
1948 | \sa returnType(), parameterNames() | - | ||||||||||||||||||||||||
1949 | */ | - | ||||||||||||||||||||||||
1950 | QList<QByteArray> QMetaMethodBuilder::parameterTypes() const | - | ||||||||||||||||||||||||
1951 | { | - | ||||||||||||||||||||||||
1952 | QMetaMethodBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
1953 | if (d) | - | ||||||||||||||||||||||||
1954 | return d->parameterTypes(); | - | ||||||||||||||||||||||||
1955 | else | - | ||||||||||||||||||||||||
1956 | return QList<QByteArray>(); | - | ||||||||||||||||||||||||
1957 | } | - | ||||||||||||||||||||||||
1958 | - | |||||||||||||||||||||||||
1959 | /*! | - | ||||||||||||||||||||||||
1960 | Returns the list of parameter names for this method. | - | ||||||||||||||||||||||||
1961 | - | |||||||||||||||||||||||||
1962 | \sa setParameterNames() | - | ||||||||||||||||||||||||
1963 | */ | - | ||||||||||||||||||||||||
1964 | QList<QByteArray> QMetaMethodBuilder::parameterNames() const | - | ||||||||||||||||||||||||
1965 | { | - | ||||||||||||||||||||||||
1966 | QMetaMethodBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
1967 | if (d) | - | ||||||||||||||||||||||||
1968 | return d->parameterNames; | - | ||||||||||||||||||||||||
1969 | else | - | ||||||||||||||||||||||||
1970 | return QList<QByteArray>(); | - | ||||||||||||||||||||||||
1971 | } | - | ||||||||||||||||||||||||
1972 | - | |||||||||||||||||||||||||
1973 | /*! | - | ||||||||||||||||||||||||
1974 | Sets the list of parameter names for this method to \a value. | - | ||||||||||||||||||||||||
1975 | - | |||||||||||||||||||||||||
1976 | \sa parameterNames() | - | ||||||||||||||||||||||||
1977 | */ | - | ||||||||||||||||||||||||
1978 | void QMetaMethodBuilder::setParameterNames(const QList<QByteArray>& value) | - | ||||||||||||||||||||||||
1979 | { | - | ||||||||||||||||||||||||
1980 | QMetaMethodBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
1981 | if (d) | - | ||||||||||||||||||||||||
1982 | d->parameterNames = value; | - | ||||||||||||||||||||||||
1983 | } | - | ||||||||||||||||||||||||
1984 | - | |||||||||||||||||||||||||
1985 | /*! | - | ||||||||||||||||||||||||
1986 | Returns the tag associated with this method. | - | ||||||||||||||||||||||||
1987 | - | |||||||||||||||||||||||||
1988 | \sa setTag() | - | ||||||||||||||||||||||||
1989 | */ | - | ||||||||||||||||||||||||
1990 | QByteArray QMetaMethodBuilder::tag() const | - | ||||||||||||||||||||||||
1991 | { | - | ||||||||||||||||||||||||
1992 | QMetaMethodBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
1993 | if (d) | - | ||||||||||||||||||||||||
1994 | return d->tag; | - | ||||||||||||||||||||||||
1995 | else | - | ||||||||||||||||||||||||
1996 | return QByteArray(); | - | ||||||||||||||||||||||||
1997 | } | - | ||||||||||||||||||||||||
1998 | - | |||||||||||||||||||||||||
1999 | /*! | - | ||||||||||||||||||||||||
2000 | Sets the tag associated with this method to \a value. | - | ||||||||||||||||||||||||
2001 | - | |||||||||||||||||||||||||
2002 | \sa setTag() | - | ||||||||||||||||||||||||
2003 | */ | - | ||||||||||||||||||||||||
2004 | void QMetaMethodBuilder::setTag(const QByteArray& value) | - | ||||||||||||||||||||||||
2005 | { | - | ||||||||||||||||||||||||
2006 | QMetaMethodBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2007 | if (d) | - | ||||||||||||||||||||||||
2008 | d->tag = value; | - | ||||||||||||||||||||||||
2009 | } | - | ||||||||||||||||||||||||
2010 | - | |||||||||||||||||||||||||
2011 | /*! | - | ||||||||||||||||||||||||
2012 | Returns the access specification of this method (private, protected, | - | ||||||||||||||||||||||||
2013 | or public). The default value is QMetaMethod::Public for methods, | - | ||||||||||||||||||||||||
2014 | slots, signals and constructors. | - | ||||||||||||||||||||||||
2015 | - | |||||||||||||||||||||||||
2016 | \sa setAccess() | - | ||||||||||||||||||||||||
2017 | */ | - | ||||||||||||||||||||||||
2018 | QMetaMethod::Access QMetaMethodBuilder::access() const | - | ||||||||||||||||||||||||
2019 | { | - | ||||||||||||||||||||||||
2020 | QMetaMethodBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2021 | if (d) | - | ||||||||||||||||||||||||
2022 | return d->access(); | - | ||||||||||||||||||||||||
2023 | else | - | ||||||||||||||||||||||||
2024 | return QMetaMethod::Public; | - | ||||||||||||||||||||||||
2025 | } | - | ||||||||||||||||||||||||
2026 | - | |||||||||||||||||||||||||
2027 | /*! | - | ||||||||||||||||||||||||
2028 | Sets the access specification of this method (private, protected, | - | ||||||||||||||||||||||||
2029 | or public) to \a value. If the method is a signal, this function | - | ||||||||||||||||||||||||
2030 | will be ignored. | - | ||||||||||||||||||||||||
2031 | - | |||||||||||||||||||||||||
2032 | \sa access() | - | ||||||||||||||||||||||||
2033 | */ | - | ||||||||||||||||||||||||
2034 | void QMetaMethodBuilder::setAccess(QMetaMethod::Access value) | - | ||||||||||||||||||||||||
2035 | { | - | ||||||||||||||||||||||||
2036 | QMetaMethodBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2037 | if (d && d->methodType() != QMetaMethod::Signal) | - | ||||||||||||||||||||||||
2038 | d->setAccess(value); | - | ||||||||||||||||||||||||
2039 | } | - | ||||||||||||||||||||||||
2040 | - | |||||||||||||||||||||||||
2041 | /*! | - | ||||||||||||||||||||||||
2042 | Returns the additional attributes for this method. | - | ||||||||||||||||||||||||
2043 | - | |||||||||||||||||||||||||
2044 | \sa setAttributes() | - | ||||||||||||||||||||||||
2045 | */ | - | ||||||||||||||||||||||||
2046 | int QMetaMethodBuilder::attributes() const | - | ||||||||||||||||||||||||
2047 | { | - | ||||||||||||||||||||||||
2048 | QMetaMethodBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2049 | if (d) | - | ||||||||||||||||||||||||
2050 | return (d->attributes >> 4); | - | ||||||||||||||||||||||||
2051 | else | - | ||||||||||||||||||||||||
2052 | return 0; | - | ||||||||||||||||||||||||
2053 | } | - | ||||||||||||||||||||||||
2054 | - | |||||||||||||||||||||||||
2055 | /*! | - | ||||||||||||||||||||||||
2056 | Sets the additional attributes for this method to \a value. | - | ||||||||||||||||||||||||
2057 | - | |||||||||||||||||||||||||
2058 | \sa attributes() | - | ||||||||||||||||||||||||
2059 | */ | - | ||||||||||||||||||||||||
2060 | void QMetaMethodBuilder::setAttributes(int value) | - | ||||||||||||||||||||||||
2061 | { | - | ||||||||||||||||||||||||
2062 | QMetaMethodBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2063 | if (d) | - | ||||||||||||||||||||||||
2064 | d->attributes = ((d->attributes & 0x0f) | (value << 4)); | - | ||||||||||||||||||||||||
2065 | } | - | ||||||||||||||||||||||||
2066 | - | |||||||||||||||||||||||||
2067 | /*! | - | ||||||||||||||||||||||||
2068 | Returns the revision of this method. | - | ||||||||||||||||||||||||
2069 | - | |||||||||||||||||||||||||
2070 | \sa setRevision() | - | ||||||||||||||||||||||||
2071 | */ | - | ||||||||||||||||||||||||
2072 | int QMetaMethodBuilder::revision() const | - | ||||||||||||||||||||||||
2073 | { | - | ||||||||||||||||||||||||
2074 | QMetaMethodBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2075 | if (d) | - | ||||||||||||||||||||||||
2076 | return d->revision; | - | ||||||||||||||||||||||||
2077 | return 0; | - | ||||||||||||||||||||||||
2078 | - | |||||||||||||||||||||||||
2079 | } | - | ||||||||||||||||||||||||
2080 | - | |||||||||||||||||||||||||
2081 | /*! | - | ||||||||||||||||||||||||
2082 | Sets the \a revision of this method. | - | ||||||||||||||||||||||||
2083 | - | |||||||||||||||||||||||||
2084 | \sa revision() | - | ||||||||||||||||||||||||
2085 | */ | - | ||||||||||||||||||||||||
2086 | void QMetaMethodBuilder::setRevision(int revision) | - | ||||||||||||||||||||||||
2087 | { | - | ||||||||||||||||||||||||
2088 | QMetaMethodBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2089 | if (d) { | - | ||||||||||||||||||||||||
2090 | d->revision = revision; | - | ||||||||||||||||||||||||
2091 | if (revision) | - | ||||||||||||||||||||||||
2092 | d->attributes |= MethodRevisioned; | - | ||||||||||||||||||||||||
2093 | else | - | ||||||||||||||||||||||||
2094 | d->attributes &= ~MethodRevisioned; | - | ||||||||||||||||||||||||
2095 | } | - | ||||||||||||||||||||||||
2096 | } | - | ||||||||||||||||||||||||
2097 | - | |||||||||||||||||||||||||
2098 | /*! | - | ||||||||||||||||||||||||
2099 | \class QMetaPropertyBuilder | - | ||||||||||||||||||||||||
2100 | \inmodule QtCore | - | ||||||||||||||||||||||||
2101 | \internal | - | ||||||||||||||||||||||||
2102 | \brief The QMetaPropertyBuilder class enables modifications to a property definition on a meta object builder. | - | ||||||||||||||||||||||||
2103 | */ | - | ||||||||||||||||||||||||
2104 | - | |||||||||||||||||||||||||
2105 | QMetaPropertyBuilderPrivate *QMetaPropertyBuilder::d_func() const | - | ||||||||||||||||||||||||
2106 | { | - | ||||||||||||||||||||||||
2107 | if (_mobj && _index >= 0 && _index < int(_mobj->d->properties.size())()))
| 0-840 | ||||||||||||||||||||||||
2108 | return &(_mobj->d->properties[_index]); executed 840 times by 1 test: return &(_mobj->d->properties[_index]); Executed by:
| 840 | ||||||||||||||||||||||||
2109 | else | - | ||||||||||||||||||||||||
2110 | return 0; executed 17 times by 1 test: return 0; Executed by:
| 17 | ||||||||||||||||||||||||
2111 | } | - | ||||||||||||||||||||||||
2112 | - | |||||||||||||||||||||||||
2113 | /*! | - | ||||||||||||||||||||||||
2114 | \fn QMetaPropertyBuilder::QMetaPropertyBuilder() | - | ||||||||||||||||||||||||
2115 | \internal | - | ||||||||||||||||||||||||
2116 | */ | - | ||||||||||||||||||||||||
2117 | - | |||||||||||||||||||||||||
2118 | /*! | - | ||||||||||||||||||||||||
2119 | \fn int QMetaPropertyBuilder::index() const | - | ||||||||||||||||||||||||
2120 | - | |||||||||||||||||||||||||
2121 | Returns the index of this property within its QMetaObjectBuilder. | - | ||||||||||||||||||||||||
2122 | */ | - | ||||||||||||||||||||||||
2123 | - | |||||||||||||||||||||||||
2124 | /*! | - | ||||||||||||||||||||||||
2125 | Returns the name associated with this property. | - | ||||||||||||||||||||||||
2126 | - | |||||||||||||||||||||||||
2127 | \sa type() | - | ||||||||||||||||||||||||
2128 | */ | - | ||||||||||||||||||||||||
2129 | QByteArray QMetaPropertyBuilder::name() const | - | ||||||||||||||||||||||||
2130 | { | - | ||||||||||||||||||||||||
2131 | QMetaPropertyBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2132 | if (d) | - | ||||||||||||||||||||||||
2133 | return d->name; | - | ||||||||||||||||||||||||
2134 | else | - | ||||||||||||||||||||||||
2135 | return QByteArray(); | - | ||||||||||||||||||||||||
2136 | } | - | ||||||||||||||||||||||||
2137 | - | |||||||||||||||||||||||||
2138 | /*! | - | ||||||||||||||||||||||||
2139 | Returns the type associated with this property. | - | ||||||||||||||||||||||||
2140 | - | |||||||||||||||||||||||||
2141 | \sa name() | - | ||||||||||||||||||||||||
2142 | */ | - | ||||||||||||||||||||||||
2143 | QByteArray QMetaPropertyBuilder::type() const | - | ||||||||||||||||||||||||
2144 | { | - | ||||||||||||||||||||||||
2145 | QMetaPropertyBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2146 | if (d) | - | ||||||||||||||||||||||||
2147 | return d->type; | - | ||||||||||||||||||||||||
2148 | else | - | ||||||||||||||||||||||||
2149 | return QByteArray(); | - | ||||||||||||||||||||||||
2150 | } | - | ||||||||||||||||||||||||
2151 | - | |||||||||||||||||||||||||
2152 | /*! | - | ||||||||||||||||||||||||
2153 | Returns \c true if this property has a notify signal; false otherwise. | - | ||||||||||||||||||||||||
2154 | - | |||||||||||||||||||||||||
2155 | \sa notifySignal(), setNotifySignal(), removeNotifySignal() | - | ||||||||||||||||||||||||
2156 | */ | - | ||||||||||||||||||||||||
2157 | bool QMetaPropertyBuilder::hasNotifySignal() const | - | ||||||||||||||||||||||||
2158 | { | - | ||||||||||||||||||||||||
2159 | QMetaPropertyBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2160 | if (d) | - | ||||||||||||||||||||||||
2161 | return d->flag(Notify); | - | ||||||||||||||||||||||||
2162 | else | - | ||||||||||||||||||||||||
2163 | return false; | - | ||||||||||||||||||||||||
2164 | } | - | ||||||||||||||||||||||||
2165 | - | |||||||||||||||||||||||||
2166 | /*! | - | ||||||||||||||||||||||||
2167 | Returns the notify signal associated with this property. | - | ||||||||||||||||||||||||
2168 | - | |||||||||||||||||||||||||
2169 | \sa hasNotifySignal(), setNotifySignal(), removeNotifySignal() | - | ||||||||||||||||||||||||
2170 | */ | - | ||||||||||||||||||||||||
2171 | QMetaMethodBuilder QMetaPropertyBuilder::notifySignal() const | - | ||||||||||||||||||||||||
2172 | { | - | ||||||||||||||||||||||||
2173 | QMetaPropertyBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2174 | if (d && d->notifySignal >= 0) | - | ||||||||||||||||||||||||
2175 | return QMetaMethodBuilder(_mobj, d->notifySignal); | - | ||||||||||||||||||||||||
2176 | else | - | ||||||||||||||||||||||||
2177 | return QMetaMethodBuilder(); | - | ||||||||||||||||||||||||
2178 | } | - | ||||||||||||||||||||||||
2179 | - | |||||||||||||||||||||||||
2180 | /*! | - | ||||||||||||||||||||||||
2181 | Sets the notify signal associated with this property to \a value. | - | ||||||||||||||||||||||||
2182 | - | |||||||||||||||||||||||||
2183 | \sa hasNotifySignal(), notifySignal(), removeNotifySignal() | - | ||||||||||||||||||||||||
2184 | */ | - | ||||||||||||||||||||||||
2185 | void QMetaPropertyBuilder::setNotifySignal(const QMetaMethodBuilder& value) | - | ||||||||||||||||||||||||
2186 | { | - | ||||||||||||||||||||||||
2187 | QMetaPropertyBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2188 | if (d) { | - | ||||||||||||||||||||||||
2189 | if (value._mobj) { | - | ||||||||||||||||||||||||
2190 | d->notifySignal = value._index; | - | ||||||||||||||||||||||||
2191 | d->setFlag(Notify, true); | - | ||||||||||||||||||||||||
2192 | } else { | - | ||||||||||||||||||||||||
2193 | d->notifySignal = -1; | - | ||||||||||||||||||||||||
2194 | d->setFlag(Notify, false); | - | ||||||||||||||||||||||||
2195 | } | - | ||||||||||||||||||||||||
2196 | } | - | ||||||||||||||||||||||||
2197 | } | - | ||||||||||||||||||||||||
2198 | - | |||||||||||||||||||||||||
2199 | /*! | - | ||||||||||||||||||||||||
2200 | Removes the notify signal from this property. | - | ||||||||||||||||||||||||
2201 | - | |||||||||||||||||||||||||
2202 | \sa hasNotifySignal(), notifySignal(), setNotifySignal() | - | ||||||||||||||||||||||||
2203 | */ | - | ||||||||||||||||||||||||
2204 | void QMetaPropertyBuilder::removeNotifySignal() | - | ||||||||||||||||||||||||
2205 | { | - | ||||||||||||||||||||||||
2206 | QMetaPropertyBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2207 | if (d) { | - | ||||||||||||||||||||||||
2208 | d->notifySignal = -1; | - | ||||||||||||||||||||||||
2209 | d->setFlag(Notify, false); | - | ||||||||||||||||||||||||
2210 | } | - | ||||||||||||||||||||||||
2211 | } | - | ||||||||||||||||||||||||
2212 | - | |||||||||||||||||||||||||
2213 | /*! | - | ||||||||||||||||||||||||
2214 | Returns \c true if this property is readable; otherwise returns \c false. | - | ||||||||||||||||||||||||
2215 | The default value is true. | - | ||||||||||||||||||||||||
2216 | - | |||||||||||||||||||||||||
2217 | \sa setReadable(), isWritable() | - | ||||||||||||||||||||||||
2218 | */ | - | ||||||||||||||||||||||||
2219 | bool QMetaPropertyBuilder::isReadable() const | - | ||||||||||||||||||||||||
2220 | { | - | ||||||||||||||||||||||||
2221 | QMetaPropertyBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2222 | if (d) | - | ||||||||||||||||||||||||
2223 | return d->flag(Readable); | - | ||||||||||||||||||||||||
2224 | else | - | ||||||||||||||||||||||||
2225 | return false; | - | ||||||||||||||||||||||||
2226 | } | - | ||||||||||||||||||||||||
2227 | - | |||||||||||||||||||||||||
2228 | /*! | - | ||||||||||||||||||||||||
2229 | Returns \c true if this property is writable; otherwise returns \c false. | - | ||||||||||||||||||||||||
2230 | The default value is true. | - | ||||||||||||||||||||||||
2231 | - | |||||||||||||||||||||||||
2232 | \sa setWritable(), isReadable() | - | ||||||||||||||||||||||||
2233 | */ | - | ||||||||||||||||||||||||
2234 | bool QMetaPropertyBuilder::isWritable() const | - | ||||||||||||||||||||||||
2235 | { | - | ||||||||||||||||||||||||
2236 | QMetaPropertyBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2237 | if (d) | - | ||||||||||||||||||||||||
2238 | return d->flag(Writable); | - | ||||||||||||||||||||||||
2239 | else | - | ||||||||||||||||||||||||
2240 | return false; | - | ||||||||||||||||||||||||
2241 | } | - | ||||||||||||||||||||||||
2242 | - | |||||||||||||||||||||||||
2243 | /*! | - | ||||||||||||||||||||||||
2244 | Returns \c true if this property can be reset to a default value; otherwise | - | ||||||||||||||||||||||||
2245 | returns \c false. The default value is false. | - | ||||||||||||||||||||||||
2246 | - | |||||||||||||||||||||||||
2247 | \sa setResettable() | - | ||||||||||||||||||||||||
2248 | */ | - | ||||||||||||||||||||||||
2249 | bool QMetaPropertyBuilder::isResettable() const | - | ||||||||||||||||||||||||
2250 | { | - | ||||||||||||||||||||||||
2251 | QMetaPropertyBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2252 | if (d) | - | ||||||||||||||||||||||||
2253 | return d->flag(Resettable); | - | ||||||||||||||||||||||||
2254 | else | - | ||||||||||||||||||||||||
2255 | return false; | - | ||||||||||||||||||||||||
2256 | } | - | ||||||||||||||||||||||||
2257 | - | |||||||||||||||||||||||||
2258 | /*! | - | ||||||||||||||||||||||||
2259 | Returns \c true if this property is designable; otherwise returns \c false. | - | ||||||||||||||||||||||||
2260 | This default value is false. | - | ||||||||||||||||||||||||
2261 | - | |||||||||||||||||||||||||
2262 | \sa setDesignable(), isScriptable(), isStored() | - | ||||||||||||||||||||||||
2263 | */ | - | ||||||||||||||||||||||||
2264 | bool QMetaPropertyBuilder::isDesignable() const | - | ||||||||||||||||||||||||
2265 | { | - | ||||||||||||||||||||||||
2266 | QMetaPropertyBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2267 | if (d) | - | ||||||||||||||||||||||||
2268 | return d->flag(Designable); | - | ||||||||||||||||||||||||
2269 | else | - | ||||||||||||||||||||||||
2270 | return false; | - | ||||||||||||||||||||||||
2271 | } | - | ||||||||||||||||||||||||
2272 | - | |||||||||||||||||||||||||
2273 | /*! | - | ||||||||||||||||||||||||
2274 | Returns \c true if the property is scriptable; otherwise returns \c false. | - | ||||||||||||||||||||||||
2275 | This default value is true. | - | ||||||||||||||||||||||||
2276 | - | |||||||||||||||||||||||||
2277 | \sa setScriptable(), isDesignable(), isStored() | - | ||||||||||||||||||||||||
2278 | */ | - | ||||||||||||||||||||||||
2279 | bool QMetaPropertyBuilder::isScriptable() const | - | ||||||||||||||||||||||||
2280 | { | - | ||||||||||||||||||||||||
2281 | QMetaPropertyBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2282 | if (d) | - | ||||||||||||||||||||||||
2283 | return d->flag(Scriptable); | - | ||||||||||||||||||||||||
2284 | else | - | ||||||||||||||||||||||||
2285 | return false; | - | ||||||||||||||||||||||||
2286 | } | - | ||||||||||||||||||||||||
2287 | - | |||||||||||||||||||||||||
2288 | /*! | - | ||||||||||||||||||||||||
2289 | Returns \c true if the property is stored; otherwise returns \c false. | - | ||||||||||||||||||||||||
2290 | This default value is false. | - | ||||||||||||||||||||||||
2291 | - | |||||||||||||||||||||||||
2292 | \sa setStored(), isDesignable(), isScriptable() | - | ||||||||||||||||||||||||
2293 | */ | - | ||||||||||||||||||||||||
2294 | bool QMetaPropertyBuilder::isStored() const | - | ||||||||||||||||||||||||
2295 | { | - | ||||||||||||||||||||||||
2296 | QMetaPropertyBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2297 | if (d) | - | ||||||||||||||||||||||||
2298 | return d->flag(Stored); | - | ||||||||||||||||||||||||
2299 | else | - | ||||||||||||||||||||||||
2300 | return false; | - | ||||||||||||||||||||||||
2301 | } | - | ||||||||||||||||||||||||
2302 | - | |||||||||||||||||||||||||
2303 | /*! | - | ||||||||||||||||||||||||
2304 | Returns \c true if the property is editable; otherwise returns \c false. | - | ||||||||||||||||||||||||
2305 | This default value is false. | - | ||||||||||||||||||||||||
2306 | - | |||||||||||||||||||||||||
2307 | \sa setEditable(), isDesignable(), isScriptable(), isStored() | - | ||||||||||||||||||||||||
2308 | */ | - | ||||||||||||||||||||||||
2309 | bool QMetaPropertyBuilder::isEditable() const | - | ||||||||||||||||||||||||
2310 | { | - | ||||||||||||||||||||||||
2311 | QMetaPropertyBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2312 | if (d) | - | ||||||||||||||||||||||||
2313 | return d->flag(Editable); | - | ||||||||||||||||||||||||
2314 | else | - | ||||||||||||||||||||||||
2315 | return false; | - | ||||||||||||||||||||||||
2316 | } | - | ||||||||||||||||||||||||
2317 | - | |||||||||||||||||||||||||
2318 | /*! | - | ||||||||||||||||||||||||
2319 | Returns \c true if this property is designated as the \c USER | - | ||||||||||||||||||||||||
2320 | property, i.e., the one that the user can edit or that is | - | ||||||||||||||||||||||||
2321 | significant in some other way. Otherwise it returns | - | ||||||||||||||||||||||||
2322 | false. This default value is false. | - | ||||||||||||||||||||||||
2323 | - | |||||||||||||||||||||||||
2324 | \sa setUser(), isDesignable(), isScriptable() | - | ||||||||||||||||||||||||
2325 | */ | - | ||||||||||||||||||||||||
2326 | bool QMetaPropertyBuilder::isUser() const | - | ||||||||||||||||||||||||
2327 | { | - | ||||||||||||||||||||||||
2328 | QMetaPropertyBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2329 | if (d) | - | ||||||||||||||||||||||||
2330 | return d->flag(User); | - | ||||||||||||||||||||||||
2331 | else | - | ||||||||||||||||||||||||
2332 | return false; | - | ||||||||||||||||||||||||
2333 | } | - | ||||||||||||||||||||||||
2334 | - | |||||||||||||||||||||||||
2335 | /*! | - | ||||||||||||||||||||||||
2336 | Returns \c true if the property has a C++ setter function that | - | ||||||||||||||||||||||||
2337 | follows Qt's standard "name" / "setName" pattern. Designer and uic | - | ||||||||||||||||||||||||
2338 | query hasStdCppSet() in order to avoid expensive | - | ||||||||||||||||||||||||
2339 | QObject::setProperty() calls. All properties in Qt [should] follow | - | ||||||||||||||||||||||||
2340 | this pattern. The default value is false. | - | ||||||||||||||||||||||||
2341 | - | |||||||||||||||||||||||||
2342 | \sa setStdCppSet() | - | ||||||||||||||||||||||||
2343 | */ | - | ||||||||||||||||||||||||
2344 | bool QMetaPropertyBuilder::hasStdCppSet() const | - | ||||||||||||||||||||||||
2345 | { | - | ||||||||||||||||||||||||
2346 | QMetaPropertyBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2347 | if (d) | - | ||||||||||||||||||||||||
2348 | return d->flag(StdCppSet); | - | ||||||||||||||||||||||||
2349 | else | - | ||||||||||||||||||||||||
2350 | return false; | - | ||||||||||||||||||||||||
2351 | } | - | ||||||||||||||||||||||||
2352 | - | |||||||||||||||||||||||||
2353 | /*! | - | ||||||||||||||||||||||||
2354 | Returns \c true if the property is an enumerator or flag type; | - | ||||||||||||||||||||||||
2355 | otherwise returns \c false. This default value is false. | - | ||||||||||||||||||||||||
2356 | - | |||||||||||||||||||||||||
2357 | \sa setEnumOrFlag() | - | ||||||||||||||||||||||||
2358 | */ | - | ||||||||||||||||||||||||
2359 | bool QMetaPropertyBuilder::isEnumOrFlag() const | - | ||||||||||||||||||||||||
2360 | { | - | ||||||||||||||||||||||||
2361 | QMetaPropertyBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2362 | if (d) | - | ||||||||||||||||||||||||
2363 | return d->flag(EnumOrFlag); | - | ||||||||||||||||||||||||
2364 | else | - | ||||||||||||||||||||||||
2365 | return false; | - | ||||||||||||||||||||||||
2366 | } | - | ||||||||||||||||||||||||
2367 | - | |||||||||||||||||||||||||
2368 | /*! | - | ||||||||||||||||||||||||
2369 | Returns \c true if the property is constant; otherwise returns \c false. | - | ||||||||||||||||||||||||
2370 | The default value is false. | - | ||||||||||||||||||||||||
2371 | */ | - | ||||||||||||||||||||||||
2372 | bool QMetaPropertyBuilder::isConstant() const | - | ||||||||||||||||||||||||
2373 | { | - | ||||||||||||||||||||||||
2374 | QMetaPropertyBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2375 | if (d) | - | ||||||||||||||||||||||||
2376 | return d->flag(Constant); | - | ||||||||||||||||||||||||
2377 | else | - | ||||||||||||||||||||||||
2378 | return false; | - | ||||||||||||||||||||||||
2379 | } | - | ||||||||||||||||||||||||
2380 | - | |||||||||||||||||||||||||
2381 | /*! | - | ||||||||||||||||||||||||
2382 | Returns \c true if the property is final; otherwise returns \c false. | - | ||||||||||||||||||||||||
2383 | The default value is false. | - | ||||||||||||||||||||||||
2384 | */ | - | ||||||||||||||||||||||||
2385 | bool QMetaPropertyBuilder::isFinal() const | - | ||||||||||||||||||||||||
2386 | { | - | ||||||||||||||||||||||||
2387 | QMetaPropertyBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2388 | if (d) | - | ||||||||||||||||||||||||
2389 | return d->flag(Final); | - | ||||||||||||||||||||||||
2390 | else | - | ||||||||||||||||||||||||
2391 | return false; | - | ||||||||||||||||||||||||
2392 | } | - | ||||||||||||||||||||||||
2393 | - | |||||||||||||||||||||||||
2394 | /*! | - | ||||||||||||||||||||||||
2395 | Sets this property to readable if \a value is true. | - | ||||||||||||||||||||||||
2396 | - | |||||||||||||||||||||||||
2397 | \sa isReadable(), setWritable() | - | ||||||||||||||||||||||||
2398 | */ | - | ||||||||||||||||||||||||
2399 | void QMetaPropertyBuilder::setReadable(bool value) | - | ||||||||||||||||||||||||
2400 | { | - | ||||||||||||||||||||||||
2401 | QMetaPropertyBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2402 | if (d) | - | ||||||||||||||||||||||||
2403 | d->setFlag(Readable, value); | - | ||||||||||||||||||||||||
2404 | } | - | ||||||||||||||||||||||||
2405 | - | |||||||||||||||||||||||||
2406 | /*! | - | ||||||||||||||||||||||||
2407 | Sets this property to writable if \a value is true. | - | ||||||||||||||||||||||||
2408 | - | |||||||||||||||||||||||||
2409 | \sa isWritable(), setReadable() | - | ||||||||||||||||||||||||
2410 | */ | - | ||||||||||||||||||||||||
2411 | void QMetaPropertyBuilder::setWritable(bool value) | - | ||||||||||||||||||||||||
2412 | { | - | ||||||||||||||||||||||||
2413 | QMetaPropertyBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2414 | if (d) | - | ||||||||||||||||||||||||
2415 | d->setFlag(Writable, value); | - | ||||||||||||||||||||||||
2416 | } | - | ||||||||||||||||||||||||
2417 | - | |||||||||||||||||||||||||
2418 | /*! | - | ||||||||||||||||||||||||
2419 | Sets this property to resettable if \a value is true. | - | ||||||||||||||||||||||||
2420 | - | |||||||||||||||||||||||||
2421 | \sa isResettable() | - | ||||||||||||||||||||||||
2422 | */ | - | ||||||||||||||||||||||||
2423 | void QMetaPropertyBuilder::setResettable(bool value) | - | ||||||||||||||||||||||||
2424 | { | - | ||||||||||||||||||||||||
2425 | QMetaPropertyBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2426 | if (d) | - | ||||||||||||||||||||||||
2427 | d->setFlag(Resettable, value); | - | ||||||||||||||||||||||||
2428 | } | - | ||||||||||||||||||||||||
2429 | - | |||||||||||||||||||||||||
2430 | /*! | - | ||||||||||||||||||||||||
2431 | Sets this property to designable if \a value is true. | - | ||||||||||||||||||||||||
2432 | - | |||||||||||||||||||||||||
2433 | \sa isDesignable(), setScriptable(), setStored() | - | ||||||||||||||||||||||||
2434 | */ | - | ||||||||||||||||||||||||
2435 | void QMetaPropertyBuilder::setDesignable(bool value) | - | ||||||||||||||||||||||||
2436 | { | - | ||||||||||||||||||||||||
2437 | QMetaPropertyBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2438 | if (d) | - | ||||||||||||||||||||||||
2439 | d->setFlag(Designable, value); | - | ||||||||||||||||||||||||
2440 | } | - | ||||||||||||||||||||||||
2441 | - | |||||||||||||||||||||||||
2442 | /*! | - | ||||||||||||||||||||||||
2443 | Sets this property to scriptable if \a value is true. | - | ||||||||||||||||||||||||
2444 | - | |||||||||||||||||||||||||
2445 | \sa isScriptable(), setDesignable(), setStored() | - | ||||||||||||||||||||||||
2446 | */ | - | ||||||||||||||||||||||||
2447 | void QMetaPropertyBuilder::setScriptable(bool value) | - | ||||||||||||||||||||||||
2448 | { | - | ||||||||||||||||||||||||
2449 | QMetaPropertyBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2450 | if (d) | - | ||||||||||||||||||||||||
2451 | d->setFlag(Scriptable, value); | - | ||||||||||||||||||||||||
2452 | } | - | ||||||||||||||||||||||||
2453 | - | |||||||||||||||||||||||||
2454 | /*! | - | ||||||||||||||||||||||||
2455 | Sets this property to storable if \a value is true. | - | ||||||||||||||||||||||||
2456 | - | |||||||||||||||||||||||||
2457 | \sa isStored(), setDesignable(), setScriptable() | - | ||||||||||||||||||||||||
2458 | */ | - | ||||||||||||||||||||||||
2459 | void QMetaPropertyBuilder::setStored(bool value) | - | ||||||||||||||||||||||||
2460 | { | - | ||||||||||||||||||||||||
2461 | QMetaPropertyBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2462 | if (d) | - | ||||||||||||||||||||||||
2463 | d->setFlag(Stored, value); | - | ||||||||||||||||||||||||
2464 | } | - | ||||||||||||||||||||||||
2465 | - | |||||||||||||||||||||||||
2466 | /*! | - | ||||||||||||||||||||||||
2467 | Sets this property to editable if \a value is true. | - | ||||||||||||||||||||||||
2468 | - | |||||||||||||||||||||||||
2469 | \sa isEditable(), setDesignable(), setScriptable(), setStored() | - | ||||||||||||||||||||||||
2470 | */ | - | ||||||||||||||||||||||||
2471 | void QMetaPropertyBuilder::setEditable(bool value) | - | ||||||||||||||||||||||||
2472 | { | - | ||||||||||||||||||||||||
2473 | QMetaPropertyBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2474 | if (d) | - | ||||||||||||||||||||||||
2475 | d->setFlag(Editable, value); | - | ||||||||||||||||||||||||
2476 | } | - | ||||||||||||||||||||||||
2477 | - | |||||||||||||||||||||||||
2478 | /*! | - | ||||||||||||||||||||||||
2479 | Sets the \c USER flag on this property to \a value. | - | ||||||||||||||||||||||||
2480 | - | |||||||||||||||||||||||||
2481 | \sa isUser(), setDesignable(), setScriptable() | - | ||||||||||||||||||||||||
2482 | */ | - | ||||||||||||||||||||||||
2483 | void QMetaPropertyBuilder::setUser(bool value) | - | ||||||||||||||||||||||||
2484 | { | - | ||||||||||||||||||||||||
2485 | QMetaPropertyBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2486 | if (d) | - | ||||||||||||||||||||||||
2487 | d->setFlag(User, value); | - | ||||||||||||||||||||||||
2488 | } | - | ||||||||||||||||||||||||
2489 | - | |||||||||||||||||||||||||
2490 | /*! | - | ||||||||||||||||||||||||
2491 | Sets the C++ setter flag on this property to \a value, which is | - | ||||||||||||||||||||||||
2492 | true if the property has a C++ setter function that follows Qt's | - | ||||||||||||||||||||||||
2493 | standard "name" / "setName" pattern. | - | ||||||||||||||||||||||||
2494 | - | |||||||||||||||||||||||||
2495 | \sa hasStdCppSet() | - | ||||||||||||||||||||||||
2496 | */ | - | ||||||||||||||||||||||||
2497 | void QMetaPropertyBuilder::setStdCppSet(bool value) | - | ||||||||||||||||||||||||
2498 | { | - | ||||||||||||||||||||||||
2499 | QMetaPropertyBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2500 | if (d) | - | ||||||||||||||||||||||||
2501 | d->setFlag(StdCppSet, value); | - | ||||||||||||||||||||||||
2502 | } | - | ||||||||||||||||||||||||
2503 | - | |||||||||||||||||||||||||
2504 | /*! | - | ||||||||||||||||||||||||
2505 | Sets this property to be of an enumerator or flag type if | - | ||||||||||||||||||||||||
2506 | \a value is true. | - | ||||||||||||||||||||||||
2507 | - | |||||||||||||||||||||||||
2508 | \sa isEnumOrFlag() | - | ||||||||||||||||||||||||
2509 | */ | - | ||||||||||||||||||||||||
2510 | void QMetaPropertyBuilder::setEnumOrFlag(bool value) | - | ||||||||||||||||||||||||
2511 | { | - | ||||||||||||||||||||||||
2512 | QMetaPropertyBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2513 | if (d) | - | ||||||||||||||||||||||||
2514 | d->setFlag(EnumOrFlag, value); | - | ||||||||||||||||||||||||
2515 | } | - | ||||||||||||||||||||||||
2516 | - | |||||||||||||||||||||||||
2517 | /*! | - | ||||||||||||||||||||||||
2518 | Sets the \c CONSTANT flag on this property to \a value. | - | ||||||||||||||||||||||||
2519 | - | |||||||||||||||||||||||||
2520 | \sa isConstant() | - | ||||||||||||||||||||||||
2521 | */ | - | ||||||||||||||||||||||||
2522 | void QMetaPropertyBuilder::setConstant(bool value) | - | ||||||||||||||||||||||||
2523 | { | - | ||||||||||||||||||||||||
2524 | QMetaPropertyBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2525 | if (d) | - | ||||||||||||||||||||||||
2526 | d->setFlag(Constant, value); | - | ||||||||||||||||||||||||
2527 | } | - | ||||||||||||||||||||||||
2528 | - | |||||||||||||||||||||||||
2529 | /*! | - | ||||||||||||||||||||||||
2530 | Sets the \c FINAL flag on this property to \a value. | - | ||||||||||||||||||||||||
2531 | - | |||||||||||||||||||||||||
2532 | \sa isFinal() | - | ||||||||||||||||||||||||
2533 | */ | - | ||||||||||||||||||||||||
2534 | void QMetaPropertyBuilder::setFinal(bool value) | - | ||||||||||||||||||||||||
2535 | { | - | ||||||||||||||||||||||||
2536 | QMetaPropertyBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2537 | if (d) | - | ||||||||||||||||||||||||
2538 | d->setFlag(Final, value); | - | ||||||||||||||||||||||||
2539 | } | - | ||||||||||||||||||||||||
2540 | - | |||||||||||||||||||||||||
2541 | /*! | - | ||||||||||||||||||||||||
2542 | Returns the revision of this property. | - | ||||||||||||||||||||||||
2543 | - | |||||||||||||||||||||||||
2544 | \sa setRevision() | - | ||||||||||||||||||||||||
2545 | */ | - | ||||||||||||||||||||||||
2546 | int QMetaPropertyBuilder::revision() const | - | ||||||||||||||||||||||||
2547 | { | - | ||||||||||||||||||||||||
2548 | QMetaPropertyBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2549 | if (d) | - | ||||||||||||||||||||||||
2550 | return d->revision; | - | ||||||||||||||||||||||||
2551 | return 0; | - | ||||||||||||||||||||||||
2552 | - | |||||||||||||||||||||||||
2553 | } | - | ||||||||||||||||||||||||
2554 | - | |||||||||||||||||||||||||
2555 | /*! | - | ||||||||||||||||||||||||
2556 | Sets the \a revision of this property. | - | ||||||||||||||||||||||||
2557 | - | |||||||||||||||||||||||||
2558 | \sa revision() | - | ||||||||||||||||||||||||
2559 | */ | - | ||||||||||||||||||||||||
2560 | void QMetaPropertyBuilder::setRevision(int revision) | - | ||||||||||||||||||||||||
2561 | { | - | ||||||||||||||||||||||||
2562 | QMetaPropertyBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2563 | if (d) { | - | ||||||||||||||||||||||||
2564 | d->revision = revision; | - | ||||||||||||||||||||||||
2565 | d->setFlag(Revisioned, revision != 0); | - | ||||||||||||||||||||||||
2566 | } | - | ||||||||||||||||||||||||
2567 | } | - | ||||||||||||||||||||||||
2568 | - | |||||||||||||||||||||||||
2569 | - | |||||||||||||||||||||||||
2570 | /*! | - | ||||||||||||||||||||||||
2571 | \class QMetaEnumBuilder | - | ||||||||||||||||||||||||
2572 | \inmodule QtCore | - | ||||||||||||||||||||||||
2573 | \internal | - | ||||||||||||||||||||||||
2574 | \brief The QMetaEnumBuilder class enables modifications to an enumerator definition on a meta object builder. | - | ||||||||||||||||||||||||
2575 | */ | - | ||||||||||||||||||||||||
2576 | - | |||||||||||||||||||||||||
2577 | QMetaEnumBuilderPrivate *QMetaEnumBuilder::d_func() const | - | ||||||||||||||||||||||||
2578 | { | - | ||||||||||||||||||||||||
2579 | if (_mobj && _index >= 0 && _index < int(_mobj->d->enumerators.size())()))
| 0-89 | ||||||||||||||||||||||||
2580 | return &(_mobj->d->enumerators[_index]); executed 89 times by 1 test: return &(_mobj->d->enumerators[_index]); Executed by:
| 89 | ||||||||||||||||||||||||
2581 | else | - | ||||||||||||||||||||||||
2582 | return 0; executed 1 time by 1 test: return 0; Executed by:
| 1 | ||||||||||||||||||||||||
2583 | } | - | ||||||||||||||||||||||||
2584 | - | |||||||||||||||||||||||||
2585 | /*! | - | ||||||||||||||||||||||||
2586 | \fn QMetaEnumBuilder::QMetaEnumBuilder() | - | ||||||||||||||||||||||||
2587 | \internal | - | ||||||||||||||||||||||||
2588 | */ | - | ||||||||||||||||||||||||
2589 | - | |||||||||||||||||||||||||
2590 | /*! | - | ||||||||||||||||||||||||
2591 | \fn int QMetaEnumBuilder::index() const | - | ||||||||||||||||||||||||
2592 | - | |||||||||||||||||||||||||
2593 | Returns the index of this enumerator within its QMetaObjectBuilder. | - | ||||||||||||||||||||||||
2594 | */ | - | ||||||||||||||||||||||||
2595 | - | |||||||||||||||||||||||||
2596 | /*! | - | ||||||||||||||||||||||||
2597 | Returns the name of the enumerator (without the scope). | - | ||||||||||||||||||||||||
2598 | */ | - | ||||||||||||||||||||||||
2599 | QByteArray QMetaEnumBuilder::name() const | - | ||||||||||||||||||||||||
2600 | { | - | ||||||||||||||||||||||||
2601 | QMetaEnumBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2602 | if (d) | - | ||||||||||||||||||||||||
2603 | return d->name; | - | ||||||||||||||||||||||||
2604 | else | - | ||||||||||||||||||||||||
2605 | return QByteArray(); | - | ||||||||||||||||||||||||
2606 | } | - | ||||||||||||||||||||||||
2607 | - | |||||||||||||||||||||||||
2608 | /*! | - | ||||||||||||||||||||||||
2609 | Returns \c true if this enumerator is used as a flag; otherwise returns | - | ||||||||||||||||||||||||
2610 | false. | - | ||||||||||||||||||||||||
2611 | - | |||||||||||||||||||||||||
2612 | \sa setIsFlag() | - | ||||||||||||||||||||||||
2613 | */ | - | ||||||||||||||||||||||||
2614 | bool QMetaEnumBuilder::isFlag() const | - | ||||||||||||||||||||||||
2615 | { | - | ||||||||||||||||||||||||
2616 | QMetaEnumBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2617 | if (d) | - | ||||||||||||||||||||||||
2618 | return d->isFlag; | - | ||||||||||||||||||||||||
2619 | else | - | ||||||||||||||||||||||||
2620 | return false; | - | ||||||||||||||||||||||||
2621 | } | - | ||||||||||||||||||||||||
2622 | - | |||||||||||||||||||||||||
2623 | /*! | - | ||||||||||||||||||||||||
2624 | Sets this enumerator to be used as a flag if \a value is true. | - | ||||||||||||||||||||||||
2625 | - | |||||||||||||||||||||||||
2626 | \sa isFlag() | - | ||||||||||||||||||||||||
2627 | */ | - | ||||||||||||||||||||||||
2628 | void QMetaEnumBuilder::setIsFlag(bool value) | - | ||||||||||||||||||||||||
2629 | { | - | ||||||||||||||||||||||||
2630 | QMetaEnumBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2631 | if (d) | - | ||||||||||||||||||||||||
2632 | d->isFlag = value; | - | ||||||||||||||||||||||||
2633 | } | - | ||||||||||||||||||||||||
2634 | - | |||||||||||||||||||||||||
2635 | /*! | - | ||||||||||||||||||||||||
2636 | Returns the number of keys. | - | ||||||||||||||||||||||||
2637 | - | |||||||||||||||||||||||||
2638 | \sa key(), addKey() | - | ||||||||||||||||||||||||
2639 | */ | - | ||||||||||||||||||||||||
2640 | int QMetaEnumBuilder::keyCount() const | - | ||||||||||||||||||||||||
2641 | { | - | ||||||||||||||||||||||||
2642 | QMetaEnumBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2643 | if (d) | - | ||||||||||||||||||||||||
2644 | return d->keys.size(); | - | ||||||||||||||||||||||||
2645 | else | - | ||||||||||||||||||||||||
2646 | return 0; | - | ||||||||||||||||||||||||
2647 | } | - | ||||||||||||||||||||||||
2648 | - | |||||||||||||||||||||||||
2649 | /*! | - | ||||||||||||||||||||||||
2650 | Returns the key with the given \a index, or an empty QByteArray | - | ||||||||||||||||||||||||
2651 | if no such key exists. | - | ||||||||||||||||||||||||
2652 | - | |||||||||||||||||||||||||
2653 | \sa keyCount(), addKey(), value() | - | ||||||||||||||||||||||||
2654 | */ | - | ||||||||||||||||||||||||
2655 | QByteArray QMetaEnumBuilder::key(int index) const | - | ||||||||||||||||||||||||
2656 | { | - | ||||||||||||||||||||||||
2657 | QMetaEnumBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2658 | if (d && index >= 0 && index < d->keys.size()) | - | ||||||||||||||||||||||||
2659 | return d->keys[index]; | - | ||||||||||||||||||||||||
2660 | else | - | ||||||||||||||||||||||||
2661 | return QByteArray(); | - | ||||||||||||||||||||||||
2662 | } | - | ||||||||||||||||||||||||
2663 | - | |||||||||||||||||||||||||
2664 | /*! | - | ||||||||||||||||||||||||
2665 | Returns the value with the given \a index; or returns -1 if there | - | ||||||||||||||||||||||||
2666 | is no such value. | - | ||||||||||||||||||||||||
2667 | - | |||||||||||||||||||||||||
2668 | \sa keyCount(), addKey(), key() | - | ||||||||||||||||||||||||
2669 | */ | - | ||||||||||||||||||||||||
2670 | int QMetaEnumBuilder::value(int index) const | - | ||||||||||||||||||||||||
2671 | { | - | ||||||||||||||||||||||||
2672 | QMetaEnumBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2673 | if (d && index >= 0 && index < d->keys.size()) | - | ||||||||||||||||||||||||
2674 | return d->values[index]; | - | ||||||||||||||||||||||||
2675 | else | - | ||||||||||||||||||||||||
2676 | return -1; | - | ||||||||||||||||||||||||
2677 | } | - | ||||||||||||||||||||||||
2678 | - | |||||||||||||||||||||||||
2679 | /*! | - | ||||||||||||||||||||||||
2680 | Adds a new key called \a name to this enumerator, associated | - | ||||||||||||||||||||||||
2681 | with \a value. Returns the index of the new key. | - | ||||||||||||||||||||||||
2682 | - | |||||||||||||||||||||||||
2683 | \sa keyCount(), key(), value(), removeKey() | - | ||||||||||||||||||||||||
2684 | */ | - | ||||||||||||||||||||||||
2685 | int QMetaEnumBuilder::addKey(const QByteArray& name, int value) | - | ||||||||||||||||||||||||
2686 | { | - | ||||||||||||||||||||||||
2687 | QMetaEnumBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2688 | if (d) { | - | ||||||||||||||||||||||||
2689 | int index = d->keys.size(); | - | ||||||||||||||||||||||||
2690 | d->keys += name; | - | ||||||||||||||||||||||||
2691 | d->values += value; | - | ||||||||||||||||||||||||
2692 | return index; | - | ||||||||||||||||||||||||
2693 | } else { | - | ||||||||||||||||||||||||
2694 | return -1; | - | ||||||||||||||||||||||||
2695 | } | - | ||||||||||||||||||||||||
2696 | } | - | ||||||||||||||||||||||||
2697 | - | |||||||||||||||||||||||||
2698 | /*! | - | ||||||||||||||||||||||||
2699 | Removes the key at \a index from this enumerator. | - | ||||||||||||||||||||||||
2700 | - | |||||||||||||||||||||||||
2701 | \sa addKey() | - | ||||||||||||||||||||||||
2702 | */ | - | ||||||||||||||||||||||||
2703 | void QMetaEnumBuilder::removeKey(int index) | - | ||||||||||||||||||||||||
2704 | { | - | ||||||||||||||||||||||||
2705 | QMetaEnumBuilderPrivate *d = d_func(); | - | ||||||||||||||||||||||||
2706 | if (d && index >= 0 && index < d->keys.size()) { | - | ||||||||||||||||||||||||
2707 | d->keys.removeAt(index); | - | ||||||||||||||||||||||||
2708 | d->values.removeAt(index); | - | ||||||||||||||||||||||||
2709 | } | - | ||||||||||||||||||||||||
2710 | } | - | ||||||||||||||||||||||||
2711 | - | |||||||||||||||||||||||||
2712 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||
Source code | Switch to Preprocessed file |