diff options
Diffstat (limited to 'src/tools/moc')
-rw-r--r-- | src/tools/moc/generator.cpp | 10 | ||||
-rw-r--r-- | src/tools/moc/moc.cpp | 2 | ||||
-rw-r--r-- | src/tools/moc/moc.h | 72 | ||||
-rwxr-xr-x | src/tools/moc/util/generate.sh | 2 |
4 files changed, 42 insertions, 44 deletions
diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index fd76646f4c..02c1fbd394 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -619,7 +619,7 @@ void Generator::generateCode() fprintf(out, "// a) You are using a NOTIFY signal that does not exist. Fix it.\n"); fprintf(out, "// b) You are using a NOTIFY signal that does exist (in a parent class) but has a non-empty parameter list. This is a moc limitation.\n"); fprintf(out, "Q_DECL_UNUSED static void checkNotifySignalValidity_%s(%s *t) {\n", qualifiedClassNameIdentifier.constData(), cdef->qualified.constData()); - for (const QByteArray &nonClassSignal : cdef->nonClassSignalList) + for (const QByteArray &nonClassSignal : qAsConst(cdef->nonClassSignalList)) fprintf(out, " t->%s();\n", nonClassSignal.constData()); fprintf(out, "}\n"); } @@ -1549,16 +1549,16 @@ void Generator::generateSignal(FunctionDef *def,int index) fprintf(out, "nullptr"); } else { if (def->returnTypeIsVolatile) - fprintf(out, "const_cast<void*>(reinterpret_cast<const volatile void*>(&_t0))"); + fprintf(out, "const_cast<void*>(reinterpret_cast<const volatile void*>(std::addressof(_t0)))"); else - fprintf(out, "const_cast<void*>(reinterpret_cast<const void*>(&_t0))"); + fprintf(out, "const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t0)))"); } int i; for (i = 1; i < offset; ++i) if (i <= def->arguments.count() && def->arguments.at(i - 1).type.isVolatile) - fprintf(out, ", const_cast<void*>(reinterpret_cast<const volatile void*>(&_t%d))", i); + fprintf(out, ", const_cast<void*>(reinterpret_cast<const volatile void*>(std::addressof(_t%d)))", i); else - fprintf(out, ", const_cast<void*>(reinterpret_cast<const void*>(&_t%d))", i); + fprintf(out, ", const_cast<void*>(reinterpret_cast<const void*>(std::addressof(_t%d)))", i); fprintf(out, " };\n"); fprintf(out, " QMetaObject::activate(%s, &staticMetaObject, %d, _a);\n", thisPtr.constData(), index); if (def->normalizedType != "void") diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 7272df4265..5d777ece2e 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -992,7 +992,7 @@ void Moc::generate(FILE *out) fprintf(out, "** WARNING! All changes made in this file will be lost!\n" "*****************************************************************************/\n\n"); - + fprintf(out, "#include <memory>\n"); // For std::addressof if (!noInclude) { if (includePath.size() && !includePath.endsWith('/')) includePath += '/'; diff --git a/src/tools/moc/moc.h b/src/tools/moc/moc.h index d98c73e1a0..d6482f4e44 100644 --- a/src/tools/moc/moc.h +++ b/src/tools/moc/moc.h @@ -83,57 +83,53 @@ Q_DECLARE_TYPEINFO(ArgumentDef, Q_MOVABLE_TYPE); struct FunctionDef { - FunctionDef(): returnTypeIsVolatile(false), access(Private), isConst(false), isVirtual(false), isStatic(false), - inlineCode(false), wasCloned(false), isCompat(false), isInvokable(false), - isScriptable(false), isSlot(false), isSignal(false), isPrivateSignal(false), - isConstructor(false), isDestructor(false), isAbstract(false), revision(0) {} Type type; + QVector<ArgumentDef> arguments; QByteArray normalizedType; QByteArray tag; QByteArray name; - bool returnTypeIsVolatile; - - QVector<ArgumentDef> arguments; + QByteArray inPrivateClass; enum Access { Private, Protected, Public }; - Access access; - bool isConst; - bool isVirtual; - bool isStatic; - bool inlineCode; - bool wasCloned; - - QByteArray inPrivateClass; - bool isCompat; - bool isInvokable; - bool isScriptable; - bool isSlot; - bool isSignal; - bool isPrivateSignal; - bool isConstructor; - bool isDestructor; - bool isAbstract; - - int revision; + Access access = Private; + int revision = 0; + + bool isConst = false; + bool isVirtual = false; + bool isStatic = false; + bool inlineCode = false; + bool wasCloned = false; + + bool returnTypeIsVolatile = false; + + bool isCompat = false; + bool isInvokable = false; + bool isScriptable = false; + bool isSlot = false; + bool isSignal = false; + bool isPrivateSignal = false; + bool isConstructor = false; + bool isDestructor = false; + bool isAbstract = false; }; Q_DECLARE_TYPEINFO(FunctionDef, Q_MOVABLE_TYPE); struct PropertyDef { - PropertyDef():notifyId(-1), constant(false), final(false), gspec(ValueSpec), revision(0){} - QByteArray name, type, member, read, write, reset, designable, scriptable, editable, stored, user, notify, inPrivateClass; - int notifyId; // -1 means no notifyId, >= 0 means signal defined in this class, < -1 means signal not defined in this class - bool constant; - bool final; - enum Specification { ValueSpec, ReferenceSpec, PointerSpec }; - Specification gspec; bool stdCppSet() const { QByteArray s("set"); s += toupper(name[0]); s += name.mid(1); return (s == write); } - int revision; + + QByteArray name, type, member, read, write, reset, designable, scriptable, editable, stored, user, notify, inPrivateClass; + int notifyId = -1; // -1 means no notifyId, >= 0 means signal defined in this class, < -1 means signal not defined in this class + enum Specification { ValueSpec, ReferenceSpec, PointerSpec }; + Specification gspec = ValueSpec; + int revision = 0; + bool constant = false; + bool final = false; }; Q_DECLARE_TYPEINFO(PropertyDef, Q_MOVABLE_TYPE); @@ -169,9 +165,6 @@ struct ClassDef : BaseDef { }; QVector<QVector<Interface> >interfaceList; - bool hasQObject = false; - bool hasQGadget = false; - struct PluginData { QByteArray iid; QMap<QString, QJsonArray> metaArgs; @@ -181,11 +174,14 @@ struct ClassDef : BaseDef { QVector<FunctionDef> constructorList; QVector<FunctionDef> signalList, slotList, methodList, publicList; QVector<QByteArray> nonClassSignalList; - int notifyableProperties = 0; QVector<PropertyDef> propertyList; + int notifyableProperties = 0; int revisionedMethods = 0; int revisionedProperties = 0; + bool hasQObject = false; + bool hasQGadget = false; + }; Q_DECLARE_TYPEINFO(ClassDef, Q_MOVABLE_TYPE); Q_DECLARE_TYPEINFO(ClassDef::Interface, Q_MOVABLE_TYPE); diff --git a/src/tools/moc/util/generate.sh b/src/tools/moc/util/generate.sh index 3894be1309..5460d28924 100755 --- a/src/tools/moc/util/generate.sh +++ b/src/tools/moc/util/generate.sh @@ -27,6 +27,8 @@ ## ############################################################################# +set -ex + qmake make cat licenseheader.txt > ../keywords.cpp |