Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qmetaobjectbuilder.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5
6#include "qobject_p.h"
7#include "qmetaobject_p.h"
8
9#include <vector>
10#include <stdlib.h>
11
13
44// copied from moc's generator.cpp
45namespace QtPrivate {
46Q_CORE_EXPORT bool isBuiltinType(const QByteArray &type)
47{
48 int id = QMetaType::fromName(type).id();
49 if (!id && !type.isEmpty() && type != "void")
50 return false;
51 return (id < QMetaType::User);
52}
53} // namespace QtPrivate
54
55// copied from qmetaobject.cpp
56[[maybe_unused]] static inline const QMetaObjectPrivate *qmobPriv(const uint* data)
57{ return reinterpret_cast<const QMetaObjectPrivate*>(data); }
58
60{
61public:
63 (QMetaMethod::MethodType _methodType,
64 const QByteArray& _signature,
65 const QByteArray& _returnType = QByteArray("void"),
67 int _revision = 0)
68 : signature(QMetaObject::normalizedSignature(_signature.constData())),
69 returnType(QMetaObject::normalizedType(_returnType)),
70 attributes(((int)_access) | (((int)_methodType) << 2)),
71 revision(_revision)
72 {
74 }
75
78 QList<QByteArray> parameterNames;
82
87
92
94 {
95 attributes = ((attributes & ~AccessMask) | (int)value);
96 }
97
98 QList<QByteArray> parameterTypes() const
99 {
101 }
102
103 int parameterCount() const
104 {
105 return parameterTypes().size();
106 }
107
109 {
110 return signature.left(qMax(signature.indexOf('('), 0));
111 }
112};
114
116{
117public:
119 (const QByteArray& _name, const QByteArray& _type, QMetaType _metaType, int notifierIdx=-1,
120 int _revision = 0)
121 : name(_name),
122 type(QMetaObject::normalizedType(_type.constData())),
123 metaType(_metaType),
124 flags(Readable | Writable | Scriptable), notifySignal(notifierIdx),
125 revision(_revision)
126 {
127
128 }
129
133 int flags;
136
137 bool flag(int f) const
138 {
139 return ((flags & f) != 0);
140 }
141
142 void setFlag(int f, bool value)
143 {
144 if (value)
145 flags |= f;
146 else
147 flags &= ~f;
148 }
149};
151
153{
154public:
156 : name(_name), enumName(_name), isFlag(false), isScoped(false)
157 {
158 }
159
163 bool isFlag;
165 QList<QByteArray> keys;
166 QList<int> values;
167};
169
171{
172public:
174 : flags(0)
175 {
176 superClass = &QObject::staticMetaObject;
177 staticMetacallFunction = nullptr;
178 }
179
180 bool hasRevisionedMethods() const;
181
185 std::vector<QMetaMethodBuilderPrivate> methods;
186 std::vector<QMetaMethodBuilderPrivate> constructors;
187 std::vector<QMetaPropertyBuilderPrivate> properties;
188 QList<QByteArray> classInfoNames;
189 QList<QByteArray> classInfoValues;
190 std::vector<QMetaEnumBuilderPrivate> enumerators;
191 QList<const QMetaObject *> relatedMetaObjects;
192 MetaObjectFlags flags;
193};
194
196{
197 for (const auto &method : methods) {
198 if (method.revision)
199 return true;
200 }
201 return false;
202}
203
211
224 QMetaObjectBuilder::AddMembers members)
225{
227 addMetaObject(prototype, members);
228}
229
237
245{
246 return d->className;
247}
248
259
268{
269 return d->superClass;
270}
271
280{
281 Q_ASSERT(meta);
282 d->superClass = meta;
283}
284
291MetaObjectFlags QMetaObjectBuilder::flags() const
292{
293 return d->flags;
294}
295
303{
304 d->flags = flags;
305}
306
315{
316 return int(d->methods.size());
317}
318
325{
326 return int(d->constructors.size());
327}
328
336{
337 return int(d->properties.size());
338}
339
348{
349 return int(d->enumerators.size());
350}
351
360{
361 return d->classInfoNames.size();
362}
363
379
389{
390 int index = int(d->methods.size());
391 d->methods.push_back(QMetaMethodBuilderPrivate(QMetaMethod::Method, signature));
392 return QMetaMethodBuilder(this, index);
393}
394
405 const QByteArray &returnType)
406{
407 int index = int(d->methods.size());
408 d->methods.push_back(QMetaMethodBuilderPrivate(QMetaMethod::Method, signature, returnType));
409 return QMetaMethodBuilder(this, index);
410}
411
424{
426 if (prototype.methodType() == QMetaMethod::Method)
427 method = addMethod(prototype.methodSignature());
428 else if (prototype.methodType() == QMetaMethod::Signal)
429 method = addSignal(prototype.methodSignature());
430 else if (prototype.methodType() == QMetaMethod::Slot)
431 method = addSlot(prototype.methodSignature());
432 else if (prototype.methodType() == QMetaMethod::Constructor)
434 method.setReturnType(prototype.typeName());
435 method.setParameterNames(prototype.parameterNames());
436 method.setTag(prototype.tag());
437 method.setAccess(prototype.access());
438 method.setAttributes(prototype.attributes());
439 method.setRevision(prototype.revision());
440 return method;
441}
442
452{
453 int index = int(d->methods.size());
454 d->methods.push_back(QMetaMethodBuilderPrivate(QMetaMethod::Slot, signature));
455 return QMetaMethodBuilder(this, index);
456}
457
467{
468 int index = int(d->methods.size());
471 return QMetaMethodBuilder(this, index);
472}
473
484{
485 int index = int(d->constructors.size());
487 /*returnType=*/QByteArray()));
488 return QMetaMethodBuilder(this, -(index + 1));
489}
490
503{
506 ctor.setReturnType(prototype.typeName());
507 ctor.setParameterNames(prototype.parameterNames());
508 ctor.setTag(prototype.tag());
509 ctor.setAccess(prototype.access());
510 ctor.setAttributes(prototype.attributes());
511 return ctor;
512}
513
524 int notifierId)
525{
526 return addProperty(name, type, QMetaType::fromName(type), notifierId);
527}
528
533{
534 int index = int(d->properties.size());
535 d->properties.push_back(QMetaPropertyBuilderPrivate(name, type, metaType, notifierId));
536 return QMetaPropertyBuilder(this, index);
537}
538
548{
549 QMetaPropertyBuilder property = addProperty(prototype.name(), prototype.typeName(), prototype.metaType());
550 property.setReadable(prototype.isReadable());
551 property.setWritable(prototype.isWritable());
552 property.setResettable(prototype.isResettable());
553 property.setDesignable(prototype.isDesignable());
554 property.setScriptable(prototype.isScriptable());
555 property.setStored(prototype.isStored());
556 property.setUser(prototype.isUser());
557 property.setStdCppSet(prototype.hasStdCppSet());
558 property.setEnumOrFlag(prototype.isEnumType());
559 property.setConstant(prototype.isConstant());
560 property.setFinal(prototype.isFinal());
561 property.setRevision(prototype.revision());
562 if (prototype.hasNotifySignal()) {
563 // Find an existing method for the notify signal, or add a new one.
564 QMetaMethod method = prototype.notifySignal();
565 int index = indexOfMethod(method.methodSignature());
566 if (index == -1)
568 d->properties[property._index].notifySignal = index;
569 }
570 return property;
571}
572
587
598{
599 QMetaEnumBuilder en = addEnumerator(prototype.name());
600 en.setEnumName(prototype.enumName());
601 en.setMetaType(prototype.metaType());
602 en.setIsFlag(prototype.isFlag());
603 en.setIsScoped(prototype.isScoped());
604 int count = prototype.keyCount();
605 for (int index = 0; index < count; ++index)
606 en.addKey(prototype.key(index), prototype.value(index));
607 return en;
608}
609
618{
619 int index = d->classInfoNames.size();
620 d->classInfoNames += name;
622 return index;
623}
624
637{
638 Q_ASSERT(meta);
639 int index = d->relatedMetaObjects.size();
640 d->relatedMetaObjects.append(meta);
641 return index;
642}
643
652 QMetaObjectBuilder::AddMembers members)
653{
654 Q_ASSERT(prototype);
655 int index;
656
657 if ((members & ClassName) != 0)
658 d->className = prototype->className();
659
660 if ((members & SuperClass) != 0)
661 d->superClass = prototype->superClass();
662
663 if ((members & (Methods | Signals | Slots)) != 0) {
664 for (index = prototype->methodOffset(); index < prototype->methodCount(); ++index) {
665 QMetaMethod method = prototype->method(index);
666 if (method.methodType() != QMetaMethod::Signal) {
667 if (method.access() == QMetaMethod::Public && (members & PublicMethods) == 0)
668 continue;
669 if (method.access() == QMetaMethod::Private && (members & PrivateMethods) == 0)
670 continue;
671 if (method.access() == QMetaMethod::Protected && (members & ProtectedMethods) == 0)
672 continue;
673 }
674 if (method.methodType() == QMetaMethod::Method && (members & Methods) != 0) {
676 } else if (method.methodType() == QMetaMethod::Signal &&
677 (members & Signals) != 0) {
679 } else if (method.methodType() == QMetaMethod::Slot &&
680 (members & Slots) != 0) {
682 }
683 }
684 }
685
686 if ((members & Constructors) != 0) {
687 for (index = 0; index < prototype->constructorCount(); ++index)
688 addConstructor(prototype->constructor(index));
689 }
690
691 if ((members & Properties) != 0) {
692 for (index = prototype->propertyOffset(); index < prototype->propertyCount(); ++index)
693 addProperty(prototype->property(index));
694 }
695
696 if ((members & Enumerators) != 0) {
697 for (index = prototype->enumeratorOffset(); index < prototype->enumeratorCount(); ++index)
698 addEnumerator(prototype->enumerator(index));
699 }
700
701 if ((members & ClassInfos) != 0) {
702 for (index = prototype->classInfoOffset(); index < prototype->classInfoCount(); ++index) {
703 QMetaClassInfo ci = prototype->classInfo(index);
704 addClassInfo(ci.name(), ci.value());
705 }
706 }
707
708 if ((members & RelatedMetaObjects) != 0) {
709 Q_ASSERT(qmobPriv(prototype->d.data)->revision >= 2);
710 const auto *objects = prototype->d.relatedMetaObjects;
711 if (objects) {
712 while (*objects != nullptr) {
713 addRelatedMetaObject(*objects);
714 ++objects;
715 }
716 }
717 }
718
719 if ((members & StaticMetacall) != 0) {
720 Q_ASSERT(qmobPriv(prototype->d.data)->revision >= 6);
721 if (prototype->d.static_metacall)
722 setStaticMetacallFunction(prototype->d.static_metacall);
723 }
724}
725
732{
733 if (uint(index) < d->methods.size())
734 return QMetaMethodBuilder(this, index);
735 else
736 return QMetaMethodBuilder();
737}
738
745{
746 if (uint(index) < d->constructors.size())
747 return QMetaMethodBuilder(this, -(index + 1));
748 else
749 return QMetaMethodBuilder();
750}
751
758{
759 if (uint(index) < d->properties.size())
760 return QMetaPropertyBuilder(this, index);
761 else
762 return QMetaPropertyBuilder();
763}
764
772{
773 if (uint(index) < d->enumerators.size())
774 return QMetaEnumBuilder(this, index);
775 else
776 return QMetaEnumBuilder();
777}
778
790{
791 if (index >= 0 && index < d->relatedMetaObjects.size())
792 return d->relatedMetaObjects[index];
793 else
794 return nullptr;
795}
796
805{
806 if (index >= 0 && index < d->classInfoNames.size())
807 return d->classInfoNames[index];
808 else
809 return QByteArray();
810}
811
820{
821 if (index >= 0 && index < d->classInfoValues.size())
822 return d->classInfoValues[index];
823 else
824 return QByteArray();
825}
826
836{
837 if (uint(index) < d->methods.size()) {
838 d->methods.erase(d->methods.begin() + index);
839 for (auto &property : d->properties) {
840 // Adjust the indices of property notify signal references.
841 if (property.notifySignal == index) {
842 property.notifySignal = -1;
843 } else if (property.notifySignal > index)
844 property.notifySignal--;
845 }
846 }
847}
848
857{
858 if (uint(index) < d->constructors.size())
859 d->constructors.erase(d->constructors.begin() + index);
860}
861
869{
870 if (uint(index) < d->properties.size())
871 d->properties.erase(d->properties.begin() + index);
872}
873
882{
883 if (uint(index) < d->enumerators.size())
884 d->enumerators.erase(d->enumerators.begin() + index);
885}
886
895{
896 if (index >= 0 && index < d->classInfoNames.size()) {
899 }
900}
901
915{
916 if (index >= 0 && index < d->relatedMetaObjects.size())
918}
919
927{
929 for (const auto &method : d->methods) {
930 if (sig == method.signature)
931 return int(&method - &d->methods.front());
932 }
933 return -1;
934}
935
943{
945 for (const auto &method : d->methods) {
946 if (method.methodType() == QMetaMethod::Signal && sig == method.signature)
947 return int(&method - &d->methods.front());
948 }
949 return -1;
950}
951
959{
961 for (const auto &method : d->methods) {
962 if (method.methodType() == QMetaMethod::Slot && sig == method.signature)
963 return int(&method - &d->methods.front());
964 }
965 return -1;
966}
967
975{
977 for (const auto &constructor : d->constructors) {
978 if (sig == constructor.signature)
979 return int(&constructor - &d->constructors.front());
980 }
981 return -1;
982}
983
991{
992 for (const auto &property : d->properties) {
993 if (name == property.name)
994 return int(&property - &d->properties.front());
995 }
996 return -1;
997}
998
1006{
1007 for (const auto &enumerator : d->enumerators) {
1008 if (name == enumerator.name)
1009 return int(&enumerator - &d->enumerators.front());
1010 }
1011 return -1;
1012}
1013
1022{
1023 for (int index = 0; index < d->classInfoNames.size(); ++index) {
1024 if (name == d->classInfoNames[index])
1025 return index;
1026 }
1027 return -1;
1028}
1029
1030// Align on a specific type boundary.
1031#ifdef ALIGN
1032# undef ALIGN
1033#endif
1034#define ALIGN(size,type) \
1035 (size) = ((size) + sizeof(type) - 1) & ~(sizeof(type) - 1)
1036
1045 : m_index(0)
1046 , m_className(className)
1047{
1048 const int index = enter(m_className);
1049 Q_ASSERT(index == 0);
1050 Q_UNUSED(index);
1051}
1052
1053// Enters the given value into the string table (if it hasn't already been
1054// entered). Returns the index of the string.
1056{
1057 Entries::iterator it = m_entries.find(value);
1058 if (it != m_entries.end())
1059 return it.value();
1060 int pos = m_index;
1061 m_entries.insert(value, pos);
1062 ++m_index;
1063 return pos;
1064}
1065
1067{
1068 return alignof(uint);
1069}
1070
1071// Returns the size (in bytes) required for serializing this string table.
1073{
1074 int size = int(m_entries.size() * 2 * sizeof(uint));
1076 for (it = m_entries.constBegin(); it != m_entries.constEnd(); ++it)
1077 size += it.key().size() + 1;
1078 return size;
1079}
1080
1081static void writeString(char *out, int i, const QByteArray &str,
1082 const int offsetOfStringdataMember, int &stringdataOffset)
1083{
1084 int size = str.size();
1085 int offset = offsetOfStringdataMember + stringdataOffset;
1086 uint offsetLen[2] = { uint(offset), uint(size) };
1087
1088 memcpy(out + 2 * i * sizeof(uint), &offsetLen, 2 * sizeof(uint));
1089
1090 memcpy(out + offset, str.constData(), size);
1091 out[offset + size] = '\0';
1092
1093 stringdataOffset += size + 1;
1094}
1095
1096// Writes strings to string data struct.
1097// The struct consists of an array of QByteArrayData, followed by a char array
1098// containing the actual strings. This format must match the one produced by
1099// moc (see generator.cpp).
1101{
1102 Q_ASSERT(!(reinterpret_cast<quintptr>(out) & (preferredAlignment() - 1)));
1103
1104 int offsetOfStringdataMember = int(m_entries.size() * 2 * sizeof(uint));
1105 int stringdataOffset = 0;
1106
1107 // qt_metacast expects the first string in the string table to be the class name.
1108 writeString(out, /*index*/ 0, m_className, offsetOfStringdataMember, stringdataOffset);
1109
1110 for (Entries::ConstIterator it = m_entries.constBegin(), end = m_entries.constEnd();
1111 it != end; ++it) {
1112 const int i = it.value();
1113 if (i == 0)
1114 continue;
1115 const QByteArray &str = it.key();
1116
1117 writeString(out, i, str, offsetOfStringdataMember, stringdataOffset);
1118 }
1119}
1120
1121// Returns the sum of all parameters (including return type) for the given
1122// \a methods. This is needed for calculating the size of the methods'
1123// parameter type/name meta-data.
1124static int aggregateParameterCount(const std::vector<QMetaMethodBuilderPrivate> &methods)
1125{
1126 int sum = 0;
1127 for (const auto &method : methods)
1128 sum += method.parameterCount() + 1; // +1 for return type
1129 return sum;
1130}
1131
1132enum Mode {
1133 Prepare, // compute the size of the metaobject
1134 Construct // construct metaobject in pre-allocated buffer
1136// Build a QMetaObject in "buf" based on the information in "d".
1137// If the mode is prepare, then return the number of bytes needed to
1138// build the QMetaObject.
1139template<Mode mode>
1141 int expectedSize)
1142{
1143 Q_UNUSED(expectedSize); // Avoid warning in release mode
1144 Q_UNUSED(buf);
1145 qsizetype size = 0;
1146 int dataIndex;
1147 int paramsIndex;
1148 int enumIndex;
1149 int index;
1150 bool hasRevisionedMethods = d->hasRevisionedMethods();
1151
1152 // Create the main QMetaObject structure at the start of the buffer.
1153 QMetaObject *meta = reinterpret_cast<QMetaObject *>(buf);
1154 size += sizeof(QMetaObject);
1155 ALIGN(size, int);
1156 if constexpr (mode == Construct) {
1157 meta->d.superdata = d->superClass;
1158 meta->d.relatedMetaObjects = nullptr;
1159 meta->d.extradata = nullptr;
1160 meta->d.metaTypes = nullptr;
1161 meta->d.static_metacall = d->staticMetacallFunction;
1162 }
1163
1164 // Populate the QMetaObjectPrivate structure.
1165 QMetaObjectPrivate *pmeta = buf ? reinterpret_cast<QMetaObjectPrivate *>(buf + size)
1166 : nullptr;
1167 //int pmetaSize = size;
1168 dataIndex = MetaObjectPrivateFieldCount;
1169 int methodParametersDataSize =
1170 ((aggregateParameterCount(d->methods)
1171 + aggregateParameterCount(d->constructors)) * 2) // types and parameter names
1172 - int(d->methods.size()) // return "parameters" don't have names
1173 - int(d->constructors.size()); // "this" parameters don't have names
1174 if constexpr (mode == Construct) {
1175 static_assert(QMetaObjectPrivate::OutputRevision == 12, "QMetaObjectBuilder should generate the same version as moc");
1176 pmeta->revision = QMetaObjectPrivate::OutputRevision;
1177 pmeta->flags = d->flags.toInt();
1178 pmeta->className = 0; // Class name is always the first string.
1179 //pmeta->signalCount is handled in the "output method loop" as an optimization.
1180
1181 pmeta->classInfoCount = d->classInfoNames.size();
1182 pmeta->classInfoData = dataIndex;
1183 dataIndex += 2 * d->classInfoNames.size();
1184
1185 pmeta->methodCount = int(d->methods.size());
1186 pmeta->methodData = dataIndex;
1187 dataIndex += QMetaObjectPrivate::IntsPerMethod * int(d->methods.size());
1188 if (hasRevisionedMethods)
1189 dataIndex += int(d->methods.size());
1190 paramsIndex = dataIndex;
1191 dataIndex += methodParametersDataSize;
1192
1193 pmeta->propertyCount = int(d->properties.size());
1194 pmeta->propertyData = dataIndex;
1195 dataIndex += QMetaObjectPrivate::IntsPerProperty * int(d->properties.size());
1196
1197 pmeta->enumeratorCount = int(d->enumerators.size());
1198 pmeta->enumeratorData = dataIndex;
1199 dataIndex += QMetaObjectPrivate::IntsPerEnum * int(d->enumerators.size());
1200
1201 pmeta->constructorCount = int(d->constructors.size());
1202 pmeta->constructorData = dataIndex;
1203 dataIndex += QMetaObjectPrivate::IntsPerMethod * int(d->constructors.size());
1204 } else {
1205 dataIndex += 2 * int(d->classInfoNames.size());
1206 dataIndex += QMetaObjectPrivate::IntsPerMethod * int(d->methods.size());
1207 if (hasRevisionedMethods)
1208 dataIndex += int(d->methods.size());
1209 paramsIndex = dataIndex;
1210 dataIndex += methodParametersDataSize;
1211 dataIndex += QMetaObjectPrivate::IntsPerProperty * int(d->properties.size());
1212 dataIndex += QMetaObjectPrivate::IntsPerEnum * int(d->enumerators.size());
1213 dataIndex += QMetaObjectPrivate::IntsPerMethod * int(d->constructors.size());
1214 }
1215
1216 // Allocate space for the enumerator key names and values.
1217 enumIndex = dataIndex;
1218 for (const auto &enumerator : d->enumerators)
1219 dataIndex += 2 * enumerator.keys.size();
1220
1221 // Zero terminator at the end of the data offset table.
1222 ++dataIndex;
1223
1224 // Find the start of the data and string tables.
1225 int *data = reinterpret_cast<int *>(pmeta);
1226 size += dataIndex * sizeof(int);
1227 ALIGN(size, void *);
1228 [[maybe_unused]] char *str = reinterpret_cast<char *>(buf + size);
1229 if constexpr (mode == Construct) {
1230 meta->d.stringdata = reinterpret_cast<const uint *>(str);
1231 meta->d.data = reinterpret_cast<uint *>(data);
1232 }
1233
1234 // Reset the current data position to just past the QMetaObjectPrivate.
1235 dataIndex = MetaObjectPrivateFieldCount;
1236
1237 QMetaStringTable strings(d->className);
1238
1239 // Output the class infos,
1240 Q_ASSERT(!buf || dataIndex == pmeta->classInfoData);
1241 for (index = 0; index < d->classInfoNames.size(); ++index) {
1242 [[maybe_unused]] int name = strings.enter(d->classInfoNames[index]);
1243 [[maybe_unused]] int value = strings.enter(d->classInfoValues[index]);
1244 if constexpr (mode == Construct) {
1245 data[dataIndex] = name;
1246 data[dataIndex + 1] = value;
1247 }
1248 dataIndex += 2;
1249 }
1250
1251 // Output the methods in the class.
1252 Q_ASSERT(!buf || dataIndex == pmeta->methodData);
1253 // + 1 for metatype of this metaobject
1254 int parameterMetaTypesIndex = int(d->properties.size()) + 1;
1255 for (const auto &method : d->methods) {
1256 [[maybe_unused]] int name = strings.enter(method.name());
1257 int argc = method.parameterCount();
1258 [[maybe_unused]] int tag = strings.enter(method.tag);
1259 [[maybe_unused]] int attrs = method.attributes;
1260 if constexpr (mode == Construct) {
1261 data[dataIndex] = name;
1262 data[dataIndex + 1] = argc;
1263 data[dataIndex + 2] = paramsIndex;
1264 data[dataIndex + 3] = tag;
1265 data[dataIndex + 4] = attrs;
1266 data[dataIndex + 5] = parameterMetaTypesIndex;
1267 if (method.methodType() == QMetaMethod::Signal)
1268 pmeta->signalCount++;
1269 }
1271 paramsIndex += 1 + argc * 2;
1272 parameterMetaTypesIndex += 1 + argc;
1273 }
1274 if (hasRevisionedMethods) {
1275 for (const auto &method : d->methods) {
1276 if constexpr (mode == Construct)
1277 data[dataIndex] = method.revision;
1278 ++dataIndex;
1279 }
1280 }
1281
1282 // Output the method parameters in the class.
1283 Q_ASSERT(!buf || dataIndex == pmeta->methodData + int(d->methods.size()) * QMetaObjectPrivate::IntsPerMethod
1284 + (hasRevisionedMethods ? int(d->methods.size()) : 0));
1285 for (int x = 0; x < 2; ++x) {
1286 const std::vector<QMetaMethodBuilderPrivate> &methods = (x == 0) ? d->methods : d->constructors;
1287 for (const auto &method : methods) {
1288 const QList<QByteArray> paramTypeNames = method.parameterTypes();
1289 int paramCount = paramTypeNames.size();
1290 for (int i = -1; i < paramCount; ++i) {
1291 const QByteArray &typeName = (i < 0) ? method.returnType : paramTypeNames.at(i);
1292 [[maybe_unused]] int typeInfo;
1294 typeInfo = QMetaType::fromName(typeName).id();
1295 else
1296 typeInfo = IsUnresolvedType | strings.enter(typeName);
1297 if constexpr (mode == Construct)
1298 data[dataIndex] = typeInfo;
1299 ++dataIndex;
1300 }
1301
1302 QList<QByteArray> paramNames = method.parameterNames;
1303 while (paramNames.size() < paramCount)
1304 paramNames.append(QByteArray());
1305 for (int i = 0; i < paramCount; ++i) {
1306 [[maybe_unused]] int stringIndex = strings.enter(paramNames.at(i));
1307 if constexpr (mode == Construct)
1308 data[dataIndex] = stringIndex;
1309 ++dataIndex;
1310 }
1311 }
1312 }
1313
1314 // Output the properties in the class.
1315 Q_ASSERT(!buf || dataIndex == pmeta->propertyData);
1316 for (QMetaPropertyBuilderPrivate &prop : d->properties) {
1317 [[maybe_unused]] int name = strings.enter(prop.name);
1318
1319 // try to resolve the metatype again if it was unknown
1320 if (!prop.metaType.isValid())
1321 prop.metaType = QMetaType::fromName(prop.type);
1322 [[maybe_unused]] const int typeInfo = prop.metaType.isValid()
1323 ? prop.metaType.id()
1324 : IsUnresolvedType | strings.enter(prop.type);
1325
1326 [[maybe_unused]] int flags = prop.flags;
1327
1328 if (!QtPrivate::isBuiltinType(prop.type))
1329 flags |= EnumOrFlag;
1330
1331 if constexpr (mode == Construct) {
1332 data[dataIndex] = name;
1333 data[dataIndex + 1] = typeInfo;
1334 data[dataIndex + 2] = flags;
1335 data[dataIndex + 3] = prop.notifySignal;
1336 data[dataIndex + 4] = prop.revision;
1337 }
1339 }
1340
1341 // Output the enumerators in the class.
1342 Q_ASSERT(!buf || dataIndex == pmeta->enumeratorData);
1343 for (const auto &enumerator : d->enumerators) {
1344 [[maybe_unused]] int name = strings.enter(enumerator.name);
1345 [[maybe_unused]] int enumName = strings.enter(enumerator.enumName);
1346 [[maybe_unused]] int isFlag = enumerator.isFlag ? EnumIsFlag : 0;
1347 [[maybe_unused]] int isScoped = enumerator.isScoped ? EnumIsScoped : 0;
1348 int count = enumerator.keys.size();
1349 int enumOffset = enumIndex;
1350 if constexpr (mode == Construct) {
1351 data[dataIndex] = name;
1352 data[dataIndex + 1] = enumName;
1353 data[dataIndex + 2] = isFlag | isScoped;
1354 data[dataIndex + 3] = count;
1355 data[dataIndex + 4] = enumOffset;
1356 }
1357 for (int key = 0; key < count; ++key) {
1358 [[maybe_unused]] int keyIndex = strings.enter(enumerator.keys[key]);
1359 if constexpr (mode == Construct) {
1360 data[enumOffset++] = keyIndex;
1361 data[enumOffset++] = enumerator.values[key];
1362 }
1363 }
1365 enumIndex += 2 * count;
1366 }
1367
1368 // Output the constructors in the class.
1369 Q_ASSERT(!buf || dataIndex == pmeta->constructorData);
1370 for (const auto &ctor : d->constructors) {
1371 [[maybe_unused]] int name = strings.enter(ctor.name());
1372 int argc = ctor.parameterCount();
1373 [[maybe_unused]] int tag = strings.enter(ctor.tag);
1374 [[maybe_unused]] int attrs = ctor.attributes;
1375 if constexpr (mode == Construct) {
1376 data[dataIndex] = name;
1377 data[dataIndex + 1] = argc;
1378 data[dataIndex + 2] = paramsIndex;
1379 data[dataIndex + 3] = tag;
1380 data[dataIndex + 4] = attrs;
1381 data[dataIndex + 5] = parameterMetaTypesIndex;
1382 }
1384 paramsIndex += 1 + argc * 2;
1385 parameterMetaTypesIndex += argc;
1386 }
1387
1388 size += strings.blobSize();
1389
1390 if constexpr (mode == Construct)
1391 strings.writeBlob(str);
1392
1393 // Output the zero terminator in the data array.
1394 if constexpr (mode == Construct)
1395 data[enumIndex] = 0;
1396
1397 // Create the relatedMetaObjects block if we need one.
1398 if (d->relatedMetaObjects.size() > 0) {
1399 using SuperData = QMetaObject::SuperData;
1400 ALIGN(size, SuperData);
1401 auto objects = reinterpret_cast<SuperData *>(buf + size);
1402 if constexpr (mode == Construct) {
1403 meta->d.relatedMetaObjects = objects;
1404 for (index = 0; index < d->relatedMetaObjects.size(); ++index)
1405 objects[index] = d->relatedMetaObjects[index];
1406 objects[index] = nullptr;
1407 }
1408 size += sizeof(SuperData) * (d->relatedMetaObjects.size() + 1);
1409 }
1410
1412 auto types = reinterpret_cast<QtPrivate::QMetaTypeInterface **>(buf + size);
1413 if constexpr (mode == Construct) {
1414 meta->d.metaTypes = types;
1415 for (const auto &prop : d->properties) {
1416 QMetaType mt = prop.metaType;
1417 *types = reinterpret_cast<QtPrivate::QMetaTypeInterface *&>(mt);
1418 types++;
1419 }
1420 // add metatype interface for this metaobject - must be null
1421 // as we can't know our metatype
1422 *types = nullptr;
1423 types++;
1424 for (const auto &method: d->methods) {
1425 QMetaType mt(QMetaType::fromName(method.returnType).id());
1426 *types = reinterpret_cast<QtPrivate::QMetaTypeInterface *&>(mt);
1427 types++;
1428 for (const auto &parameterType: method.parameterTypes()) {
1429 QMetaType mt = QMetaType::fromName(parameterType);
1430 *types = reinterpret_cast<QtPrivate::QMetaTypeInterface *&>(mt);
1431 types++;
1432 }
1433 }
1434 for (const auto &constructor : d->constructors) {
1435 for (const auto &parameterType : constructor.parameterTypes()) {
1436 QMetaType mt = QMetaType::fromName(parameterType);
1437 *types = reinterpret_cast<QtPrivate::QMetaTypeInterface *&>(mt);
1438 types++;
1439 }
1440 }
1441 }
1442 // parameterMetaTypesIndex is equal to the total number of metatypes
1443 size += sizeof(QMetaType) * parameterMetaTypesIndex;
1444
1445 // Align the final size and return it.
1446 ALIGN(size, void *);
1447 Q_ASSERT(!buf || size == expectedSize);
1448 return size;
1449}
1450
1462{
1463 int size = buildMetaObject<Prepare>(d, nullptr, 0);
1464 char *buf = reinterpret_cast<char *>(malloc(size));
1465 memset(buf, 0, size);
1466 buildMetaObject<Construct>(d, buf, size);
1467 return reinterpret_cast<QMetaObject *>(buf);
1468}
1469
1488
1500
1508QMetaMethodBuilderPrivate *QMetaMethodBuilder::d_func() const
1509{
1510 // Positive indices indicate methods, negative indices indicate constructors.
1511 if (_mobj && _index >= 0 && _index < int(_mobj->d->methods.size()))
1512 return &(_mobj->d->methods[_index]);
1513 else if (_mobj && -_index >= 1 && -_index <= int(_mobj->d->constructors.size()))
1514 return &(_mobj->d->constructors[(-_index) - 1]);
1515 else
1516 return nullptr;
1517}
1518
1528{
1529 if (_index >= 0)
1530 return _index; // Method, signal, or slot
1531 else
1532 return (-_index) - 1; // Constructor
1533}
1534
1539{
1540 QMetaMethodBuilderPrivate *d = d_func();
1541 if (d)
1542 return d->methodType();
1543 else
1544 return QMetaMethod::Method;
1545}
1546
1553{
1554 QMetaMethodBuilderPrivate *d = d_func();
1555 if (d)
1556 return d->signature;
1557 else
1558 return QByteArray();
1559}
1560
1568{
1569 QMetaMethodBuilderPrivate *d = d_func();
1570 if (d)
1571 return d->returnType;
1572 else
1573 return QByteArray();
1574}
1575
1584{
1585 QMetaMethodBuilderPrivate *d = d_func();
1586 if (d)
1587 d->returnType = QMetaObject::normalizedType(value);
1588}
1589
1595QList<QByteArray> QMetaMethodBuilder::parameterTypes() const
1596{
1597 QMetaMethodBuilderPrivate *d = d_func();
1598 if (d)
1599 return d->parameterTypes();
1600 else
1601 return QList<QByteArray>();
1602}
1603
1609QList<QByteArray> QMetaMethodBuilder::parameterNames() const
1610{
1611 QMetaMethodBuilderPrivate *d = d_func();
1612 if (d)
1613 return d->parameterNames;
1614 else
1615 return QList<QByteArray>();
1616}
1617
1623void QMetaMethodBuilder::setParameterNames(const QList<QByteArray> &value)
1624{
1625 QMetaMethodBuilderPrivate *d = d_func();
1626 if (d)
1627 d->parameterNames = value;
1628}
1629
1636{
1637 QMetaMethodBuilderPrivate *d = d_func();
1638 if (d)
1639 return d->tag;
1640 else
1641 return QByteArray();
1642}
1643
1650{
1651 QMetaMethodBuilderPrivate *d = d_func();
1652 if (d)
1653 d->tag = value;
1654}
1655
1664{
1665 QMetaMethodBuilderPrivate *d = d_func();
1666 if (d)
1667 return d->access();
1668 else
1669 return QMetaMethod::Public;
1670}
1671
1680{
1681 QMetaMethodBuilderPrivate *d = d_func();
1682 if (d && d->methodType() != QMetaMethod::Signal)
1683 d->setAccess(value);
1684}
1685
1692{
1693 QMetaMethodBuilderPrivate *d = d_func();
1694 if (d)
1695 return (d->attributes >> 4);
1696 else
1697 return 0;
1698}
1699
1706{
1707 QMetaMethodBuilderPrivate *d = d_func();
1708 if (d)
1709 d->attributes = ((d->attributes & 0x0f) | (value << 4));
1710}
1711
1716{
1717 QMetaMethodBuilderPrivate *d = d_func();
1718 if (!d)
1719 return false;
1720 return (d->attributes & MethodIsConst);
1721}
1722
1723void QMetaMethodBuilder::setConst(bool methodIsConst)
1724{
1725 QMetaMethodBuilderPrivate *d = d_func();
1726 if (!d)
1727 return;
1728 if (methodIsConst)
1729 d->attributes |= MethodIsConst;
1730 else
1731 d->attributes &= ~MethodIsConst;
1732}
1733
1740{
1741 QMetaMethodBuilderPrivate *d = d_func();
1742 if (d)
1743 return d->revision;
1744 return 0;
1745}
1746
1753{
1754 QMetaMethodBuilderPrivate *d = d_func();
1755 if (d) {
1756 d->revision = revision;
1757 if (revision)
1758 d->attributes |= MethodRevisioned;
1759 else
1760 d->attributes &= ~MethodRevisioned;
1761 }
1762}
1763
1771QMetaPropertyBuilderPrivate *QMetaPropertyBuilder::d_func() const
1772{
1773 if (_mobj && _index >= 0 && _index < int(_mobj->d->properties.size()))
1774 return &(_mobj->d->properties[_index]);
1775 else
1776 return nullptr;
1777}
1778
1796{
1797 QMetaPropertyBuilderPrivate *d = d_func();
1798 if (d)
1799 return d->name;
1800 else
1801 return QByteArray();
1802}
1803
1810{
1811 QMetaPropertyBuilderPrivate *d = d_func();
1812 if (d)
1813 return d->type;
1814 else
1815 return QByteArray();
1816}
1817
1824{
1825 QMetaPropertyBuilderPrivate *d = d_func();
1826 if (d)
1827 return d->notifySignal != -1;
1828 else
1829 return false;
1830}
1831
1838{
1839 QMetaPropertyBuilderPrivate *d = d_func();
1840 if (d && d->notifySignal >= 0)
1841 return QMetaMethodBuilder(_mobj, d->notifySignal);
1842 else
1843 return QMetaMethodBuilder();
1844}
1845
1852{
1853 QMetaPropertyBuilderPrivate *d = d_func();
1854 if (d) {
1855 if (value._mobj) {
1856 d->notifySignal = value._index;
1857 } else {
1858 d->notifySignal = -1;
1859 }
1860 }
1861}
1862
1869{
1870 QMetaPropertyBuilderPrivate *d = d_func();
1871 if (d)
1872 d->notifySignal = -1;
1873}
1874
1882{
1883 QMetaPropertyBuilderPrivate *d = d_func();
1884 if (d)
1885 return d->flag(Readable);
1886 else
1887 return false;
1888}
1889
1897{
1898 QMetaPropertyBuilderPrivate *d = d_func();
1899 if (d)
1900 return d->flag(Writable);
1901 else
1902 return false;
1903}
1904
1912{
1913 QMetaPropertyBuilderPrivate *d = d_func();
1914 if (d)
1915 return d->flag(Resettable);
1916 else
1917 return false;
1918}
1919
1927{
1928 QMetaPropertyBuilderPrivate *d = d_func();
1929 if (d)
1930 return d->flag(Designable);
1931 else
1932 return false;
1933}
1934
1942{
1943 QMetaPropertyBuilderPrivate *d = d_func();
1944 if (d)
1945 return d->flag(Scriptable);
1946 else
1947 return false;
1948}
1949
1957{
1958 QMetaPropertyBuilderPrivate *d = d_func();
1959 if (d)
1960 return d->flag(Stored);
1961 else
1962 return false;
1963}
1964
1974{
1975 QMetaPropertyBuilderPrivate *d = d_func();
1976 if (d)
1977 return d->flag(User);
1978 else
1979 return false;
1980}
1981
1992{
1993 QMetaPropertyBuilderPrivate *d = d_func();
1994 if (d)
1995 return d->flag(StdCppSet);
1996 else
1997 return false;
1998}
1999
2007{
2008 QMetaPropertyBuilderPrivate *d = d_func();
2009 if (d)
2010 return d->flag(EnumOrFlag);
2011 else
2012 return false;
2013}
2014
2020{
2021 QMetaPropertyBuilderPrivate *d = d_func();
2022 if (d)
2023 return d->flag(Constant);
2024 else
2025 return false;
2026}
2027
2033{
2034 QMetaPropertyBuilderPrivate *d = d_func();
2035 if (d)
2036 return d->flag(Final);
2037 else
2038 return false;
2039}
2040
2046{
2047 QMetaPropertyBuilderPrivate *d = d_func();
2048 if (d)
2049 return d->flag(Alias);
2050 else
2051 return false;
2052}
2053
2059{
2060 if (auto d = d_func())
2061 return d->flag(Bindable);
2062 else
2063 return false;
2064}
2065
2072{
2073 QMetaPropertyBuilderPrivate *d = d_func();
2074 if (d)
2075 d->setFlag(Readable, value);
2076}
2077
2084{
2085 QMetaPropertyBuilderPrivate *d = d_func();
2086 if (d)
2087 d->setFlag(Writable, value);
2088}
2089
2096{
2097 QMetaPropertyBuilderPrivate *d = d_func();
2098 if (d)
2099 d->setFlag(Resettable, value);
2100}
2101
2108{
2109 QMetaPropertyBuilderPrivate *d = d_func();
2110 if (d)
2111 d->setFlag(Designable, value);
2112}
2113
2120{
2121 QMetaPropertyBuilderPrivate *d = d_func();
2122 if (d)
2123 d->setFlag(Scriptable, value);
2124}
2125
2132{
2133 QMetaPropertyBuilderPrivate *d = d_func();
2134 if (d)
2135 d->setFlag(Stored, value);
2136}
2137
2144{
2145 QMetaPropertyBuilderPrivate *d = d_func();
2146 if (d)
2147 d->setFlag(User, value);
2148}
2149
2158{
2159 QMetaPropertyBuilderPrivate *d = d_func();
2160 if (d)
2161 d->setFlag(StdCppSet, value);
2162}
2163
2171{
2172 QMetaPropertyBuilderPrivate *d = d_func();
2173 if (d)
2174 d->setFlag(EnumOrFlag, value);
2175}
2176
2183{
2184 QMetaPropertyBuilderPrivate *d = d_func();
2185 if (d)
2186 d->setFlag(Constant, value);
2187}
2188
2195{
2196 QMetaPropertyBuilderPrivate *d = d_func();
2197 if (d)
2198 d->setFlag(Final, value);
2199}
2200
2205{
2206 QMetaPropertyBuilderPrivate *d = d_func();
2207 if (d)
2208 d->setFlag(Alias, value);
2209}
2210
2215{
2216 if (auto d = d_func())
2217 d->setFlag(Bindable, value);
2218}
2219
2226{
2227 QMetaPropertyBuilderPrivate *d = d_func();
2228 if (d)
2229 return d->revision;
2230 return 0;
2231}
2232
2239{
2240 QMetaPropertyBuilderPrivate *d = d_func();
2241 if (d)
2242 d->revision = revision;
2243}
2244
2252QMetaEnumBuilderPrivate *QMetaEnumBuilder::d_func() const
2253{
2254 if (_mobj && _index >= 0 && _index < int(_mobj->d->enumerators.size()))
2255 return &(_mobj->d->enumerators[_index]);
2256 else
2257 return nullptr;
2258}
2259
2275{
2276 QMetaEnumBuilderPrivate *d = d_func();
2277 if (d)
2278 return d->name;
2279 else
2280 return QByteArray();
2281}
2282
2289{
2290 QMetaEnumBuilderPrivate *d = d_func();
2291 if (d)
2292 return d->enumName;
2293 else
2294 return QByteArray();
2295}
2296
2304{
2305 QMetaEnumBuilderPrivate *d = d_func();
2306 if (d)
2307 d->enumName = alias;
2308}
2309
2316{
2317 if (QMetaEnumBuilderPrivate *d = d_func())
2318 return d->metaType;
2319 return QMetaType();
2320}
2321
2329{
2330 QMetaEnumBuilderPrivate *d = d_func();
2331 if (d)
2332 d->metaType = metaType;
2333}
2334
2342{
2343 QMetaEnumBuilderPrivate *d = d_func();
2344 if (d)
2345 return d->isFlag;
2346 else
2347 return false;
2348}
2349
2356{
2357 QMetaEnumBuilderPrivate *d = d_func();
2358 if (d)
2359 d->isFlag = value;
2360}
2361
2368{
2369 QMetaEnumBuilderPrivate *d = d_func();
2370 if (d)
2371 return d->isScoped;
2372 return false;
2373}
2374
2381{
2382 QMetaEnumBuilderPrivate *d = d_func();
2383 if (d)
2384 d->isScoped = value;
2385}
2386
2393{
2394 QMetaEnumBuilderPrivate *d = d_func();
2395 if (d)
2396 return d->keys.size();
2397 else
2398 return 0;
2399}
2400
2408{
2409 QMetaEnumBuilderPrivate *d = d_func();
2410 if (d && index >= 0 && index < d->keys.size())
2411 return d->keys[index];
2412 else
2413 return QByteArray();
2414}
2415
2423{
2424 QMetaEnumBuilderPrivate *d = d_func();
2425 if (d && index >= 0 && index < d->keys.size())
2426 return d->values[index];
2427 else
2428 return -1;
2429}
2430
2438{
2439 QMetaEnumBuilderPrivate *d = d_func();
2440 if (d) {
2441 int index = d->keys.size();
2442 d->keys += name;
2443 d->values += value;
2444 return index;
2445 } else {
2446 return -1;
2447 }
2448}
2449
2456{
2457 QMetaEnumBuilderPrivate *d = d_func();
2458 if (d && index >= 0 && index < d->keys.size()) {
2459 d->keys.removeAt(index);
2460 d->values.removeAt(index);
2461 }
2462}
2463
static JNINativeMethod methods[]
\inmodule QtCore
Definition qbytearray.h:57
QByteArray left(qsizetype n) const &
Definition qbytearray.h:169
qsizetype indexOf(char c, qsizetype from=0) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool isNull() const noexcept
Returns true if this byte array is null; otherwise returns false.
qsizetype size() const noexcept
Returns the number of items in the hash.
Definition qhash.h:927
const_iterator constEnd() const noexcept
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the ...
Definition qhash.h:1219
iterator find(const Key &key)
Returns an iterator pointing to the item with the key in the hash.
Definition qhash.h:1291
const_iterator constBegin() const noexcept
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item in the hash.
Definition qhash.h:1215
friend class iterator
Definition qhash.h:1142
iterator end() noexcept
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the last ...
Definition qhash.h:1216
friend class const_iterator
Definition qhash.h:1182
const_iterator ConstIterator
Qt-style synonym for QHash::const_iterator.
Definition qhash.h:1289
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition qhash.h:1303
qsizetype size() const noexcept
Definition qlist.h:397
void removeAt(qsizetype i)
Definition qlist.h:590
void append(parameter_type t)
Definition qlist.h:458
\inmodule QtCore
QMetaEnumBuilderPrivate(const QByteArray &_name)
int keyCount() const
Returns the number of keys.
void setMetaType(QMetaType metaType)
Sets this enumerator to have the given metaType.
QByteArray key(int index) const
Returns the key with the given index, or an empty QByteArray if no such key exists.
QByteArray enumName() const
Returns the enum name of the enumerator (without the scope).
void removeKey(int index)
Removes the key at index from this enumerator.
void setIsFlag(bool value)
Sets this enumerator to be used as a flag if value is true.
bool isFlag() const
Returns true if this enumerator is used as a flag; otherwise returns false.
QMetaType metaType() const
Returns the meta type of the enumerator.
int value(int index) const
Returns the value with the given index; or returns -1 if there is no such value.
bool isScoped() const
Return true if this enumerator should be considered scoped (C++11 enum class).
void setIsScoped(bool value)
Sets this enumerator to be a scoped enum if \value is true.
int index() const
Returns the index of this enumerator within its QMetaObjectBuilder.
QByteArray name() const
Returns the type name of the enumerator (without the scope).
int addKey(const QByteArray &name, int value)
Adds a new key called name to this enumerator, associated with value.
void setEnumName(const QByteArray &alias)
Sets this enumerator to have the enum name alias.
\inmodule QtCore
int value(int index) const
Returns the value with the given index; or returns -1 if there is no such value.
bool isFlag() const
Returns true if this enumerator is used as a flag; otherwise returns false.
const char * name() const
Returns the name of the type (without the scope).
const char * key(int index) const
Returns the key with the given index, or \nullptr if no such key exists.
int keyCount() const
Returns the number of keys.
QMetaType metaType() const
Returns the meta type of the enum.
bool isScoped() const
const char * enumName() const
Returns the enum name of the flag (without the scope).
QList< QByteArray > parameterNames
void setAccess(QMetaMethod::Access value)
QMetaMethod::Access access() const
QMetaMethod::MethodType methodType() const
QMetaMethodBuilderPrivate(QMetaMethod::MethodType _methodType, const QByteArray &_signature, const QByteArray &_returnType=QByteArray("void"), QMetaMethod::Access _access=QMetaMethod::Public, int _revision=0)
QList< QByteArray > parameterTypes() const
int attributes() const
Returns the additional attributes for this method.
void setRevision(int revision)
Sets the revision of this method.
void setTag(const QByteArray &value)
Sets the tag associated with this method to value.
QMetaMethod::Access access() const
Returns the access specification of this method (private, protected, or public).
void setConst(bool methodIsConst=true)
void setAttributes(int value)
Sets the additional attributes for this method to value.
QByteArray returnType() const
Returns the return type for this method; empty if the method's return type is {void}.
int isConst() const
Returns true if the method is const qualified.
int index() const
Returns the index of this method within its QMetaObjectBuilder.
QByteArray signature() const
Returns the signature of this method.
QList< QByteArray > parameterTypes() const
Returns the list of parameter types for this method.
int revision() const
Returns the revision of this method.
QMetaMethod::MethodType methodType() const
Returns the type of this method (signal, slot, method, or constructor).
void setAccess(QMetaMethod::Access value)
Sets the access specification of this method (private, protected, or public) to value.
QList< QByteArray > parameterNames() const
Returns the list of parameter names for this method.
void setReturnType(const QByteArray &value)
Sets the return type for this method to value.
QByteArray tag() const
Returns the tag associated with this method.
void setParameterNames(const QList< QByteArray > &value)
Sets the list of parameter names for this method to value.
\inmodule QtCore
Definition qmetaobject.h:19
Access
This enum describes the access level of a method, following the conventions used in C++.
Definition qmetaobject.h:36
Access access() const
Returns the access specification of this method (private, protected, or public).
const char * typeName() const
Returns the return type name of this method.
MethodType
\value Method The function is a plain member function.
Definition qmetaobject.h:38
const char * tag() const
Returns the tag associated with this method.
int revision() const
int attributes() const
QByteArray methodSignature() const
MethodType methodType() const
Returns the type of this method (signal, slot, or method).
QList< QByteArray > parameterNames() const
Returns a list of parameter names.
QList< QByteArray > classInfoNames
std::vector< QMetaPropertyBuilderPrivate > properties
QList< const QMetaObject * > relatedMetaObjects
std::vector< QMetaMethodBuilderPrivate > methods
std::vector< QMetaEnumBuilderPrivate > enumerators
std::vector< QMetaMethodBuilderPrivate > constructors
QMetaObjectBuilder::StaticMetacallFunction staticMetacallFunction
QList< QByteArray > classInfoValues
void removeConstructor(int index)
Removes the constructor at index from this class.
QMetaMethodBuilder addConstructor(const QByteArray &signature)
Adds a new constructor to this class with the specified signature.
void(* StaticMetacallFunction)(QObject *, QMetaObject::Call, int, void **)
Typedef for static metacall functions.
void setSuperClass(const QMetaObject *meta)
Sets the superclass meta object of the class being constructed by this meta object builder to meta.
void setStaticMetacallFunction(QMetaObjectBuilder::StaticMetacallFunction value)
Sets the static metacall function to use to construct objects of this class to value.
int relatedMetaObjectCount() const
Returns the number of related meta objects that are associated with this class.
void addMetaObject(const QMetaObject *prototype, QMetaObjectBuilder::AddMembers members=AllMembers)
Adds the contents of prototype to this meta object builder.
QByteArray classInfoValue(int index) const
Returns the value of the item of class information at index in this class.
void removeClassInfo(int index)
Removes the item of class information at index from this class.
QMetaEnumBuilder enumerator(int index) const
Returns the enumerator at index in this class.
int addRelatedMetaObject(const QMetaObject *meta)
Adds meta to this class as a related meta object.
QMetaObjectBuilder()
Constructs a new QMetaObjectBuilder.
int constructorCount() const
Returns the number of constructors in this class.
QMetaEnumBuilder addEnumerator(const QByteArray &name)
Adds a new enumerator to this class with the specified name.
QMetaObject * toMetaObject() const
Converts this meta object builder into a concrete QMetaObject.
QByteArray classInfoName(int index) const
Returns the name of the item of class information at index in this class.
QByteArray className() const
Returns the name of the class being constructed by this meta object builder.
void removeEnumerator(int index)
Removes the enumerator at index from this class.
QMetaMethodBuilder addSignal(const QByteArray &signature)
Adds a new signal to this class with the specified signature.
friend class QMetaPropertyBuilder
void removeRelatedMetaObject(int index)
Removes the related meta object at index from this class.
int indexOfClassInfo(const QByteArray &name)
Finds an item of class information with the specified name and returns its index; otherwise returns -...
int methodCount() const
Returns the number of methods in this class, excluding the number of methods in the base class.
void removeProperty(int index)
Removes the property at index from this class.
const QMetaObject * superClass() const
Returns the superclass meta object of the class being constructed by this meta object builder.
int indexOfConstructor(const QByteArray &signature)
Finds a constructor with the specified signature and returns its index; otherwise returns -1.
int indexOfProperty(const QByteArray &name)
Finds a property with the specified name and returns its index; otherwise returns -1.
int indexOfMethod(const QByteArray &signature)
Finds a method with the specified signature and returns its index; otherwise returns -1.
int propertyCount() const
Returns the number of properties in this class, excluding the number of properties in the base class.
void removeMethod(int index)
Removes the method at index from this class.
int indexOfEnumerator(const QByteArray &name)
Finds an enumerator with the specified name and returns its index; otherwise returns -1.
int indexOfSignal(const QByteArray &signature)
Finds a signal with the specified signature and returns its index; otherwise returns -1.
int addClassInfo(const QByteArray &name, const QByteArray &value)
Adds name and value as an item of class information to this class.
void setFlags(MetaObjectFlags)
Sets the flags of the class being constructed by this meta object builder.
QMetaMethodBuilder addMethod(const QByteArray &signature)
Adds a new public method to this class with the specified signature.
int classInfoCount() const
Returns the number of items of class information in this class, exclusing the number of items of clas...
QMetaMethodBuilder constructor(int index) const
Returns the constructor at index in this class.
QMetaPropertyBuilder addProperty(const QByteArray &name, const QByteArray &type, int notifierId=-1)
Adds a new readable/writable property to this class with the specified name and type.
int enumeratorCount() const
Returns the number of enumerators in this class, excluding the number of enumerators in the base clas...
void setClassName(const QByteArray &name)
Sets the name of the class being constructed by this meta object builder.
const QMetaObject * relatedMetaObject(int index) const
Returns the related meta object at index in this class.
QMetaMethodBuilder method(int index) const
Returns the method at index in this class.
QMetaObjectBuilder::StaticMetacallFunction staticMetacallFunction() const
Returns the static metacall function to use to construct objects of this class.
QMetaPropertyBuilder property(int index) const
Returns the property at index in this class.
virtual ~QMetaObjectBuilder()
Destroys this meta object builder.
QMetaMethodBuilder addSlot(const QByteArray &signature)
Adds a new public slot to this class with the specified signature.
int indexOfSlot(const QByteArray &signature)
Finds a slot with the specified signature and returns its index; otherwise returns -1.
MetaObjectFlags flags() const
Returns the flags of the class being constructed by this meta object builder.
void setFlag(int f, bool value)
QMetaPropertyBuilderPrivate(const QByteArray &_name, const QByteArray &_type, QMetaType _metaType, int notifierIdx=-1, int _revision=0)
bool hasStdCppSet() const
Returns true if the property has a C++ setter function that follows Qt's standard "name" / "setName" ...
bool isUser() const
Returns true if this property is designated as the USER property, i.e., the one that the user can edi...
bool isConstant() const
Returns true if the property is constant; otherwise returns false.
QMetaMethodBuilder notifySignal() const
Returns the notify signal associated with this property.
void setAlias(bool value)
Sets the ALIAS flag on this property to value.
void setRevision(int revision)
Sets the revision of this property.
bool isReadable() const
Returns true if this property is readable; otherwise returns false.
void setReadable(bool value)
Sets this property to readable if value is true.
void setDesignable(bool value)
Sets this property to designable if value is true.
bool isDesignable() const
Returns true if this property is designable; otherwise returns false.
void setStored(bool value)
Sets this property to storable if value is true.
bool hasNotifySignal() const
Returns true if this property has a notify signal; false otherwise.
void setUser(bool value)
Sets the USER flag on this property to value.
void removeNotifySignal()
Removes the notify signal from this property.
void setFinal(bool value)
Sets the FINAL flag on this property to value.
bool isAlias() const
Returns true if the property is an alias.
void setBindable(bool value)
Sets theBINDABLE flag on this property to value.
void setConstant(bool value)
Sets the CONSTANT flag on this property to value.
int revision() const
Returns the revision of this property.
bool isEnumOrFlag() const
Returns true if the property is an enumerator or flag type; otherwise returns false.
QByteArray name() const
Returns the name associated with this property.
void setScriptable(bool value)
Sets this property to scriptable if value is true.
bool isResettable() const
Returns true if this property can be reset to a default value; otherwise returns false.
bool isFinal() const
Returns true if the property is final; otherwise returns false.
void setEnumOrFlag(bool value)
Sets this property to be of an enumerator or flag type if value is true.
bool isScriptable() const
Returns true if the property is scriptable; otherwise returns false.
bool isWritable() const
Returns true if this property is writable; otherwise returns false.
QByteArray type() const
Returns the type associated with this property.
void setWritable(bool value)
Sets this property to writable if value is true.
bool isStored() const
Returns true if the property is stored; otherwise returns false.
void setNotifySignal(const QMetaMethodBuilder &value)
Sets the notify signal associated with this property to value.
void setStdCppSet(bool value)
Sets the C++ setter flag on this property to value, which is true if the property has a C++ setter fu...
bool isBindable() const
Returns true if the property is bindable The default value is false.
void setResettable(bool value)
Sets this property to resettable if value is true.
\inmodule QtCore
bool hasStdCppSet() const
int revision() const
bool isUser() const
Returns false if the {Q_PROPERTY()}'s USER attribute is false.
const char * typeName() const
Returns the name of this property's type.
bool isStored() const
Returns true if the property is stored; otherwise returns false.
bool isScriptable() const
Returns false if the {Q_PROPERTY()}'s SCRIPTABLE attribute is false; otherwise returns true.
QMetaType metaType() const
bool isDesignable() const
Returns false if the {Q_PROPERTY()}'s DESIGNABLE attribute is false; otherwise returns true.
QMetaMethod notifySignal() const
bool isWritable() const
Returns true if this property is writable; otherwise returns false.
bool isConstant() const
bool isResettable() const
Returns true if this property can be reset to a default value; otherwise returns false.
bool isFinal() const
bool isEnumType() const
Returns true if the property's type is an enumeration value; otherwise returns false.
const char * name() const
Returns this property's name.
bool isReadable() const
Returns true if this property is readable; otherwise returns false.
bool hasNotifySignal() const
Returns true if this property has a corresponding change notify signal; otherwise returns false.
int enter(const QByteArray &value)
void writeBlob(char *out) const
QMetaStringTable(const QByteArray &className)
static int preferredAlignment()
\inmodule QtCore
Definition qmetatype.h:341
static QMetaType fromName(QByteArrayView name)
Returns a QMetaType matching typeName.
qsizetype size() const
Definition qset.h:50
const QChar * constData() const
Returns a pointer to the data stored in the QString.
Definition qstring.h:1246
qsizetype size() const noexcept
Returns the number of characters in this string.
Definition qstring.h:186
QString str
[2]
QSet< QString >::iterator it
Combined button and popup list for selecting options.
\macro QT_NO_KEYWORDS >
Q_CORE_EXPORT bool isBuiltinType(const QByteArray &type)
AudioChannelLayoutTag tag
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char * method
static struct AttrInfo attrs[]
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
@ MetaObjectPrivateFieldCount
@ MethodTypeMask
@ MethodIsConst
@ AccessMask
@ MethodRevisioned
@ EnumIsScoped
@ EnumIsFlag
@ Readable
@ StdCppSet
@ Bindable
@ Alias
@ Stored
@ Designable
@ Resettable
@ Scriptable
@ Constant
@ Final
@ EnumOrFlag
@ Writable
@ User
@ IsUnresolvedType
#define ALIGN(size, type)
static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf, int expectedSize)
static const QMetaObjectPrivate * qmobPriv(const uint *data)
static void writeString(char *out, int i, const QByteArray &str, const int offsetOfStringdataMember, int &stringdataOffset)
static int aggregateParameterCount(const std::vector< QMetaMethodBuilderPrivate > &methods)
const char * typeName
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
GLint GLint GLint GLint GLint x
[0]
GLenum mode
GLuint64 key
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint index
[2]
GLuint GLuint end
GLsizei GLenum GLenum * types
GLsizei const GLchar ** strings
[1]
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLfloat GLfloat f
GLenum type
GLenum GLuint GLenum GLsizei const GLchar * buf
GLbitfield flags
GLenum GLuint GLintptr offset
GLuint name
Members members(const Members &candidates, QTypeRevision maxMajorVersion, Postprocess &&process)
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
#define Q_UNUSED(x)
@ Q_RELOCATABLE_TYPE
Definition qtypeinfo.h:158
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS)
Definition qtypeinfo.h:180
size_t quintptr
Definition qtypes.h:167
ptrdiff_t qsizetype
Definition qtypes.h:165
unsigned int uint
Definition qtypes.h:34
const char property[13]
Definition qwizard.cpp:101
const char className[16]
[1]
Definition qwizard.cpp:100
QStringList keys
QTextStream out(stdout)
[7]
void writeString(QCborStreamWriter &writer, const QString &str)
[8]
static QList< QByteArray > parameterTypeNamesFromSignature(const char *signature)
\inmodule QtCore
int propertyCount() const
Returns the number of properties in this class, including the number of properties provided by each b...
QMetaClassInfo classInfo(int index) const
Returns the meta-data for the item of class information with the given index.
QMetaProperty property(int index) const
Returns the meta-data for the property with the given index.
const char * className() const
Returns the class name.
static QByteArray normalizedSignature(const char *method)
Normalizes the signature of the given method.
int enumeratorOffset() const
Returns the enumerator offset for this class; i.e.
int methodCount() const
Returns the number of methods in this class, including the number of methods provided by each base cl...
QMetaEnum enumerator(int index) const
Returns the meta-data for the enumerator with the given index.
int classInfoCount() const
Returns the number of items of class information in this class.
QMetaMethod constructor(int index) const
int methodOffset() const
Returns the method offset for this class; i.e.
const QMetaObject * superClass() const
Returns the meta-object of the superclass, or \nullptr if there is no such object.
struct QMetaObject::Data d
QMetaMethod method(int index) const
Returns the meta-data for the method with the given index.
int constructorCount() const
static QByteArray normalizedType(const char *type)
int propertyOffset() const
Returns the property offset for this class; i.e.
int enumeratorCount() const
Returns the number of enumerators in this class.
int classInfoOffset() const
Returns the class information offset for this class; i.e.