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
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().classname;
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.
136static int aggregateParameterCount(const QList<FunctionDef> &list)
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 if (it->access == FunctionDef::Private)
597 continue;
598 const char *cname = it->classname.constData();
599 fprintf(out, " if (!strcmp(_clname, \"%s\"))\n return static_cast< %s*>(this);\n",
600 cname, cname);
601 }
602 }
603
604 for (const QList<ClassDef::Interface> &iface : std::as_const(cdef->interfaceList)) {
605 for (qsizetype j = 0; j < iface.size(); ++j) {
606 fprintf(out, " if (!strcmp(_clname, %s))\n return ", iface.at(j).interfaceId.constData());
607 for (qsizetype k = j; k >= 0; --k)
608 fprintf(out, "static_cast< %s*>(", iface.at(k).className.constData());
609 fprintf(out, "this%s;\n", QByteArray(j + 1, ')').constData());
610 }
611 }
612 if (!purestSuperClass.isEmpty() && !isQObject) {
613 QByteArray superClass = purestSuperClass;
614 fprintf(out, " return %s::qt_metacast(_clname);\n", superClass.constData());
615 } else {
616 fprintf(out, " return nullptr;\n");
617 }
618 fprintf(out, "}\n");
619
620//
621// Generate internal qt_metacall() function
622//
623 generateMetacall();
624
625//
626// Generate internal signal functions
627//
628 for (int signalindex = 0; signalindex < int(cdef->signalList.size()); ++signalindex)
629 generateSignal(&cdef->signalList.at(signalindex), signalindex);
630
631//
632// Generate plugin meta data
633//
634 generatePluginMetaData();
635
636//
637// Generate function to make sure the non-class signals exist in the parent classes
638//
639 if (!cdef->nonClassSignalList.isEmpty()) {
640 fprintf(out, "namespace CheckNotifySignalValidity_%s {\n", qualifiedClassNameIdentifier.constData());
641 for (const QByteArray &nonClassSignal : std::as_const(cdef->nonClassSignalList)) {
642 const auto propertyIt = std::find_if(cdef->propertyList.constBegin(),
643 cdef->propertyList.constEnd(),
644 [&nonClassSignal](const PropertyDef &p) {
645 return nonClassSignal == p.notify;
646 });
647 // must find something, otherwise checkProperties wouldn't have inserted an entry into nonClassSignalList
648 Q_ASSERT(propertyIt != cdef->propertyList.constEnd());
649 fprintf(out, "template<typename T> using has_nullary_%s = decltype(std::declval<T>().%s());\n",
650 nonClassSignal.constData(),
651 nonClassSignal.constData());
652 const auto &propertyType = propertyIt->type;
653 fprintf(out, "template<typename T> using has_unary_%s = decltype(std::declval<T>().%s(std::declval<%s>()));\n",
654 nonClassSignal.constData(),
655 nonClassSignal.constData(),
656 propertyType.constData());
657 fprintf(out, "static_assert(qxp::is_detected_v<has_nullary_%s, %s> || qxp::is_detected_v<has_unary_%s, %s>,\n"
658 " \"NOTIFY signal %s does not exist in class (or is private in its parent)\");\n",
659 nonClassSignal.constData(), cdef->qualified.constData(),
660 nonClassSignal.constData(), cdef->qualified.constData(),
661 nonClassSignal.constData());
662 }
663 fprintf(out, "}\n");
664 }
665}
666
667
668void Generator::registerClassInfoStrings()
669{
670 for (const ClassInfoDef &c : std::as_const(cdef->classInfoList)) {
671 strreg(c.name);
672 strreg(c.value);
673 }
674}
675
676void Generator::generateClassInfos()
677{
678 if (cdef->classInfoList.isEmpty())
679 return;
680
681 fprintf(out, "\n // classinfo: key, value\n");
682
683 for (const ClassInfoDef &c : std::as_const(cdef->classInfoList))
684 fprintf(out, " %4d, %4d,\n", stridx(c.name), stridx(c.value));
685}
686
687void Generator::registerFunctionStrings(const QList<FunctionDef> &list)
688{
689 for (const FunctionDef &f : list) {
690 strreg(f.name);
691 if (!isBuiltinType(f.normalizedType))
692 strreg(f.normalizedType);
693 strreg(f.tag);
694
695 for (const ArgumentDef &a : f.arguments) {
696 if (!isBuiltinType(a.normalizedType))
697 strreg(a.normalizedType);
698 strreg(a.name);
699 }
700 }
701}
702
703void Generator::registerByteArrayVector(const QList<QByteArray> &list)
704{
705 for (const QByteArray &ba : list)
706 strreg(ba);
707}
708
709void Generator::generateFunctions(const QList<FunctionDef> &list, const char *functype, int type,
710 int &paramsIndex, int &initialMetatypeOffset)
711{
712 if (list.isEmpty())
713 return;
714 fprintf(out, "\n // %ss: name, argc, parameters, tag, flags, initial metatype offsets\n", functype);
715
716 for (const FunctionDef &f : list) {
717 QByteArray comment;
718 uint flags = type;
719 if (f.access == FunctionDef::Private) {
721 comment.append("Private");
722 } else if (f.access == FunctionDef::Public) {
724 comment.append("Public");
725 } else if (f.access == FunctionDef::Protected) {
727 comment.append("Protected");
728 }
729 if (f.isCompat) {
731 comment.append(" | MethodCompatibility");
732 }
733 if (f.wasCloned) {
735 comment.append(" | MethodCloned");
736 }
737 if (f.isScriptable) {
739 comment.append(" | isScriptable");
740 }
741 if (f.revision > 0) {
743 comment.append(" | MethodRevisioned");
744 }
745
746 if (f.isConst) {
748 comment.append(" | MethodIsConst ");
749 }
750
751 const int argc = int(f.arguments.size());
752 fprintf(out, " %4d, %4d, %4d, %4d, 0x%02x, %4d /* %s */,\n",
753 stridx(f.name), argc, paramsIndex, stridx(f.tag), flags, initialMetatypeOffset, comment.constData());
754
755 paramsIndex += 1 + argc * 2;
756 // constructors don't have a return type
757 initialMetatypeOffset += (f.isConstructor ? 0 : 1) + argc;
758 }
759}
760
761void Generator::generateFunctionRevisions(const QList<FunctionDef> &list, const char *functype)
762{
763 if (list.size())
764 fprintf(out, "\n // %ss: revision\n", functype);
765 for (const FunctionDef &f : list)
766 fprintf(out, " %4d,\n", f.revision);
767}
768
769void Generator::generateFunctionParameters(const QList<FunctionDef> &list, const char *functype)
770{
771 if (list.isEmpty())
772 return;
773 fprintf(out, "\n // %ss: parameters\n", functype);
774 for (const FunctionDef &f : list) {
775 fprintf(out, " ");
776
777 // Types
778 const bool allowEmptyName = f.isConstructor;
779 generateTypeInfo(f.normalizedType, allowEmptyName);
780 fputc(',', out);
781 for (const ArgumentDef &arg : f.arguments) {
782 fputc(' ', out);
783 generateTypeInfo(arg.normalizedType, allowEmptyName);
784 fputc(',', out);
785 }
786
787 // Parameter names
788 for (const ArgumentDef &arg : f.arguments)
789 fprintf(out, " %4d,", stridx(arg.name));
790
791 fprintf(out, "\n");
792 }
793}
794
795void Generator::generateTypeInfo(const QByteArray &typeName, bool allowEmptyName)
796{
797 Q_UNUSED(allowEmptyName);
798 if (isBuiltinType(typeName)) {
799 int type;
800 const char *valueString;
801 if (typeName == "qreal") {
803 valueString = "QReal";
804 } else {
806 valueString = metaTypeEnumValueString(type);
807 }
808 if (valueString) {
809 fprintf(out, "QMetaType::%s", valueString);
810 } else {
812 fprintf(out, "%4d", type);
813 }
814 } else {
815 Q_ASSERT(!typeName.isEmpty() || allowEmptyName);
816 fprintf(out, "0x%.8x | %d", IsUnresolvedType, stridx(typeName));
817 }
818}
819
820void Generator::registerPropertyStrings()
821{
822 for (const PropertyDef &p : std::as_const(cdef->propertyList)) {
823 strreg(p.name);
824 if (!isBuiltinType(p.type))
825 strreg(p.type);
826 }
827}
828
829void Generator::generateProperties()
830{
831 //
832 // Create meta data
833 //
834
835 if (cdef->propertyList.size())
836 fprintf(out, "\n // properties: name, type, flags, notifyId, revision\n");
837 for (const PropertyDef &p : std::as_const(cdef->propertyList)) {
839 if (!isBuiltinType(p.type))
840 flags |= EnumOrFlag;
841 if (!p.member.isEmpty() && !p.constant)
842 flags |= Writable;
843 if (!p.read.isEmpty() || !p.member.isEmpty())
844 flags |= Readable;
845 if (!p.write.isEmpty()) {
846 flags |= Writable;
847 if (p.stdCppSet())
848 flags |= StdCppSet;
849 }
850
851 if (!p.reset.isEmpty())
852 flags |= Resettable;
853
854 if (p.designable != "false")
855 flags |= Designable;
856
857 if (p.scriptable != "false")
858 flags |= Scriptable;
859
860 if (p.stored != "false")
861 flags |= Stored;
862
863 if (p.user != "false")
864 flags |= User;
865
866 if (p.constant)
867 flags |= Constant;
868 if (p.final)
869 flags |= Final;
870 if (p.required)
871 flags |= Required;
872
873 if (!p.bind.isEmpty())
874 flags |= Bindable;
875
876 fprintf(out, " %4d, ", stridx(p.name));
877 generateTypeInfo(p.type);
878 int notifyId = p.notifyId;
879 if (p.notifyId < -1) {
880 // signal is in parent class
881 const int indexInStrings = int(strings.indexOf(p.notify));
882 notifyId = indexInStrings | IsUnresolvedSignal;
883 }
884 fprintf(out, ", 0x%.8x, uint(%d), %d,\n", flags, notifyId, p.revision);
885 }
886}
887
888void Generator::registerEnumStrings()
889{
890 for (const EnumDef &e : std::as_const(cdef->enumList)) {
891 strreg(e.name);
892 if (!e.enumName.isNull())
893 strreg(e.enumName);
894 for (const QByteArray &val : e.values)
895 strreg(val);
896 }
897}
898
899void Generator::generateEnums(int index)
900{
901 if (cdef->enumDeclarations.isEmpty())
902 return;
903
904 fprintf(out, "\n // enums: name, alias, flags, count, data\n");
906 int i;
907 for (i = 0; i < cdef->enumList.size(); ++i) {
908 const EnumDef &e = cdef->enumList.at(i);
909 int flags = 0;
910 if (cdef->enumDeclarations.value(e.name))
911 flags |= EnumIsFlag;
912 if (e.isEnumClass)
914 fprintf(out, " %4d, %4d, 0x%.1x, %4d, %4d,\n",
915 stridx(e.name),
916 e.enumName.isNull() ? stridx(e.name) : stridx(e.enumName),
917 flags,
918 int(e.values.size()),
919 index);
920 index += e.values.size() * 2;
921 }
922
923 fprintf(out, "\n // enum data: key, value\n");
924 for (const EnumDef &e : std::as_const(cdef->enumList)) {
925 for (const QByteArray &val : e.values) {
927 if (e.isEnumClass)
928 code += "::" + (e.enumName.isNull() ? e.name : e.enumName);
929 code += "::" + val;
930 fprintf(out, " %4d, uint(%s),\n",
931 stridx(val), code.constData());
932 }
933 }
934}
935
936void Generator::generateMetacall()
937{
938 bool isQObject = (cdef->classname == "QObject");
939
940 fprintf(out, "\nint %s::qt_metacall(QMetaObject::Call _c, int _id, void **_a)\n{\n",
941 cdef->qualified.constData());
942
943 if (!purestSuperClass.isEmpty() && !isQObject) {
944 QByteArray superClass = purestSuperClass;
945 fprintf(out, " _id = %s::qt_metacall(_c, _id, _a);\n", superClass.constData());
946 }
947
948
949 bool needElse = false;
950 QList<FunctionDef> methodList;
951 methodList += cdef->signalList;
952 methodList += cdef->slotList;
953 methodList += cdef->methodList;
954
955 // If there are no methods or properties, we will return _id anyway, so
956 // don't emit this comparison -- it is unnecessary, and it makes coverity
957 // unhappy.
958 if (methodList.size() || cdef->propertyList.size()) {
959 fprintf(out, " if (_id < 0)\n return _id;\n");
960 }
961
962 fprintf(out, " ");
963
964 if (methodList.size()) {
965 needElse = true;
966 fprintf(out, "if (_c == QMetaObject::InvokeMetaMethod) {\n");
967 fprintf(out, " if (_id < %d)\n", int(methodList.size()));
968 fprintf(out, " qt_static_metacall(this, _c, _id, _a);\n");
969 fprintf(out, " _id -= %d;\n }", int(methodList.size()));
970
971 fprintf(out, " else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {\n");
972 fprintf(out, " if (_id < %d)\n", int(methodList.size()));
973
974 if (methodsWithAutomaticTypesHelper(methodList).isEmpty())
975 fprintf(out, " *reinterpret_cast<QMetaType *>(_a[0]) = QMetaType();\n");
976 else
977 fprintf(out, " qt_static_metacall(this, _c, _id, _a);\n");
978 fprintf(out, " _id -= %d;\n }", int(methodList.size()));
979
980 }
981
982 if (cdef->propertyList.size()) {
983 if (needElse)
984 fprintf(out, "else ");
985 fprintf(out,
986 "if (_c == QMetaObject::ReadProperty || _c == QMetaObject::WriteProperty\n"
987 " || _c == QMetaObject::ResetProperty || _c == QMetaObject::BindableProperty\n"
988 " || _c == QMetaObject::RegisterPropertyMetaType) {\n"
989 " qt_static_metacall(this, _c, _id, _a);\n"
990 " _id -= %d;\n }", int(cdef->propertyList.size()));
991 }
992 if (methodList.size() || cdef->propertyList.size())
993 fprintf(out, "\n ");
994 fprintf(out,"return _id;\n}\n");
995}
996
997
998// ### Qt 7 (6.x?): remove
999QMultiMap<QByteArray, int> Generator::automaticPropertyMetaTypesHelper()
1000{
1001 QMultiMap<QByteArray, int> automaticPropertyMetaTypes;
1002 for (int i = 0; i < int(cdef->propertyList.size()); ++i) {
1003 const QByteArray propertyType = cdef->propertyList.at(i).type;
1004 if (registerableMetaType(propertyType) && !isBuiltinType(propertyType))
1005 automaticPropertyMetaTypes.insert(propertyType, i);
1006 }
1007 return automaticPropertyMetaTypes;
1008}
1009
1010QMap<int, QMultiMap<QByteArray, int>>
1011Generator::methodsWithAutomaticTypesHelper(const QList<FunctionDef> &methodList)
1012{
1013 QMap<int, QMultiMap<QByteArray, int> > methodsWithAutomaticTypes;
1014 for (int i = 0; i < methodList.size(); ++i) {
1015 const FunctionDef &f = methodList.at(i);
1016 for (int j = 0; j < f.arguments.size(); ++j) {
1017 const QByteArray argType = f.arguments.at(j).normalizedType;
1018 if (registerableMetaType(argType) && !isBuiltinType(argType))
1019 methodsWithAutomaticTypes[i].insert(argType, j);
1020 }
1021 }
1022 return methodsWithAutomaticTypes;
1023}
1024
1025void Generator::generateStaticMetacall()
1026{
1027 fprintf(out, "void %s::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)\n{\n",
1028 cdef->qualified.constData());
1029
1030 bool needElse = false;
1031 bool isUsed_a = false;
1032
1033 const auto generateCtorArguments = [&](int ctorindex) {
1034 const FunctionDef &f = cdef->constructorList.at(ctorindex);
1035 Q_ASSERT(!f.isPrivateSignal); // That would be a strange ctor indeed
1036 int offset = 1;
1037
1038 const auto begin = f.arguments.cbegin();
1039 const auto end = f.arguments.cend();
1040 for (auto it = begin; it != end; ++it) {
1041 const ArgumentDef &a = *it;
1042 if (it != begin)
1043 fprintf(out, ",");
1044 fprintf(out, "(*reinterpret_cast<%s>(_a[%d]))",
1045 a.typeNameForCast.constData(), offset++);
1046 }
1047 };
1048
1049 if (!cdef->constructorList.isEmpty()) {
1050 fprintf(out, " if (_c == QMetaObject::CreateInstance) {\n");
1051 fprintf(out, " switch (_id) {\n");
1052 const int ctorend = int(cdef->constructorList.size());
1053 for (int ctorindex = 0; ctorindex < ctorend; ++ctorindex) {
1054 fprintf(out, " case %d: { %s *_r = new %s(", ctorindex,
1055 cdef->classname.constData(), cdef->classname.constData());
1056 generateCtorArguments(ctorindex);
1057 fprintf(out, ");\n");
1058 fprintf(out, " if (_a[0]) *reinterpret_cast<%s**>(_a[0]) = _r; } break;\n",
1059 (cdef->hasQGadget || cdef->hasQNamespace) ? "void" : "QObject");
1060 }
1061 fprintf(out, " default: break;\n");
1062 fprintf(out, " }\n");
1063 fprintf(out, " } else if (_c == QMetaObject::ConstructInPlace) {\n");
1064 fprintf(out, " switch (_id) {\n");
1065 for (int ctorindex = 0; ctorindex < ctorend; ++ctorindex) {
1066 fprintf(out, " case %d: { new (_a[0]) %s(",
1067 ctorindex, cdef->classname.constData());
1068 generateCtorArguments(ctorindex);
1069 fprintf(out, "); } break;\n");
1070 }
1071 fprintf(out, " default: break;\n");
1072 fprintf(out, " }\n");
1073 fprintf(out, " }");
1074 needElse = true;
1075 isUsed_a = true;
1076 }
1077
1078 QList<FunctionDef> methodList;
1079 methodList += cdef->signalList;
1080 methodList += cdef->slotList;
1081 methodList += cdef->methodList;
1082
1083 if (!methodList.isEmpty()) {
1084 if (needElse)
1085 fprintf(out, " else ");
1086 else
1087 fprintf(out, " ");
1088 fprintf(out, "if (_c == QMetaObject::InvokeMetaMethod) {\n");
1089 if (cdef->hasQObject) {
1090#ifndef QT_NO_DEBUG
1091 fprintf(out, " Q_ASSERT(staticMetaObject.cast(_o));\n");
1092#endif
1093 fprintf(out, " auto *_t = static_cast<%s *>(_o);\n", cdef->classname.constData());
1094 } else {
1095 fprintf(out, " auto *_t = reinterpret_cast<%s *>(_o);\n", cdef->classname.constData());
1096 }
1097 fprintf(out, " (void)_t;\n");
1098 fprintf(out, " switch (_id) {\n");
1099 for (int methodindex = 0; methodindex < methodList.size(); ++methodindex) {
1100 const FunctionDef &f = methodList.at(methodindex);
1101 Q_ASSERT(!f.normalizedType.isEmpty());
1102 fprintf(out, " case %d: ", methodindex);
1103 if (f.normalizedType != "void")
1104 fprintf(out, "{ %s _r = ", noRef(f.normalizedType).constData());
1105 fprintf(out, "_t->");
1106 if (f.inPrivateClass.size())
1107 fprintf(out, "%s->", f.inPrivateClass.constData());
1108 fprintf(out, "%s(", f.name.constData());
1109 int offset = 1;
1110
1111 if (f.isRawSlot) {
1112 fprintf(out, "QMethodRawArguments{ _a }");
1113 } else {
1114 const auto begin = f.arguments.cbegin();
1115 const auto end = f.arguments.cend();
1116 for (auto it = begin; it != end; ++it) {
1117 const ArgumentDef &a = *it;
1118 if (it != begin)
1119 fprintf(out, ",");
1120 fprintf(out, "(*reinterpret_cast< %s>(_a[%d]))",a.typeNameForCast.constData(), offset++);
1121 isUsed_a = true;
1122 }
1123 if (f.isPrivateSignal) {
1124 if (!f.arguments.isEmpty())
1125 fprintf(out, ", ");
1126 fprintf(out, "%s", "QPrivateSignal()");
1127 }
1128 }
1129 fprintf(out, ");");
1130 if (f.normalizedType != "void") {
1131 fprintf(out, "\n if (_a[0]) *reinterpret_cast< %s*>(_a[0]) = std::move(_r); } ",
1132 noRef(f.normalizedType).constData());
1133 isUsed_a = true;
1134 }
1135 fprintf(out, " break;\n");
1136 }
1137 fprintf(out, " default: ;\n");
1138 fprintf(out, " }\n");
1139 fprintf(out, " }");
1140 needElse = true;
1141
1142 QMap<int, QMultiMap<QByteArray, int> > methodsWithAutomaticTypes = methodsWithAutomaticTypesHelper(methodList);
1143
1144 if (!methodsWithAutomaticTypes.isEmpty()) {
1145 fprintf(out, " else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {\n");
1146 fprintf(out, " switch (_id) {\n");
1147 fprintf(out, " default: *reinterpret_cast<QMetaType *>(_a[0]) = QMetaType(); break;\n");
1148 QMap<int, QMultiMap<QByteArray, int> >::const_iterator it = methodsWithAutomaticTypes.constBegin();
1149 const QMap<int, QMultiMap<QByteArray, int> >::const_iterator end = methodsWithAutomaticTypes.constEnd();
1150 for ( ; it != end; ++it) {
1151 fprintf(out, " case %d:\n", it.key());
1152 fprintf(out, " switch (*reinterpret_cast<int*>(_a[1])) {\n");
1153 fprintf(out, " default: *reinterpret_cast<QMetaType *>(_a[0]) = QMetaType(); break;\n");
1154 auto jt = it->begin();
1155 const auto jend = it->end();
1156 while (jt != jend) {
1157 fprintf(out, " case %d:\n", jt.value());
1158 const QByteArray &lastKey = jt.key();
1159 ++jt;
1160 if (jt == jend || jt.key() != lastKey)
1161 fprintf(out, " *reinterpret_cast<QMetaType *>(_a[0]) = QMetaType::fromType< %s >(); break;\n", lastKey.constData());
1162 }
1163 fprintf(out, " }\n");
1164 fprintf(out, " break;\n");
1165 }
1166 fprintf(out, " }\n");
1167 fprintf(out, " }");
1168 isUsed_a = true;
1169 }
1170
1171 }
1172 if (!cdef->signalList.isEmpty()) {
1173 Q_ASSERT(needElse); // if there is signal, there was method.
1174 fprintf(out, " else if (_c == QMetaObject::IndexOfMethod) {\n");
1175 fprintf(out, " int *result = reinterpret_cast<int *>(_a[0]);\n");
1176 bool anythingUsed = false;
1177 for (int methodindex = 0; methodindex < int(cdef->signalList.size()); ++methodindex) {
1178 const FunctionDef &f = cdef->signalList.at(methodindex);
1179 if (f.wasCloned || !f.inPrivateClass.isEmpty() || f.isStatic)
1180 continue;
1181 anythingUsed = true;
1182 fprintf(out, " {\n");
1183 fprintf(out, " using _t = %s (%s::*)(",f.type.rawName.constData() , cdef->classname.constData());
1184
1185 const auto begin = f.arguments.cbegin();
1186 const auto end = f.arguments.cend();
1187 for (auto it = begin; it != end; ++it) {
1188 const ArgumentDef &a = *it;
1189 if (it != begin)
1190 fprintf(out, ", ");
1191 fprintf(out, "%s", QByteArray(a.type.name + ' ' + a.rightType).constData());
1192 }
1193 if (f.isPrivateSignal) {
1194 if (!f.arguments.isEmpty())
1195 fprintf(out, ", ");
1196 fprintf(out, "%s", "QPrivateSignal");
1197 }
1198 if (f.isConst)
1199 fprintf(out, ") const;\n");
1200 else
1201 fprintf(out, ");\n");
1202 fprintf(out, " if (_t _q_method = &%s::%s; *reinterpret_cast<_t *>(_a[1]) == _q_method) {\n",
1203 cdef->classname.constData(), f.name.constData());
1204 fprintf(out, " *result = %d;\n", methodindex);
1205 fprintf(out, " return;\n");
1206 fprintf(out, " }\n }\n");
1207 }
1208 if (!anythingUsed)
1209 fprintf(out, " (void)result;\n");
1210 fprintf(out, " }");
1211 needElse = true;
1212 }
1213
1214 const QMultiMap<QByteArray, int> automaticPropertyMetaTypes = automaticPropertyMetaTypesHelper();
1215
1216 if (!automaticPropertyMetaTypes.isEmpty()) {
1217 if (needElse)
1218 fprintf(out, " else ");
1219 else
1220 fprintf(out, " ");
1221 fprintf(out, "if (_c == QMetaObject::RegisterPropertyMetaType) {\n");
1222 fprintf(out, " switch (_id) {\n");
1223 fprintf(out, " default: *reinterpret_cast<int*>(_a[0]) = -1; break;\n");
1224 auto it = automaticPropertyMetaTypes.begin();
1225 const auto end = automaticPropertyMetaTypes.end();
1226 while (it != end) {
1227 fprintf(out, " case %d:\n", it.value());
1228 const QByteArray &lastKey = it.key();
1229 ++it;
1230 if (it == end || it.key() != lastKey)
1231 fprintf(out, " *reinterpret_cast<int*>(_a[0]) = qRegisterMetaType< %s >(); break;\n", lastKey.constData());
1232 }
1233 fprintf(out, " }\n");
1234 fprintf(out, " } ");
1235 isUsed_a = true;
1236 needElse = true;
1237 }
1238
1239 if (!cdef->propertyList.empty()) {
1240 bool needGet = false;
1241 bool needTempVarForGet = false;
1242 bool needSet = false;
1243 bool needReset = false;
1244 bool hasBindableProperties = false;
1245 for (const PropertyDef &p : std::as_const(cdef->propertyList)) {
1246 needGet |= !p.read.isEmpty() || !p.member.isEmpty();
1247 if (!p.read.isEmpty() || !p.member.isEmpty())
1248 needTempVarForGet |= (p.gspec != PropertyDef::PointerSpec
1249 && p.gspec != PropertyDef::ReferenceSpec);
1250
1251 needSet |= !p.write.isEmpty() || (!p.member.isEmpty() && !p.constant);
1252 needReset |= !p.reset.isEmpty();
1253 hasBindableProperties |= !p.bind.isEmpty();
1254 }
1255 if (needElse)
1256 fprintf(out, " else ");
1257 fprintf(out, "if (_c == QMetaObject::ReadProperty) {\n");
1258
1259 auto setupMemberAccess = [this]() {
1260 if (cdef->hasQObject) {
1261#ifndef QT_NO_DEBUG
1262 fprintf(out, " Q_ASSERT(staticMetaObject.cast(_o));\n");
1263#endif
1264 fprintf(out, " auto *_t = static_cast<%s *>(_o);\n", cdef->classname.constData());
1265 } else {
1266 fprintf(out, " auto *_t = reinterpret_cast<%s *>(_o);\n", cdef->classname.constData());
1267 }
1268 fprintf(out, " (void)_t;\n");
1269 };
1270
1271 if (needGet) {
1272 setupMemberAccess();
1273 if (needTempVarForGet)
1274 fprintf(out, " void *_v = _a[0];\n");
1275 fprintf(out, " switch (_id) {\n");
1276 for (int propindex = 0; propindex < int(cdef->propertyList.size()); ++propindex) {
1277 const PropertyDef &p = cdef->propertyList.at(propindex);
1278 if (p.read.isEmpty() && p.member.isEmpty())
1279 continue;
1280 QByteArray prefix = "_t->";
1281 if (p.inPrivateClass.size()) {
1282 prefix += p.inPrivateClass + "->";
1283 }
1284
1285 if (p.gspec == PropertyDef::PointerSpec)
1286 fprintf(out, " case %d: _a[0] = const_cast<void*>(reinterpret_cast<const void*>(%s%s())); break;\n",
1287 propindex, prefix.constData(), p.read.constData());
1288 else if (p.gspec == PropertyDef::ReferenceSpec)
1289 fprintf(out, " case %d: _a[0] = const_cast<void*>(reinterpret_cast<const void*>(&%s%s())); break;\n",
1290 propindex, prefix.constData(), p.read.constData());
1291 else if (cdef->enumDeclarations.value(p.type, false))
1292 fprintf(out, " case %d: *reinterpret_cast<int*>(_v) = QFlag(%s%s()); break;\n",
1293 propindex, prefix.constData(), p.read.constData());
1294 else if (p.read == "default")
1295 fprintf(out, " case %d: *reinterpret_cast< %s*>(_v) = %s%s().value(); break;\n",
1296 propindex, p.type.constData(), prefix.constData(), p.bind.constData());
1297 else if (!p.read.isEmpty())
1298 fprintf(out, " case %d: *reinterpret_cast< %s*>(_v) = %s%s(); break;\n",
1299 propindex, p.type.constData(), prefix.constData(), p.read.constData());
1300 else
1301 fprintf(out, " case %d: *reinterpret_cast< %s*>(_v) = %s%s; break;\n",
1302 propindex, p.type.constData(), prefix.constData(), p.member.constData());
1303 }
1304 fprintf(out, " default: break;\n");
1305 fprintf(out, " }\n");
1306 }
1307
1308 fprintf(out, " }");
1309
1310 fprintf(out, " else ");
1311 fprintf(out, "if (_c == QMetaObject::WriteProperty) {\n");
1312
1313 if (needSet) {
1314 setupMemberAccess();
1315 fprintf(out, " void *_v = _a[0];\n");
1316 fprintf(out, " switch (_id) {\n");
1317 for (int propindex = 0; propindex < int(cdef->propertyList.size()); ++propindex) {
1318 const PropertyDef &p = cdef->propertyList.at(propindex);
1319 if (p.constant)
1320 continue;
1321 if (p.write.isEmpty() && p.member.isEmpty())
1322 continue;
1323 QByteArray prefix = "_t->";
1324 if (p.inPrivateClass.size()) {
1325 prefix += p.inPrivateClass + "->";
1326 }
1327 if (cdef->enumDeclarations.value(p.type, false)) {
1328 fprintf(out, " case %d: %s%s(QFlag(*reinterpret_cast<int*>(_v))); break;\n",
1329 propindex, prefix.constData(), p.write.constData());
1330 } else if (p.write == "default") {
1331 fprintf(out, " case %d: {\n", propindex);
1332 fprintf(out, " %s%s().setValue(*reinterpret_cast< %s*>(_v));\n",
1333 prefix.constData(), p.bind.constData(), p.type.constData());
1334 fprintf(out, " break;\n");
1335 fprintf(out, " }\n");
1336 } else if (!p.write.isEmpty()) {
1337 fprintf(out, " case %d: %s%s(*reinterpret_cast< %s*>(_v)); break;\n",
1338 propindex, prefix.constData(), p.write.constData(), p.type.constData());
1339 } else {
1340 fprintf(out, " case %d:\n", propindex);
1341 fprintf(out, " if (%s%s != *reinterpret_cast< %s*>(_v)) {\n",
1342 prefix.constData(), p.member.constData(), p.type.constData());
1343 fprintf(out, " %s%s = *reinterpret_cast< %s*>(_v);\n",
1344 prefix.constData(), p.member.constData(), p.type.constData());
1345 if (!p.notify.isEmpty() && p.notifyId > -1) {
1346 const FunctionDef &f = cdef->signalList.at(p.notifyId);
1347 if (f.arguments.size() == 0)
1348 fprintf(out, " Q_EMIT _t->%s();\n", p.notify.constData());
1349 else if (f.arguments.size() == 1 && f.arguments.at(0).normalizedType == p.type)
1350 fprintf(out, " Q_EMIT _t->%s(%s%s);\n",
1351 p.notify.constData(), prefix.constData(), p.member.constData());
1352 } else if (!p.notify.isEmpty() && p.notifyId < -1) {
1353 fprintf(out, " Q_EMIT _t->%s();\n", p.notify.constData());
1354 }
1355 fprintf(out, " }\n");
1356 fprintf(out, " break;\n");
1357 }
1358 }
1359 fprintf(out, " default: break;\n");
1360 fprintf(out, " }\n");
1361 }
1362
1363 fprintf(out, " }");
1364
1365 fprintf(out, " else ");
1366 fprintf(out, "if (_c == QMetaObject::ResetProperty) {\n");
1367 if (needReset) {
1368 setupMemberAccess();
1369 fprintf(out, " switch (_id) {\n");
1370 for (int propindex = 0; propindex < int(cdef->propertyList.size()); ++propindex) {
1371 const PropertyDef &p = cdef->propertyList.at(propindex);
1372 if (p.reset.isEmpty())
1373 continue;
1374 QByteArray prefix = "_t->";
1375 if (p.inPrivateClass.size()) {
1376 prefix += p.inPrivateClass + "->";
1377 }
1378 fprintf(out, " case %d: %s%s(); break;\n",
1379 propindex, prefix.constData(), p.reset.constData());
1380 }
1381 fprintf(out, " default: break;\n");
1382 fprintf(out, " }\n");
1383 }
1384 fprintf(out, " }");
1385
1386 fprintf(out, " else ");
1387 fprintf(out, "if (_c == QMetaObject::BindableProperty) {\n");
1388 if (hasBindableProperties) {
1389 setupMemberAccess();
1390 fprintf(out, " switch (_id) {\n");
1391 for (int propindex = 0; propindex < int(cdef->propertyList.size()); ++propindex) {
1392 const PropertyDef &p = cdef->propertyList.at(propindex);
1393 if (p.bind.isEmpty())
1394 continue;
1395 QByteArray prefix = "_t->";
1396 if (p.inPrivateClass.size()) {
1397 prefix += p.inPrivateClass + "->";
1398 }
1399 fprintf(out,
1400 " case %d: *static_cast<QUntypedBindable *>(_a[0]) = %s%s(); "
1401 "break;\n",
1402 propindex, prefix.constData(), p.bind.constData());
1403 }
1404 fprintf(out, " default: break;\n");
1405 fprintf(out, " }\n");
1406 }
1407 fprintf(out, " }");
1408 needElse = true;
1409 }
1410
1411 if (needElse)
1412 fprintf(out, "\n");
1413
1414 if (methodList.isEmpty()) {
1415 fprintf(out, " (void)_o;\n");
1416 if (cdef->constructorList.isEmpty() && automaticPropertyMetaTypes.isEmpty() && methodsWithAutomaticTypesHelper(methodList).isEmpty()) {
1417 fprintf(out, " (void)_id;\n");
1418 fprintf(out, " (void)_c;\n");
1419 }
1420 }
1421 if (!isUsed_a)
1422 fprintf(out, " (void)_a;\n");
1423
1424 fprintf(out, "}\n");
1425}
1426
1427void Generator::generateSignal(const FunctionDef *def, int index)
1428{
1429 if (def->wasCloned || def->isAbstract)
1430 return;
1431 fprintf(out, "\n// SIGNAL %d\n%s %s::%s(",
1432 index, def->type.name.constData(), cdef->qualified.constData(), def->name.constData());
1433
1434 QByteArray thisPtr = "this";
1435 const char *constQualifier = "";
1436
1437 if (def->isConst) {
1438 thisPtr = "const_cast< " + cdef->qualified + " *>(this)";
1439 constQualifier = "const";
1440 }
1441
1443 if (def->arguments.isEmpty() && def->normalizedType == "void" && !def->isPrivateSignal) {
1444 fprintf(out, ")%s\n{\n"
1445 " QMetaObject::activate(%s, &staticMetaObject, %d, nullptr);\n"
1446 "}\n", constQualifier, thisPtr.constData(), index);
1447 return;
1448 }
1449
1450 int offset = 1;
1451 const auto begin = def->arguments.cbegin();
1452 const auto end = def->arguments.cend();
1453 for (auto it = begin; it != end; ++it) {
1454 const ArgumentDef &a = *it;
1455 if (it != begin)
1456 fputs(", ", out);
1457 if (a.type.name.size())
1458 fputs(a.type.name.constData(), out);
1459 fprintf(out, " _t%d", offset++);
1460 if (a.rightType.size())
1461 fputs(a.rightType.constData(), out);
1462 }
1463 if (def->isPrivateSignal) {
1464 if (!def->arguments.isEmpty())
1465 fprintf(out, ", ");
1466 fprintf(out, "QPrivateSignal _t%d", offset++);
1467 }
1468
1469 fprintf(out, ")%s\n{\n", constQualifier);
1470 if (def->type.name.size() && def->normalizedType != "void") {
1471 QByteArray returnType = noRef(def->normalizedType);
1472 fprintf(out, " %s _t0{};\n", returnType.constData());
1473 }
1474
1475 fprintf(out, " void *_a[] = { ");
1476 if (def->normalizedType == "void") {
1477 fprintf(out, "nullptr");
1478 } else {
1479 if (def->returnTypeIsVolatile)
1480 fprintf(out, "const_cast<void*>(reinterpret_cast<const volatile void*>(std::addressof(_t0)))");
1481 else
1482 fprintf(out, "const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t0)))");
1483 }
1484 int i;
1485 for (i = 1; i < offset; ++i)
1486 if (i <= def->arguments.size() && def->arguments.at(i - 1).type.isVolatile)
1487 fprintf(out, ", const_cast<void*>(reinterpret_cast<const volatile void*>(std::addressof(_t%d)))", i);
1488 else
1489 fprintf(out, ", const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t%d)))", i);
1490 fprintf(out, " };\n");
1491 fprintf(out, " QMetaObject::activate(%s, &staticMetaObject, %d, _a);\n", thisPtr.constData(), index);
1492 if (def->normalizedType != "void")
1493 fprintf(out, " return _t0;\n");
1494 fprintf(out, "}\n");
1495}
1496
1497static CborError jsonValueToCbor(CborEncoder *parent, const QJsonValue &v);
1498static CborError jsonObjectToCbor(CborEncoder *parent, const QJsonObject &o)
1499{
1500 auto it = o.constBegin();
1501 auto end = o.constEnd();
1502 CborEncoder map;
1503 cbor_encoder_create_map(parent, &map, o.size());
1504
1505 for ( ; it != end; ++it) {
1506 QByteArray key = it.key().toUtf8();
1507 cbor_encode_text_string(&map, key.constData(), key.size());
1508 jsonValueToCbor(&map, it.value());
1509 }
1510 return cbor_encoder_close_container(parent, &map);
1511}
1512
1513static CborError jsonArrayToCbor(CborEncoder *parent, const QJsonArray &a)
1514{
1515 CborEncoder array;
1516 cbor_encoder_create_array(parent, &array, a.size());
1517 for (const QJsonValue v : a)
1519 return cbor_encoder_close_container(parent, &array);
1520}
1521
1522static CborError jsonValueToCbor(CborEncoder *parent, const QJsonValue &v)
1523{
1524 switch (v.type()) {
1525 case QJsonValue::Null:
1527 return cbor_encode_null(parent);
1528 case QJsonValue::Bool:
1529 return cbor_encode_boolean(parent, v.toBool());
1530 case QJsonValue::Array:
1531 return jsonArrayToCbor(parent, v.toArray());
1532 case QJsonValue::Object:
1533 return jsonObjectToCbor(parent, v.toObject());
1534 case QJsonValue::String: {
1535 QByteArray s = v.toString().toUtf8();
1536 return cbor_encode_text_string(parent, s.constData(), s.size());
1537 }
1538 case QJsonValue::Double: {
1539 double d = v.toDouble();
1540 if (d == floor(d) && fabs(d) <= (Q_INT64_C(1) << std::numeric_limits<double>::digits))
1541 return cbor_encode_int(parent, qint64(d));
1542 return cbor_encode_double(parent, d);
1543 }
1544 }
1545 Q_UNREACHABLE_RETURN(CborUnknownError);
1546}
1547
1548void Generator::generatePluginMetaData()
1549{
1550 if (cdef->pluginData.iid.isEmpty())
1551 return;
1552
1553 auto outputCborData = [this]() {
1554 CborDevice dev(out);
1555 CborEncoder enc;
1556 cbor_encoder_init_writer(&enc, CborDevice::callback, &dev);
1557
1558 CborEncoder map;
1559 cbor_encoder_create_map(&enc, &map, CborIndefiniteLength);
1560
1561 dev.nextItem("\"IID\"");
1562 cbor_encode_int(&map, int(QtPluginMetaDataKeys::IID));
1563 cbor_encode_text_string(&map, cdef->pluginData.iid.constData(), cdef->pluginData.iid.size());
1564
1565 dev.nextItem("\"className\"");
1566 cbor_encode_int(&map, int(QtPluginMetaDataKeys::ClassName));
1567 cbor_encode_text_string(&map, cdef->classname.constData(), cdef->classname.size());
1568
1569 QJsonObject o = cdef->pluginData.metaData.object();
1570 if (!o.isEmpty()) {
1571 dev.nextItem("\"MetaData\"");
1572 cbor_encode_int(&map, int(QtPluginMetaDataKeys::MetaData));
1574 }
1575
1576 if (!cdef->pluginData.uri.isEmpty()) {
1577 dev.nextItem("\"URI\"");
1578 cbor_encode_int(&map, int(QtPluginMetaDataKeys::URI));
1579 cbor_encode_text_string(&map, cdef->pluginData.uri.constData(), cdef->pluginData.uri.size());
1580 }
1581
1582 // Add -M args from the command line:
1583 for (auto it = cdef->pluginData.metaArgs.cbegin(), end = cdef->pluginData.metaArgs.cend(); it != end; ++it) {
1584 const QJsonArray &a = it.value();
1585 QByteArray key = it.key().toUtf8();
1586 dev.nextItem(QByteArray("command-line \"" + key + "\"").constData());
1587 cbor_encode_text_string(&map, key.constData(), key.size());
1589 }
1590
1591 // Close the CBOR map manually
1592 dev.nextItem();
1593 cbor_encoder_close_container(&enc, &map);
1594 };
1595
1596 // 'Use' all namespaces.
1597 qsizetype pos = cdef->qualified.indexOf("::");
1598 for ( ; pos != -1 ; pos = cdef->qualified.indexOf("::", pos + 2) )
1599 fprintf(out, "using namespace %s;\n", cdef->qualified.left(pos).constData());
1600
1601 fputs("\n#ifdef QT_MOC_EXPORT_PLUGIN_V2", out);
1602
1603 // Qt 6.3+ output
1604 fprintf(out, "\nstatic constexpr unsigned char qt_pluginMetaDataV2_%s[] = {",
1605 cdef->classname.constData());
1606 outputCborData();
1607 fprintf(out, "\n};\nQT_MOC_EXPORT_PLUGIN_V2(%s, %s, qt_pluginMetaDataV2_%s)\n",
1608 cdef->qualified.constData(), cdef->classname.constData(), cdef->classname.constData());
1609
1610 // compatibility with Qt 6.0-6.2
1611 fprintf(out, "#else\nQT_PLUGIN_METADATA_SECTION\n"
1612 "Q_CONSTINIT static constexpr unsigned char qt_pluginMetaData_%s[] = {\n"
1613 " 'Q', 'T', 'M', 'E', 'T', 'A', 'D', 'A', 'T', 'A', ' ', '!',\n"
1614 " // metadata version, Qt version, architectural requirements\n"
1615 " 0, QT_VERSION_MAJOR, QT_VERSION_MINOR, qPluginArchRequirements(),",
1616 cdef->classname.constData());
1617 outputCborData();
1618 fprintf(out, "\n};\nQT_MOC_EXPORT_PLUGIN(%s, %s)\n"
1619 "#endif // QT_MOC_EXPORT_PLUGIN_V2\n",
1620 cdef->qualified.constData(), cdef->classname.constData());
1621
1622 fputs("\n", out);
1623}
1624
1625QT_WARNING_DISABLE_GCC("-Wunused-function")
1626QT_WARNING_DISABLE_CLANG("-Wunused-function")
1627QT_WARNING_DISABLE_CLANG("-Wundefined-internal")
1628QT_WARNING_DISABLE_MSVC(4334) // '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
1629
1630#define CBOR_ENCODER_WRITER_CONTROL 1
1631#define CBOR_ENCODER_WRITE_FUNCTION CborDevice::callback
1632
1634
1635#include "cborencoder.c"
static CborError callback(void *self, const void *ptr, size_t len, CborEncoderAppendType t)
Definition cbordevice.h:29
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:208
Q_NORETURN void error(const Symbol &symbol)
Definition parser.cpp:54
\inmodule QtCore
Definition qbytearray.h:57
char * data()
\macro QT_NO_CAST_FROM_BYTEARRAY
Definition qbytearray.h:611
bool endsWith(char c) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qbytearray.h:227
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
Definition qbytearray.h:494
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
Definition qbytearray.h:124
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...
void chop(qsizetype n)
Removes n bytes from the end of the byte array.
bool startsWith(QByteArrayView bv) const
Definition qbytearray.h:223
char at(qsizetype i) const
Returns the byte at index position i in the byte array.
Definition qbytearray.h:600
QByteArray & insert(qsizetype i, QByteArrayView data)
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
Definition qbytearray.h:107
QByteArray sliced(qsizetype pos) const &
Definition qbytearray.h:200
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 &
bool isNull() const noexcept
Returns true if this byte array is null; otherwise returns false.
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:339
bool contains(const Key &key) const noexcept
Returns true if the hash contains an item with the key; otherwise returns false.
Definition qhash.h:1007
\inmodule QtCore\reentrant
Definition qjsonarray.h:18
\inmodule QtCore\reentrant
Definition qjsonobject.h:20
\inmodule QtCore\reentrant
Definition qjsonvalue.h:25
qsizetype size() const noexcept
Definition qlist.h:397
bool isEmpty() const noexcept
Definition qlist.h:401
bool empty() const noexcept
Definition qlist.h:685
const_reference at(qsizetype i) const noexcept
Definition qlist.h:446
const_iterator constBegin() const noexcept
Definition qlist.h:632
const T & constFirst() const noexcept
Definition qlist.h:647
const_iterator cend() const noexcept
Definition qlist.h:631
const_iterator constEnd() const noexcept
Definition qlist.h:633
const_iterator cbegin() const noexcept
Definition qlist.h:630
T value(const Key &key, const T &defaultValue=T()) const
Definition qmap.h:357
bool contains(const Key &key) const
Definition qmap.h:341
bool isEmpty() const
Definition qmap.h:269
size_type size() const
Definition qmap.h:267
key_iterator keyBegin() const
Definition qmap.h:606
key_iterator keyEnd() const
Definition qmap.h:607
\inmodule QtCore
Definition qhash.h:1840
iterator begin()
Definition qset.h:136
iterator end()
Definition qset.h:140
const_iterator constBegin() const noexcept
Definition qset.h:139
const QChar * constData() const
Returns a pointer to the data stored in the QString.
Definition qstring.h:1246
QString str
[2]
QMap< QString, QString > map
[6]
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:297
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)
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
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:242
#define QT_FOR_EACH_AUTOMATIC_TEMPLATE_1ARG(F)
Definition qmetatype.h:231
#define QT_FOR_EACH_STATIC_TYPE(F)
Definition qmetatype.h:219
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
GLbitfield flags
GLenum GLuint GLintptr offset
GLuint name
GLdouble s
[6]
Definition qopenglext.h:235
const GLubyte * c
GLuint GLfloat * val
GLenum array
GLfloat GLfloat p
[1]
GLenum GLsizei len
#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:172
ptrdiff_t qsizetype
Definition qtypes.h:165
unsigned int uint
Definition qtypes.h:34
long long qint64
Definition qtypes.h:60
#define Q_INT64_C(c)
Definition qtypes.h:57
QList< int > list
[14]
QByteArray ba
[0]
QTextStream out(stdout)
[7]
QDBusArgument argument
Type type
Definition moc.h:57
QMap< QByteArray, QByteArray > flagAliases
Definition moc.h:153
QByteArray qualified
Definition moc.h:149
QByteArray classname
Definition moc.h:148
QMap< QByteArray, bool > enumDeclarations
Definition moc.h:151
QList< ClassInfoDef > classInfoList
Definition moc.h:150
QList< EnumDef > enumList
Definition moc.h:152
bool hasQObject
Definition moc.h:191
QList< QList< Interface > > interfaceList
Definition moc.h:176
QList< FunctionDef > methodList
Definition moc.h:186
QList< PropertyDef > propertyList
Definition moc.h:188
QList< FunctionDef > constructorList
Definition moc.h:185
bool hasQGadget
Definition moc.h:192
QList< SuperClass > superclassList
Definition moc.h:166
bool requireCompleteMethodTypes
Definition moc.h:194
bool hasQNamespace
Definition moc.h:193
QList< FunctionDef > slotList
Definition moc.h:186
QList< FunctionDef > signalList
Definition moc.h:186
int revisionedMethods
Definition moc.h:189
struct ClassDef::PluginData pluginData
QList< QByteArray > nonClassSignalList
Definition moc.h:187
Definition moc.h:42
bool isEnumClass
Definition moc.h:47
QByteArray enumName
Definition moc.h:44
QList< QByteArray > values
Definition moc.h:46
QByteArray name
Definition moc.h:43
bool wasCloned
Definition moc.h:83
QByteArray normalizedType
Definition moc.h:70
Type type
Definition moc.h:68
QByteArray name
Definition moc.h:72
bool isConst
Definition moc.h:79
QList< ArgumentDef > arguments
Definition moc.h:69
bool returnTypeIsVolatile
Definition moc.h:85
bool isAbstract
Definition moc.h:95
bool isPrivateSignal
Definition moc.h:92
@ Public
Definition moc.h:75
@ Protected
Definition moc.h:75
@ Private
Definition moc.h:75
@ ReferenceSpec
Definition moc.h:116
@ PointerSpec
Definition moc.h:116
QByteArray type
Definition moc.h:114
bool contains(const AT &t) const noexcept
Definition qlist.h:45
QByteArray classname
Definition moc.h:159
uint isVolatile
Definition moc.h:33
QByteArray name
Definition moc.h:29