Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
generator.cpp
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// Copyright (C) 2019 Olivier Goffart <ogoffart@woboq.com>
3// Copyright (C) 2018 Intel Corporation.
4// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
5
6#include "generator.h"
7#include "cbordevice.h"
8#include "outputrevision.h"
9#include "utils.h"
10#include <QtCore/qmetatype.h>
11#include <QtCore/qjsondocument.h>
12#include <QtCore/qjsonobject.h>
13#include <QtCore/qjsonvalue.h>
14#include <QtCore/qjsonarray.h>
15#include <QtCore/qplugin.h>
16#include <QtCore/qstringview.h>
17
18#include <math.h>
19#include <stdio.h>
20
21#include <private/qmetaobject_p.h> //for the flags.
22#include <private/qplugin_p.h> //for the flags.
23
25
26using namespace QtMiscUtils;
27
29{
30 if (name.isEmpty())
31 return 0;
32
33 uint tp = qMetaTypeTypeInternal(name.constData());
35}
36
37/*
38 Returns \c true if the type is a built-in type.
39*/
41 {
42 int id = qMetaTypeTypeInternal(type.constData());
43 if (id == QMetaType::UnknownType)
44 return false;
45 return (id < QMetaType::User);
46}
47
48static const char *metaTypeEnumValueString(int type)
49 {
50#define RETURN_METATYPENAME_STRING(MetaTypeName, MetaTypeId, RealType) \
51 case QMetaType::MetaTypeName: return #MetaTypeName;
52
53 switch (type) {
55 }
56#undef RETURN_METATYPENAME_STRING
57 return nullptr;
58 }
59
60 Generator::Generator(Moc *moc, ClassDef *classDef, const QList<QByteArray> &metaTypes,
61 const QHash<QByteArray, QByteArray> &knownQObjectClasses,
62 const QHash<QByteArray, QByteArray> &knownGadgets, FILE *outfile,
63 bool requireCompleteTypes)
64 : parser(moc),
65 out(outfile),
66 cdef(classDef),
67 metaTypes(metaTypes),
68 knownQObjectClasses(knownQObjectClasses),
69 knownGadgets(knownGadgets),
70 requireCompleteTypes(requireCompleteTypes)
71 {
72 if (cdef->superclassList.size())
73 purestSuperClass = cdef->superclassList.constFirst().first;
74}
75
77{
78 if (s.at(i) != '\\' || i >= s.size() - 1)
79 return 1;
80 const qsizetype startPos = i;
81 ++i;
82 char ch = s.at(i);
83 if (ch == 'x') {
84 ++i;
85 while (i < s.size() && isHexDigit(s.at(i)))
86 ++i;
87 } else if (isOctalDigit(ch)) {
88 while (i < startPos + 4
89 && i < s.size()
90 && isOctalDigit(s.at(i))) {
91 ++i;
92 }
93 } else { // single character escape sequence
94 i = qMin(i + 1, s.size());
95 }
96 return i - startPos;
97}
98
99// Prints \a s to \a out, breaking it into lines of at most ColumnWidth. The
100// opening and closing quotes are NOT included (it's up to the caller).
101static void printStringWithIndentation(FILE *out, const QByteArray &s)
102{
103 static constexpr int ColumnWidth = 72;
104 const qsizetype len = s.size();
105 qsizetype idx = 0;
106
107 do {
108 qsizetype spanLen = qMin(ColumnWidth - 2, len - idx);
109 // don't cut escape sequences at the end of a line
110 const qsizetype backSlashPos = s.lastIndexOf('\\', idx + spanLen - 1);
111 if (backSlashPos >= idx) {
112 const qsizetype escapeLen = lengthOfEscapeSequence(s, backSlashPos);
113 spanLen = qBound(spanLen, backSlashPos + escapeLen - idx, len - idx);
114 }
115 fprintf(out, "\n \"%.*s\"", int(spanLen), s.constData() + idx);
116 idx += spanLen;
117 } while (idx < len);
118}
119
120void Generator::strreg(const QByteArray &s)
121{
122 if (!strings.contains(s))
123 strings.append(s);
124}
125
126int Generator::stridx(const QByteArray &s)
127{
128 int i = int(strings.indexOf(s));
129 Q_ASSERT_X(i != -1, Q_FUNC_INFO, "We forgot to register some strings");
130 return i;
131}
132
133// Returns the sum of all parameters (including return type) for the given
134// \a list of methods. This is needed for calculating the size of the methods'
135// parameter type/name meta-data.
137{
138 int sum = 0;
139 for (const FunctionDef &def : list)
140 sum += int(def.arguments.size()) + 1; // +1 for return type
141 return sum;
142}
143
144bool Generator::registerableMetaType(const QByteArray &propertyType)
145{
146 if (metaTypes.contains(propertyType))
147 return true;
148
149 if (propertyType.endsWith('*')) {
150 QByteArray objectPointerType = propertyType;
151 // The objects container stores class names, such as 'QState', 'QLabel' etc,
152 // not 'QState*', 'QLabel*'. The propertyType does contain the '*', so we need
153 // to chop it to find the class type in the known QObjects list.
154 objectPointerType.chop(1);
155 if (knownQObjectClasses.contains(objectPointerType))
156 return true;
157 }
158
159 static const QList<QByteArray> smartPointers = QList<QByteArray>()
160#define STREAM_SMART_POINTER(SMART_POINTER) << #SMART_POINTER
162#undef STREAM_SMART_POINTER
163 ;
164
165 for (const QByteArray &smartPointer : smartPointers) {
166 QByteArray ba = smartPointer + "<";
167 if (propertyType.startsWith(ba) && !propertyType.endsWith("&"))
168 return knownQObjectClasses.contains(propertyType.mid(smartPointer.size() + 1, propertyType.size() - smartPointer.size() - 1 - 1));
169 }
170
171 static const QList<QByteArray> oneArgTemplates = QList<QByteArray>()
172#define STREAM_1ARG_TEMPLATE(TEMPLATENAME) << #TEMPLATENAME
174#undef STREAM_1ARG_TEMPLATE
175 ;
176 for (const QByteArray &oneArgTemplateType : oneArgTemplates) {
177 const QByteArray ba = oneArgTemplateType + "<";
178 if (propertyType.startsWith(ba) && propertyType.endsWith(">")) {
179 const qsizetype argumentSize = propertyType.size() - ba.size()
180 // The closing '>'
181 - 1
182 // templates inside templates have an extra whitespace char to strip.
183 - (propertyType.at(propertyType.size() - 2) == ' ' ? 1 : 0 );
184 const QByteArray templateArg = propertyType.sliced(ba.size(), argumentSize);
185 return isBuiltinType(templateArg) || registerableMetaType(templateArg);
186 }
187 }
188 return false;
189}
190
191/* returns \c true if name and qualifiedName refers to the same name.
192 * If qualified name is "A::B::C", it returns \c true for "C", "B::C" or "A::B::C" */
193static bool qualifiedNameEquals(const QByteArray &qualifiedName, const QByteArray &name)
194{
195 if (qualifiedName == name)
196 return true;
197 const qsizetype index = qualifiedName.indexOf("::");
198 if (index == -1)
199 return false;
200 return qualifiedNameEquals(qualifiedName.mid(index+2), name);
201}
202
204{
205 QByteArray qualifiedClassNameIdentifier = identifier;
206
207 // Remove ':'s in the name, but be sure not to create any illegal
208 // identifiers in the process. (Don't replace with '_', because
209 // that will create problems with things like NS_::_class.)
210 qualifiedClassNameIdentifier.replace("::", "SCOPE");
211
212 // Also, avoid any leading/trailing underscores (we'll concatenate
213 // the generated name with other prefixes/suffixes, and these latter
214 // may already include an underscore, leading to two underscores)
215 qualifiedClassNameIdentifier = "CLASS" + qualifiedClassNameIdentifier + "ENDCLASS";
216 return qualifiedClassNameIdentifier;
217}
218
220{
221 bool isQObject = (cdef->classname == "QObject");
222 bool isConstructible = !cdef->constructorList.isEmpty();
223
224 // filter out undeclared enumerators and sets
225 {
226 QList<EnumDef> enumList;
227 for (EnumDef def : std::as_const(cdef->enumList)) {
228 if (cdef->enumDeclarations.contains(def.name)) {
229 enumList += def;
230 }
231 def.enumName = def.name;
232 QByteArray alias = cdef->flagAliases.value(def.name);
233 if (cdef->enumDeclarations.contains(alias)) {
234 def.name = alias;
235 enumList += def;
236 }
237 }
238 cdef->enumList = enumList;
239 }
240
241//
242// Register all strings used in data section
243//
244 strreg(cdef->qualified);
245 registerClassInfoStrings();
246 registerFunctionStrings(cdef->signalList);
247 registerFunctionStrings(cdef->slotList);
248 registerFunctionStrings(cdef->methodList);
249 registerFunctionStrings(cdef->constructorList);
250 registerByteArrayVector(cdef->nonClassSignalList);
251 registerPropertyStrings();
252 registerEnumStrings();
253
254 const bool hasStaticMetaCall =
255 (cdef->hasQObject || !cdef->methodList.isEmpty()
256 || !cdef->propertyList.isEmpty() || !cdef->constructorList.isEmpty());
257
258 const QByteArray qualifiedClassNameIdentifier = generateQualifiedClassNameIdentifier(cdef->qualified);
259
260 // ensure the qt_meta_stringdata_XXXX_t type is local
261 fprintf(out, "namespace {\n");
262
263//
264// Build the strings using QtMocHelpers::StringData
265//
266
267 fprintf(out, "\n#ifdef QT_MOC_HAS_STRINGDATA\n"
268 "struct qt_meta_stringdata_%s_t {};\n"
269 "constexpr auto qt_meta_stringdata_%s = QtMocHelpers::stringData(",
270 qualifiedClassNameIdentifier.constData(), qualifiedClassNameIdentifier.constData());
271 {
272 char comma = 0;
273 for (const QByteArray &str : strings) {
274 if (comma)
275 fputc(comma, out);
277 comma = ',';
278 }
279 }
280 fprintf(out, "\n);\n"
281 "#else // !QT_MOC_HAS_STRINGDATA\n");
282 fprintf(out, "#error \"qtmochelpers.h not found or too old.\"\n");
283 fprintf(out, "#endif // !QT_MOC_HAS_STRINGDATA\n");
284 fprintf(out, "} // unnamed namespace\n\n");
285
286//
287// build the data array
288//
289
291 fprintf(out, "Q_CONSTINIT static const uint qt_meta_data_%s[] = {\n", qualifiedClassNameIdentifier.constData());
292 fprintf(out, "\n // content:\n");
293 fprintf(out, " %4d, // revision\n", int(QMetaObjectPrivate::OutputRevision));
294 fprintf(out, " %4d, // classname\n", stridx(cdef->qualified));
295 fprintf(out, " %4d, %4d, // classinfo\n", int(cdef->classInfoList.size()), int(cdef->classInfoList.size() ? index : 0));
296 index += cdef->classInfoList.size() * 2;
297
298 qsizetype methodCount = 0;
299 if (qAddOverflow(cdef->signalList.size(), cdef->slotList.size(), &methodCount)
300 || qAddOverflow(cdef->methodList.size(), methodCount, &methodCount)) {
301 parser->error("internal limit exceeded: the total number of member functions"
302 " (including signals and slots) is too big.");
303 }
304
305 fprintf(out, " %4" PRIdQSIZETYPE ", %4d, // methods\n", methodCount, methodCount ? index : 0);
307 if (cdef->revisionedMethods)
308 index += methodCount;
309 int paramsIndex = index;
310 int totalParameterCount = aggregateParameterCount(cdef->signalList)
314 index += totalParameterCount * 2 // types and parameter names
315 - methodCount // return "parameters" don't have names
316 - int(cdef->constructorList.size()); // "this" parameters don't have names
317
318 fprintf(out, " %4d, %4d, // properties\n", int(cdef->propertyList.size()), int(cdef->propertyList.size() ? index : 0));
320 fprintf(out, " %4d, %4d, // enums/sets\n", int(cdef->enumList.size()), cdef->enumList.size() ? index : 0);
321
322 int enumsIndex = index;
323 for (const EnumDef &def : std::as_const(cdef->enumList))
324 index += QMetaObjectPrivate::IntsPerEnum + (def.values.size() * 2);
325
326 fprintf(out, " %4d, %4d, // constructors\n", isConstructible ? int(cdef->constructorList.size()) : 0,
327 isConstructible ? index : 0);
328
329 int flags = 0;
330 if (cdef->hasQGadget || cdef->hasQNamespace) {
331 // Ideally, all the classes could have that flag. But this broke classes generated
332 // by qdbusxml2cpp which generate code that require that we call qt_metacall for properties
334 }
335 fprintf(out, " %4d, // flags\n", flags);
336 fprintf(out, " %4d, // signalCount\n", int(cdef->signalList.size()));
337
338
339//
340// Build classinfo array
341//
342 generateClassInfos();
343
344 qsizetype propEnumCount = 0;
345 // all property metatypes + all enum metatypes + 1 for the type of the current class itself
346 if (qAddOverflow(cdef->propertyList.size(), cdef->enumList.size(), &propEnumCount)
347 || qAddOverflow(propEnumCount, qsizetype(1), &propEnumCount)
348 || propEnumCount >= std::numeric_limits<int>::max()) {
349 parser->error("internal limit exceeded: number of property and enum metatypes is too big.");
350 }
351 int initialMetaTypeOffset = int(propEnumCount);
352
353//
354// Build signals array first, otherwise the signal indices would be wrong
355//
356 generateFunctions(cdef->signalList, "signal", MethodSignal, paramsIndex, initialMetaTypeOffset);
357
358//
359// Build slots array
360//
361 generateFunctions(cdef->slotList, "slot", MethodSlot, paramsIndex, initialMetaTypeOffset);
362
363//
364// Build method array
365//
366 generateFunctions(cdef->methodList, "method", MethodMethod, paramsIndex, initialMetaTypeOffset);
367
368//
369// Build method version arrays
370//
371 if (cdef->revisionedMethods) {
372 generateFunctionRevisions(cdef->signalList, "signal");
373 generateFunctionRevisions(cdef->slotList, "slot");
374 generateFunctionRevisions(cdef->methodList, "method");
375 }
376
377//
378// Build method parameters array
379//
380 generateFunctionParameters(cdef->signalList, "signal");
381 generateFunctionParameters(cdef->slotList, "slot");
382 generateFunctionParameters(cdef->methodList, "method");
383 if (isConstructible)
384 generateFunctionParameters(cdef->constructorList, "constructor");
385
386//
387// Build property array
388//
389 generateProperties();
390
391//
392// Build enums array
393//
394 generateEnums(enumsIndex);
395
396//
397// Build constructors array
398//
399 if (isConstructible)
400 generateFunctions(cdef->constructorList, "constructor", MethodConstructor, paramsIndex, initialMetaTypeOffset);
401
402//
403// Terminate data array
404//
405 fprintf(out, "\n 0 // eod\n};\n\n");
406
407//
408// Build extra array
409//
410 QList<QByteArray> extraList;
411 QMultiHash<QByteArray, QByteArray> knownExtraMetaObject(knownGadgets);
412 knownExtraMetaObject.unite(knownQObjectClasses);
413
414 for (const PropertyDef &p : std::as_const(cdef->propertyList)) {
415 if (isBuiltinType(p.type))
416 continue;
417
418 if (p.type.contains('*') || p.type.contains('<') || p.type.contains('>'))
419 continue;
420
421 const qsizetype s = p.type.lastIndexOf("::");
422 if (s <= 0)
423 continue;
424
425 QByteArray unqualifiedScope = p.type.left(s);
426
427 // The scope may be a namespace for example, so it's only safe to include scopes that are known QObjects (QTBUG-2151)
429
430 QByteArray thisScope = cdef->qualified;
431 do {
432 const qsizetype s = thisScope.lastIndexOf("::");
433 thisScope = thisScope.left(s);
434 QByteArray currentScope = thisScope.isEmpty() ? unqualifiedScope : thisScope + "::" + unqualifiedScope;
435 scopeIt = knownExtraMetaObject.constFind(currentScope);
436 } while (!thisScope.isEmpty() && scopeIt == knownExtraMetaObject.constEnd());
437
438 if (scopeIt == knownExtraMetaObject.constEnd())
439 continue;
440
441 const QByteArray &scope = *scopeIt;
442
443 if (scope == "Qt")
444 continue;
445 if (qualifiedNameEquals(cdef->qualified, scope))
446 continue;
447
448 if (!extraList.contains(scope))
449 extraList += scope;
450 }
451
452 // QTBUG-20639 - Accept non-local enums for QML signal/slot parameters.
453 // Look for any scoped enum declarations, and add those to the list
454 // of extra/related metaobjects for this object.
455 for (auto it = cdef->enumDeclarations.keyBegin(),
456 end = cdef->enumDeclarations.keyEnd(); it != end; ++it) {
457 const QByteArray &enumKey = *it;
458 const qsizetype s = enumKey.lastIndexOf("::");
459 if (s > 0) {
460 QByteArray scope = enumKey.left(s);
461 if (scope != "Qt" && !qualifiedNameEquals(cdef->qualified, scope) && !extraList.contains(scope))
462 extraList += scope;
463 }
464 }
465
466//
467// Generate meta object link to parent meta objects
468//
469
470 if (!extraList.isEmpty()) {
471 fprintf(out, "Q_CONSTINIT static const QMetaObject::SuperData qt_meta_extradata_%s[] = {\n",
472 qualifiedClassNameIdentifier.constData());
473 for (const QByteArray &ba : std::as_const(extraList))
474 fprintf(out, " QMetaObject::SuperData::link<%s::staticMetaObject>(),\n", ba.constData());
475
476 fprintf(out, " nullptr\n};\n\n");
477 }
478
479//
480// Finally create and initialize the static meta object
481//
482 fprintf(out, "Q_CONSTINIT const QMetaObject %s::staticMetaObject = { {\n",
483 cdef->qualified.constData());
484
485 if (isQObject)
486 fprintf(out, " nullptr,\n");
487 else if (cdef->superclassList.size() && !cdef->hasQGadget && !cdef->hasQNamespace) // for qobject, we know the super class must have a static metaobject
488 fprintf(out, " QMetaObject::SuperData::link<%s::staticMetaObject>(),\n", purestSuperClass.constData());
489 else if (cdef->superclassList.size()) // for gadgets we need to query at compile time for it
490 fprintf(out, " QtPrivate::MetaObjectForType<%s>::value,\n", purestSuperClass.constData());
491 else
492 fprintf(out, " nullptr,\n");
493 fprintf(out, " qt_meta_stringdata_%s.offsetsAndSizes,\n"
494 " qt_meta_data_%s,\n", qualifiedClassNameIdentifier.constData(),
495 qualifiedClassNameIdentifier.constData());
496 if (hasStaticMetaCall)
497 fprintf(out, " qt_static_metacall,\n");
498 else
499 fprintf(out, " nullptr,\n");
500
501 if (extraList.isEmpty())
502 fprintf(out, " nullptr,\n");
503 else
504 fprintf(out, " qt_meta_extradata_%s,\n", qualifiedClassNameIdentifier.constData());
505
506 const char *comma = "";
507 const bool requireCompleteness = requireCompleteTypes || cdef->requireCompleteMethodTypes;
508 auto stringForType = [requireCompleteness](const QByteArray &type, bool forceComplete) -> QByteArray {
509 const char *forceCompleteType = forceComplete ? ", std::true_type>" : ", std::false_type>";
510 if (requireCompleteness)
511 return type;
512 return "QtPrivate::TypeAndForceComplete<" % type % forceCompleteType;
513 };
514 if (!requireCompleteness) {
515 fprintf(out, " qt_incomplete_metaTypeArray<qt_meta_stringdata_%s_t", qualifiedClassNameIdentifier.constData());
516 comma = ",";
517 } else {
518 fprintf(out, " qt_metaTypeArray<");
519 }
520 // metatypes for properties
521 for (const PropertyDef &p : std::as_const(cdef->propertyList)) {
522 fprintf(out, "%s\n // property '%s'\n %s",
523 comma, p.name.constData(), stringForType(p.type, true).constData());
524 comma = ",";
525 }
526
527 // metatypes for enums
528 for (const EnumDef &e : std::as_const(cdef->enumList)) {
529 fprintf(out, "%s\n // enum '%s'\n %s",
530 comma, e.name.constData(), stringForType(e.qualifiedType(cdef), true).constData());
531 comma = ",";
532 }
533
534 // type name for the Q_OJBECT/GADGET itself, void for namespaces
535 auto ownType = !cdef->hasQNamespace ? cdef->classname.data() : "void";
536 fprintf(out, "%s\n // Q_OBJECT / Q_GADGET\n %s",
537 comma, stringForType(ownType, true).constData());
538 comma = ",";
539
540 // metatypes for all exposed methods
541 // because we definitely printed something above, this section doesn't need comma control
542 const auto allMethods = {&cdef->signalList, &cdef->slotList, &cdef->methodList};
543 for (const QList<FunctionDef> *methodContainer : allMethods) {
544 for (const FunctionDef &fdef : *methodContainer) {
545 fprintf(out, ",\n // method '%s'\n %s",
546 fdef.name.constData(), stringForType(fdef.type.name, false).constData());
547 for (const auto &argument: fdef.arguments)
548 fprintf(out, ",\n %s", stringForType(argument.type.name, false).constData());
549 }
550 }
551
552 // but constructors have no return types, so this needs comma control again
553 for (const FunctionDef &fdef : std::as_const(cdef->constructorList)) {
554 if (fdef.arguments.isEmpty())
555 continue;
556
557 fprintf(out, "%s\n // constructor '%s'", comma, fdef.name.constData());
558 comma = "";
559 for (const auto &argument: fdef.arguments) {
560 fprintf(out, "%s\n %s", comma,
561 stringForType(argument.type.name, false).constData());
562 comma = ",";
563 }
564 }
565 fprintf(out, "\n >,\n");
566
567 fprintf(out, " nullptr\n} };\n\n");
568
569//
570// Generate internal qt_static_metacall() function
571//
572 if (hasStaticMetaCall)
573 generateStaticMetacall();
574
575 if (!cdef->hasQObject)
576 return;
577
578 fprintf(out, "\nconst QMetaObject *%s::metaObject() const\n{\n return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;\n}\n",
579 cdef->qualified.constData());
580
581
582//
583// Generate smart cast function
584//
585 fprintf(out, "\nvoid *%s::qt_metacast(const char *_clname)\n{\n", cdef->qualified.constData());
586 fprintf(out, " if (!_clname) return nullptr;\n");
587 fprintf(out, " if (!strcmp(_clname, qt_meta_stringdata_%s.stringdata0))\n"
588 " return static_cast<void*>(this);\n",
589 qualifiedClassNameIdentifier.constData());
590
591 // for all superclasses but the first one
592 if (cdef->superclassList.size() > 1) {
593 auto it = cdef->superclassList.cbegin() + 1;
594 const auto end = cdef->superclassList.cend();
595 for (; it != end; ++it) {
596 const auto &[className, access] = *it;
598 continue;
599 const char *cname = className.constData();
600 fprintf(out, " if (!strcmp(_clname, \"%s\"))\n return static_cast< %s*>(this);\n",
601 cname, cname);
602 }
603 }
604
605 for (const QList<ClassDef::Interface> &iface : std::as_const(cdef->interfaceList)) {
606 for (qsizetype j = 0; j < iface.size(); ++j) {
607 fprintf(out, " if (!strcmp(_clname, %s))\n return ", iface.at(j).interfaceId.constData());
608 for (qsizetype k = j; k >= 0; --k)
609 fprintf(out, "static_cast< %s*>(", iface.at(k).className.constData());
610 fprintf(out, "this%s;\n", QByteArray(j + 1, ')').constData());
611 }
612 }
613 if (!purestSuperClass.isEmpty() && !isQObject) {
614 QByteArray superClass = purestSuperClass;
615 fprintf(out, " return %s::qt_metacast(_clname);\n", superClass.constData());
616 } else {
617 fprintf(out, " return nullptr;\n");
618 }
619 fprintf(out, "}\n");
620
621//
622// Generate internal qt_metacall() function
623//
624 generateMetacall();
625
626//
627// Generate internal signal functions
628//
629 for (int signalindex = 0; signalindex < int(cdef->signalList.size()); ++signalindex)
630 generateSignal(&cdef->signalList.at(signalindex), signalindex);
631
632//
633// Generate plugin meta data
634//
635 generatePluginMetaData();
636
637//
638// Generate function to make sure the non-class signals exist in the parent classes
639//
640 if (!cdef->nonClassSignalList.isEmpty()) {
641 fprintf(out, "// If you get a compile error in this function it can be because either\n");
642 fprintf(out, "// a) You are using a NOTIFY signal that does not exist. Fix it.\n");
643 fprintf(out, "// b) You are using a NOTIFY signal that does exist (in a parent class) but has a non-empty parameter list. This is a moc limitation.\n");
644 fprintf(out, "[[maybe_unused]] static void checkNotifySignalValidity_%s(%s *t) {\n", qualifiedClassNameIdentifier.constData(), cdef->qualified.constData());
645 for (const QByteArray &nonClassSignal : std::as_const(cdef->nonClassSignalList))
646 fprintf(out, " t->%s();\n", nonClassSignal.constData());
647 fprintf(out, "}\n");
648 }
649}
650
651
652void Generator::registerClassInfoStrings()
653{
654 for (const ClassInfoDef &c : std::as_const(cdef->classInfoList)) {
655 strreg(c.name);
656 strreg(c.value);
657 }
658}
659
660void Generator::generateClassInfos()
661{
662 if (cdef->classInfoList.isEmpty())
663 return;
664
665 fprintf(out, "\n // classinfo: key, value\n");
666
667 for (const ClassInfoDef &c : std::as_const(cdef->classInfoList))
668 fprintf(out, " %4d, %4d,\n", stridx(c.name), stridx(c.value));
669}
670
671void Generator::registerFunctionStrings(const QList<FunctionDef> &list)
672{
673 for (const FunctionDef &f : list) {
674 strreg(f.name);
675 if (!isBuiltinType(f.normalizedType))
676 strreg(f.normalizedType);
677 strreg(f.tag);
678
679 for (const ArgumentDef &a : f.arguments) {
680 if (!isBuiltinType(a.normalizedType))
681 strreg(a.normalizedType);
682 strreg(a.name);
683 }
684 }
685}
686
687void Generator::registerByteArrayVector(const QList<QByteArray> &list)
688{
689 for (const QByteArray &ba : list)
690 strreg(ba);
691}
692
693void Generator::generateFunctions(const QList<FunctionDef> &list, const char *functype, int type,
694 int &paramsIndex, int &initialMetatypeOffset)
695{
696 if (list.isEmpty())
697 return;
698 fprintf(out, "\n // %ss: name, argc, parameters, tag, flags, initial metatype offsets\n", functype);
699
700 for (const FunctionDef &f : list) {
701 QByteArray comment;
702 uint flags = type;
703 if (f.access == FunctionDef::Private) {
705 comment.append("Private");
706 } else if (f.access == FunctionDef::Public) {
708 comment.append("Public");
709 } else if (f.access == FunctionDef::Protected) {
711 comment.append("Protected");
712 }
713 if (f.isCompat) {
715 comment.append(" | MethodCompatibility");
716 }
717 if (f.wasCloned) {
719 comment.append(" | MethodCloned");
720 }
721 if (f.isScriptable) {
723 comment.append(" | isScriptable");
724 }
725 if (f.revision > 0) {
727 comment.append(" | MethodRevisioned");
728 }
729
730 if (f.isConst) {
732 comment.append(" | MethodIsConst ");
733 }
734
735 const int argc = int(f.arguments.size());
736 fprintf(out, " %4d, %4d, %4d, %4d, 0x%02x, %4d /* %s */,\n",
737 stridx(f.name), argc, paramsIndex, stridx(f.tag), flags, initialMetatypeOffset, comment.constData());
738
739 paramsIndex += 1 + argc * 2;
740 // constructors don't have a return type
741 initialMetatypeOffset += (f.isConstructor ? 0 : 1) + argc;
742 }
743}
744
745void Generator::generateFunctionRevisions(const QList<FunctionDef> &list, const char *functype)
746{
747 if (list.size())
748 fprintf(out, "\n // %ss: revision\n", functype);
749 for (const FunctionDef &f : list)
750 fprintf(out, " %4d,\n", f.revision);
751}
752
753void Generator::generateFunctionParameters(const QList<FunctionDef> &list, const char *functype)
754{
755 if (list.isEmpty())
756 return;
757 fprintf(out, "\n // %ss: parameters\n", functype);
758 for (const FunctionDef &f : list) {
759 fprintf(out, " ");
760
761 // Types
762 const bool allowEmptyName = f.isConstructor;
763 generateTypeInfo(f.normalizedType, allowEmptyName);
764 fputc(',', out);
765 for (const ArgumentDef &arg : f.arguments) {
766 fputc(' ', out);
767 generateTypeInfo(arg.normalizedType, allowEmptyName);
768 fputc(',', out);
769 }
770
771 // Parameter names
772 for (const ArgumentDef &arg : f.arguments)
773 fprintf(out, " %4d,", stridx(arg.name));
774
775 fprintf(out, "\n");
776 }
777}
778
779void Generator::generateTypeInfo(const QByteArray &typeName, bool allowEmptyName)
780{
781 Q_UNUSED(allowEmptyName);
782 if (isBuiltinType(typeName)) {
783 int type;
784 const char *valueString;
785 if (typeName == "qreal") {
787 valueString = "QReal";
788 } else {
790 valueString = metaTypeEnumValueString(type);
791 }
792 if (valueString) {
793 fprintf(out, "QMetaType::%s", valueString);
794 } else {
796 fprintf(out, "%4d", type);
797 }
798 } else {
799 Q_ASSERT(!typeName.isEmpty() || allowEmptyName);
800 fprintf(out, "0x%.8x | %d", IsUnresolvedType, stridx(typeName));
801 }
802}
803
804void Generator::registerPropertyStrings()
805{
806 for (const PropertyDef &p : std::as_const(cdef->propertyList)) {
807 strreg(p.name);
808 if (!isBuiltinType(p.type))
809 strreg(p.type);
810 }
811}
812
813void Generator::generateProperties()
814{
815 //
816 // Create meta data
817 //
818
819 if (cdef->propertyList.size())
820 fprintf(out, "\n // properties: name, type, flags\n");
821 for (const PropertyDef &p : std::as_const(cdef->propertyList)) {
823 if (!isBuiltinType(p.type))
824 flags |= EnumOrFlag;
825 if (!p.member.isEmpty() && !p.constant)
826 flags |= Writable;
827 if (!p.read.isEmpty() || !p.member.isEmpty())
828 flags |= Readable;
829 if (!p.write.isEmpty()) {
830 flags |= Writable;
831 if (p.stdCppSet())
832 flags |= StdCppSet;
833 }
834
835 if (!p.reset.isEmpty())
836 flags |= Resettable;
837
838 if (p.designable != "false")
839 flags |= Designable;
840
841 if (p.scriptable != "false")
842 flags |= Scriptable;
843
844 if (p.stored != "false")
845 flags |= Stored;
846
847 if (p.user != "false")
848 flags |= User;
849
850 if (p.constant)
851 flags |= Constant;
852 if (p.final)
853 flags |= Final;
854 if (p.required)
855 flags |= Required;
856
857 if (!p.bind.isEmpty())
858 flags |= Bindable;
859
860 fprintf(out, " %4d, ", stridx(p.name));
861 generateTypeInfo(p.type);
862 int notifyId = p.notifyId;
863 if (p.notifyId < -1) {
864 // signal is in parent class
865 const int indexInStrings = int(strings.indexOf(p.notify));
866 notifyId = indexInStrings | IsUnresolvedSignal;
867 }
868 fprintf(out, ", 0x%.8x, uint(%d), %d,\n", flags, notifyId, p.revision);
869 }
870}
871
872void Generator::registerEnumStrings()
873{
874 for (const EnumDef &e : std::as_const(cdef->enumList)) {
875 strreg(e.name);
876 if (!e.enumName.isNull())
877 strreg(e.enumName);
878 for (const QByteArray &val : e.values)
879 strreg(val);
880 }
881}
882
883void Generator::generateEnums(int index)
884{
885 if (cdef->enumDeclarations.isEmpty())
886 return;
887
888 fprintf(out, "\n // enums: name, alias, flags, count, data\n");
890 int i;
891 for (i = 0; i < cdef->enumList.size(); ++i) {
892 const EnumDef &e = cdef->enumList.at(i);
893 int flags = 0;
894 if (cdef->enumDeclarations.value(e.name))
895 flags |= EnumIsFlag;
896 if (e.isEnumClass)
898 fprintf(out, " %4d, %4d, 0x%.1x, %4d, %4d,\n",
899 stridx(e.name),
900 e.enumName.isNull() ? stridx(e.name) : stridx(e.enumName),
901 flags,
902 int(e.values.size()),
903 index);
904 index += e.values.size() * 2;
905 }
906
907 fprintf(out, "\n // enum data: key, value\n");
908 for (const EnumDef &e : std::as_const(cdef->enumList)) {
909 for (const QByteArray &val : e.values) {
911 if (e.isEnumClass)
912 code += "::" + (e.enumName.isNull() ? e.name : e.enumName);
913 code += "::" + val;
914 fprintf(out, " %4d, uint(%s),\n",
915 stridx(val), code.constData());
916 }
917 }
918}
919
920void Generator::generateMetacall()
921{
922 bool isQObject = (cdef->classname == "QObject");
923
924 fprintf(out, "\nint %s::qt_metacall(QMetaObject::Call _c, int _id, void **_a)\n{\n",
925 cdef->qualified.constData());
926
927 if (!purestSuperClass.isEmpty() && !isQObject) {
928 QByteArray superClass = purestSuperClass;
929 fprintf(out, " _id = %s::qt_metacall(_c, _id, _a);\n", superClass.constData());
930 }
931
932
933 bool needElse = false;
934 QList<FunctionDef> methodList;
935 methodList += cdef->signalList;
936 methodList += cdef->slotList;
937 methodList += cdef->methodList;
938
939 // If there are no methods or properties, we will return _id anyway, so
940 // don't emit this comparison -- it is unnecessary, and it makes coverity
941 // unhappy.
942 if (methodList.size() || cdef->propertyList.size()) {
943 fprintf(out, " if (_id < 0)\n return _id;\n");
944 }
945
946 fprintf(out, " ");
947
948 if (methodList.size()) {
949 needElse = true;
950 fprintf(out, "if (_c == QMetaObject::InvokeMetaMethod) {\n");
951 fprintf(out, " if (_id < %d)\n", int(methodList.size()));
952 fprintf(out, " qt_static_metacall(this, _c, _id, _a);\n");
953 fprintf(out, " _id -= %d;\n }", int(methodList.size()));
954
955 fprintf(out, " else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {\n");
956 fprintf(out, " if (_id < %d)\n", int(methodList.size()));
957
958 if (methodsWithAutomaticTypesHelper(methodList).isEmpty())
959 fprintf(out, " *reinterpret_cast<QMetaType *>(_a[0]) = QMetaType();\n");
960 else
961 fprintf(out, " qt_static_metacall(this, _c, _id, _a);\n");
962 fprintf(out, " _id -= %d;\n }", int(methodList.size()));
963
964 }
965
966 if (cdef->propertyList.size()) {
967 if (needElse)
968 fprintf(out, "else ");
969 fprintf(out,
970 "if (_c == QMetaObject::ReadProperty || _c == QMetaObject::WriteProperty\n"
971 " || _c == QMetaObject::ResetProperty || _c == QMetaObject::BindableProperty\n"
972 " || _c == QMetaObject::RegisterPropertyMetaType) {\n"
973 " qt_static_metacall(this, _c, _id, _a);\n"
974 " _id -= %d;\n }", int(cdef->propertyList.size()));
975 }
976 if (methodList.size() || cdef->propertyList.size())
977 fprintf(out, "\n ");
978 fprintf(out,"return _id;\n}\n");
979}
980
981
982// ### Qt 7 (6.x?): remove
983QMultiMap<QByteArray, int> Generator::automaticPropertyMetaTypesHelper()
984{
985 QMultiMap<QByteArray, int> automaticPropertyMetaTypes;
986 for (int i = 0; i < int(cdef->propertyList.size()); ++i) {
987 const QByteArray propertyType = cdef->propertyList.at(i).type;
988 if (registerableMetaType(propertyType) && !isBuiltinType(propertyType))
989 automaticPropertyMetaTypes.insert(propertyType, i);
990 }
991 return automaticPropertyMetaTypes;
992}
993
995Generator::methodsWithAutomaticTypesHelper(const QList<FunctionDef> &methodList)
996{
997 QMap<int, QMultiMap<QByteArray, int> > methodsWithAutomaticTypes;
998 for (int i = 0; i < methodList.size(); ++i) {
999 const FunctionDef &f = methodList.at(i);
1000 for (int j = 0; j < f.arguments.size(); ++j) {
1001 const QByteArray argType = f.arguments.at(j).normalizedType;
1002 if (registerableMetaType(argType) && !isBuiltinType(argType))
1003 methodsWithAutomaticTypes[i].insert(argType, j);
1004 }
1005 }
1006 return methodsWithAutomaticTypes;
1007}
1008
1009void Generator::generateStaticMetacall()
1010{
1011 fprintf(out, "void %s::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)\n{\n",
1012 cdef->qualified.constData());
1013
1014 bool needElse = false;
1015 bool isUsed_a = false;
1016
1017 const auto generateCtorArguments = [&](int ctorindex) {
1018 const FunctionDef &f = cdef->constructorList.at(ctorindex);
1019 Q_ASSERT(!f.isPrivateSignal); // That would be a strange ctor indeed
1020 int offset = 1;
1021
1022 const auto begin = f.arguments.cbegin();
1023 const auto end = f.arguments.cend();
1024 for (auto it = begin; it != end; ++it) {
1025 const ArgumentDef &a = *it;
1026 if (it != begin)
1027 fprintf(out, ",");
1028 fprintf(out, "(*reinterpret_cast<%s>(_a[%d]))",
1029 a.typeNameForCast.constData(), offset++);
1030 }
1031 };
1032
1033 if (!cdef->constructorList.isEmpty()) {
1034 fprintf(out, " if (_c == QMetaObject::CreateInstance) {\n");
1035 fprintf(out, " switch (_id) {\n");
1036 const int ctorend = int(cdef->constructorList.size());
1037 for (int ctorindex = 0; ctorindex < ctorend; ++ctorindex) {
1038 fprintf(out, " case %d: { %s *_r = new %s(", ctorindex,
1039 cdef->classname.constData(), cdef->classname.constData());
1040 generateCtorArguments(ctorindex);
1041 fprintf(out, ");\n");
1042 fprintf(out, " if (_a[0]) *reinterpret_cast<%s**>(_a[0]) = _r; } break;\n",
1043 (cdef->hasQGadget || cdef->hasQNamespace) ? "void" : "QObject");
1044 }
1045 fprintf(out, " default: break;\n");
1046 fprintf(out, " }\n");
1047 fprintf(out, " } else if (_c == QMetaObject::ConstructInPlace) {\n");
1048 fprintf(out, " switch (_id) {\n");
1049 for (int ctorindex = 0; ctorindex < ctorend; ++ctorindex) {
1050 fprintf(out, " case %d: { new (_a[0]) %s(",
1051 ctorindex, cdef->classname.constData());
1052 generateCtorArguments(ctorindex);
1053 fprintf(out, "); } break;\n");
1054 }
1055 fprintf(out, " default: break;\n");
1056 fprintf(out, " }\n");
1057 fprintf(out, " }");
1058 needElse = true;
1059 isUsed_a = true;
1060 }
1061
1062 QList<FunctionDef> methodList;
1063 methodList += cdef->signalList;
1064 methodList += cdef->slotList;
1065 methodList += cdef->methodList;
1066
1067 if (!methodList.isEmpty()) {
1068 if (needElse)
1069 fprintf(out, " else ");
1070 else
1071 fprintf(out, " ");
1072 fprintf(out, "if (_c == QMetaObject::InvokeMetaMethod) {\n");
1073 if (cdef->hasQObject) {
1074#ifndef QT_NO_DEBUG
1075 fprintf(out, " Q_ASSERT(staticMetaObject.cast(_o));\n");
1076#endif
1077 fprintf(out, " auto *_t = static_cast<%s *>(_o);\n", cdef->classname.constData());
1078 } else {
1079 fprintf(out, " auto *_t = reinterpret_cast<%s *>(_o);\n", cdef->classname.constData());
1080 }
1081 fprintf(out, " (void)_t;\n");
1082 fprintf(out, " switch (_id) {\n");
1083 for (int methodindex = 0; methodindex < methodList.size(); ++methodindex) {
1084 const FunctionDef &f = methodList.at(methodindex);
1085 Q_ASSERT(!f.normalizedType.isEmpty());
1086 fprintf(out, " case %d: ", methodindex);
1087 if (f.normalizedType != "void")
1088 fprintf(out, "{ %s _r = ", noRef(f.normalizedType).constData());
1089 fprintf(out, "_t->");
1090 if (f.inPrivateClass.size())
1091 fprintf(out, "%s->", f.inPrivateClass.constData());
1092 fprintf(out, "%s(", f.name.constData());
1093 int offset = 1;
1094
1095 if (f.isRawSlot) {
1096 fprintf(out, "QMethodRawArguments{ _a }");
1097 } else {
1098 const auto begin = f.arguments.cbegin();
1099 const auto end = f.arguments.cend();
1100 for (auto it = begin; it != end; ++it) {
1101 const ArgumentDef &a = *it;
1102 if (it != begin)
1103 fprintf(out, ",");
1104 fprintf(out, "(*reinterpret_cast< %s>(_a[%d]))",a.typeNameForCast.constData(), offset++);
1105 isUsed_a = true;
1106 }
1107 if (f.isPrivateSignal) {
1108 if (!f.arguments.isEmpty())
1109 fprintf(out, ", ");
1110 fprintf(out, "%s", "QPrivateSignal()");
1111 }
1112 }
1113 fprintf(out, ");");
1114 if (f.normalizedType != "void") {
1115 fprintf(out, "\n if (_a[0]) *reinterpret_cast< %s*>(_a[0]) = std::move(_r); } ",
1116 noRef(f.normalizedType).constData());
1117 isUsed_a = true;
1118 }
1119 fprintf(out, " break;\n");
1120 }
1121 fprintf(out, " default: ;\n");
1122 fprintf(out, " }\n");
1123 fprintf(out, " }");
1124 needElse = true;
1125
1126 QMap<int, QMultiMap<QByteArray, int> > methodsWithAutomaticTypes = methodsWithAutomaticTypesHelper(methodList);
1127
1128 if (!methodsWithAutomaticTypes.isEmpty()) {
1129 fprintf(out, " else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {\n");
1130 fprintf(out, " switch (_id) {\n");
1131 fprintf(out, " default: *reinterpret_cast<QMetaType *>(_a[0]) = QMetaType(); break;\n");
1132 QMap<int, QMultiMap<QByteArray, int> >::const_iterator it = methodsWithAutomaticTypes.constBegin();
1133 const QMap<int, QMultiMap<QByteArray, int> >::const_iterator end = methodsWithAutomaticTypes.constEnd();
1134 for ( ; it != end; ++it) {
1135 fprintf(out, " case %d:\n", it.key());
1136 fprintf(out, " switch (*reinterpret_cast<int*>(_a[1])) {\n");
1137 fprintf(out, " default: *reinterpret_cast<QMetaType *>(_a[0]) = QMetaType(); break;\n");
1138 auto jt = it->begin();
1139 const auto jend = it->end();
1140 while (jt != jend) {
1141 fprintf(out, " case %d:\n", jt.value());
1142 const QByteArray &lastKey = jt.key();
1143 ++jt;
1144 if (jt == jend || jt.key() != lastKey)
1145 fprintf(out, " *reinterpret_cast<QMetaType *>(_a[0]) = QMetaType::fromType< %s >(); break;\n", lastKey.constData());
1146 }
1147 fprintf(out, " }\n");
1148 fprintf(out, " break;\n");
1149 }
1150 fprintf(out, " }\n");
1151 fprintf(out, " }");
1152 isUsed_a = true;
1153 }
1154
1155 }
1156 if (!cdef->signalList.isEmpty()) {
1157 Q_ASSERT(needElse); // if there is signal, there was method.
1158 fprintf(out, " else if (_c == QMetaObject::IndexOfMethod) {\n");
1159 fprintf(out, " int *result = reinterpret_cast<int *>(_a[0]);\n");
1160 bool anythingUsed = false;
1161 for (int methodindex = 0; methodindex < int(cdef->signalList.size()); ++methodindex) {
1162 const FunctionDef &f = cdef->signalList.at(methodindex);
1163 if (f.wasCloned || !f.inPrivateClass.isEmpty() || f.isStatic)
1164 continue;
1165 anythingUsed = true;
1166 fprintf(out, " {\n");
1167 fprintf(out, " using _t = %s (%s::*)(",f.type.rawName.constData() , cdef->classname.constData());
1168
1169 const auto begin = f.arguments.cbegin();
1170 const auto end = f.arguments.cend();
1171 for (auto it = begin; it != end; ++it) {
1172 const ArgumentDef &a = *it;
1173 if (it != begin)
1174 fprintf(out, ", ");
1175 fprintf(out, "%s", QByteArray(a.type.name + ' ' + a.rightType).constData());
1176 }
1177 if (f.isPrivateSignal) {
1178 if (!f.arguments.isEmpty())
1179 fprintf(out, ", ");
1180 fprintf(out, "%s", "QPrivateSignal");
1181 }
1182 if (f.isConst)
1183 fprintf(out, ") const;\n");
1184 else
1185 fprintf(out, ");\n");
1186 fprintf(out, " if (_t _q_method = &%s::%s; *reinterpret_cast<_t *>(_a[1]) == _q_method) {\n",
1187 cdef->classname.constData(), f.name.constData());
1188 fprintf(out, " *result = %d;\n", methodindex);
1189 fprintf(out, " return;\n");
1190 fprintf(out, " }\n }\n");
1191 }
1192 if (!anythingUsed)
1193 fprintf(out, " (void)result;\n");
1194 fprintf(out, " }");
1195 needElse = true;
1196 }
1197
1198 const QMultiMap<QByteArray, int> automaticPropertyMetaTypes = automaticPropertyMetaTypesHelper();
1199
1200 if (!automaticPropertyMetaTypes.isEmpty()) {
1201 if (needElse)
1202 fprintf(out, " else ");
1203 else
1204 fprintf(out, " ");
1205 fprintf(out, "if (_c == QMetaObject::RegisterPropertyMetaType) {\n");
1206 fprintf(out, " switch (_id) {\n");
1207 fprintf(out, " default: *reinterpret_cast<int*>(_a[0]) = -1; break;\n");
1208 auto it = automaticPropertyMetaTypes.begin();
1209 const auto end = automaticPropertyMetaTypes.end();
1210 while (it != end) {
1211 fprintf(out, " case %d:\n", it.value());
1212 const QByteArray &lastKey = it.key();
1213 ++it;
1214 if (it == end || it.key() != lastKey)
1215 fprintf(out, " *reinterpret_cast<int*>(_a[0]) = qRegisterMetaType< %s >(); break;\n", lastKey.constData());
1216 }
1217 fprintf(out, " }\n");
1218 fprintf(out, " } ");
1219 isUsed_a = true;
1220 needElse = true;
1221 }
1222
1223 if (!cdef->propertyList.empty()) {
1224 bool needGet = false;
1225 bool needTempVarForGet = false;
1226 bool needSet = false;
1227 bool needReset = false;
1228 bool hasBindableProperties = false;
1229 for (const PropertyDef &p : std::as_const(cdef->propertyList)) {
1230 needGet |= !p.read.isEmpty() || !p.member.isEmpty();
1231 if (!p.read.isEmpty() || !p.member.isEmpty())
1232 needTempVarForGet |= (p.gspec != PropertyDef::PointerSpec
1233 && p.gspec != PropertyDef::ReferenceSpec);
1234
1235 needSet |= !p.write.isEmpty() || (!p.member.isEmpty() && !p.constant);
1236 needReset |= !p.reset.isEmpty();
1237 hasBindableProperties |= !p.bind.isEmpty();
1238 }
1239 if (needElse)
1240 fprintf(out, " else ");
1241 fprintf(out, "if (_c == QMetaObject::ReadProperty) {\n");
1242
1243 auto setupMemberAccess = [this]() {
1244 if (cdef->hasQObject) {
1245#ifndef QT_NO_DEBUG
1246 fprintf(out, " Q_ASSERT(staticMetaObject.cast(_o));\n");
1247#endif
1248 fprintf(out, " auto *_t = static_cast<%s *>(_o);\n", cdef->classname.constData());
1249 } else {
1250 fprintf(out, " auto *_t = reinterpret_cast<%s *>(_o);\n", cdef->classname.constData());
1251 }
1252 fprintf(out, " (void)_t;\n");
1253 };
1254
1255 if (needGet) {
1256 setupMemberAccess();
1257 if (needTempVarForGet)
1258 fprintf(out, " void *_v = _a[0];\n");
1259 fprintf(out, " switch (_id) {\n");
1260 for (int propindex = 0; propindex < int(cdef->propertyList.size()); ++propindex) {
1261 const PropertyDef &p = cdef->propertyList.at(propindex);
1262 if (p.read.isEmpty() && p.member.isEmpty())
1263 continue;
1264 QByteArray prefix = "_t->";
1265 if (p.inPrivateClass.size()) {
1266 prefix += p.inPrivateClass + "->";
1267 }
1268
1269 if (p.gspec == PropertyDef::PointerSpec)
1270 fprintf(out, " case %d: _a[0] = const_cast<void*>(reinterpret_cast<const void*>(%s%s())); break;\n",
1271 propindex, prefix.constData(), p.read.constData());
1272 else if (p.gspec == PropertyDef::ReferenceSpec)
1273 fprintf(out, " case %d: _a[0] = const_cast<void*>(reinterpret_cast<const void*>(&%s%s())); break;\n",
1274 propindex, prefix.constData(), p.read.constData());
1275 else if (cdef->enumDeclarations.value(p.type, false))
1276 fprintf(out, " case %d: *reinterpret_cast<int*>(_v) = QFlag(%s%s()); break;\n",
1277 propindex, prefix.constData(), p.read.constData());
1278 else if (p.read == "default")
1279 fprintf(out, " case %d: *reinterpret_cast< %s*>(_v) = %s%s().value(); break;\n",
1280 propindex, p.type.constData(), prefix.constData(), p.bind.constData());
1281 else if (!p.read.isEmpty())
1282 fprintf(out, " case %d: *reinterpret_cast< %s*>(_v) = %s%s(); break;\n",
1283 propindex, p.type.constData(), prefix.constData(), p.read.constData());
1284 else
1285 fprintf(out, " case %d: *reinterpret_cast< %s*>(_v) = %s%s; break;\n",
1286 propindex, p.type.constData(), prefix.constData(), p.member.constData());
1287 }
1288 fprintf(out, " default: break;\n");
1289 fprintf(out, " }\n");
1290 }
1291
1292 fprintf(out, " }");
1293
1294 fprintf(out, " else ");
1295 fprintf(out, "if (_c == QMetaObject::WriteProperty) {\n");
1296
1297 if (needSet) {
1298 setupMemberAccess();
1299 fprintf(out, " void *_v = _a[0];\n");
1300 fprintf(out, " switch (_id) {\n");
1301 for (int propindex = 0; propindex < int(cdef->propertyList.size()); ++propindex) {
1302 const PropertyDef &p = cdef->propertyList.at(propindex);
1303 if (p.constant)
1304 continue;
1305 if (p.write.isEmpty() && p.member.isEmpty())
1306 continue;
1307 QByteArray prefix = "_t->";
1308 if (p.inPrivateClass.size()) {
1309 prefix += p.inPrivateClass + "->";
1310 }
1311 if (cdef->enumDeclarations.value(p.type, false)) {
1312 fprintf(out, " case %d: %s%s(QFlag(*reinterpret_cast<int*>(_v))); break;\n",
1313 propindex, prefix.constData(), p.write.constData());
1314 } else if (p.write == "default") {
1315 fprintf(out, " case %d: {\n", propindex);
1316 fprintf(out, " %s%s().setValue(*reinterpret_cast< %s*>(_v));\n",
1317 prefix.constData(), p.bind.constData(), p.type.constData());
1318 fprintf(out, " break;\n");
1319 fprintf(out, " }\n");
1320 } else if (!p.write.isEmpty()) {
1321 fprintf(out, " case %d: %s%s(*reinterpret_cast< %s*>(_v)); break;\n",
1322 propindex, prefix.constData(), p.write.constData(), p.type.constData());
1323 } else {
1324 fprintf(out, " case %d:\n", propindex);
1325 fprintf(out, " if (%s%s != *reinterpret_cast< %s*>(_v)) {\n",
1326 prefix.constData(), p.member.constData(), p.type.constData());
1327 fprintf(out, " %s%s = *reinterpret_cast< %s*>(_v);\n",
1328 prefix.constData(), p.member.constData(), p.type.constData());
1329 if (!p.notify.isEmpty() && p.notifyId > -1) {
1330 const FunctionDef &f = cdef->signalList.at(p.notifyId);
1331 if (f.arguments.size() == 0)
1332 fprintf(out, " Q_EMIT _t->%s();\n", p.notify.constData());
1333 else if (f.arguments.size() == 1 && f.arguments.at(0).normalizedType == p.type)
1334 fprintf(out, " Q_EMIT _t->%s(%s%s);\n",
1335 p.notify.constData(), prefix.constData(), p.member.constData());
1336 } else if (!p.notify.isEmpty() && p.notifyId < -1) {
1337 fprintf(out, " Q_EMIT _t->%s();\n", p.notify.constData());
1338 }
1339 fprintf(out, " }\n");
1340 fprintf(out, " break;\n");
1341 }
1342 }
1343 fprintf(out, " default: break;\n");
1344 fprintf(out, " }\n");
1345 }
1346
1347 fprintf(out, " }");
1348
1349 fprintf(out, " else ");
1350 fprintf(out, "if (_c == QMetaObject::ResetProperty) {\n");
1351 if (needReset) {
1352 setupMemberAccess();
1353 fprintf(out, " switch (_id) {\n");
1354 for (int propindex = 0; propindex < int(cdef->propertyList.size()); ++propindex) {
1355 const PropertyDef &p = cdef->propertyList.at(propindex);
1356 if (p.reset.isEmpty())
1357 continue;
1358 QByteArray prefix = "_t->";
1359 if (p.inPrivateClass.size()) {
1360 prefix += p.inPrivateClass + "->";
1361 }
1362 fprintf(out, " case %d: %s%s(); break;\n",
1363 propindex, prefix.constData(), p.reset.constData());
1364 }
1365 fprintf(out, " default: break;\n");
1366 fprintf(out, " }\n");
1367 }
1368 fprintf(out, " }");
1369
1370 fprintf(out, " else ");
1371 fprintf(out, "if (_c == QMetaObject::BindableProperty) {\n");
1372 if (hasBindableProperties) {
1373 setupMemberAccess();
1374 fprintf(out, " switch (_id) {\n");
1375 for (int propindex = 0; propindex < int(cdef->propertyList.size()); ++propindex) {
1376 const PropertyDef &p = cdef->propertyList.at(propindex);
1377 if (p.bind.isEmpty())
1378 continue;
1379 QByteArray prefix = "_t->";
1380 if (p.inPrivateClass.size()) {
1381 prefix += p.inPrivateClass + "->";
1382 }
1383 fprintf(out,
1384 " case %d: *static_cast<QUntypedBindable *>(_a[0]) = %s%s(); "
1385 "break;\n",
1386 propindex, prefix.constData(), p.bind.constData());
1387 }
1388 fprintf(out, " default: break;\n");
1389 fprintf(out, " }\n");
1390 }
1391 fprintf(out, " }");
1392 needElse = true;
1393 }
1394
1395 if (needElse)
1396 fprintf(out, "\n");
1397
1398 if (methodList.isEmpty()) {
1399 fprintf(out, " (void)_o;\n");
1400 if (cdef->constructorList.isEmpty() && automaticPropertyMetaTypes.isEmpty() && methodsWithAutomaticTypesHelper(methodList).isEmpty()) {
1401 fprintf(out, " (void)_id;\n");
1402 fprintf(out, " (void)_c;\n");
1403 }
1404 }
1405 if (!isUsed_a)
1406 fprintf(out, " (void)_a;\n");
1407
1408 fprintf(out, "}\n");
1409}
1410
1411void Generator::generateSignal(const FunctionDef *def, int index)
1412{
1413 if (def->wasCloned || def->isAbstract)
1414 return;
1415 fprintf(out, "\n// SIGNAL %d\n%s %s::%s(",
1416 index, def->type.name.constData(), cdef->qualified.constData(), def->name.constData());
1417
1418 QByteArray thisPtr = "this";
1419 const char *constQualifier = "";
1420
1421 if (def->isConst) {
1422 thisPtr = "const_cast< " + cdef->qualified + " *>(this)";
1423 constQualifier = "const";
1424 }
1425
1427 if (def->arguments.isEmpty() && def->normalizedType == "void" && !def->isPrivateSignal) {
1428 fprintf(out, ")%s\n{\n"
1429 " QMetaObject::activate(%s, &staticMetaObject, %d, nullptr);\n"
1430 "}\n", constQualifier, thisPtr.constData(), index);
1431 return;
1432 }
1433
1434 int offset = 1;
1435 const auto begin = def->arguments.cbegin();
1436 const auto end = def->arguments.cend();
1437 for (auto it = begin; it != end; ++it) {
1438 const ArgumentDef &a = *it;
1439 if (it != begin)
1440 fputs(", ", out);
1441 if (a.type.name.size())
1442 fputs(a.type.name.constData(), out);
1443 fprintf(out, " _t%d", offset++);
1444 if (a.rightType.size())
1445 fputs(a.rightType.constData(), out);
1446 }
1447 if (def->isPrivateSignal) {
1448 if (!def->arguments.isEmpty())
1449 fprintf(out, ", ");
1450 fprintf(out, "QPrivateSignal _t%d", offset++);
1451 }
1452
1453 fprintf(out, ")%s\n{\n", constQualifier);
1454 if (def->type.name.size() && def->normalizedType != "void") {
1455 QByteArray returnType = noRef(def->normalizedType);
1456 fprintf(out, " %s _t0{};\n", returnType.constData());
1457 }
1458
1459 fprintf(out, " void *_a[] = { ");
1460 if (def->normalizedType == "void") {
1461 fprintf(out, "nullptr");
1462 } else {
1463 if (def->returnTypeIsVolatile)
1464 fprintf(out, "const_cast<void*>(reinterpret_cast<const volatile void*>(std::addressof(_t0)))");
1465 else
1466 fprintf(out, "const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t0)))");
1467 }
1468 int i;
1469 for (i = 1; i < offset; ++i)
1470 if (i <= def->arguments.size() && def->arguments.at(i - 1).type.isVolatile)
1471 fprintf(out, ", const_cast<void*>(reinterpret_cast<const volatile void*>(std::addressof(_t%d)))", i);
1472 else
1473 fprintf(out, ", const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t%d)))", i);
1474 fprintf(out, " };\n");
1475 fprintf(out, " QMetaObject::activate(%s, &staticMetaObject, %d, _a);\n", thisPtr.constData(), index);
1476 if (def->normalizedType != "void")
1477 fprintf(out, " return _t0;\n");
1478 fprintf(out, "}\n");
1479}
1480
1481static CborError jsonValueToCbor(CborEncoder *parent, const QJsonValue &v);
1482static CborError jsonObjectToCbor(CborEncoder *parent, const QJsonObject &o)
1483{
1484 auto it = o.constBegin();
1485 auto end = o.constEnd();
1486 CborEncoder map;
1487 cbor_encoder_create_map(parent, &map, o.size());
1488
1489 for ( ; it != end; ++it) {
1490 QByteArray key = it.key().toUtf8();
1491 cbor_encode_text_string(&map, key.constData(), key.size());
1492 jsonValueToCbor(&map, it.value());
1493 }
1494 return cbor_encoder_close_container(parent, &map);
1495}
1496
1497static CborError jsonArrayToCbor(CborEncoder *parent, const QJsonArray &a)
1498{
1499 CborEncoder array;
1500 cbor_encoder_create_array(parent, &array, a.size());
1501 for (const QJsonValue v : a)
1503 return cbor_encoder_close_container(parent, &array);
1504}
1505
1506static CborError jsonValueToCbor(CborEncoder *parent, const QJsonValue &v)
1507{
1508 switch (v.type()) {
1509 case QJsonValue::Null:
1511 return cbor_encode_null(parent);
1512 case QJsonValue::Bool:
1513 return cbor_encode_boolean(parent, v.toBool());
1514 case QJsonValue::Array:
1515 return jsonArrayToCbor(parent, v.toArray());
1516 case QJsonValue::Object:
1517 return jsonObjectToCbor(parent, v.toObject());
1518 case QJsonValue::String: {
1519 QByteArray s = v.toString().toUtf8();
1520 return cbor_encode_text_string(parent, s.constData(), s.size());
1521 }
1522 case QJsonValue::Double: {
1523 double d = v.toDouble();
1524 if (d == floor(d) && fabs(d) <= (Q_INT64_C(1) << std::numeric_limits<double>::digits))
1525 return cbor_encode_int(parent, qint64(d));
1526 return cbor_encode_double(parent, d);
1527 }
1528 }
1529 Q_UNREACHABLE_RETURN(CborUnknownError);
1530}
1531
1532void Generator::generatePluginMetaData()
1533{
1534 if (cdef->pluginData.iid.isEmpty())
1535 return;
1536
1537 auto outputCborData = [this]() {
1538 CborDevice dev(out);
1539 CborEncoder enc;
1540 cbor_encoder_init_writer(&enc, CborDevice::callback, &dev);
1541
1542 CborEncoder map;
1543 cbor_encoder_create_map(&enc, &map, CborIndefiniteLength);
1544
1545 dev.nextItem("\"IID\"");
1546 cbor_encode_int(&map, int(QtPluginMetaDataKeys::IID));
1547 cbor_encode_text_string(&map, cdef->pluginData.iid.constData(), cdef->pluginData.iid.size());
1548
1549 dev.nextItem("\"className\"");
1550 cbor_encode_int(&map, int(QtPluginMetaDataKeys::ClassName));
1551 cbor_encode_text_string(&map, cdef->classname.constData(), cdef->classname.size());
1552
1554 if (!o.isEmpty()) {
1555 dev.nextItem("\"MetaData\"");
1556 cbor_encode_int(&map, int(QtPluginMetaDataKeys::MetaData));
1558 }
1559
1560 if (!cdef->pluginData.uri.isEmpty()) {
1561 dev.nextItem("\"URI\"");
1562 cbor_encode_int(&map, int(QtPluginMetaDataKeys::URI));
1563 cbor_encode_text_string(&map, cdef->pluginData.uri.constData(), cdef->pluginData.uri.size());
1564 }
1565
1566 // Add -M args from the command line:
1567 for (auto it = cdef->pluginData.metaArgs.cbegin(), end = cdef->pluginData.metaArgs.cend(); it != end; ++it) {
1568 const QJsonArray &a = it.value();
1569 QByteArray key = it.key().toUtf8();
1570 dev.nextItem(QByteArray("command-line \"" + key + "\"").constData());
1571 cbor_encode_text_string(&map, key.constData(), key.size());
1573 }
1574
1575 // Close the CBOR map manually
1576 dev.nextItem();
1577 cbor_encoder_close_container(&enc, &map);
1578 };
1579
1580 // 'Use' all namespaces.
1581 qsizetype pos = cdef->qualified.indexOf("::");
1582 for ( ; pos != -1 ; pos = cdef->qualified.indexOf("::", pos + 2) )
1583 fprintf(out, "using namespace %s;\n", cdef->qualified.left(pos).constData());
1584
1585 fputs("\n#ifdef QT_MOC_EXPORT_PLUGIN_V2", out);
1586
1587 // Qt 6.3+ output
1588 fprintf(out, "\nstatic constexpr unsigned char qt_pluginMetaDataV2_%s[] = {",
1589 cdef->classname.constData());
1590 outputCborData();
1591 fprintf(out, "\n};\nQT_MOC_EXPORT_PLUGIN_V2(%s, %s, qt_pluginMetaDataV2_%s)\n",
1592 cdef->qualified.constData(), cdef->classname.constData(), cdef->classname.constData());
1593
1594 // compatibility with Qt 6.0-6.2
1595 fprintf(out, "#else\nQT_PLUGIN_METADATA_SECTION\n"
1596 "Q_CONSTINIT static constexpr unsigned char qt_pluginMetaData_%s[] = {\n"
1597 " 'Q', 'T', 'M', 'E', 'T', 'A', 'D', 'A', 'T', 'A', ' ', '!',\n"
1598 " // metadata version, Qt version, architectural requirements\n"
1599 " 0, QT_VERSION_MAJOR, QT_VERSION_MINOR, qPluginArchRequirements(),",
1600 cdef->classname.constData());
1601 outputCborData();
1602 fprintf(out, "\n};\nQT_MOC_EXPORT_PLUGIN(%s, %s)\n"
1603 "#endif // QT_MOC_EXPORT_PLUGIN_V2\n",
1604 cdef->qualified.constData(), cdef->classname.constData());
1605
1606 fputs("\n", out);
1607}
1608
1609QT_WARNING_DISABLE_GCC("-Wunused-function")
1610QT_WARNING_DISABLE_CLANG("-Wunused-function")
1611QT_WARNING_DISABLE_CLANG("-Wundefined-internal")
1612QT_WARNING_DISABLE_MSVC(4334) // '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
1613
1614#define CBOR_ENCODER_WRITER_CONTROL 1
1615#define CBOR_ENCODER_WRITE_FUNCTION CborDevice::callback
1616
1618
1619#include "cborencoder.c"
static CborError callback(void *self, const void *ptr, size_t len, CborEncoderAppendType t)
Definition cbordevice.h:27
Generator(Moc *moc, ClassDef *classDef, const QList< QByteArray > &metaTypes, const QHash< QByteArray, QByteArray > &knownQObjectClasses, const QHash< QByteArray, QByteArray > &knownGadgets, FILE *outfile=nullptr, bool requireCompleteTypes=false)
Definition generator.cpp:60
void generateCode()
Definition moc.h:202
Q_NORETURN void error(const Symbol &symbol)
Definition parser.cpp:58
\inmodule QtCore
Definition qbytearray.h:57
char * data()
\macro QT_NO_CAST_FROM_BYTEARRAY
Definition qbytearray.h:534
bool endsWith(char c) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qbytearray.h:174
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
Definition qbytearray.h:474
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
Definition qbytearray.h:122
qsizetype indexOf(char c, qsizetype from=0) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void chop(qsizetype n)
Removes n bytes from the end of the byte array.
bool startsWith(QByteArrayView bv) const
Definition qbytearray.h:170
char at(qsizetype i) const
Returns the byte at index position i in the byte array.
Definition qbytearray.h:523
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
Definition qbytearray.h:106
QByteArray sliced(qsizetype pos) const
Definition qbytearray.h:163
QByteArray left(qsizetype len) const
Returns a byte array that contains the first len bytes of this byte array.
qsizetype lastIndexOf(char c, qsizetype from=-1) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
QByteArray & append(char c)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QByteArray mid(qsizetype index, qsizetype len=-1) const
Returns a byte array containing len bytes from this byte array, starting at position pos.
QByteArray & replace(qsizetype index, qsizetype len, const char *s, qsizetype alen)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qbytearray.h:275
\inmodule QtCore
Definition qhash.h:818
bool contains(const Key &key) const noexcept
Returns true if the hash contains an item with the key; otherwise returns false.
Definition qhash.h:991
\inmodule QtCore\reentrant
Definition qjsonarray.h:18
QJsonObject object() const
Returns the QJsonObject contained in the document.
\inmodule QtCore\reentrant
Definition qjsonobject.h:20
\inmodule QtCore\reentrant
Definition qjsonvalue.h:24
Definition qlist.h:74
qsizetype size() const noexcept
Definition qlist.h:386
bool isEmpty() const noexcept
Definition qlist.h:390
bool empty() const noexcept
Definition qlist.h:682
const_reference at(qsizetype i) const noexcept
Definition qlist.h:429
const T & constFirst() const noexcept
Definition qlist.h:630
const_iterator cend() const noexcept
Definition qlist.h:614
const_iterator cbegin() const noexcept
Definition qlist.h:613
Definition qmap.h:186
iterator insert(const Key &key, const T &value)
Definition qmap.h:687
T value(const Key &key, const T &defaultValue=T()) const
Definition qmap.h:356
bool contains(const Key &key) const
Definition qmap.h:340
const_iterator cend() const
Definition qmap.h:604
const_iterator cbegin() const
Definition qmap.h:600
bool isEmpty() const
Definition qmap.h:268
const_iterator constBegin() const
Definition qmap.h:599
size_type size() const
Definition qmap.h:266
key_iterator keyBegin() const
Definition qmap.h:605
const_iterator constEnd() const
Definition qmap.h:603
key_iterator keyEnd() const
Definition qmap.h:606
\inmodule QtCore
Definition qhash.h:1748
\inmodule QtCore
Definition qhash.h:1348
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:1833
QMultiHash & unite(const QMultiHash &other)
Definition qhash.h:2093
const_iterator constFind(const Key &key) const noexcept
Definition qhash.h:1921
iterator end()
Definition qmap.h:1300
bool isEmpty() const
Definition qmap.h:913
iterator insert(const Key &key, const T &value)
Definition qmap.h:1425
iterator begin()
Definition qmap.h:1296
iterator begin()
Definition qset.h:136
iterator end()
Definition qset.h:140
const QChar * constData() const
Returns a pointer to the data stored in the QString.
Definition qstring.h:1101
QString str
[2]
QMap< QString, QString > map
[6]
double e
QSet< QString >::iterator it
QList< QVariant > arguments
static QByteArray generateQualifiedClassNameIdentifier(const QByteArray &identifier)
static CborError jsonValueToCbor(CborEncoder *parent, const QJsonValue &v)
static bool qualifiedNameEquals(const QByteArray &qualifiedName, const QByteArray &name)
uint nameToBuiltinType(const QByteArray &name)
Definition generator.cpp:28
static int aggregateParameterCount(const QList< FunctionDef > &list)
#define STREAM_1ARG_TEMPLATE(TEMPLATENAME)
static CborError jsonArrayToCbor(CborEncoder *parent, const QJsonArray &a)
bool isBuiltinType(const QByteArray &type)
Definition generator.cpp:40
static const char * metaTypeEnumValueString(int type)
Definition generator.cpp:48
static void printStringWithIndentation(FILE *out, const QByteArray &s)
#define STREAM_SMART_POINTER(SMART_POINTER)
static qsizetype lengthOfEscapeSequence(const QByteArray &s, qsizetype i)
Definition generator.cpp:76
static CborError jsonObjectToCbor(CborEncoder *parent, const QJsonObject &o)
#define RETURN_METATYPENAME_STRING(MetaTypeName, MetaTypeId, RealType)
QByteArray noRef(const QByteArray &type)
Definition moc.h:289
Combined button and popup list for selecting options.
constexpr bool isOctalDigit(char32_t c) noexcept
Definition qtools_p.h:57
constexpr bool isHexDigit(char32_t c) noexcept
Definition qtools_p.h:37
#define QT_WARNING_DISABLE_MSVC(number)
#define QT_WARNING_DISABLE_GCC(text)
#define Q_FUNC_INFO
#define QT_WARNING_DISABLE_CLANG(text)
static QString moc(const QString &name)
static QString templateArg(const QByteArray &arg)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
@ MetaObjectPrivateFieldCount
@ PropertyAccessInStaticMetaCall
Q_CORE_EXPORT int qMetaTypeTypeInternal(const char *)
@ MethodSignal
@ MethodScriptable
@ AccessPublic
@ MethodSlot
@ MethodCompatibility
@ AccessProtected
@ MethodCloned
@ MethodMethod
@ MethodIsConst
@ AccessPrivate
@ MethodConstructor
@ MethodRevisioned
@ EnumIsScoped
@ EnumIsFlag
@ Readable
@ StdCppSet
@ Bindable
@ Stored
@ Designable
@ Resettable
@ Scriptable
@ Required
@ Constant
@ Final
@ EnumOrFlag
@ Writable
@ User
@ Invalid
@ IsUnresolvedSignal
@ IsUnresolvedType
static int aggregateParameterCount(const std::vector< QMetaMethodBuilderPrivate > &methods)
const char * typeName
#define QT_FOR_EACH_AUTOMATIC_TEMPLATE_SMART_POINTER(F)
Definition qmetatype.h:221
#define QT_FOR_EACH_AUTOMATIC_TEMPLATE_1ARG(F)
Definition qmetatype.h:210
#define QT_FOR_EACH_STATIC_TYPE(F)
Definition qmetatype.h:198
constexpr const T & qMin(const T &a, const T &b)
Definition qminmax.h:40
constexpr const T & qBound(const T &min, const T &val, const T &max)
Definition qminmax.h:44
std::enable_if_t< std::is_unsigned_v< T >, bool > qAddOverflow(T v1, T v2, T *r)
Definition qnumeric.h:113
GLenum GLsizei GLsizei GLint * values
[15]
GLsizei const GLfloat * v
[13]
GLuint64 key
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint index
[2]
GLuint GLuint end
GLsizei const GLchar ** strings
[1]
GLfloat GLfloat f
GLenum type
GLenum access
GLbitfield flags
GLenum GLuint GLintptr offset
GLuint name
const GLubyte * c
GLuint GLfloat * val
GLenum array
GLenum GLsizei len
GLdouble s
[6]
Definition qopenglext.h:235
GLfloat GLfloat p
[1]
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
#define Q_ASSERT_X(cond, x, msg)
Definition qrandom.cpp:48
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)
SSL_CTX int(*) void arg)
#define Q_UNUSED(x)
#define PRIdQSIZETYPE
Definition qtypes.h:77
ptrdiff_t qsizetype
Definition qtypes.h:70
unsigned int uint
Definition qtypes.h:29
long long qint64
Definition qtypes.h:55
#define Q_INT64_C(c)
Definition qtypes.h:52
const char className[16]
[1]
Definition qwizard.cpp:100
QList< int > list
[14]
QByteArray ba
[0]
QTextStream out(stdout)
[7]
QDBusArgument argument
Type type
Definition moc.h:58
QMap< QByteArray, QByteArray > flagAliases
Definition moc.h:154
QByteArray qualified
Definition moc.h:150
QByteArray classname
Definition moc.h:149
QMap< QByteArray, bool > enumDeclarations
Definition moc.h:152
QList< ClassInfoDef > classInfoList
Definition moc.h:151
QList< EnumDef > enumList
Definition moc.h:153
QMap< QString, QJsonArray > metaArgs
Definition moc.h:175
QJsonDocument metaData
Definition moc.h:176
QByteArray uri
Definition moc.h:174
QByteArray iid
Definition moc.h:173
bool hasQObject
Definition moc.h:185
QList< QList< Interface > > interfaceList
Definition moc.h:170
QList< FunctionDef > methodList
Definition moc.h:180
QList< PropertyDef > propertyList
Definition moc.h:182
QList< FunctionDef > constructorList
Definition moc.h:179
bool hasQGadget
Definition moc.h:186
bool requireCompleteMethodTypes
Definition moc.h:188
QList< QPair< QByteArray, FunctionDef::Access > > superclassList
Definition moc.h:160
bool hasQNamespace
Definition moc.h:187
QList< FunctionDef > slotList
Definition moc.h:180
QList< FunctionDef > signalList
Definition moc.h:180
int revisionedMethods
Definition moc.h:183
struct ClassDef::PluginData pluginData
QList< QByteArray > nonClassSignalList
Definition moc.h:181
Definition moc.h:43
bool wasCloned
Definition moc.h:84
QByteArray normalizedType
Definition moc.h:71
Type type
Definition moc.h:69
QByteArray name
Definition moc.h:73
bool isConst
Definition moc.h:80
QList< ArgumentDef > arguments
Definition moc.h:70
bool returnTypeIsVolatile
Definition moc.h:86
bool isAbstract
Definition moc.h:96
bool isPrivateSignal
Definition moc.h:93
@ Public
Definition moc.h:76
@ Protected
Definition moc.h:76
@ Private
Definition moc.h:76
@ ReferenceSpec
Definition moc.h:117
@ PointerSpec
Definition moc.h:117
QByteArray type
Definition moc.h:115
bool contains(const AT &t) const noexcept
Definition qlist.h:44
uint isVolatile
Definition moc.h:34
QByteArray name
Definition moc.h:30
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent