12#include <qcoreapplication.h>
18#include "private/qthread_p.h"
20#include <qsemaphore.h>
24#include "private/qmetaobject_moc_p.h"
31using namespace Qt::StringLiterals;
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
111
112
113
114
115
116
117
118
125 Q_ASSERT(priv(mo->d.data)->revision >= 7);
126 uint offset = mo->d.stringdata[2*index];
127 return reinterpret_cast<
const char *>(mo->d.stringdata) + offset;
132 Q_ASSERT(priv(mo->d.data)->revision >= 7);
133 uint offset = mo->d.stringdata[2*index];
134 uint length = mo->d.stringdata[2*index + 1];
135 const char *string =
reinterpret_cast<
const char *>(mo->d.stringdata) + offset;
136 return {string, qsizetype(length)};
141 if (QMetaObjectPrivate::get(mo)->flags & AllocatedMetaObject) {
143 return view.toByteArray();
148 return QByteArray::fromRawData(view.data(), view.size());
153 return stringData(mo, stringDataView(mo, index));
158 if (typeInfo & IsUnresolvedType)
159 return stringDataView(mo, typeInfo & TypeNameIndexMask);
161 return QByteArrayView(QMetaType(typeInfo).name());
166 if (!(typeInfo & IsUnresolvedType))
168 return QMetaType::fromName(rawStringData(mo, typeInfo & TypeNameIndexMask)).id();
174 std::optional<QByteArrayView> scope;
177 if (qualifiedKey.startsWith(
"QFlags<") && qualifiedKey.endsWith(
'>'))
178 qualifiedKey.slice(7, qualifiedKey.length() - 8);
179 const auto scopePos = qualifiedKey.lastIndexOf(
"::"_L1);
181 return R{
std::nullopt, qualifiedKey};
183 return R{qualifiedKey.first(scopePos), qualifiedKey.sliced(scopePos + 2)};
190 static const QMetaMethodPrivate *get(
const QMetaMethod *q)
191 {
return static_cast<
const QMetaMethodPrivate *>(q); }
194 inline QByteArrayView name()
const noexcept;
195 inline int typesDataIndex()
const;
196 inline const char *rawReturnTypeName()
const;
197 inline int returnType()
const;
198 inline int parameterCount()
const;
199 inline int parametersDataIndex()
const;
200 inline uint parameterTypeInfo(
int index)
const;
201 inline int parameterType(
int index)
const;
202 inline void getParameterTypes(
int *types)
const;
205 inline QByteArrayView parameterTypeName(
int index)
const noexcept;
206 inline QList<QByteArray> parameterTypes()
const;
207 inline QList<QByteArray> parameterNames()
const;
208 inline const char *tag()
const;
209 inline int ownMethodIndex()
const;
210 inline int ownConstructorMethodIndex()
const;
214 QMetaMethodPrivate();
220#if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
)
222
223
224
225
226
227
228
229
230
231
232
233
234
235QObject *QMetaObject::newInstance(QGenericArgument val0,
236 QGenericArgument val1,
237 QGenericArgument val2,
238 QGenericArgument val3,
239 QGenericArgument val4,
240 QGenericArgument val5,
241 QGenericArgument val6,
242 QGenericArgument val7,
243 QGenericArgument val8,
244 QGenericArgument val9)
const
246 const char *typeNames[] = {
248 val0.name(), val1.name(), val2.name(), val3.name(), val4.name(),
249 val5.name(), val6.name(), val7.name(), val8.name(), val9.name()
251 const void *parameters[] = {
253 val0.data(), val1.data(), val2.data(), val3.data(), val4.data(),
254 val5.data(), val6.data(), val7.data(), val8.data(), val9.data()
258 for (paramCount = 1; paramCount < MaximumParamCount; ++paramCount) {
259 int len =
int(qstrlen(typeNames[paramCount]));
264 return newInstanceImpl(
this, paramCount, parameters, typeNames,
nullptr);
269
270
271
272
273
274
275
276
277
278
279
280
281
283QObject *QMetaObject::newInstanceImpl(
const QMetaObject *mobj, qsizetype paramCount,
284 const void **parameters,
const char **typeNames,
285 const QtPrivate::QMetaTypeInterface **metaTypes)
287 if (!mobj->inherits(&QObject::staticMetaObject)) {
288 qWarning(
"QMetaObject::newInstance: type %s does not inherit QObject", mobj->className());
294QT_WARNING_DISABLE_GCC(
"-Wdangling-pointer")
298 QObject *returnValue =
nullptr;
299 QMetaType returnValueMetaType = QMetaType::fromType<
decltype(returnValue)>();
300 parameters[0] = &returnValue;
301 typeNames[0] = returnValueMetaType.name();
303 metaTypes[0] = returnValueMetaType.iface();
308 auto priv = QMetaObjectPrivate::get(mobj);
309 for (
int i = 0; i < priv->constructorCount; ++i) {
310 QMetaMethod m = QMetaMethod::fromRelativeConstructorIndex(mobj, i);
311 if (m.parameterCount() != (paramCount - 1))
315 QMetaMethodPrivate::InvokeFailReason r =
316 QMetaMethodPrivate::invokeImpl(m,
nullptr, Qt::DirectConnection, paramCount,
317 parameters, typeNames, metaTypes);
318 if (r == QMetaMethodPrivate::InvokeFailReason::None)
328
329
330int QMetaObject::static_metacall(Call cl,
int idx,
void **argv)
const
332 Q_ASSERT(priv(d.data)->revision >= 6);
333 if (!d.static_metacall)
335 d.static_metacall(
nullptr, cl, idx, argv);
340
341
342int QMetaObject::metacall(QObject *object, Call cl,
int idx,
void **argv)
344 if (object->d_ptr->metaObject)
345 return object->d_ptr->metaObject->metaCall(object, cl, idx, argv);
347 return object->qt_metacall(cl, idx, argv);
352 return stringDataView(m, priv(m->d.data)->className);
356
357
358
359
360const char *QMetaObject::className()
const
362 return objectClassName(
this).constData();
366
367
368
369
370
371
372
375
376
377
378
379
380
381
382bool QMetaObject::inherits(
const QMetaObject *metaObject)
const noexcept
384 const QMetaObject *m =
this;
388 }
while ((m = m->d.superdata));
393
394
395
396
397
398
401
402
403
404
405
406const QObject *QMetaObject::cast(
const QObject *obj)
const
408 return (obj && obj->metaObject()->inherits(
this)) ? obj :
nullptr;
411#ifndef QT_NO_TRANSLATION
413
414
415QString QMetaObject::tr(
const char *s,
const char *c,
int n)
const
417 return QCoreApplication::translate(className(), s, c, n);
422
423
424
425
426QMetaType QMetaObject::metaType()
const
429 const QMetaObjectPrivate *d = priv(
this->d.data);
430 if (d->revision < 10) {
432 return QMetaType::fromName(className());
435
436
437
438
439
440
441
442
443
444
445
446
447#if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
)
451 const qsizetype offset = d->revision < 12
453 : d->propertyCount + d->enumeratorCount;
455 const qsizetype offset = d->propertyCount + d->enumeratorCount;
458 auto iface =
this->d.metaTypes[offset];
459 if (iface && QtMetaTypePrivate::isInterfaceFor<
void>(iface))
462 return QMetaType(iface);
464 return QMetaType::fromName(className());
469
470
471
472
473
474
475
476
477
478int QMetaObject::methodOffset()
const
481 const QMetaObject *m = d.superdata;
483 offset += priv(m->d.data)->methodCount;
491
492
493
494
495
496
497
498
499
500int QMetaObject::enumeratorOffset()
const
503 const QMetaObject *m = d.superdata;
505 offset += priv(m->d.data)->enumeratorCount;
512
513
514
515
516
517
518
519
520
521int QMetaObject::propertyOffset()
const
524 const QMetaObject *m = d.superdata;
526 offset += priv(m->d.data)->propertyCount;
533
534
535
536
537
538
539
540
541
542int QMetaObject::classInfoOffset()
const
545 const QMetaObject *m = d.superdata;
547 offset += priv(m->d.data)->classInfoCount;
554
555
556
557
558
559
560int QMetaObject::constructorCount()
const
562 Q_ASSERT(priv(d.data)->revision >= 2);
563 return priv(d.data)->constructorCount;
567
568
569
570
571
572
573
574
575
576
577
578int QMetaObject::methodCount()
const
580 int n = priv(d.data)->methodCount;
581 const QMetaObject *m = d.superdata;
583 n += priv(m->d.data)->methodCount;
590
591
592
593
594int QMetaObject::enumeratorCount()
const
596 int n = priv(d.data)->enumeratorCount;
597 const QMetaObject *m = d.superdata;
599 n += priv(m->d.data)->enumeratorCount;
606
607
608
609
610
611
612
613
614
615
616int QMetaObject::propertyCount()
const
618 int n = priv(d.data)->propertyCount;
619 const QMetaObject *m = d.superdata;
621 n += priv(m->d.data)->propertyCount;
628
629
630
631
632int QMetaObject::classInfoCount()
const
634 int n = priv(d.data)->classInfoCount;
635 const QMetaObject *m = d.superdata;
637 n += priv(m->d.data)->classInfoCount;
650 const QMetaMethod::Data &data = method.data;
651 auto priv = QMetaMethodPrivate::get(&method);
652 if (priv->parameterCount() != argc)
655 if (QMetaMethodPrivate::get(&method)->name() != name)
659 int paramsIndex = data.parameters() + 1;
660 for (
int i = 0; i < argc; ++i) {
661 uint typeInfo = m->d.data[paramsIndex + i];
664 if (mt == QMetaType(ifaces[i]))
666 if (mt.id() != typeFromTypeInfo(m, typeInfo))
669 if (types[i].name() == QMetaType(ifaces[i]).name())
671 if (types[i].name() != typeNameFromTypeInfo(m, typeInfo))
680
681
682
685 for (
const QMetaObject *currentObject = baseObject; currentObject; currentObject = currentObject->superClass()) {
686 const int start = priv(currentObject->d.data)->methodCount - 1;
688 for (
int i = start; i >= end; --i) {
689 auto candidate = QMetaMethod::fromRelativeMethodIndex(currentObject, i);
690 if (name == candidate.name())
694 return QMetaMethod{};
698
699
700
701
702
703template<
int MethodType>
708 for (
const QMetaObject *m = *baseObject; m; m = m->d.superdata) {
709 Q_ASSERT(priv(m->d.data)->revision >= 7);
710 int i = (MethodType == MethodSignal)
711 ? (priv(m->d.data)->signalCount - 1) : (priv(m->d.data)->methodCount - 1);
712 const int end = (MethodType == MethodSlot)
713 ? (priv(m->d.data)->signalCount) : 0;
715 for (; i >= end; --i) {
716 auto data = QMetaMethod::fromRelativeMethodIndex(m, i);
717 if (methodMatch(m, data, name, argc, types)) {
728
729
730
731
732
733
734
735
736
737int QMetaObject::indexOfConstructor(
const char *constructor)
const
739 Q_ASSERT(priv(d.data)->revision >= 7);
740 QArgumentTypeArray types;
741 QByteArray name = QMetaObjectPrivate::decodeMethodSignature(constructor, types);
742 return QMetaObjectPrivate::indexOfConstructor(
this, name, types.size(), types.constData());
746
747
748
749
750
751
752
753int QMetaObject::indexOfMethod(
const char *method)
const
755 const QMetaObject *m =
this;
757 Q_ASSERT(priv(m->d.data)->revision >= 7);
758 QArgumentTypeArray types;
759 QByteArray name = QMetaObjectPrivate::decodeMethodSignature(method, types);
760 i = QMetaObjectPrivate::indexOfMethodRelative<0>(&m, name, types.size(), types.constData());
762 i += m->methodOffset();
771 Q_ASSERT(str <= end);
773 if (!types.isEmpty())
775 const char *begin = str;
777 while (str != end && (level > 0 || *str !=
',')) {
780 else if (*str ==
'>')
785 argType.replace(
"QVector<",
"QList<");
795 Q_ASSERT(signature !=
nullptr);
796 const char *lparens = strchr(signature,
'(');
799 const char *rparens = strrchr(lparens + 1,
')');
800 if (!rparens || *(rparens+1))
802 int nameLength = lparens - signature;
804 return QByteArray::fromRawData(signature, nameLength);
808
809
810
811
812
813
814
815
816
817
818int QMetaObject::indexOfSignal(
const char *signal)
const
820 const QMetaObject *m =
this;
822 Q_ASSERT(priv(m->d.data)->revision >= 7);
823 QArgumentTypeArray types;
824 QByteArray name = QMetaObjectPrivate::decodeMethodSignature(signal, types);
825 i = QMetaObjectPrivate::indexOfSignalRelative(&m, name, types.size(), types.constData());
827 i += m->methodOffset();
832
833
834
835
836
841 int i = indexOfMethodRelative<MethodSignal>(baseObject, name, argc, types);
843 const QMetaObject *m = *baseObject;
844 if (i >= 0 && m && m->d.superdata) {
845 int conflict = indexOfMethod(m->d.superdata, name, argc, types);
847 QMetaMethod conflictMethod = m->d.superdata->method(conflict);
848 qWarning(
"QMetaObject::indexOfSignal: signal %s from %s redefined in %s",
849 conflictMethod.methodSignature().constData(),
850 m->d.superdata->className(), m->className());
858
859
860
861
862
863
864
865int QMetaObject::indexOfSlot(
const char *slot)
const
867 const QMetaObject *m =
this;
869 Q_ASSERT(priv(m->d.data)->revision >= 7);
870 QArgumentTypeArray types;
871 QByteArray name = QMetaObjectPrivate::decodeMethodSignature(slot, types);
872 i = QMetaObjectPrivate::indexOfSlotRelative(&m, name, types.size(), types.constData());
874 i += m->methodOffset();
883 return indexOfMethodRelative<MethodSlot>(m, name, argc, types);
889 int i = indexOfSignalRelative(&m, name, argc, types);
891 i += m->methodOffset();
898 int i = indexOfSlotRelative(&m, name, argc, types);
900 i += m->methodOffset();
907 int i = indexOfMethodRelative<0>(&m, name, argc, types);
909 i += m->methodOffset();
916 for (
int i = priv(m->d.data)->constructorCount-1; i >= 0; --i) {
917 const QMetaMethod method = QMetaMethod::fromRelativeConstructorIndex(m, i);
918 if (methodMatch(m, method, name, argc, types))
925
926
927
928
929
930
931
932
933
934
937
938
939
940
941
942
943
944
945
948 Q_ASSERT(m !=
nullptr);
949 int n = priv(m->d.data)->signalCount;
950 for (m = m->d.superdata; m; m = m->d.superdata)
951 n += priv(m->d.data)->signalCount;
956
957
958
959
960
961
962
963
968 return QMetaMethodPrivate::get(&m)->ownMethodIndex() + signalOffset(m.mobj);
972
973
974
975
976
977
978
979
982 if (signal_index < 0)
983 return QMetaMethod();
985 Q_ASSERT(m !=
nullptr);
986 int i = signal_index;
987 i -= signalOffset(m);
988 if (i < 0 && m->d.superdata)
989 return signal(m->d.superdata, signal_index);
992 if (i >= 0 && i < priv(m->d.data)->signalCount)
993 return QMetaMethod::fromRelativeMethodIndex(m, i);
994 return QMetaMethod();
998
999
1000
1001
1002
1006 if (signalArgc < methodArgc)
1008 for (
int i = 0; i < methodArgc; ++i) {
1009 if (signalTypes[i] != methodTypes[i])
1016
1017
1018
1019
1020
1022 const QMetaMethodPrivate *method)
1024 if (signal->methodType() != QMetaMethod::Signal)
1026 if (signal->parameterCount() < method->parameterCount())
1028 const QMetaObject *smeta = signal->enclosingMetaObject();
1029 const QMetaObject *rmeta = method->enclosingMetaObject();
1030 for (
int i = 0; i < method->parameterCount(); ++i) {
1031 uint sourceTypeInfo = signal->parameterTypeInfo(i);
1032 uint targetTypeInfo = method->parameterTypeInfo(i);
1033 if ((sourceTypeInfo & IsUnresolvedType)
1034 || (targetTypeInfo & IsUnresolvedType)) {
1035 QByteArrayView sourceName = typeNameFromTypeInfo(smeta, sourceTypeInfo);
1036 QByteArrayView targetName = typeNameFromTypeInfo(rmeta, targetTypeInfo);
1037 if (sourceName != targetName)
1042 if (sourceType != targetType)
1054 if (self->d.relatedMetaObjects) {
1055 Q_ASSERT(priv(self->d.data)->revision >= 2);
1056 const auto *e = self->d.relatedMetaObjects;
1059 if (
const QMetaObject *m =QMetaObject_findMetaObject((*e), name))
1065 self = self->d.superdata;
1071
1072
1073
1074
1075
1076int QMetaObject::indexOfEnumerator(
const char *name)
const
1078 return QMetaObjectPrivate::indexOfEnumerator(
this, name);
1084 for (
auto which : { W::Name, W::Alias }) {
1085 if (
int index = indexOfEnumerator(m, name, which); index != -1)
1096 const QMetaEnum e(m, i);
1097 const quint32 id = which == Which::Name ? e.data.name() : e.data.alias();
1098 QByteArrayView prop = stringDataView(m, id);
1100 i += m->enumeratorOffset();
1110
1111
1112
1113
1114
1115int QMetaObject::indexOfProperty(
const char *name)
const
1117 const QMetaObject *m =
this;
1119 const QMetaObjectPrivate *d = priv(m->d.data);
1120 for (
int i = 0; i < d->propertyCount; ++i) {
1121 const QMetaProperty::Data data = QMetaProperty::getMetaPropertyData(m, i);
1122 const char *prop = rawStringData(m, data.name());
1123 if (strcmp(name, prop) == 0) {
1124 i += m->propertyOffset();
1131 if (priv(
this->d.data)->flags & DynamicMetaObject) {
1132 QAbstractDynamicMetaObject *me =
1133 const_cast<QAbstractDynamicMetaObject *>(
static_cast<
const QAbstractDynamicMetaObject *>(
this));
1135 return me->createProperty(name,
nullptr);
1142
1143
1144
1145
1146
1147int QMetaObject::indexOfClassInfo(
const char *name)
const
1150 const QMetaObject *m =
this;
1151 while (m && i < 0) {
1152 for (i = priv(m->d.data)->classInfoCount-1; i >= 0; --i)
1153 if (strcmp(name, rawStringData(m, m->d.data[priv(m->d.data)->classInfoData + 2*i])) == 0) {
1154 i += m->classInfoOffset();
1163
1164
1165
1166
1167
1168
1169QMetaMethod QMetaObject::constructor(
int index)
const
1172 if (i >= 0 && i < priv(d.data)->constructorCount)
1173 return QMetaMethod::fromRelativeConstructorIndex(
this, i);
1174 return QMetaMethod();
1178
1179
1180
1181
1182QMetaMethod QMetaObject::method(
int index)
const
1185 i -= methodOffset();
1186 if (i < 0 && d.superdata)
1187 return d.superdata->method(index);
1189 if (i >= 0 && i < priv(d.data)->methodCount)
1190 return QMetaMethod::fromRelativeMethodIndex(
this, i);
1191 return QMetaMethod();
1195
1196
1197
1198
1199QMetaEnum QMetaObject::enumerator(
int index)
const
1202 i -= enumeratorOffset();
1203 if (i < 0 && d.superdata)
1204 return d.superdata->enumerator(index);
1206 if (i >= 0 && i < priv(d.data)->enumeratorCount)
1207 return QMetaEnum(
this, i);
1212
1213
1214
1215
1216
1217QMetaProperty QMetaObject::property(
int index)
const
1220 i -= propertyOffset();
1221 if (i < 0 && d.superdata)
1222 return d.superdata->property(index);
1224 if (i >= 0 && i < priv(d.data)->propertyCount)
1225 return QMetaProperty(
this, i);
1226 return QMetaProperty();
1230
1231
1232
1233
1234
1235
1236QMetaProperty QMetaObject::userProperty()
const
1238 const int propCount = propertyCount();
1239 for (
int i = propCount - 1; i >= 0; --i) {
1240 const QMetaProperty prop = property(i);
1244 return QMetaProperty();
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257QMetaClassInfo QMetaObject::classInfo(
int index)
const
1260 i -= classInfoOffset();
1261 if (i < 0 && d.superdata)
1262 return d.superdata->classInfo(index);
1264 QMetaClassInfo result;
1265 if (i >= 0 && i < priv(d.data)->classInfoCount) {
1267 result.data = { d.data + priv(d.data)->classInfoData + i * QMetaClassInfo::Data::Size };
1273
1274
1275
1276
1277
1278
1279
1280bool QMetaObject::checkConnectArgs(
const char *signal,
const char *method)
1282 const char *s1 = signal;
1283 const char *s2 = method;
1284 while (*s1++ !=
'(') { }
1285 while (*s2++ !=
'(') { }
1286 if (*s2 ==
')' || qstrcmp(s1,s2) == 0)
1288 const auto s1len = qstrlen(s1);
1289 const auto s2len = qstrlen(s2);
1290 if (s2len < s1len && strncmp(s1,s2,s2len-1)==0 && s1[s2len-1]==
',')
1296
1297
1298
1299
1300
1301
1302bool QMetaObject::checkConnectArgs(
const QMetaMethod &signal,
1303 const QMetaMethod &method)
1305 return QMetaObjectPrivate::checkConnectArgs(
1306 QMetaMethodPrivate::get(&signal),
1307 QMetaMethodPrivate::get(&method));
1321 || ((*s ==
':') && (last ==
'<')))) {
1331 while (*d && (templdepth
1332 || (*d !=
',' && *d !=
')'))) {
1341 if (strncmp(
"void)", t, d - t + 1) != 0)
1342 result += normalizeTypeInternal(t, d);
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362QByteArray QMetaObject::normalizedType(
const char *type)
1364 return normalizeTypeInternal(type, type + qstrlen(type));
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378QByteArray QMetaObject::normalizedSignature(
const char *method)
1381 if (!method || !*method)
1383 int len =
int(strlen(method));
1384 QVarLengthArray<
char> stackbuf(len + 1);
1385 char *d = stackbuf.data();
1386 qRemoveWhitespace(method, d);
1388 result.reserve(len);
1393 if (argdepth == 1) {
1394 d = qNormalizeType(d, templdepth, result);
1410 const char *
const *names,
1415 for (
int i = 0; i < meta->methodCount(); ++i) {
1416 const QMetaMethod method = meta->method(i);
1417 if (method.name() == name)
1418 candidateMessage +=
" " + method.methodSignature() +
'\n';
1420 if (!candidateMessage.isEmpty()) {
1421 candidateMessage.prepend(
"\nCandidates are:\n");
1422 candidateMessage.chop(1);
1425 QVarLengthArray<
char, 512> sig;
1426 for (qsizetype i = 1; i < paramCount; ++i) {
1428 sig.append(names[i], qstrlen(names[i]));
1430 sig.append(metaTypes[i]->name, qstrlen(metaTypes[i]->name));
1433 if (paramCount != 1)
1434 sig.resize(sig.size() - 1);
1436 qWarning(
"QMetaObject::invokeMethod: No such method %s::%.*s(%.*s)%.*s",
1437 meta->className(),
int(name.size()), name.constData(),
1438 int(sig.size()), sig.constData(),
1439 int(candidateMessage.size()), candidateMessage.constData());
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558bool QMetaObject::invokeMethod(QObject *obj,
1560 Qt::ConnectionType type,
1561 QGenericReturnArgument ret,
1562 QGenericArgument val0,
1563 QGenericArgument val1,
1564 QGenericArgument val2,
1565 QGenericArgument val3,
1566 QGenericArgument val4,
1567 QGenericArgument val5,
1568 QGenericArgument val6,
1569 QGenericArgument val7,
1570 QGenericArgument val8,
1571 QGenericArgument val9)
1576 const char *typeNames[] = {ret.name(), val0.name(), val1.name(), val2.name(), val3.name(),
1577 val4.name(), val5.name(), val6.name(), val7.name(), val8.name(),
1579 const void *parameters[] = {ret.data(), val0.data(), val1.data(), val2.data(), val3.data(),
1580 val4.data(), val5.data(), val6.data(), val7.data(), val8.data(),
1583 for (paramCount = 1; paramCount < MaximumParamCount; ++paramCount) {
1584 if (qstrlen(typeNames[paramCount]) <= 0)
1587 return invokeMethodImpl(obj, member, type, paramCount, parameters, typeNames,
nullptr);
1590bool QMetaObject::invokeMethodImpl(QObject *obj,
const char *member, Qt::ConnectionType type,
1591 qsizetype paramCount,
const void *
const *parameters,
1592 const char *
const *typeNames,
1593 const QtPrivate::QMetaTypeInterface *
const *metaTypes)
1598 Q_ASSERT(paramCount >= 1);
1599 Q_ASSERT(parameters);
1600 Q_ASSERT(typeNames);
1603 QByteArrayView name(member);
1607 const QMetaObject *meta = obj->metaObject();
1608 for ( ; meta; meta = meta->superClass()) {
1609 auto priv = QMetaObjectPrivate::get(meta);
1610 for (
int i = 0; i < priv->methodCount; ++i) {
1611 QMetaMethod m = QMetaMethod::fromRelativeMethodIndex(meta, i);
1612 if (m.parameterCount() != (paramCount - 1))
1614 if (name != stringDataView(meta, m.data.name()))
1618 QMetaMethodPrivate::InvokeFailReason r =
1619 QMetaMethodPrivate::invokeImpl(m, obj, type, paramCount, parameters,
1620 typeNames, metaTypes);
1622 return r == QMetaMethodPrivate::InvokeFailReason::None;
1627 return printMethodNotFoundWarning(obj->metaObject(), name, paramCount, typeNames, metaTypes);
1630bool QMetaObject::invokeMethodImpl(QObject *object, QtPrivate::QSlotObjectBase *slotObj, Qt::ConnectionType type,
1631 qsizetype parameterCount,
const void *
const *params,
const char *
const *names,
1632 const QtPrivate::QMetaTypeInterface *
const *metaTypes)
1637 auto slot = QtPrivate::SlotObjUniquePtr(slotObj);
1642 Qt::HANDLE currentThreadId = QThread::currentThreadId();
1643 QThread *objectThread = object->thread();
1644 bool receiverInSameThread =
false;
1646 receiverInSameThread = currentThreadId == QThreadData::get2(objectThread)->threadId.loadRelaxed();
1648 if (type == Qt::AutoConnection)
1649 type = receiverInSameThread ? Qt::DirectConnection : Qt::QueuedConnection;
1651 void **argv =
const_cast<
void **>(params);
1652 if (type == Qt::DirectConnection) {
1653 slot->call(object, argv);
1654 }
else if (type == Qt::QueuedConnection) {
1656 qWarning(
"QMetaObject::invokeMethod: Unable to invoke methods with return values in "
1657 "queued connections");
1660 auto event = std::make_unique<QMetaCallEvent>(std::move(slot),
nullptr, -1, parameterCount);
1661 void **args = event->args();
1662 QMetaType *types = event->types();
1664 for (
int i = 1; i < parameterCount; ++i) {
1665 types[i] = QMetaType(metaTypes[i]);
1666 args[i] = types[i].create(argv[i]);
1669 QCoreApplication::postEvent(object, event.release());
1670 }
else if (type == Qt::BlockingQueuedConnection) {
1671#if QT_CONFIG(thread)
1672 if (receiverInSameThread)
1673 qWarning(
"QMetaObject::invokeMethod: Dead lock detected");
1675 QSemaphore semaphore;
1676 QCoreApplication::postEvent(object,
new QMetaCallEvent(std::move(slot),
nullptr, -1, argv, &semaphore));
1677 semaphore.acquire();
1680 qWarning(
"QMetaObject::invokeMethod: Unknown connection type");
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1788
1789
1790
1791
1793
1794
1795
1796
1797
1800
1801
1802
1803
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1824
1825
1826
1827
1828
1829
1830
1831
1834
1835
1836
1837
1838
1839
1842
1843
1844
1845
1846
1847
1850
1851
1852
1853
1854
1855
1858
1859
1860
1863
1864
1865
1866
1867
1868
1869
1872
1873
1874
1877
1878
1879QMetaMethod QMetaMethod::fromRelativeMethodIndex(
const QMetaObject *mobj,
int index)
1881 Q_ASSERT(index >= 0 && index < priv(mobj->d.data)->methodCount);
1884 m.data = { mobj->d.data + priv(mobj->d.data)->methodData + index * Data::Size };
1888QMetaMethod QMetaMethod::fromRelativeConstructorIndex(
const QMetaObject *mobj,
int index)
1890 Q_ASSERT(index >= 0 && index < priv(mobj->d.data)->constructorCount);
1893 m.data = { mobj->d.data + priv(mobj->d.data)->constructorData + index * Data::Size };
1898
1899
1900
1901
1902
1903
1907 Q_ASSERT(priv(mobj->d.data)->revision >= 7);
1909 result.reserve(256);
1912 QList<QByteArray> argTypes = parameterTypes();
1913 for (
int i = 0; i < argTypes.size(); ++i) {
1916 result += argTypes.at(i);
1922QByteArrayView QMetaMethodPrivate::name()
const noexcept
1924 Q_ASSERT(priv(mobj->d.data)->revision >= 7);
1925 QByteArrayView name = stringDataView(mobj, data.name());
1926 if (qsizetype colon = name.lastIndexOf(
':'); colon > 0)
1927 return name.sliced(colon + 1);
1931int QMetaMethodPrivate::typesDataIndex()
const
1933 Q_ASSERT(priv(mobj->d.data)->revision >= 7);
1934 return data.parameters();
1937const char *QMetaMethodPrivate::rawReturnTypeName()
const
1939 Q_ASSERT(priv(mobj->d.data)->revision >= 7);
1940 uint typeInfo = mobj->d.data[typesDataIndex()];
1941 if (typeInfo & IsUnresolvedType)
1942 return rawStringData(mobj, typeInfo & TypeNameIndexMask);
1944 return QMetaType(typeInfo).name();
1947int QMetaMethodPrivate::returnType()
const
1949 return parameterType(-1);
1952int QMetaMethodPrivate::parameterCount()
const
1954 Q_ASSERT(priv(mobj->d.data)->revision >= 7);
1962 uint typeInfo = parameterTypeInfo(index);
1965 if ((typeInfo & IsUnresolvedType) == 0)
1966 Q_ASSERT(mt.id() ==
int(typeInfo & TypeNameIndexMask));
1967 Q_ASSERT(mt.name());
1973#define ASSERT_NOT_PRIMITIVE_TYPE(TYPE, METATYPEID, NAME)
1974 Q_ASSERT(typeInfo != QMetaType::TYPE);
1976#undef ASSERT_NOT_PRIMITIVE_TYPE
1977 Q_ASSERT(typeInfo != QMetaType::QObjectStar);
1980 if (priv(mobj->d.data)->revision >= 11) {
1981 Q_ASSERT(typeInfo != QMetaType::Void);
1982 Q_ASSERT(typeInfo != QMetaType::VoidStar);
1987int QMetaMethodPrivate::parametersDataIndex()
const
1989 Q_ASSERT(priv(mobj->d.data)->revision >= 7);
1990 return typesDataIndex() + 1;
1993uint QMetaMethodPrivate::parameterTypeInfo(
int index)
const
1995 Q_ASSERT(priv(mobj->d.data)->revision >= 7);
1996 return mobj->d.data[parametersDataIndex() + index];
2001 Q_ASSERT(priv(mobj->d.data)->revision >= 7);
2002 if (methodType() == QMetaMethod::Constructor)
2006 checkMethodMetaTypeConsistency(iface, -1);
2012 Q_ASSERT(priv(mobj->d.data)->revision >= 7);
2013 int offset = (methodType() == QMetaMethod::Constructor ? 0 : 1);
2014 const auto ifaces = &mobj->d.metaTypes[data.metaTypeOffset() + offset];
2016 for (
int i = 0; i < parameterCount(); ++i)
2017 checkMethodMetaTypeConsistency(ifaces[i], i);
2022int QMetaMethodPrivate::parameterType(
int index)
const
2024 Q_ASSERT(priv(mobj->d.data)->revision >= 7);
2025 return typeFromTypeInfo(mobj, parameterTypeInfo(index));
2028void QMetaMethodPrivate::getParameterTypes(
int *types)
const
2030 Q_ASSERT(priv(mobj->d.data)->revision >= 7);
2031 int dataIndex = parametersDataIndex();
2032 int argc = parameterCount();
2033 for (
int i = 0; i < argc; ++i) {
2034 int id = typeFromTypeInfo(mobj, mobj->d.data[dataIndex++]);
2039QByteArrayView QMetaMethodPrivate::parameterTypeName(
int index)
const noexcept
2041 int paramsIndex = parametersDataIndex();
2042 return typeNameFromTypeInfo(mobj, mobj->d.data[paramsIndex + index]);
2045QList<QByteArray> QMetaMethodPrivate::parameterTypes()
const
2047 Q_ASSERT(priv(mobj->d.data)->revision >= 7);
2048 int argc = parameterCount();
2049 QList<QByteArray> list;
2051 int paramsIndex = parametersDataIndex();
2052 for (
int i = 0; i < argc; ++i) {
2053 QByteArrayView name = typeNameFromTypeInfo(mobj, mobj->d.data[paramsIndex + i]);
2054 list.emplace_back(name.toByteArray());
2059QList<QByteArray> QMetaMethodPrivate::parameterNames()
const
2061 Q_ASSERT(priv(mobj->d.data)->revision >= 7);
2062 int argc = parameterCount();
2063 QList<QByteArray> list;
2065 int namesIndex = parametersDataIndex() + argc;
2066 for (
int i = 0; i < argc; ++i)
2067 list += stringData(mobj, mobj->d.data[namesIndex + i]);
2071const char *QMetaMethodPrivate::tag()
const
2073 Q_ASSERT(priv(mobj->d.data)->revision >= 7);
2074 return rawStringData(mobj, data.tag());
2077int QMetaMethodPrivate::ownMethodIndex()
const
2080 return ( data.d - mobj->d.data - priv(mobj->d.data)->methodData)/Data::Size;
2083int QMetaMethodPrivate::ownConstructorMethodIndex()
const
2086 Q_ASSERT(methodType() == Constructor);
2087 return ( data.d - mobj->d.data - priv(mobj->d.data)->constructorData)/Data::Size;
2091
2092
2093
2094
2095
2096
2097
2098QByteArray QMetaMethod::methodSignature()
const
2101 return QByteArray();
2102 return QMetaMethodPrivate::get(
this)->signature();
2106
2107
2108
2109
2110
2111
2112QByteArray QMetaMethod::name()
const
2115 return QByteArray();
2117 return stringData(mobj, QMetaMethodPrivate::get(
this)->name());
2121
2122
2123
2124
2125
2126
2127
2128
2129QByteArrayView QMetaMethod::nameView()
const
2131 return QMetaMethodPrivate::get(
this)->name();
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144int QMetaMethod::returnType()
const
2146 return returnMetaType().id();
2150
2151
2152
2153
2154
2155QMetaType QMetaMethod::returnMetaType()
const
2157 if (!mobj || methodType() == QMetaMethod::Constructor)
2159 auto mt = QMetaType(mobj->d.metaTypes[data.metaTypeOffset()]);
2160 if (mt.id() == QMetaType::UnknownType)
2161 return QMetaType(QMetaMethodPrivate::get(
this)->returnType());
2167
2168
2169
2170
2171
2172
2173int QMetaMethod::parameterCount()
const
2177 return QMetaMethodPrivate::get(
this)->parameterCount();
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190int QMetaMethod::parameterType(
int index)
const
2192 return parameterMetaType(index).id();
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205QMetaType QMetaMethod::parameterMetaType(
int index)
const
2207 if (!mobj || index < 0)
2209 auto priv = QMetaMethodPrivate::get(
this);
2210 if (index >= priv->parameterCount())
2213 auto parameterOffset = index + (methodType() == QMetaMethod::Constructor ? 0 : 1);
2214 auto mt = QMetaType(mobj->d.metaTypes[data.metaTypeOffset() + parameterOffset]);
2215 if (mt.id() == QMetaType::UnknownType)
2216 return QMetaType(QMetaMethodPrivate::get(
this)->parameterType(index));
2222
2223
2224
2225
2226
2227
2228
2229
2230void QMetaMethod::getParameterTypes(
int *types)
const
2234 QMetaMethodPrivate::get(
this)->getParameterTypes(types);
2238
2239
2240
2241
2242QList<QByteArray> QMetaMethod::parameterTypes()
const
2245 return QList<QByteArray>();
2246 return QMetaMethodPrivate::get(
this)->parameterTypes();
2250
2251
2252
2253
2254
2255
2256QByteArray QMetaMethod::parameterTypeName(
int index)
const
2258 if (!mobj || index < 0 || index >= parameterCount())
2261 return stringData(mobj, QMetaMethodPrivate::get(
this)->parameterTypeName(index));
2265
2266
2267
2268
2269QList<QByteArray> QMetaMethod::parameterNames()
const
2272 return QList<QByteArray>();
2273 return QMetaMethodPrivate::get(
this)->parameterNames();
2278
2279
2280
2281
2282
2283
2284
2285
2286const char *QMetaMethod::typeName()
const
2290#if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
)
2291 if (methodType() == QMetaMethod::Constructor)
2294 return QMetaMethodPrivate::get(
this)->rawReturnTypeName();
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321const char *QMetaMethod::tag()
const
2325 return QMetaMethodPrivate::get(
this)->tag();
2330
2331
2332int QMetaMethod::attributes()
const
2336 return data.flags() >> 4;
2340
2341
2342
2343
2344int QMetaMethod::methodIndex()
const
2348 return QMetaMethodPrivate::get(
this)->ownMethodIndex() + mobj->methodOffset();
2352
2353
2354
2355
2356int QMetaMethod::relativeMethodIndex()
const
2360 return QMetaMethodPrivate::get(
this)->ownMethodIndex();
2365
2366
2367
2368
2369
2370int QMetaMethod::revision()
const
2374 if ((data.flags() & MethodRevisioned) == 0)
2376#if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
)
2377 if (priv(mobj->d.data)->revision < 13) {
2379 int offset = priv(mobj->d.data)->methodData
2380 + priv(mobj->d.data)->methodCount * Data::Size
2381 + QMetaMethodPrivate::get(
this)->ownMethodIndex();
2382 return mobj->d.data[offset];
2386 return mobj->d.data[data.parameters() - 1];
2390
2391
2392
2393
2394
2395
2396
2397bool QMetaMethod::isConst()
const
2401 if (QMetaObjectPrivate::get(mobj)->revision < 10)
2403 return data.flags() & MethodIsConst;
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416QMetaMethod::Access QMetaMethod::access()
const
2420 return (QMetaMethod::Access)(data.flags() & AccessMask);
2424
2425
2426
2427
2428QMetaMethod::MethodType QMetaMethod::methodType()
const
2431 return QMetaMethod::Method;
2432 return (QMetaMethod::MethodType)((data.flags() & MethodTypeMask)>>2);
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2448
2449
2450
2451
2452
2453
2454
2455QMetaMethod QMetaMethod::fromSignalImpl(
const QMetaObject *metaObject,
void **signal)
2458 void *args[] = { &i, signal };
2459 for (
const QMetaObject *m = metaObject; m; m = m->d.superdata) {
2460 m->static_metacall(QMetaObject::IndexOfMethod, 0, args);
2462 return QMetaMethod::fromRelativeMethodIndex(m, i);
2464 return QMetaMethod();
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579bool QMetaMethod::invoke(QObject *object,
2580 Qt::ConnectionType connectionType,
2581 QGenericReturnArgument returnValue,
2582 QGenericArgument val0,
2583 QGenericArgument val1,
2584 QGenericArgument val2,
2585 QGenericArgument val3,
2586 QGenericArgument val4,
2587 QGenericArgument val5,
2588 QGenericArgument val6,
2589 QGenericArgument val7,
2590 QGenericArgument val8,
2591 QGenericArgument val9)
const
2593 if (!object || !mobj)
2597 const char *typeNames[] = {
2625 for (paramCount = 1; paramCount < MaximumParamCount; ++paramCount) {
2626 if (qstrlen(typeNames[paramCount]) <= 0)
2629 return invokeImpl(*
this, object, connectionType, paramCount, param, typeNames,
nullptr);
2632bool QMetaMethod::invokeImpl(QMetaMethod self,
void *target, Qt::ConnectionType connectionType,
2633 qsizetype paramCount,
const void *
const *parameters,
2634 const char *
const *typeNames,
2635 const QtPrivate::QMetaTypeInterface *
const *metaTypes)
2637 if (!target || !self.mobj)
2639 QMetaMethodPrivate::InvokeFailReason r =
2640 QMetaMethodPrivate::invokeImpl(self, target, connectionType, paramCount, parameters,
2641 typeNames, metaTypes);
2642 if (Q_LIKELY(r == QMetaMethodPrivate::InvokeFailReason::None))
2645 if (
int(r) >=
int(QMetaMethodPrivate::InvokeFailReason::FormalParameterMismatch)) {
2646 int n =
int(r) -
int(QMetaMethodPrivate::InvokeFailReason::FormalParameterMismatch);
2647 qWarning(
"QMetaMethod::invoke: cannot convert formal parameter %d from %s in call to %s::%s",
2648 n, typeNames[n + 1] ? typeNames[n + 1] : metaTypes[n + 1]->name,
2649 self.mobj->className(), self.methodSignature().constData());
2651 if (r == QMetaMethodPrivate::InvokeFailReason::TooFewArguments) {
2652 qWarning(
"QMetaMethod::invoke: too few arguments (%d) in call to %s::%s",
2653 int(paramCount), self.mobj->className(), self.methodSignature().constData());
2659 Qt::ConnectionType connectionType,
2660 qsizetype paramCount,
const void *
const *parameters,
2661 const char *
const *typeNames,
2664 auto object =
static_cast<QObject *>(target);
2665 auto priv = QMetaMethodPrivate::get(&self);
2666 constexpr bool MetaTypesAreOptional = QT_VERSION < QT_VERSION_CHECK(7, 0, 0);
2667 auto methodMetaTypes = priv->parameterMetaTypeInterfaces();
2668 auto param =
const_cast<
void **>(parameters);
2670 Q_ASSERT(priv->mobj);
2671 Q_ASSERT(self.methodType() == Constructor || object);
2672 Q_ASSERT(self.methodType() == Constructor || connectionType == Qt::ConnectionType(-1) ||
2673 priv->mobj->cast(object));
2674 Q_ASSERT(paramCount >= 1);
2675 Q_ASSERT(parameters);
2676 Q_ASSERT(typeNames);
2677 Q_ASSERT(MetaTypesAreOptional || metaTypes);
2679 if ((paramCount - 1) < qsizetype(priv->data.argc()))
2683 auto checkTypesAreCompatible = [=](
int idx) {
2684 uint typeInfo = priv->parameterTypeInfo(idx - 1);
2685 QByteArrayView userTypeName(typeNames[idx] ? typeNames[idx] : metaTypes[idx]->name);
2687 if ((typeInfo & IsUnresolvedType) == 0) {
2689 if (MetaTypesAreOptional && !metaTypes)
2690 return int(typeInfo) == QMetaType::fromName(userTypeName).id();
2691 return int(typeInfo) == metaTypes[idx]->typeId;
2694 QByteArrayView methodTypeName = stringDataView(priv->mobj, typeInfo & TypeNameIndexMask);
2695 if ((MetaTypesAreOptional && !metaTypes) || !metaTypes[idx]) {
2697 if (methodTypeName == userTypeName)
2701 QByteArray normalized = normalizeTypeInternal(userTypeName.begin(), userTypeName.end());
2702 return methodTypeName == normalized;
2706 Q_ASSERT(userType.isValid());
2707 if (QMetaType(methodMetaTypes[idx - 1]) == userType)
2712 if (methodMetaTypes[idx - 1])
2716 QMetaType resolved = QMetaType::fromName(methodTypeName);
2717 return resolved == userType;
2721 for (qsizetype i = 0; metaTypes && i < paramCount; ++i)
2725 for (qsizetype i = 1; i < paramCount; ++i) {
2726 if (!checkTypesAreCompatible(i))
2731 if (self.methodType() == Constructor) {
2733 qWarning(
"QMetaMethod::invokeMethod: cannot call constructor %s on object %p",
2734 self.methodSignature().constData(), object);
2738 if (!parameters[0]) {
2739 qWarning(
"QMetaMethod::invokeMethod: constructor call to %s must assign a return type",
2740 self.methodSignature().constData());
2744 if (!MetaTypesAreOptional || metaTypes) {
2745 if (metaTypes[0]->typeId != QMetaType::QObjectStar) {
2746 qWarning(
"QMetaMethod::invokeMethod: cannot convert QObject* to %s on constructor call %s",
2747 metaTypes[0]
->name, self.methodSignature().constData());
2752 int idx = priv->ownConstructorMethodIndex();
2753 if (priv->mobj->static_metacall(QMetaObject::CreateInstance, idx, param) >= 0)
2759 if (parameters[0]) {
2760 if (!checkTypesAreCompatible(0)) {
2761 const char *retType = typeNames[0] ? typeNames[0] : metaTypes[0]
->name;
2762 qWarning(
"QMetaMethod::invokeMethod: return type mismatch for method %s::%s:"
2763 " cannot convert from %s to %s during invocation",
2764 priv->mobj->className(), priv->methodSignature().constData(),
2765 priv->rawReturnTypeName(), retType);
2770 Qt::HANDLE currentThreadId =
nullptr;
2771 QThread *objectThread =
nullptr;
2772 auto receiverInSameThread = [&]() {
2773 if (!currentThreadId) {
2774 currentThreadId = QThread::currentThreadId();
2775 objectThread = object->thread();
2778 return currentThreadId == QThreadData::get2(objectThread)->threadId.loadRelaxed();
2783 if (connectionType == Qt::AutoConnection)
2784 connectionType = receiverInSameThread() ? Qt::DirectConnection : Qt::QueuedConnection;
2785 else if (connectionType == Qt::ConnectionType(-1))
2786 connectionType = Qt::DirectConnection;
2788#if !QT_CONFIG(thread)
2789 if (connectionType == Qt::BlockingQueuedConnection) {
2790 connectionType = Qt::DirectConnection;
2795 int idx_relative = priv->ownMethodIndex();
2796 int idx_offset = priv->mobj->methodOffset();
2797 QObjectPrivate::StaticMetaCallFunction callFunction = priv->mobj->d.static_metacall;
2799 if (connectionType == Qt::DirectConnection) {
2801 callFunction(object, QMetaObject::InvokeMetaMethod, idx_relative, param);
2802 else if (QMetaObject::metacall(object, QMetaObject::InvokeMetaMethod, idx_relative + idx_offset, param) >= 0)
2804 }
else if (connectionType == Qt::QueuedConnection) {
2805 if (parameters[0]) {
2806 qWarning(
"QMetaMethod::invoke: Unable to invoke methods with return values in "
2807 "queued connections");
2811 auto event =
std::make_unique<
QMetaCallEvent>(idx_offset, idx_relative, callFunction,
nullptr, -1, paramCount);
2812 QMetaType *types = event->types();
2813 void **args = event->args();
2816 for (
int i = 1; i < paramCount; ++i) {
2817 types[i] = QMetaType(methodMetaTypes[i - 1]);
2818 if (!types[i].iface() && (!MetaTypesAreOptional || metaTypes))
2819 types[i] = QMetaType(metaTypes[i]);
2820 if (!types[i].iface())
2821 types[i] = priv->parameterMetaType(i - 1);
2822 if (!types[i].iface() && typeNames[i])
2823 types[i] = QMetaType::fromName(typeNames[i]);
2824 if (!types[i].iface()) {
2825 qWarning(
"QMetaMethod::invoke: Unable to handle unregistered datatype '%s'",
2832 for (
int i = 1; i < paramCount; ++i)
2833 args[i] = types[i].create(parameters[i]);
2835 QCoreApplication::postEvent(object, event.release());
2837#if QT_CONFIG(thread)
2838 if (receiverInSameThread()) {
2839 qWarning(
"QMetaMethod::invoke: Dead lock detected in BlockingQueuedConnection: "
2840 "Receiver is %s(%p)", priv->mobj->className(), object);
2841 return InvokeFailReason::DeadLockDetected;
2844 QSemaphore semaphore;
2845 QCoreApplication::postEvent(object,
new QMetaCallEvent(idx_offset, idx_relative, callFunction,
2846 nullptr, -1, param, &semaphore));
2847 semaphore.acquire();
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956bool QMetaMethod::invokeOnGadget(
void *gadget,
2957 QGenericReturnArgument returnValue,
2958 QGenericArgument val0,
2959 QGenericArgument val1,
2960 QGenericArgument val2,
2961 QGenericArgument val3,
2962 QGenericArgument val4,
2963 QGenericArgument val5,
2964 QGenericArgument val6,
2965 QGenericArgument val7,
2966 QGenericArgument val8,
2967 QGenericArgument val9)
const
2969 if (!gadget || !mobj)
2973 if (returnValue.data()) {
2974 const char *retType = typeName();
2975 if (qstrcmp(returnValue.name(), retType) != 0) {
2977 QByteArray normalized = QMetaObject::normalizedType(returnValue.name());
2978 if (qstrcmp(normalized.constData(), retType) != 0) {
2980 int t = returnType();
2981 if (t == QMetaType::UnknownType || t != QMetaType::fromName(normalized).id())
2988 const char *typeNames[] = {
3002 for (paramCount = 1; paramCount < MaximumParamCount; ++paramCount) {
3003 if (qstrlen(typeNames[paramCount]) <= 0)
3006 if (paramCount <= QMetaMethodPrivate::get(
this)->parameterCount())
3023 int idx_relative = QMetaMethodPrivate::get(
this)->ownMethodIndex();
3024 Q_ASSERT(QMetaObjectPrivate::get(mobj)->revision >= 6);
3025 QObjectPrivate::StaticMetaCallFunction callFunction = mobj->d.static_metacall;
3028 callFunction(
reinterpret_cast<QObject*>(gadget), QMetaObject::InvokeMetaMethod, idx_relative, param);
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3075
3076
3077
3078
3079
3080
3081
3084
3085
3086
3090
3091
3092
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105const char *QMetaEnum::name()
const
3109 return rawStringData(mobj, data.name());
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124const char *QMetaEnum::enumName()
const
3128 return rawStringData(mobj, data.alias());
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143QMetaType QMetaEnum::metaType()
const
3148 const QMetaObjectPrivate *p = priv(mobj->d.data);
3149#if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
)
3150 if (p->revision < 12)
3154 return QMetaType(mobj->d.metaTypes[data.index(mobj) + p->propertyCount]);
3158
3159
3160
3161
3162int QMetaEnum::keyCount()
const
3166 return data.keyCount();
3170
3171
3172
3173
3174const char *QMetaEnum::key(
int index)
const
3178 if (index >= 0 && index <
int(data.keyCount()))
3179 return rawStringData(mobj, mobj->d.data[data.data() + 2*index]);
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193int QMetaEnum::value(
int index)
const
3195 return value64(index).value_or(-1);
3203Q_DECL_PURE_FUNCTION
static inline EnumExtendMode enumExtendMode(
const QMetaEnum &e)
3209 if (e.metaType().flags() & QMetaType::IsUnsignedEnumeration)
3221 return value == uint(value);
3222 return value == quint64(
int(value));
3225template <
typename... Mode>
inline
3226quint64 QMetaEnum::value_helper(uint index, Mode... modes)
const noexcept
3228 static_assert(
sizeof...(Mode) < 2);
3229 if constexpr (
sizeof...(Mode) == 0) {
3230 return value_helper(index, enumExtendMode(*
this));
3231 }
else if constexpr (
sizeof...(Mode) == 1) {
3232 auto mode = (modes, ...);
3233 quint64 value = mobj->d.data[data.data() + 2U * index + 1];
3235 value |= quint64(mobj->d.data[data.data() + 2U * data.keyCount() + index]) << 32;
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264std::optional<quint64> QMetaEnum::value64(
int index)
const
3267 return std::nullopt;
3268 if (index < 0 || index >=
int(data.keyCount()))
3269 return std::nullopt;
3271 return value_helper(index);
3275
3276
3277
3278
3279
3280
3281
3282
3283bool QMetaEnum::isFlag()
const
3287 return data.flags() & EnumIsFlag;
3291
3292
3293
3294
3295
3296bool QMetaEnum::isScoped()
const
3300 return data.flags() & EnumIsScoped;
3304
3305
3306
3307
3308
3309
3310bool QMetaEnum::is64Bit()
const
3314 return data.flags() & EnumIs64Bit;
3318
3319
3320
3321
3322
3323
3324
3325const char *QMetaEnum::scope()
const
3327 return mobj ? mobj->className() :
nullptr;
3332 const QByteArrayView className = e->enclosingMetaObject()->className();
3337 if (scope == className)
3343 QByteArrayView name = e->enumName();
3347 const auto sz = className.size();
3348 if (scope.size() == sz + qsizetype(qstrlen(
"::")) + name.size()
3349 && scope.startsWith(className)
3350 && scope.sliced(sz, 2) ==
"::"
3351 && scope.sliced(sz + 2) == name)
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372int QMetaEnum::keyToValue(
const char *key,
bool *ok)
const
3374 auto value = keyToValue64(key);
3376 *ok = value.has_value();
3377 return int(value.value_or(-1));
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392std::optional<quint64> QMetaEnum::keyToValue64(
const char *key)
const
3395 return std::nullopt;
3396 const auto [scope, enumKey] = parse_scope(QLatin1StringView(key));
3397 for (
int i = 0; i <
int(data.keyCount()); ++i) {
3398 if ((!scope || isScopeMatch(*scope,
this))
3399 && enumKey == stringDataView(mobj, mobj->d.data[data.data() + 2 * i])) {
3400 return value_helper(i);
3403 return std::nullopt;
3407
3408
3409
3410
3411
3412
3413
3414const char *QMetaEnum::valueToKey(quint64 value)
const
3419 EnumExtendMode mode = enumExtendMode(*
this);
3420 if (!isEnumValueSuitable(value, mode))
3423 for (
int i = 0; i <
int(data.keyCount()); ++i) {
3424 if (value == value_helper(i, mode))
3425 return rawStringData(mobj, mobj->d.data[data.data() + 2 * i]);
3430static bool parseEnumFlags(QByteArrayView v, QVarLengthArray<QByteArrayView, 10> &list)
3434 qWarning(
"QMetaEnum::keysToValue: empty keys string.");
3438 qsizetype sep = v.indexOf(
'|', 0);
3440 qWarning(
"QMetaEnum::keysToValue: malformed keys string, starts with '|', \"%s\"",
3450 if (v.endsWith(
'|')) {
3451 qWarning(
"QMetaEnum::keysToValue: malformed keys string, ends with '|', \"%s\"",
3456 const auto begin = v.begin();
3457 const auto end = v.end();
3459 for (; b != end && sep != -1; sep = v.indexOf(
'|', sep)) {
3460 list.push_back({b, begin + sep});
3464 qWarning(
"QMetaEnum::keysToValue: malformed keys string, has two consecutive '|': "
3465 "\"%s\"", v.constData());
3471 list.push_back({b, end});
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489int QMetaEnum::keysToValue(
const char *keys,
bool *ok)
const
3491 auto value = keysToValue64(keys);
3493 *ok = value.has_value();
3494 return int(value.value_or(-1));
3498
3499
3500
3501
3502
3503
3504
3505
3506std::optional<quint64> QMetaEnum::keysToValue64(
const char *keys)
const
3509 return std::nullopt;
3511 EnumExtendMode mode = enumExtendMode(*
this);
3512 auto lookup = [&] (QByteArrayView key) -> std::optional<quint64> {
3513 for (
int i = data.keyCount() - 1; i >= 0; --i) {
3514 if (key == stringDataView(mobj, mobj->d.data[data.data() + 2*i]))
3515 return value_helper(i, mode);
3517 return std::nullopt;
3521 QVarLengthArray<QByteArrayView, 10> list;
3522 const bool r = parseEnumFlags(QByteArrayView{keys}, list);
3524 return std::nullopt;
3525 for (
const auto &untrimmed : list) {
3526 const auto parsed = parse_scope(untrimmed.trimmed());
3527 if (parsed.scope && !isScopeMatch(*parsed.scope,
this))
3528 return std::nullopt;
3529 if (
auto thisValue = lookup(parsed.key))
3530 value |= *thisValue;
3532 return std::nullopt;
3539template <
typename String,
typename Container,
typename Separator>
3540void join_reversed(String &s,
const Container &c, Separator sep)
3544 qsizetype len = qsizetype(c.size()) - 1;
3546 len += qsizetype(e.size());
3549 for (
auto rit = c.rbegin(), rend = c.rend(); rit != rend; ++rit) {
3550 const auto &e = *rit;
3554 s.append(e.data(), e.size());
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569QByteArray QMetaEnum::valueToKeys(quint64 value)
const
3575 EnumExtendMode mode = enumExtendMode(*
this);
3576 if (!isEnumValueSuitable(value, mode))
3579 QVarLengthArray<QByteArrayView,
sizeof(
int) * CHAR_BIT> parts;
3583 for (
int i = data.keyCount() - 1; i >= 0; --i) {
3584 quint64 k = value_helper(i, mode);
3585 if ((k != 0 && (v & k) == k) || (k == value)) {
3587 parts.push_back(stringDataView(mobj, mobj->d.data[data.data() + 2 * i]));
3590 join_reversed(keys, parts,
'|');
3595
3596
3597QMetaEnum::QMetaEnum(
const QMetaObject *mobj,
int index)
3598 : mobj(mobj), data({ mobj->d.data + priv(mobj->d.data)->enumeratorData + index * Data::Size })
3600 Q_ASSERT(index >= 0 && index < priv(mobj->d.data)->enumeratorCount);
3603int QMetaEnum::Data::index(
const QMetaObject *mobj)
const
3605#if QT_VERSION >= QT_VERSION_CHECK(7
, 0
, 0
)
3606# warning "Consider changing Size to a power of 2"
3608 return (
unsigned(d - mobj->d.data) - priv(mobj->d.data)->enumeratorData) / Size;
3612
3613
3614
3615
3616
3617
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3656
3657
3658
3659
3660
3661
3662
3665
3666
3667
3670
3671
3672
3675
3676
3677
3678
3679const char *QMetaProperty::name()
const
3683 return rawStringData(mobj, data.name());
3687
3688
3689
3690
3691const char *QMetaProperty::typeName()
const
3696 if (
const auto mt = metaType(); mt.isValid())
3698 return typeNameFromTypeInfo(mobj, data.type()).constData();
3702
3703
3704
3705
3706
3707
3708
3711
3712
3713
3714
3715
3716
3717
3718
3719
3722
3723
3724
3725
3726
3727
3728
3731
3732
3733
3734
3735
3736
3737QMetaType QMetaProperty::metaType()
const
3741 return QMetaType(mobj->d.metaTypes[data.index(mobj)]);
3744int QMetaProperty::Data::index(
const QMetaObject *mobj)
const
3746#if QT_VERSION >= QT_VERSION_CHECK(7
, 0
, 0
)
3747# warning "Consider changing Size to a power of 2"
3749 return (
unsigned(d - mobj->d.data) - priv(mobj->d.data)->propertyData) / Size;
3753
3754
3755
3756
3757int QMetaProperty::propertyIndex()
const
3761 return data.index(mobj) + mobj->propertyOffset();
3765
3766
3767
3768
3769int QMetaProperty::relativePropertyIndex()
const
3773 return data.index(mobj);
3777
3778
3779
3780
3781
3782
3783
3784
3786bool QMetaProperty::isFlagType()
const
3788 return isEnumType() && menum.isFlag();
3792
3793
3794
3795
3796
3797bool QMetaProperty::isEnumType()
const
3801 return (data.flags() & EnumOrFlag) && menum.name();
3805
3806
3807
3808
3809
3810
3811
3812
3813bool QMetaProperty::hasStdCppSet()
const
3817 return (data.flags() & StdCppSet);
3821
3822
3823
3824
3825
3826
3827bool QMetaProperty::isAlias()
const
3831 return (data.flags() & Alias);
3834#if QT_DEPRECATED_SINCE(6
, 4
)
3836
3837
3838
3839
3840
3841
3842
3843int QMetaProperty::registerPropertyType()
const
3849QMetaProperty::QMetaProperty(
const QMetaObject *mobj,
int index)
3851 data(getMetaPropertyData(mobj, index))
3853 Q_ASSERT(index >= 0 && index < priv(mobj->d.data)->propertyCount);
3855 if (!(data.flags() & EnumOrFlag) || !metaType().flags().testFlag(QMetaType::IsEnumeration))
3857 QByteArrayView enum_name = typeNameFromTypeInfo(mobj, data.type());
3858 menum = mobj->enumerator(QMetaObjectPrivate::indexOfEnumerator(mobj, enum_name));
3859 if (menum.isValid())
3862 QByteArrayView scope_name;
3863 const auto parsed = parse_scope(enum_name);
3865 scope_name = *parsed.scope;
3866 enum_name = parsed.key;
3868 scope_name = objectClassName(mobj);
3871 const QMetaObject *scope =
nullptr;
3872 if (scope_name ==
"Qt")
3873 scope = &Qt::staticMetaObject;
3875 scope = QMetaObject_findMetaObject(mobj, QByteArrayView(scope_name));
3878 menum = scope->enumerator(QMetaObjectPrivate::indexOfEnumerator(scope, enum_name));
3882
3883
3884
3885QMetaProperty::Data QMetaProperty::getMetaPropertyData(
const QMetaObject *mobj,
int index)
3887 return { mobj->d.data + priv(mobj->d.data)->propertyData + index * Data::Size };
3891
3892
3893
3894
3895
3896QMetaEnum QMetaProperty::enumerator()
const
3902
3903
3904
3905
3906
3907QVariant QMetaProperty::read(
const QObject *object)
const
3909 if (!object || !mobj)
3919 void *argv[] = {
nullptr, &value, &status };
3920 QMetaType t(mobj->d.metaTypes[data.index(mobj)]);
3921 if (t == QMetaType::fromType<QVariant>()) {
3924 value = QVariant(t,
nullptr);
3925 argv[0] = value.data();
3927 if (priv(mobj->d.data)->flags & PropertyAccessInStaticMetaCall && mobj->d.static_metacall) {
3928 mobj->d.static_metacall(
const_cast<QObject*>(object), QMetaObject::ReadProperty, data.index(mobj), argv);
3930 QMetaObject::metacall(
const_cast<QObject*>(object), QMetaObject::ReadProperty,
3931 data.index(mobj) + mobj->propertyOffset(), argv);
3936 if (t != QMetaType::fromType<QVariant>() && argv[0] != value.data())
3938 return QVariant(t, argv[0]);
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956bool QMetaProperty::write(QObject *object,
const QVariant &value)
const
3958 if (!object || !isWritable())
3960 return write(object, QVariant(value));
3964
3965
3966
3967bool QMetaProperty::write(QObject *object, QVariant &&v)
const
3969 if (!object || !isWritable())
3971 QMetaType t(mobj->d.metaTypes[data.index(mobj)]);
3972 if (t != QMetaType::fromType<QVariant>() && t != v.metaType()) {
3973 if (isEnumType() && !t.metaObject() && v.metaType() == QMetaType::fromType<QString>()) {
3977 std::optional value = isFlagType() ? menum.keysToValue64(v.toByteArray())
3978 : menum.keyToValue64(v.toByteArray());
3980 v = QVariant(qlonglong(*value));
3987 return reset(object);
3988 v = QVariant(t,
nullptr);
3989 }
else if (!v.convert(t)) {
4002 void *argv[] = {
nullptr, &v, &status, &flags };
4003 if (t == QMetaType::fromType<QVariant>())
4007 if (priv(mobj->d.data)->flags & PropertyAccessInStaticMetaCall && mobj->d.static_metacall)
4008 mobj->d.static_metacall(object, QMetaObject::WriteProperty, data.index(mobj), argv);
4010 QMetaObject::metacall(object, QMetaObject::WriteProperty, data.index(mobj) + mobj->propertyOffset(), argv);
4016
4017
4018
4019
4020
4021
4022
4023bool QMetaProperty::reset(QObject *object)
const
4025 if (!object || !mobj || !isResettable())
4027 void *argv[] = {
nullptr };
4028 if (priv(mobj->d.data)->flags & PropertyAccessInStaticMetaCall && mobj->d.static_metacall)
4029 mobj->d.static_metacall(object, QMetaObject::ResetProperty, data.index(mobj), argv);
4031 QMetaObject::metacall(object, QMetaObject::ResetProperty, data.index(mobj) + mobj->propertyOffset(), argv);
4036
4037
4038
4039
4040
4041
4042
4043
4044QUntypedBindable QMetaProperty::bindable(QObject *object)
const
4046 QUntypedBindable bindable;
4047 void * argv[1] { &bindable };
4048 mobj->metacall(object, QMetaObject::BindableProperty, data.index(mobj) + mobj->propertyOffset(), argv);
4052
4053
4054
4055
4056
4057
4058
4059QVariant QMetaProperty::readOnGadget(
const void *gadget)
const
4061 Q_ASSERT(priv(mobj->d.data)->flags & PropertyAccessInStaticMetaCall && mobj->d.static_metacall);
4062 return read(
reinterpret_cast<
const QObject*>(gadget));
4066
4067
4068
4069
4070
4071
4072
4073bool QMetaProperty::writeOnGadget(
void *gadget,
const QVariant &value)
const
4075 Q_ASSERT(priv(mobj->d.data)->flags & PropertyAccessInStaticMetaCall && mobj->d.static_metacall);
4076 return write(
reinterpret_cast<QObject*>(gadget), value);
4080
4081
4082
4083bool QMetaProperty::writeOnGadget(
void *gadget, QVariant &&value)
const
4085 Q_ASSERT(priv(mobj->d.data)->flags & PropertyAccessInStaticMetaCall && mobj->d.static_metacall);
4086 return write(
reinterpret_cast<QObject*>(gadget), std::move(value));
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099bool QMetaProperty::resetOnGadget(
void *gadget)
const
4101 Q_ASSERT(priv(mobj->d.data)->flags & PropertyAccessInStaticMetaCall && mobj->d.static_metacall);
4102 return reset(
reinterpret_cast<QObject*>(gadget));
4106
4107
4108
4109
4110
4111bool QMetaProperty::isResettable()
const
4115 return data.flags() & Resettable;
4119
4120
4121
4122
4123bool QMetaProperty::isReadable()
const
4127 return data.flags() & Readable;
4131
4132
4133
4134
4135
4136bool QMetaProperty::hasNotifySignal()
const
4140 return data.notifyIndex() != uint(-1);
4144
4145
4146
4147
4148
4149
4150
4151QMetaMethod QMetaProperty::notifySignal()
const
4153 int id = notifySignalIndex();
4155 return mobj->method(id);
4157 return QMetaMethod();
4161
4162
4163
4164
4165
4166
4167
4168int QMetaProperty::notifySignalIndex()
const
4170 if (!mobj || data.notifyIndex() == std::numeric_limits<uint>::max())
4172 uint methodIndex = data.notifyIndex();
4173 if (!(methodIndex & IsUnresolvedSignal))
4174 return methodIndex + mobj->methodOffset();
4175 methodIndex &= ~IsUnresolvedSignal;
4176 const QByteArray signalName = stringData(mobj, methodIndex);
4177 const QMetaObject *m = mobj;
4179 int idx = QMetaObjectPrivate::indexOfMethodRelative<MethodSignal>(&m, signalName, 0,
nullptr);
4181 return idx + m->methodOffset();
4183 QArgumentType argType(metaType());
4184 idx = QMetaObjectPrivate::indexOfMethodRelative<MethodSignal>(&m, signalName, 1, &argType);
4186 return idx + m->methodOffset();
4187 qWarning(
"QMetaProperty::notifySignal: cannot find the NOTIFY signal %s in class %s for property '%s'",
4188 signalName.constData(), mobj->className(), name());
4194
4195
4196
4197
4198
4199
4200int QMetaProperty::revision()
const
4204 return data.revision();
4208
4209
4210
4211
4212
4213bool QMetaProperty::isWritable()
const
4217 return data.flags() & Writable;
4221
4222
4223
4224
4225
4226bool QMetaProperty::isDesignable()
const
4230 return data.flags() & Designable;
4234
4235
4236
4237
4238
4239bool QMetaProperty::isScriptable()
const
4243 return data.flags() & Scriptable;
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256bool QMetaProperty::isStored()
const
4260 return data.flags() & Stored;
4264
4265
4266
4267
4268
4269
4270
4271bool QMetaProperty::isUser()
const
4275 return data.flags() & User;
4279
4280
4281
4282
4283
4284
4285bool QMetaProperty::isConstant()
const
4289 return data.flags() & Constant;
4293
4294
4295
4296
4297
4298
4299bool QMetaProperty::isFinal()
const
4303 return data.flags() & Final;
4307
4308
4309
4310
4311
4312
4313bool QMetaProperty::isRequired()
const
4317 return data.flags() & Required;
4321
4322
4323
4324
4325
4326
4327
4328
4329bool QMetaProperty::isBindable()
const
4333 return (data.flags() & Bindable);
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4361
4362
4363
4366
4367
4368
4371
4372
4373
4374
4375const char *QMetaClassInfo::name()
const
4379 return rawStringData(mobj, data.name());
4383
4384
4385
4386
4387const char *QMetaClassInfo::value()
const
4391 return rawStringData(mobj, data.value());
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4409
4410
4411
4412
4413
4414
4415
4416
4417
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4445
4446
4447
4448
4451
4452
4453
4454
4457
4458
4459
4460
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4476
4477
4478
4479
4480
4483
4484
4485
4486
4487
4490 Q_ASSERT(local_method_index < get(mobj)->methodCount);
4491 while (QMetaMethod::fromRelativeMethodIndex(mobj, local_method_index).data.flags() & MethodCloned) {
4492 Q_ASSERT(local_method_index > 0);
4493 --local_method_index;
4495 return local_method_index;
4499
4500
4501
4502
4505 QList<QByteArray> list;
4506 while (*signature && *signature !=
'(')
4508 while (*signature && *signature !=
')' && *++signature !=
')') {
4509 const char *begin = signature;
4511 while (*signature && (level > 0 || *signature !=
',') && *signature !=
')') {
4512 if (*signature ==
'<')
4514 else if (*signature ==
'>')
4518 list += QByteArray(begin, signature - begin);
Combined button and popup list for selecting options.