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#include <QtCore/qtmocconstants.h>
22#include <private/qmetaobject_p.h>
23#include <private/qplugin_p.h>
27using namespace QtMiscUtils;
34 uint tp = QMetaType::UnknownType;
35 if (
const QtPrivate::QMetaTypeInterface *iface = QMetaType::fromName(name).iface())
36 tp = iface->typeId.loadRelaxed();
38#ifndef QT_BOOTSTRAPPED
39 if (tp >= uint(QMetaType::User))
40 tp = QMetaType::UnknownType;
47
48
51 int id = nameToBuiltinType(type);
52 return id != QMetaType::UnknownType;
61 return "enum struct ";
71#define RETURN_METATYPENAME_STRING(MetaTypeName, MetaTypeId, RealType)
72 case QMetaType::MetaTypeName: return #MetaTypeName;
75QT_FOR_EACH_STATIC_TYPE(RETURN_METATYPENAME_STRING)
77#undef RETURN_METATYPENAME_STRING
82 const QHash<QByteArray, QByteArray> &knownQObjectClasses,
83 const QHash<QByteArray, QByteArray> &knownGadgets, FILE *outfile,
84 bool requireCompleteTypes)
91 requireCompleteTypes(requireCompleteTypes)
93 if (cdef->superclassList.size())
94 purestSuperClass = cdef->superclassList.constFirst().classname;
99 if (s.at(i) !=
'\\' || i >= s.size() - 1)
101 const qsizetype startPos = i;
106 while (i < s.size() && isHexDigit(s.at(i)))
108 }
else if (isOctalDigit(ch)) {
109 while (i < startPos + 4
111 && isOctalDigit(s.at(i))) {
115 i = qMin(i + 1, s.size());
124 static constexpr int ColumnWidth = 68;
125 const qsizetype len = s.size();
129 qsizetype spanLen = qMin(ColumnWidth - 2, len - idx);
131 const qsizetype backSlashPos = s.lastIndexOf(
'\\', idx + spanLen - 1);
132 if (backSlashPos >= idx) {
133 const qsizetype escapeLen = lengthOfEscapeSequence(s, backSlashPos);
134 spanLen = qBound(spanLen, backSlashPos + escapeLen - idx, len - idx);
136 fprintf(out,
"\n \"%.*s\"",
int(spanLen), s.constData() + idx);
141void Generator::strreg(
const QByteArray &s)
143 if (!strings.contains(s))
147int Generator::stridx(
const QByteArray &s)
149 int i =
int(strings.indexOf(s));
150 Q_ASSERT_X(i != -1, Q_FUNC_INFO,
"We forgot to register some strings");
154bool Generator::registerableMetaType(
const QByteArray &propertyType)
156 if (metaTypes.contains(propertyType))
159 if (propertyType.endsWith(
'*')) {
160 QByteArray objectPointerType = propertyType;
164 objectPointerType.chop(1);
165 if (knownQObjectClasses.contains(objectPointerType))
169 static const QList<QByteArray> smartPointers = QList<QByteArray>()
170#define STREAM_SMART_POINTER(SMART_POINTER) << #SMART_POINTER
171 QT_FOR_EACH_AUTOMATIC_TEMPLATE_SMART_POINTER(STREAM_SMART_POINTER)
172#undef STREAM_SMART_POINTER
175 for (
const QByteArray &smartPointer : smartPointers) {
176 QByteArray ba = smartPointer +
"<";
177 if (propertyType.startsWith(ba) && !propertyType.endsWith(
"&"))
178 return knownQObjectClasses.contains(propertyType.mid(smartPointer.size() + 1, propertyType.size() - smartPointer.size() - 1 - 1));
181 static const QList<QByteArray> oneArgTemplates = QList<QByteArray>()
182#define STREAM_1ARG_TEMPLATE(TEMPLATENAME) << #TEMPLATENAME
183 QT_FOR_EACH_AUTOMATIC_TEMPLATE_1ARG(STREAM_1ARG_TEMPLATE)
184#undef STREAM_1ARG_TEMPLATE
186 for (
const QByteArray &oneArgTemplateType : oneArgTemplates) {
187 const QByteArray ba = oneArgTemplateType +
"<";
188 if (propertyType.startsWith(ba) && propertyType.endsWith(
">")) {
189 const qsizetype argumentSize = propertyType.size() - ba.size()
193 - (propertyType.at(propertyType.size() - 2) ==
' ' ? 1 : 0 );
194 const QByteArray templateArg = propertyType.sliced(ba.size(), argumentSize);
195 return isBuiltinType(templateArg) || registerableMetaType(templateArg);
202
205 if (qualifiedName == name)
207 const qsizetype index = qualifiedName.indexOf(
"::");
210 return qualifiedNameEquals(qualifiedName.mid(index+2), name);
216 QByteArray qualifiedClassNameIdentifier =
"ZN";
217 for (
const auto scope : qTokenize(QLatin1StringView(identifier), QLatin1Char(
':'),
218 Qt::SkipEmptyParts)) {
219 qualifiedClassNameIdentifier += QByteArray::number(scope.size());
220 qualifiedClassNameIdentifier += scope;
222 qualifiedClassNameIdentifier +=
'E';
223 return qualifiedClassNameIdentifier;
228 bool isQObject = (cdef->classname ==
"QObject");
229 bool isConstructible = !cdef->constructorList.isEmpty();
234 strreg(cdef->qualified);
235 registerClassInfoStrings();
236 registerFunctionStrings(cdef->signalList);
237 registerFunctionStrings(cdef->slotList);
238 registerFunctionStrings(cdef->methodList);
239 registerFunctionStrings(cdef->constructorList);
240 registerByteArrayVector(cdef->nonClassSignalList);
241 registerPropertyStrings();
242 registerEnumStrings();
245 bool hasStaticMetaCall =
247 || !cdef->propertyList.isEmpty() || !cdef->constructorList.isEmpty());
248 if (parser->activeQtMode)
249 hasStaticMetaCall =
false;
251 const QByteArray qualifiedClassNameIdentifier = generateQualifiedClassNameIdentifier(cdef->qualified);
254 const char *ownType = !cdef
->hasQNamespace ? cdef->classname.data() :
"void";
257 fprintf(out,
"namespace {\n"
258 "struct qt_meta_tag_%s_t {};\n"
259 "} // unnamed namespace\n\n",
260 qualifiedClassNameIdentifier.constData());
270 fprintf(out,
"template <> constexpr inline auto %s::qt_create_metaobjectdata<qt_meta_tag_%s_t>()\n"
272 " namespace QMC = QtMocConstants;\n",
273 cdef->qualified.constData(), qualifiedClassNameIdentifier.constData());
275 fprintf(out,
" QtMocHelpers::StringRefStorage qt_stringData {");
277 fprintf(out,
"\n };\n\n");
279 fprintf(out,
" QtMocHelpers::UintData qt_methods {\n");
282 addFunctions(cdef->signalList,
"Signal");
283 addFunctions(cdef->slotList,
"Slot");
284 addFunctions(cdef->methodList,
"Method");
286 " QtMocHelpers::UintData qt_properties {\n");
289 " QtMocHelpers::UintData qt_enums {\n");
291 fprintf(out,
" };\n");
293 const char *uintDataParams =
"";
294 if (isConstructible || !cdef->classInfoList.isEmpty()) {
295 if (isConstructible) {
296 fprintf(out,
" using Constructor = QtMocHelpers::NoType;\n"
297 " QtMocHelpers::UintData qt_constructors {\n");
298 addFunctions(cdef->constructorList,
"Constructor");
299 fprintf(out,
" };\n");
301 fputs(
" QtMocHelpers::UintData qt_constructors {};\n", out);
304 uintDataParams =
", qt_constructors";
305 if (!cdef->classInfoList.isEmpty()) {
306 fprintf(out,
" QtMocHelpers::ClassInfos qt_classinfo({\n");
308 fprintf(out,
" });\n");
309 uintDataParams =
", qt_constructors, qt_classinfo";
313 const char *metaObjectFlags =
"QMC::MetaObjectFlag{}";
318 metaObjectFlags =
"QMC::PropertyAccessInStaticMetaCall";
321 QByteArray tagType = QByteArrayLiteral(
"void");
322 if (!requireCompleteness)
323 tagType =
"qt_meta_tag_" + qualifiedClassNameIdentifier +
"_t";
324 fprintf(out,
" return QtMocHelpers::metaObjectData<%s, %s>(%s, qt_stringData,\n"
325 " qt_methods, qt_properties, qt_enums%s);\n"
327 ownType, tagType.constData(), metaObjectFlags, uintDataParams);
330 QByteArray metaVarNameSuffix;
334 metaVarNameSuffix =
'_' + qualifiedClassNameIdentifier;
335 const char *n = metaVarNameSuffix.constData();
337static constexpr auto qt_staticMetaObjectContent%s =
338 %s::qt_create_metaobjectdata<qt_meta_tag%s_t>();
339static constexpr auto qt_staticMetaObjectStaticContent%s =
340 qt_staticMetaObjectContent%s.staticData;
341static constexpr auto qt_staticMetaObjectRelocatingContent%s =
342 qt_staticMetaObjectContent%s.relocatingData;
343
344)",
345 n, cdef->qualified.constData(), n,
350 metaVarNameSuffix =
"<qt_meta_tag_" + qualifiedClassNameIdentifier +
"_t>";
356 QList<QByteArray> extraList;
357 QMultiHash<QByteArray, QByteArray> knownExtraMetaObject(knownGadgets);
358 knownExtraMetaObject.unite(knownQObjectClasses);
360 for (
const PropertyDef &p : std::as_const(cdef->propertyList)) {
361 if (isBuiltinType(p.type))
364 if (p.type.contains(
'*') || p.type.contains(
'<') || p.type.contains(
'>'))
367 const qsizetype s = p.type.lastIndexOf(
"::");
371 QByteArray unqualifiedScope = p.type.left(s);
374 QMultiHash<QByteArray, QByteArray>::ConstIterator scopeIt;
376 QByteArray thisScope = cdef->qualified;
378 const qsizetype s = thisScope.lastIndexOf(
"::");
379 thisScope = thisScope.left(s);
380 QByteArray currentScope = thisScope.isEmpty() ? unqualifiedScope : thisScope +
"::" + unqualifiedScope;
381 scopeIt = knownExtraMetaObject.constFind(currentScope);
382 }
while (!thisScope.isEmpty() && scopeIt == knownExtraMetaObject.constEnd());
384 if (scopeIt == knownExtraMetaObject.constEnd())
387 const QByteArray &scope = *scopeIt;
391 if (qualifiedNameEquals(cdef->qualified, scope))
394 if (!extraList.contains(scope))
401 for (
auto it = cdef->enumDeclarations.keyBegin(),
402 end = cdef->enumDeclarations.keyEnd(); it != end; ++it) {
403 const QByteArray &enumKey = *it;
404 const qsizetype s = enumKey.lastIndexOf(
"::");
406 QByteArray scope = enumKey.left(s);
407 if (scope !=
"Qt" && !qualifiedNameEquals(cdef->qualified, scope) && !extraList.contains(scope))
416 if (!extraList.isEmpty()) {
417 fprintf(out,
"Q_CONSTINIT static const QMetaObject::SuperData qt_meta_extradata_%s[] = {\n",
418 qualifiedClassNameIdentifier.constData());
419 for (
const QByteArray &ba : std::as_const(extraList))
420 fprintf(out,
" QMetaObject::SuperData::link<%s::staticMetaObject>(),\n", ba.constData());
422 fprintf(out,
" nullptr\n};\n\n");
428 fprintf(out,
"Q_CONSTINIT const QMetaObject %s::staticMetaObject = { {\n",
429 cdef->qualified.constData());
432 fprintf(out,
" nullptr,\n");
434 fprintf(out,
" QMetaObject::SuperData::link<%s::staticMetaObject>(),\n", purestSuperClass.constData());
435 else if (cdef->superclassList.size())
436 fprintf(out,
" QtPrivate::MetaObjectForType<%s>::value,\n", purestSuperClass.constData());
438 fprintf(out,
" nullptr,\n");
439 fprintf(out,
" qt_staticMetaObjectStaticContent%s.stringdata,\n"
440 " qt_staticMetaObjectStaticContent%s.data,\n",
441 metaVarNameSuffix.constData(),
442 metaVarNameSuffix.constData());
443 if (hasStaticMetaCall)
444 fprintf(out,
" qt_static_metacall,\n");
446 fprintf(out,
" nullptr,\n");
448 if (extraList.isEmpty())
449 fprintf(out,
" nullptr,\n");
451 fprintf(out,
" qt_meta_extradata_%s,\n", qualifiedClassNameIdentifier.constData());
453 fprintf(out,
" qt_staticMetaObjectRelocatingContent%s.metaTypes,\n",
454 metaVarNameSuffix.constData());
456 fprintf(out,
" nullptr\n} };\n\n");
461 if (hasStaticMetaCall)
462 generateStaticMetacall();
467 fprintf(out,
"\nconst QMetaObject *%s::metaObject() const\n{\n"
468 " return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;\n"
470 cdef->qualified.constData());
475 fprintf(out,
"\nvoid *%s::qt_metacast(const char *_clname)\n{\n", cdef->qualified.constData());
476 fprintf(out,
" if (!_clname) return nullptr;\n");
477 fprintf(out,
" if (!strcmp(_clname, qt_staticMetaObjectStaticContent<qt_meta_tag_%s_t>.strings))\n"
478 " return static_cast<void*>(this);\n",
479 qualifiedClassNameIdentifier.constData());
482 if (cdef->superclassList.size() > 1) {
483 auto it = cdef->superclassList.cbegin() + 1;
484 const auto end = cdef->superclassList.cend();
485 for (; it != end; ++it) {
488 const char *cname = it->classname.constData();
489 fprintf(out,
" if (!strcmp(_clname, \"%s\"))\n return static_cast< %s*>(this);\n",
494 for (
const QList<ClassDef::Interface> &iface : std::as_const(cdef->interfaceList)) {
495 for (qsizetype j = 0; j < iface.size(); ++j) {
496 fprintf(out,
" if (!strcmp(_clname, %s))\n return ", iface.at(j).interfaceId.constData());
497 for (qsizetype k = j; k >= 0; --k)
498 fprintf(out,
"static_cast< %s*>(", iface.at(k).className.constData());
499 fprintf(out,
"this%s;\n", QByteArray(j + 1,
')').constData());
502 if (!purestSuperClass.isEmpty() && !isQObject) {
503 QByteArray superClass = purestSuperClass;
504 fprintf(out,
" return %s::qt_metacast(_clname);\n", superClass.constData());
506 fprintf(out,
" return nullptr;\n");
510 if (parser->activeQtMode)
521 for (
int signalindex = 0; signalindex <
int(cdef->signalList.size()); ++signalindex)
522 generateSignal(&cdef->signalList.at(signalindex), signalindex);
527 generatePluginMetaData();
532 if (!cdef->nonClassSignalList.isEmpty()) {
533 fprintf(out,
"namespace CheckNotifySignalValidity_%s {\n", qualifiedClassNameIdentifier.constData());
534 for (
const QByteArray &nonClassSignal : std::as_const(cdef->nonClassSignalList)) {
535 const auto propertyIt = std::find_if(cdef->propertyList.constBegin(),
536 cdef->propertyList.constEnd(),
537 [&nonClassSignal](
const PropertyDef &p) {
538 return nonClassSignal == p.notify;
541 Q_ASSERT(propertyIt != cdef->propertyList.constEnd());
542 fprintf(out,
"template<typename T> using has_nullary_%s = decltype(std::declval<T>().%s());\n",
543 nonClassSignal.constData(),
544 nonClassSignal.constData());
545 const auto &propertyType = propertyIt->type;
546 fprintf(out,
"template<typename T> using has_unary_%s = decltype(std::declval<T>().%s(std::declval<%s>()));\n",
547 nonClassSignal.constData(),
548 nonClassSignal.constData(),
549 propertyType.constData());
550 fprintf(out,
"static_assert(qxp::is_detected_v<has_nullary_%s, %s> || qxp::is_detected_v<has_unary_%s, %s>,\n"
551 " \"NOTIFY signal %s does not exist in class (or is private in its parent)\");\n",
552 nonClassSignal.constData(), cdef->qualified.constData(),
553 nonClassSignal.constData(), cdef->qualified.constData(),
554 nonClassSignal.constData());
561void Generator::registerClassInfoStrings()
563 for (
const ClassInfoDef &c : std::as_const(cdef->classInfoList)) {
571 for (
const ClassInfoDef &c : std::as_const(cdef->classInfoList))
572 fprintf(out,
" { %4d, %4d },\n", stridx(c.name), stridx(c.value));
577 for (
const FunctionDef &f : list) {
579 if (!isBuiltinType(f.normalizedType))
580 strreg(f.normalizedType);
583 for (
const ArgumentDef &a : f.arguments) {
584 if (!isBuiltinType(a.normalizedType))
585 strreg(a.normalizedType);
591void Generator::registerByteArrayVector(
const QList<QByteArray> &list)
593 for (
const QByteArray &ba : list)
597void Generator::addStrings(
const QByteArrayList &strings)
600 for (
const QByteArray &str : strings) {
603 printStringWithIndentation(out, str);
610 for (
const FunctionDef &f : list) {
611 if (!f.isConstructor)
612 fprintf(out,
" // %s '%s'\n", functype, f.name.constData());
613 fprintf(out,
" QtMocHelpers::%s%sData<",
614 f.revision > 0 ?
"Revisioned" :
"", functype);
617 fprintf(out,
"Constructor(");
619 fprintf(out,
"%s(", disambiguatedTypeName(f.type.name).constData());
621 const char *comma =
"";
622 for (
const auto &argument : f.arguments) {
623 fprintf(out,
"%s%s", comma, disambiguatedTypeName(argument.type.name).constData());
628 fprintf(out,
")>(%d, ", stridx(f.tag));
630 fprintf(out,
")%s>(%d, %d, ", f.isConst ?
" const" :
"", stridx(f.name), stridx(f.tag));
634 if (f.access == FunctionDef::Private)
635 fprintf(out,
"QMC::AccessPrivate");
636 else if (f.access == FunctionDef::Public)
637 fprintf(out,
"QMC::AccessPublic");
638 else if (f.access == FunctionDef::Protected)
639 fprintf(out,
"QMC::AccessProtected");
641 fprintf(out,
" | QMC::MethodCompatibility");
643 fprintf(out,
" | QMC::MethodCloned");
645 fprintf(out,
" | QMC::MethodScriptable");
649 fprintf(out,
", %#x", f.revision);
652 if (!f.isConstructor) {
654 generateTypeInfo(f.normalizedType);
657 if (f.arguments.isEmpty()) {
658 fprintf(out,
"),\n");
661 fprintf(out,
", {{");
662 for (qsizetype i = 0; i < f.arguments.size(); ++i) {
665 const ArgumentDef &arg = f.arguments.at(i);
667 generateTypeInfo(arg.normalizedType);
668 fprintf(out,
", %d },", stridx(arg.name));
671 fprintf(out,
"\n }}),\n");
677void Generator::generateTypeInfo(
const QByteArray &typeName,
bool allowEmptyName)
679 Q_UNUSED(allowEmptyName);
680 if (
int type = nameToBuiltinType(typeName); type != QMetaType::UnknownType) {
681 const char *valueString;
682 if (typeName ==
"qreal") {
683 type = QMetaType::UnknownType;
684 valueString =
"QReal";
689 fprintf(out,
"QMetaType::%s", valueString);
691 Q_ASSERT(type != QMetaType::UnknownType);
692 fprintf(out,
"%4d", type);
695 Q_ASSERT(!typeName.isEmpty() || allowEmptyName);
696 fprintf(out,
"0x%.8x | %d", IsUnresolvedType, stridx(typeName));
702 for (
const PropertyDef &p : std::as_const(cdef->propertyList)) {
704 if (!isBuiltinType(p.type))
711 for (
const PropertyDef &p : std::as_const(cdef->propertyList)) {
712 fprintf(out,
" // property '%s'\n"
713 " QtMocHelpers::PropertyData<%s%s>(%d, ",
714 p.name.constData(), cxxTypeTag(p.typeTag),
715 disambiguatedTypeName(p.type, p.typeTag).constData(),
717 generateTypeInfo(p.type);
720 const char *separator =
"";
721 auto addFlag = [
this, &separator](
const char *text) {
722 fprintf(out,
"%s QMC::%s", separator, text);
725 bool readable = !p.read.isEmpty() || !p.member.isEmpty();
726 bool designable = p.designable !=
"false";
727 bool scriptable = p.scriptable !=
"false";
728 bool stored = p.stored !=
"false";
729 if (readable && designable && scriptable && stored) {
730 addFlag(
"DefaultPropertyFlags");
731 if ((!p.member.isEmpty() && !p.constant) || !p.write.isEmpty())
736 if ((!p.member.isEmpty() && !p.constant) || !p.write.isEmpty())
739 addFlag(
"Designable");
741 addFlag(
"Scriptable");
745 if (!p.reset.isEmpty())
746 addFlag(
"Resettable");
747 if (!isBuiltinType(p.type))
748 addFlag(
"EnumOrFlag");
750 addFlag(
"StdCppSet");
759 if (p.user !=
"false")
763 if (!p.bind.isEmpty())
766 if (*separator ==
'\0')
769 int notifyId = p.notifyId;
770 if (notifyId != -1 || p.revision > 0) {
772 if (p.notifyId < -1) {
774 const int indexInStrings =
int(strings.indexOf(p.notify));
775 notifyId = indexInStrings;
776 fprintf(out,
"%#x | ", IsUnresolvedSignal);
778 fprintf(out,
"%d", notifyId);
780 fprintf(out,
", %#x", p.revision);
783 fprintf(out,
"),\n");
789 for (
const EnumDef &e : std::as_const(cdef->enumList)) {
791 if (!e.enumName.isNull())
793 for (
const QByteArray &val : e.values)
800 for (
const EnumDef &e : std::as_const(cdef->enumList)) {
801 const QByteArray &typeName = e.enumName.isNull() ? e.name : e.enumName;
802 fprintf(out,
" // %s '%s'\n"
803 " QtMocHelpers::EnumData<%s>(%d, %d,",
804 e.flags & EnumIsFlag ?
"flag" :
"enum", e.name.constData(),
805 disambiguatedTypeName(e.name).constData(), stridx(e.name), stridx(typeName));
808 const char *separator =
"";
809 auto addFlag = [
this, &separator](
const char *text) {
810 fprintf(out,
"%s QMC::%s", separator, text);
813 if (e.flags & EnumIsFlag)
814 addFlag(
"EnumIsFlag");
815 if (e.flags & EnumIsScoped)
816 addFlag(
"EnumIsScoped");
818 fprintf(out,
" QMC::EnumFlags{}");
821 if (e.values.isEmpty()) {
822 fprintf(out,
"),\n");
827 fprintf(out,
").add({\n");
828 QByteArray prefix = (e.enumName.isNull() ? e.name : e.enumName);
829 for (
const QByteArray &val : e.values) {
830 fprintf(out,
" { %4d, %s::%s },\n", stridx(val),
831 prefix.constData(), val.constData());
834 fprintf(out,
" }),\n");
840 bool isQObject = (cdef->classname ==
"QObject");
842 fprintf(out,
"\nint %s::qt_metacall(QMetaObject::Call _c, int _id, void **_a)\n{\n",
843 cdef->qualified.constData());
845 if (!purestSuperClass.isEmpty() && !isQObject) {
846 QByteArray superClass = purestSuperClass;
847 fprintf(out,
" _id = %s::qt_metacall(_c, _id, _a);\n", superClass.constData());
852 methodList += cdef->signalList;
853 methodList += cdef->slotList;
854 methodList += cdef->methodList;
859 if (methodList.size() || cdef->propertyList.size()) {
860 fprintf(out,
" if (_id < 0)\n return _id;\n");
863 if (methodList.size()) {
864 fprintf(out,
" if (_c == QMetaObject::InvokeMetaMethod) {\n");
865 fprintf(out,
" if (_id < %d)\n",
int(methodList.size()));
866 fprintf(out,
" qt_static_metacall(this, _c, _id, _a);\n");
867 fprintf(out,
" _id -= %d;\n }\n",
int(methodList.size()));
869 fprintf(out,
" if (_c == QMetaObject::RegisterMethodArgumentMetaType) {\n");
870 fprintf(out,
" if (_id < %d)\n",
int(methodList.size()));
872 if (methodsWithAutomaticTypesHelper(methodList).isEmpty())
873 fprintf(out,
" *reinterpret_cast<QMetaType *>(_a[0]) = QMetaType();\n");
875 fprintf(out,
" qt_static_metacall(this, _c, _id, _a);\n");
876 fprintf(out,
" _id -= %d;\n }\n",
int(methodList.size()));
880 if (cdef->propertyList.size()) {
882 " if (_c == QMetaObject::ReadProperty || _c == QMetaObject::WriteProperty\n"
883 " || _c == QMetaObject::ResetProperty || _c == QMetaObject::BindableProperty\n"
884 " || _c == QMetaObject::RegisterPropertyMetaType) {\n"
885 " qt_static_metacall(this, _c, _id, _a);\n"
886 " _id -= %d;\n }\n",
int(cdef->propertyList.size()));
888 fprintf(out,
" return _id;\n}\n");
893QMultiMap<QByteArray,
int>
Generator::automaticPropertyMetaTypesHelper()
895 QMultiMap<QByteArray,
int> automaticPropertyMetaTypes;
896 for (
int i = 0; i <
int(cdef->propertyList.size()); ++i) {
898 const QByteArray &propertyType = p.type;
899 if (registerableMetaType(propertyType) && !isBuiltinType(propertyType))
900 automaticPropertyMetaTypes.insert(cxxTypeTag(p.typeTag) + propertyType, i);
902 return automaticPropertyMetaTypes;
905QMap<
int, QMultiMap<QByteArray,
int>>
908 QMap<
int, QMultiMap<QByteArray,
int> > methodsWithAutomaticTypes;
909 for (
int i = 0; i < methodList.size(); ++i) {
911 for (
int j = 0; j < f.arguments.size(); ++j) {
912 const QByteArray &argType = f.arguments.at(j).normalizedType;
913 if (registerableMetaType(argType) && !isBuiltinType(argType))
914 methodsWithAutomaticTypes[i].insert(argType, j);
917 return methodsWithAutomaticTypes;
922 fprintf(out,
"void %s::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)\n{\n",
923 cdef->qualified.constData());
935 fprintf(out,
" Q_ASSERT(_o == nullptr || staticMetaObject.cast(_o));\n");
937 fprintf(out,
" auto *_t = static_cast<%s *>(_o);\n", cdef->classname.constData());
939 fprintf(out,
" auto *_t = reinterpret_cast<%s *>(_o);\n", cdef->classname.constData());
942 const auto generateCtorArguments = [&](
int ctorindex) {
943 const FunctionDef &f = cdef->constructorList.at(ctorindex);
947 const auto begin = f.arguments.cbegin();
948 const auto end = f.arguments.cend();
949 for (
auto it = begin; it != end; ++it) {
953 fprintf(out,
"(*reinterpret_cast<%s>(_a[%d]))",
954 disambiguatedTypeNameForCast(a.normalizedType).constData(), offset++);
958 if (!cdef->constructorList.isEmpty()) {
959 fprintf(out,
" if (_c == QMetaObject::CreateInstance) {\n");
960 fprintf(out,
" switch (_id) {\n");
961 const int ctorend =
int(cdef->constructorList.size());
962 for (
int ctorindex = 0; ctorindex < ctorend; ++ctorindex) {
963 fprintf(out,
" case %d: { %s *_r = new %s(", ctorindex,
964 cdef->classname.constData(), cdef->classname.constData());
965 generateCtorArguments(ctorindex);
966 fprintf(out,
");\n");
967 fprintf(out,
" if (_a[0]) *reinterpret_cast<%s**>(_a[0]) = _r; } break;\n",
970 fprintf(out,
" default: break;\n");
971 fprintf(out,
" }\n");
972 fprintf(out,
" }\n");
973 fprintf(out,
" if (_c == QMetaObject::ConstructInPlace) {\n");
974 fprintf(out,
" switch (_id) {\n");
975 for (
int ctorindex = 0; ctorindex < ctorend; ++ctorindex) {
976 fprintf(out,
" case %d: { new (_a[0]) %s(",
977 ctorindex, cdef->classname.constData());
978 generateCtorArguments(ctorindex);
979 fprintf(out,
"); } break;\n");
981 fprintf(out,
" default: break;\n");
982 fprintf(out,
" }\n");
983 fprintf(out,
" }\n");
984 usedArgs |= UsedC | UsedId | UsedA;
988 methodList += cdef->signalList;
989 methodList += cdef->slotList;
990 methodList += cdef->methodList;
992 if (!methodList.isEmpty()) {
993 usedArgs |= UsedT | UsedC | UsedId;
994 fprintf(out,
" if (_c == QMetaObject::InvokeMetaMethod) {\n");
995 fprintf(out,
" switch (_id) {\n");
996 for (
int methodindex = 0; methodindex < methodList.size(); ++methodindex) {
998 Q_ASSERT(!f.normalizedType.isEmpty());
999 fprintf(out,
" case %d: ", methodindex);
1000 if (f.normalizedType !=
"void")
1001 fprintf(out,
"{ %s _r = ", disambiguatedTypeName(noRef(f.normalizedType)).constData());
1002 fprintf(out,
"_t->");
1003 if (f.inPrivateClass.size())
1004 fprintf(out,
"%s->", f.inPrivateClass.constData());
1005 fprintf(out,
"%s(", f.name.constData());
1009 fprintf(out,
"QMethodRawArguments{ _a }");
1012 const auto begin = f.arguments.cbegin();
1013 const auto end = f.arguments.cend();
1014 for (
auto it = begin; it != end; ++it) {
1018 fprintf(out,
"(*reinterpret_cast<%s>(_a[%d]))", disambiguatedTypeNameForCast(a.normalizedType).constData(), offset++);
1022 if (!f.arguments.isEmpty())
1024 fprintf(out,
"%s",
"QPrivateSignal()");
1028 if (f.normalizedType !=
"void") {
1029 fprintf(out,
"\n if (_a[0]) *reinterpret_cast<%s*>(_a[0]) = std::move(_r); } ",
1030 disambiguatedTypeName(noRef(f.normalizedType)).constData());
1033 fprintf(out,
" break;\n");
1035 fprintf(out,
" default: ;\n");
1036 fprintf(out,
" }\n");
1037 fprintf(out,
" }\n");
1039 QMap<
int, QMultiMap<QByteArray,
int> > methodsWithAutomaticTypes = methodsWithAutomaticTypesHelper(methodList);
1041 if (!methodsWithAutomaticTypes.isEmpty()) {
1042 fprintf(out,
" if (_c == QMetaObject::RegisterMethodArgumentMetaType) {\n");
1043 fprintf(out,
" switch (_id) {\n");
1044 fprintf(out,
" default: *reinterpret_cast<QMetaType *>(_a[0]) = QMetaType(); break;\n");
1045 QMap<
int, QMultiMap<QByteArray,
int> >::const_iterator it = methodsWithAutomaticTypes.constBegin();
1046 const QMap<
int, QMultiMap<QByteArray,
int> >::const_iterator end = methodsWithAutomaticTypes.constEnd();
1047 for ( ; it != end; ++it) {
1048 fprintf(out,
" case %d:\n", it.key());
1049 fprintf(out,
" switch (*reinterpret_cast<int*>(_a[1])) {\n");
1050 fprintf(out,
" default: *reinterpret_cast<QMetaType *>(_a[0]) = QMetaType(); break;\n");
1051 auto jt = it->begin();
1052 const auto jend = it->end();
1053 while (jt != jend) {
1054 fprintf(out,
" case %d:\n", jt.value());
1055 const QByteArray &lastKey = jt.key();
1057 if (jt == jend || jt.key() != lastKey)
1058 fprintf(out,
" *reinterpret_cast<QMetaType *>(_a[0]) = QMetaType::fromType< %s >(); break;\n", lastKey.constData());
1060 fprintf(out,
" }\n");
1061 fprintf(out,
" break;\n");
1063 fprintf(out,
" }\n");
1064 fprintf(out,
" }\n");
1065 usedArgs |= UsedC | UsedId | UsedA;
1069 if (!cdef->signalList.isEmpty()) {
1070 usedArgs |= UsedC | UsedA;
1071 fprintf(out,
" if (_c == QMetaObject::IndexOfMethod) {\n");
1072 for (
int methodindex = 0; methodindex <
int(cdef->signalList.size()); ++methodindex) {
1073 const FunctionDef &f = cdef->signalList.at(methodindex);
1076 fprintf(out,
" if (QtMocHelpers::indexOfMethod<%s (%s::*)(",
1077 f.type.rawName.constData() , cdef->classname.constData());
1079 const auto begin = f.arguments.cbegin();
1080 const auto end = f.arguments.cend();
1081 for (
auto it = begin; it != end; ++it) {
1085 fprintf(out,
"%s", QByteArray(a.type.name +
' ' + a.rightType).constData());
1088 if (!f.arguments.isEmpty())
1090 fprintf(out,
"%s",
"QPrivateSignal");
1092 fprintf(out,
")%s>(_a, &%s::%s, %d))\n",
1094 cdef->classname.constData(), f.name.constData(), methodindex);
1095 fprintf(out,
" return;\n");
1097 fprintf(out,
" }\n");
1100 const QMultiMap<QByteArray,
int> automaticPropertyMetaTypes = automaticPropertyMetaTypesHelper();
1102 if (!automaticPropertyMetaTypes.isEmpty()) {
1103 fprintf(out,
" if (_c == QMetaObject::RegisterPropertyMetaType) {\n");
1104 fprintf(out,
" switch (_id) {\n");
1105 fprintf(out,
" default: *reinterpret_cast<int*>(_a[0]) = -1; break;\n");
1106 auto it = automaticPropertyMetaTypes.begin();
1107 const auto end = automaticPropertyMetaTypes.end();
1109 fprintf(out,
" case %d:\n", it.value());
1110 const QByteArray &lastKey = it.key();
1112 if (it == end || it.key() != lastKey)
1113 fprintf(out,
" *reinterpret_cast<int*>(_a[0]) = qRegisterMetaType< %s >(); break;\n", lastKey.constData());
1115 fprintf(out,
" }\n");
1116 fprintf(out,
" }\n");
1117 usedArgs |= UsedC | UsedId | UsedA;
1120 if (!cdef->propertyList.empty()) {
1121 bool needGet =
false;
1122 bool needTempVarForGet =
false;
1123 bool needSet =
false;
1124 bool needReset =
false;
1125 bool hasBindableProperties =
false;
1126 for (
const PropertyDef &p : std::as_const(cdef->propertyList)) {
1127 needGet |= !p.read.isEmpty() || !p.member.isEmpty();
1128 if (!p.read.isEmpty() || !p.member.isEmpty())
1129 needTempVarForGet |= (p.gspec != PropertyDef::PointerSpec
1130 && p.gspec != PropertyDef::ReferenceSpec);
1132 needSet |= !p.write.isEmpty() || (!p.member.isEmpty() && !p.constant);
1133 needReset |= !p.reset.isEmpty();
1134 hasBindableProperties |= !p.bind.isEmpty();
1136 if (needGet || needSet || hasBindableProperties || needReset)
1137 usedArgs |= UsedT | UsedC | UsedId;
1138 if (needGet || needSet || hasBindableProperties)
1142 fprintf(out,
" if (_c == QMetaObject::ReadProperty) {\n");
1143 if (needTempVarForGet)
1144 fprintf(out,
" void *_v = _a[0];\n");
1145 fprintf(out,
" switch (_id) {\n");
1146 for (
int propindex = 0; propindex <
int(cdef->propertyList.size()); ++propindex) {
1147 const PropertyDef &p = cdef->propertyList.at(propindex);
1148 if (p.read.isEmpty() && p.member.isEmpty())
1150 QByteArray prefix =
"_t->";
1151 if (p.inPrivateClass.size()) {
1152 prefix += p.inPrivateClass +
"->";
1156 fprintf(out,
" case %d: _a[0] = const_cast<void*>(reinterpret_cast<const void*>(%s%s())); break;\n",
1157 propindex, prefix.constData(), p.read.constData());
1159 fprintf(out,
" case %d: _a[0] = const_cast<void*>(reinterpret_cast<const void*>(&%s%s())); break;\n",
1160 propindex, prefix.constData(), p.read.constData());
1161#if QT_VERSION <= QT_VERSION_CHECK(7
, 0
, 0
)
1162 else if (
auto eflags = cdef->enumDeclarations.value(p.type); eflags & EnumIsFlag)
1163 fprintf(out,
" case %d: QtMocHelpers::assignFlags<%s>(_v, %s%s()); break;\n",
1164 propindex, disambiguatedTypeName(p.type, p.typeTag).constData(), prefix.constData(), p.read.constData());
1166 else if (p.read ==
"default")
1167 fprintf(out,
" case %d: *reinterpret_cast<%s%s*>(_v) = %s%s().value(); break;\n",
1168 propindex, cxxTypeTag(p.typeTag), disambiguatedTypeName(p.type, p.typeTag).constData(),
1169 prefix.constData(), p.bind.constData());
1170 else if (!p.read.isEmpty())
1171 fprintf(out,
" case %d: *reinterpret_cast<%s%s*>(_v) = %s%s(); break;\n",
1172 propindex, cxxTypeTag(p.typeTag), disambiguatedTypeName(p.type, p.typeTag).constData(),
1173 prefix.constData(), p.read.constData());
1175 fprintf(out,
" case %d: *reinterpret_cast<%s%s*>(_v) = %s%s; break;\n",
1176 propindex, cxxTypeTag(p.typeTag), disambiguatedTypeName(p.type, p.typeTag).constData(),
1177 prefix.constData(), p.member.constData());
1179 fprintf(out,
" default: break;\n");
1180 fprintf(out,
" }\n");
1181 fprintf(out,
" }\n");
1185 fprintf(out,
" if (_c == QMetaObject::WriteProperty) {\n");
1186 fprintf(out,
" void *_v = _a[0];\n");
1187 fprintf(out,
" switch (_id) {\n");
1188 for (
int propindex = 0; propindex <
int(cdef->propertyList.size()); ++propindex) {
1189 const PropertyDef &p = cdef->propertyList.at(propindex);
1192 if (p.write.isEmpty() && p.member.isEmpty())
1194 QByteArray prefix =
"_t->";
1195 if (p.inPrivateClass.size()) {
1196 prefix += p.inPrivateClass +
"->";
1198 if (p.write ==
"default") {
1199 fprintf(out,
" case %d: {\n", propindex);
1200 fprintf(out,
" %s%s().setValue(*reinterpret_cast<%s%s*>(_v));\n",
1201 prefix.constData(), p.bind.constData(), cxxTypeTag(p.typeTag),
1202 disambiguatedTypeName(p.type, p.typeTag).constData());
1203 fprintf(out,
" break;\n");
1204 fprintf(out,
" }\n");
1205 }
else if (!p.write.isEmpty()) {
1206 fprintf(out,
" case %d: %s%s(*reinterpret_cast<%s%s*>(_v)); break;\n",
1207 propindex, prefix.constData(), p.write.constData(),
1208 cxxTypeTag(p.typeTag), disambiguatedTypeName(p.type, p.typeTag).constData());
1210 fprintf(out,
" case %d:", propindex);
1211 if (p.notify.isEmpty()) {
1212 fprintf(out,
" QtMocHelpers::setProperty(%s%s, *reinterpret_cast<%s%s*>(_v)); break;\n",
1213 prefix.constData(), p.member.constData(), cxxTypeTag(p.typeTag),
1214 disambiguatedTypeName(p.type, p.typeTag).constData());
1216 fprintf(out,
"\n if (QtMocHelpers::setProperty(%s%s, *reinterpret_cast<%s%s*>(_v)))\n",
1217 prefix.constData(), p.member.constData(), cxxTypeTag(p.typeTag),
1218 disambiguatedTypeName(p.type, p.typeTag).constData());
1219 fprintf(out,
" Q_EMIT _t->%s(", p.notify.constData());
1222 if (f.arguments.size() == 1 && f.arguments.at(0).normalizedType == p.type)
1223 fprintf(out,
"%s%s", prefix.constData(), p.member.constData());
1225 fprintf(out,
");\n");
1226 fprintf(out,
" break;\n");
1230 fprintf(out,
" default: break;\n");
1231 fprintf(out,
" }\n");
1232 fprintf(out,
" }\n");
1236 fprintf(out,
" if (_c == QMetaObject::ResetProperty) {\n");
1237 fprintf(out,
" switch (_id) {\n");
1238 for (
int propindex = 0; propindex <
int(cdef->propertyList.size()); ++propindex) {
1239 const PropertyDef &p = cdef->propertyList.at(propindex);
1240 if (p.reset.isEmpty())
1242 QByteArray prefix =
"_t->";
1243 if (p.inPrivateClass.size()) {
1244 prefix += p.inPrivateClass +
"->";
1246 fprintf(out,
" case %d: %s%s(); break;\n",
1247 propindex, prefix.constData(), p.reset.constData());
1249 fprintf(out,
" default: break;\n");
1250 fprintf(out,
" }\n");
1251 fprintf(out,
" }\n");
1254 if (hasBindableProperties) {
1255 fprintf(out,
" if (_c == QMetaObject::BindableProperty) {\n");
1256 fprintf(out,
" switch (_id) {\n");
1257 for (
int propindex = 0; propindex <
int(cdef->propertyList.size()); ++propindex) {
1258 const PropertyDef &p = cdef->propertyList.at(propindex);
1259 if (p.bind.isEmpty())
1261 QByteArray prefix =
"_t->";
1262 if (p.inPrivateClass.size()) {
1263 prefix += p.inPrivateClass +
"->";
1266 " case %d: *static_cast<QUntypedBindable *>(_a[0]) = %s%s(); "
1268 propindex, prefix.constData(), p.bind.constData());
1270 fprintf(out,
" default: break;\n");
1271 fprintf(out,
" }\n");
1272 fprintf(out,
" }\n");
1276 auto printUnused = [&](UsedArgs entry,
const char *name) {
1277 if ((usedArgs & entry) == 0)
1278 fprintf(out,
" (void)%s;\n", name);
1280 printUnused(UsedT,
"_t");
1281 printUnused(UsedC,
"_c");
1282 printUnused(UsedId,
"_id");
1283 printUnused(UsedA,
"_a");
1285 fprintf(out,
"}\n");
1292 fprintf(out,
"\n// SIGNAL %d\n%s %s::%s(",
1293 index, def->type.name.constData(), cdef->qualified.constData(), def->name.constData());
1295 QByteArray thisPtr =
"this";
1296 const char *constQualifier =
"";
1299 thisPtr =
"const_cast< " + cdef->qualified +
" *>(this)";
1300 constQualifier =
"const";
1303 Q_ASSERT(!def->normalizedType.isEmpty());
1304 if (def->arguments.isEmpty() && def->normalizedType ==
"void" && !def
->isPrivateSignal) {
1305 fprintf(out,
")%s\n{\n"
1306 " QMetaObject::activate(%s, &staticMetaObject, %d, nullptr);\n"
1307 "}\n", constQualifier, thisPtr.constData(), index);
1312 const auto begin = def->arguments.cbegin();
1313 const auto end = def->arguments.cend();
1314 for (
auto it = begin; it != end; ++it) {
1318 if (a.type.name.size())
1319 fputs(a.type.name.constData(), out);
1320 fprintf(out,
" _t%d", offset++);
1321 if (a.rightType.size())
1322 fputs(a.rightType.constData(), out);
1325 if (!def->arguments.isEmpty())
1327 fprintf(out,
"QPrivateSignal _t%d", offset++);
1330 fprintf(out,
")%s\n{\n", constQualifier);
1331 if (def->type.name.size() && def->normalizedType !=
"void") {
1332 QByteArray returnType = noRef(def->normalizedType);
1333 fprintf(out,
" %s _t0{};\n", returnType.constData());
1336 fprintf(out,
" QMetaObject::activate<%s>(%s, &staticMetaObject, %d, ",
1337 def->normalizedType.constData(), thisPtr.constData(), index);
1338 if (def->normalizedType ==
"void") {
1339 fprintf(out,
"nullptr");
1341 fprintf(out,
"std::addressof(_t0)");
1344 for (i = 1; i < offset; ++i)
1345 fprintf(out,
", _t%d", i);
1346 fprintf(out,
");\n");
1348 if (def->normalizedType !=
"void")
1349 fprintf(out,
" return _t0;\n");
1350 fprintf(out,
"}\n");
1353static CborError jsonValueToCbor(CborEncoder *parent,
const QJsonValue &v);
1354static CborError jsonObjectToCbor(CborEncoder *parent,
const QJsonObject &o)
1356 auto it = o.constBegin();
1357 auto end = o.constEnd();
1359 cbor_encoder_create_map(parent, &map, o.size());
1361 for ( ; it != end; ++it) {
1362 QByteArray key = it.key().toUtf8();
1363 cbor_encode_text_string(&map, key.constData(), key.size());
1364 jsonValueToCbor(&map, it.value());
1366 return cbor_encoder_close_container(parent, &map);
1369static CborError jsonArrayToCbor(CborEncoder *parent,
const QJsonArray &a)
1372 cbor_encoder_create_array(parent, &array, a.size());
1373 for (
const QJsonValue v : a)
1374 jsonValueToCbor(&array, v);
1375 return cbor_encoder_close_container(parent, &array);
1378static CborError jsonValueToCbor(CborEncoder *parent,
const QJsonValue &v)
1381 case QJsonValue::Null:
1382 case QJsonValue::Undefined:
1383 return cbor_encode_null(parent);
1384 case QJsonValue::Bool:
1385 return cbor_encode_boolean(parent, v.toBool());
1386 case QJsonValue::Array:
1387 return jsonArrayToCbor(parent, v.toArray());
1388 case QJsonValue::Object:
1389 return jsonObjectToCbor(parent, v.toObject());
1390 case QJsonValue::String: {
1391 QByteArray s = v.toString().toUtf8();
1392 return cbor_encode_text_string(parent, s.constData(), s.size());
1394 case QJsonValue::Double: {
1395 double d = v.toDouble();
1396 if (d == floor(d) && fabs(d) <= (Q_INT64_C(1) <<
std::numeric_limits<
double>::digits))
1397 return cbor_encode_int(parent, qint64(d));
1398 return cbor_encode_double(parent, d);
1401 Q_UNREACHABLE_RETURN(CborUnknownError);
1406 if (cdef->pluginData.iid.isEmpty())
1409 auto outputCborData = [
this]() {
1412 cbor_encoder_init_writer(&enc, CborDevice::callback, &dev);
1415 cbor_encoder_create_map(&enc, &map, CborIndefiniteLength);
1418 cbor_encode_int(&map,
int(QtPluginMetaDataKeys::IID));
1419 cbor_encode_text_string(&map, cdef->pluginData.iid.constData(), cdef->pluginData.iid.size());
1422 cbor_encode_int(&map,
int(QtPluginMetaDataKeys::ClassName));
1423 cbor_encode_text_string(&map, cdef->classname.constData(), cdef->classname.size());
1425 QJsonObject o = cdef->pluginData.metaData.object();
1428 cbor_encode_int(&map,
int(QtPluginMetaDataKeys::MetaData));
1429 jsonObjectToCbor(&map, o);
1432 if (!cdef->pluginData.uri.isEmpty()) {
1434 cbor_encode_int(&map,
int(QtPluginMetaDataKeys::URI));
1435 cbor_encode_text_string(&map, cdef->pluginData.uri.constData(), cdef->pluginData.uri.size());
1439 for (
auto it = cdef->pluginData.metaArgs.cbegin(), end = cdef->pluginData.metaArgs.cend(); it != end; ++it) {
1440 const QJsonArray &a = it.value();
1441 QByteArray key = it.key().toUtf8();
1442 dev
.nextItem(QByteArray(
"command-line \"" + key +
"\"").constData()
);
1443 cbor_encode_text_string(&map, key.constData(), key.size());
1444 jsonArrayToCbor(&map, a);
1449 cbor_encoder_close_container(&enc, &map);
1453 qsizetype pos = cdef->qualified.indexOf(
"::");
1454 for ( ; pos != -1 ; pos = cdef->qualified.indexOf(
"::", pos + 2) )
1455 fprintf(out,
"using namespace %s;\n", cdef->qualified.left(pos).constData());
1457 fputs(
"\n#ifdef QT_MOC_EXPORT_PLUGIN_V2", out);
1460 fprintf(out,
"\nstatic constexpr unsigned char qt_pluginMetaDataV2_%s[] = {",
1461 cdef->classname.constData());
1463 fprintf(out,
"\n};\nQT_MOC_EXPORT_PLUGIN_V2(%s, %s, qt_pluginMetaDataV2_%s)\n",
1464 cdef->qualified.constData(), cdef->classname.constData(), cdef->classname.constData());
1467 fprintf(out,
"#else\nQT_PLUGIN_METADATA_SECTION\n"
1468 "Q_CONSTINIT static constexpr unsigned char qt_pluginMetaData_%s[] = {\n"
1469 " 'Q', 'T', 'M', 'E', 'T', 'A', 'D', 'A', 'T', 'A', ' ', '!',\n"
1470 " // metadata version, Qt version, architectural requirements\n"
1471 " 0, QT_VERSION_MAJOR, QT_VERSION_MINOR, qPluginArchRequirements(),",
1472 cdef->classname.constData());
1474 fprintf(out,
"\n};\nQT_MOC_EXPORT_PLUGIN(%s, %s)\n"
1475 "#endif // QT_MOC_EXPORT_PLUGIN_V2\n",
1476 cdef->qualified.constData(), cdef->classname.constData());
1481QByteArray
Generator::disambiguatedTypeName(
const QByteArray &name)
1483 if (cdef->allEnumNames.contains(name))
1484 return "enum " + name;
1490QByteArray
Generator::disambiguatedTypeName(
const QByteArray &name, TypeTags tag)
1492 if (tag == TypeTag::None)
1493 return disambiguatedTypeName(name);
1497QByteArray
Generator::disambiguatedTypeNameForCast(
const QByteArray &name)
1499 return QByteArray(
"std::add_pointer_t<"+ disambiguatedTypeName(name) +
">");
1502QT_WARNING_DISABLE_GCC(
"-Wunused-function")
1503QT_WARNING_DISABLE_CLANG(
"-Wunused-function")
1504QT_WARNING_DISABLE_CLANG(
"-Wundefined-internal")
1505QT_WARNING_DISABLE_MSVC(4334)
1507#define CBOR_NO_HALF_FLOAT_TYPE 1
1508#define CBOR_ENCODER_WRITER_CONTROL 1
1509#define CBOR_ENCODER_WRITE_FUNCTION CborDevice::callback
1513#include "cborencoder.c"
void nextItem(const char *comment=nullptr)
Generator(Moc *moc, const ClassDef *classDef, const QList< QByteArray > &metaTypes, const QHash< QByteArray, QByteArray > &knownQObjectClasses, const QHash< QByteArray, QByteArray > &knownGadgets, FILE *outfile=nullptr, bool requireCompleteTypes=false)
bool requireCompleteMethodTypes