qdbusmetatype.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7 -
8 -
9class QDBusCustomTypeInfo -
10{ -
11public: -
12 QDBusCustomTypeInfo() : signature(), marshall(0), demarshall(0) -
13 { }
executed: }
Execution Count:15691
15691
14 -
15 -
16 -
17 QByteArray signature; -
18 QDBusMetaType::MarshallFunction marshall; -
19 QDBusMetaType::DemarshallFunction demarshall; -
20}; -
21 -
22template<typename T> -
23inline static void registerHelper(T * = 0) -
24{ -
25 void (*mf)(QDBusArgument &, const T *) = qDBusMarshallHelper<T>; -
26 void (*df)(const QDBusArgument &, T *) = qDBusDemarshallHelper<T>; -
27 QDBusMetaType::registerMarshallOperators(qMetaTypeId<T>(), -
28 reinterpret_cast<QDBusMetaType::MarshallFunction>(mf), -
29 reinterpret_cast<QDBusMetaType::DemarshallFunction>(df)); -
30}
executed: }
Execution Count:210
210
31 -
32void QDBusMetaTypeId::init() -
33{ -
34 static QBasicAtomicInt initialized = { (false) }; -
35 -
36 -
37 -
38 if (!initialized.load()) {
evaluated: !initialized.load()
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:4940
15-4940
39 -
40 (void)message(); -
41 (void)argument(); -
42 (void)variant(); -
43 (void)objectpath(); -
44 (void)signature(); -
45 (void)error(); -
46 (void)unixfd(); -
47 -
48 -
49 -
50 registerHelper<QDate>(); -
51 registerHelper<QTime>(); -
52 registerHelper<QDateTime>(); -
53 registerHelper<QRect>(); -
54 registerHelper<QRectF>(); -
55 registerHelper<QSize>(); -
56 registerHelper<QSizeF>(); -
57 registerHelper<QPoint>(); -
58 registerHelper<QPointF>(); -
59 registerHelper<QLine>(); -
60 registerHelper<QLineF>(); -
61 registerHelper<QVariantList>(); -
62 registerHelper<QVariantMap>(); -
63 registerHelper<QVariantHash>(); -
64 -
65 qDBusRegisterMetaType<QList<bool> >(); -
66 qDBusRegisterMetaType<QList<short> >(); -
67 qDBusRegisterMetaType<QList<ushort> >(); -
68 qDBusRegisterMetaType<QList<int> >(); -
69 qDBusRegisterMetaType<QList<uint> >(); -
70 qDBusRegisterMetaType<QList<qlonglong> >(); -
71 qDBusRegisterMetaType<QList<qulonglong> >(); -
72 qDBusRegisterMetaType<QList<double> >(); -
73 qDBusRegisterMetaType<QList<QDBusObjectPath> >(); -
74 qDBusRegisterMetaType<QList<QDBusSignature> >(); -
75 qDBusRegisterMetaType<QList<QDBusUnixFileDescriptor> >(); -
76 -
77 -
78 initialized.store(true); -
79 }
executed: }
Execution Count:15
15
80}
executed: }
Execution Count:4955
4955
81 -
82static QVector<QDBusCustomTypeInfo> *customTypes() { static QGlobalStatic<QVector<QDBusCustomTypeInfo> > thisGlobalStatic = { { (0) }, false }; if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { QVector<QDBusCustomTypeInfo> *x = new QVector<QDBusCustomTypeInfo>; if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) delete x; else static QGlobalStaticDeleter<QVector<QDBusCustomTypeInfo> > cleanup(thisGlobalStatic); } return thisGlobalStatic.pointer.load(); }
never executed: delete x;
executed: return thisGlobalStatic.pointer.load();
Execution Count:1336
partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15
evaluated: !thisGlobalStatic.pointer.load()
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:1321
partially evaluated: !thisGlobalStatic.destroyed
TRUEFALSE
yes
Evaluation Count:15
no
Evaluation Count:0
0-1336
83static QReadWriteLock *customTypesLock() { static QGlobalStatic<QReadWriteLock > thisGlobalStatic = { { (0) }, false }; if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { QReadWriteLock *x = new QReadWriteLock; if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) delete x; else static QGlobalStaticDeleter<QReadWriteLock > cleanup(thisGlobalStatic); } return thisGlobalStatic.pointer.load(); }
never executed: delete x;
executed: return thisGlobalStatic.pointer.load();
Execution Count:1397
partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15
evaluated: !thisGlobalStatic.pointer.load()
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:1382
partially evaluated: !thisGlobalStatic.destroyed
TRUEFALSE
yes
Evaluation Count:15
no
Evaluation Count:0
0-1397
84void QDBusMetaType::registerMarshallOperators(int id, MarshallFunction mf, -
85 DemarshallFunction df) -
86{ -
87 QByteArray var; -
88 QVector<QDBusCustomTypeInfo> *ct = customTypes(); -
89 if (id < 0 || !mf || !df || !ct)
partially evaluated: id < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:433
partially evaluated: !mf
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:433
partially evaluated: !df
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:433
partially evaluated: !ct
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:433
0-433
90 return;
never executed: return;
0
91 -
92 QWriteLocker locker(customTypesLock()); -
93 if (id >= ct->size())
evaluated: id >= ct->size()
TRUEFALSE
yes
Evaluation Count:320
yes
Evaluation Count:113
113-320
94 ct->resize(id + 1);
executed: ct->resize(id + 1);
Execution Count:320
320
95 QDBusCustomTypeInfo &info = (*ct)[id]; -
96 info.marshall = mf; -
97 info.demarshall = df; -
98}
executed: }
Execution Count:433
433
99 -
100 -
101 -
102 -
103 -
104 -
105 -
106bool QDBusMetaType::marshall(QDBusArgument &arg, int id, const void *data) -
107{ -
108 QDBusMetaTypeId::init(); -
109 -
110 MarshallFunction mf; -
111 { -
112 QReadLocker locker(customTypesLock()); -
113 QVector<QDBusCustomTypeInfo> *ct = customTypes(); -
114 if (id >= ct->size())
partially evaluated: id >= ct->size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:115
0-115
115 return false;
never executed: return false;
0
116 -
117 const QDBusCustomTypeInfo &info = (*ct).at(id); -
118 if (!info.marshall) {
partially evaluated: !info.marshall
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:115
0-115
119 mf = 0; -
120 return false;
never executed: return false;
0
121 } else -
122 mf = info.marshall;
executed: mf = info.marshall;
Execution Count:115
115
123 } -
124 -
125 mf(arg, data); -
126 return true;
executed: return true;
Execution Count:115
115
127} -
128 -
129 -
130 -
131 -
132 -
133 -
134 -
135bool QDBusMetaType::demarshall(const QDBusArgument &arg, int id, void *data) -
136{ -
137 QDBusMetaTypeId::init(); -
138 -
139 DemarshallFunction df; -
140 { -
141 QReadLocker locker(customTypesLock()); -
142 QVector<QDBusCustomTypeInfo> *ct = customTypes(); -
143 if (id >= ct->size())
partially evaluated: id >= ct->size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:43
0-43
144 return false;
never executed: return false;
0
145 -
146 const QDBusCustomTypeInfo &info = (*ct).at(id); -
147 if (!info.demarshall) {
partially evaluated: !info.demarshall
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:43
0-43
148 df = 0; -
149 return false;
never executed: return false;
0
150 } else -
151 df = info.demarshall;
executed: df = info.demarshall;
Execution Count:43
43
152 } -
153 -
154 QDBusArgument copy = arg; -
155 df(copy, data); -
156 -
157 -
158 -
159 -
160 -
161 return true;
executed: return true;
Execution Count:43
43
162} -
163int QDBusMetaType::signatureToType(const char *signature) -
164{ -
165 if (!signature)
partially evaluated: !signature
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2012
0-2012
166 return QMetaType::UnknownType;
never executed: return QMetaType::UnknownType;
0
167 -
168 QDBusMetaTypeId::init(); -
169 switch (signature[0]) -
170 { -
171 case ((int) 'b'): -
172 return QVariant::Bool;
executed: return QVariant::Bool;
Execution Count:78
78
173 -
174 case ((int) 'y'): -
175 return QMetaType::UChar;
executed: return QMetaType::UChar;
Execution Count:78
78
176 -
177 case ((int) 'n'): -
178 return QMetaType::Short;
executed: return QMetaType::Short;
Execution Count:78
78
179 -
180 case ((int) 'q'): -
181 return QMetaType::UShort;
executed: return QMetaType::UShort;
Execution Count:78
78
182 -
183 case ((int) 'i'): -
184 return QVariant::Int;
executed: return QVariant::Int;
Execution Count:178
178
185 -
186 case ((int) 'u'): -
187 return QVariant::UInt;
executed: return QVariant::UInt;
Execution Count:78
78
188 -
189 case ((int) 'x'): -
190 return QVariant::LongLong;
executed: return QVariant::LongLong;
Execution Count:78
78
191 -
192 case ((int) 't'): -
193 return QVariant::ULongLong;
executed: return QVariant::ULongLong;
Execution Count:78
78
194 -
195 case ((int) 'd'): -
196 return QVariant::Double;
executed: return QVariant::Double;
Execution Count:78
78
197 -
198 case ((int) 's'): -
199 return QVariant::String;
executed: return QVariant::String;
Execution Count:332
332
200 -
201 case ((int) 'o'): -
202 return QDBusMetaTypeId::objectpath();
executed: return QDBusMetaTypeId::objectpath();
Execution Count:79
79
203 -
204 case ((int) 'g'): -
205 return QDBusMetaTypeId::signature();
executed: return QDBusMetaTypeId::signature();
Execution Count:78
78
206 -
207 case int('h'): -
208 return QDBusMetaTypeId::unixfd();
executed: return QDBusMetaTypeId::unixfd();
Execution Count:1
1
209 -
210 case ((int) 'v'): -
211 return QDBusMetaTypeId::variant();
executed: return QDBusMetaTypeId::variant();
Execution Count:142
142
212 -
213 case ((int) 'a'): -
214 switch (signature[1]) { -
215 case ((int) 'y'): -
216 return QVariant::ByteArray;
executed: return QVariant::ByteArray;
Execution Count:79
79
217 -
218 case ((int) 's'): -
219 return QVariant::StringList;
executed: return QVariant::StringList;
Execution Count:81
81
220 -
221 case ((int) 'v'): -
222 return QVariant::List;
executed: return QVariant::List;
Execution Count:78
78
223 -
224 case ((int) 'o'): -
225 return qMetaTypeId<QList<QDBusObjectPath> >();
executed: return qMetaTypeId<QList<QDBusObjectPath> >();
Execution Count:3
3
226 -
227 case ((int) 'g'): -
228 return qMetaTypeId<QList<QDBusSignature> >();
executed: return qMetaTypeId<QList<QDBusSignature> >();
Execution Count:1
1
229 -
230 } -
231 -
232 default: -
233 return QMetaType::UnknownType;
executed: return QMetaType::UnknownType;
Execution Count:336
336
234 } -
235}
never executed: }
0
236const char *QDBusMetaType::typeToSignature(int type) -
237{ -
238 -
239 switch (type) -
240 { -
241 case QMetaType::UChar: -
242 return "y";
executed: return "y";
Execution Count:69
69
243 -
244 case QVariant::Bool: -
245 return "b";
executed: return "b";
Execution Count:78
78
246 -
247 case QMetaType::Short: -
248 return "n";
executed: return "n";
Execution Count:85
85
249 -
250 case QMetaType::UShort: -
251 return "q";
executed: return "q";
Execution Count:69
69
252 -
253 case QVariant::Int: -
254 return "i";
executed: return "i";
Execution Count:409
409
255 -
256 case QVariant::UInt: -
257 return "u";
executed: return "u";
Execution Count:101
101
258 -
259 case QVariant::LongLong: -
260 return "x";
executed: return "x";
Execution Count:80
80
261 -
262 case QVariant::ULongLong: -
263 return "t";
executed: return "t";
Execution Count:69
69
264 -
265 case QVariant::Double: -
266 return "d";
executed: return "d";
Execution Count:69
69
267 -
268 case QVariant::String: -
269 return "s";
executed: return "s";
Execution Count:2020
2020
270 -
271 case QVariant::StringList: -
272 return "a" 82
273 "s";
executed: return "a" "s";
Execution Count:82
82
274 -
275 case QVariant::ByteArray: -
276 return "a" 81
277 "y";
executed: return "a" "y";
Execution Count:81
81
278 } -
279 -
280 QDBusMetaTypeId::init(); -
281 if (type == QDBusMetaTypeId::variant())
evaluated: type == QDBusMetaTypeId::variant()
TRUEFALSE
yes
Evaluation Count:318
yes
Evaluation Count:875
318-875
282 return "v";
executed: return "v";
Execution Count:318
318
283 else if (type == QDBusMetaTypeId::objectpath())
evaluated: type == QDBusMetaTypeId::objectpath()
TRUEFALSE
yes
Evaluation Count:66
yes
Evaluation Count:809
66-809
284 return "o";
executed: return "o";
Execution Count:66
66
285 else if (type == QDBusMetaTypeId::signature())
evaluated: type == QDBusMetaTypeId::signature()
TRUEFALSE
yes
Evaluation Count:64
yes
Evaluation Count:745
64-745
286 return "g";
executed: return "g";
Execution Count:64
64
287 else if (type == QDBusMetaTypeId::unixfd())
partially evaluated: type == QDBusMetaTypeId::unixfd()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:745
0-745
288 return "h";
never executed: return "h";
0
289 -
290 -
291 QVector<QDBusCustomTypeInfo> *ct = customTypes(); -
292 { -
293 QReadLocker locker(customTypesLock()); -
294 if (type >= ct->size())
evaluated: type >= ct->size()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:743
2-743
295 return 0;
executed: return 0;
Execution Count:2
2
296 -
297 const QDBusCustomTypeInfo &info = (*ct).at(type); -
298 -
299 if (!info.signature.isNull())
evaluated: !info.signature.isNull()
TRUEFALSE
yes
Evaluation Count:667
yes
Evaluation Count:76
76-667
300 return info.signature;
executed: return info.signature;
Execution Count:667
667
301 -
302 if (!info.marshall)
evaluated: !info.marshall
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:61
15-61
303 return 0;
executed: return 0;
Execution Count:15
15
304 } -
305 -
306 -
307 QDBusCustomTypeInfo *info; -
308 { -
309 -
310 -
311 QByteArray signature = QDBusArgumentPrivate::createSignature(type); -
312 -
313 -
314 QWriteLocker locker(customTypesLock()); -
315 info = &(*ct)[type]; -
316 info->signature = signature; -
317 } -
318 return info->signature;
executed: return info->signature;
Execution Count:61
61
319} -
320 -
321 -
322 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial