diff --git a/src/checks/level0/README-fully-qualified-moc-types.md b/src/checks/level0/README-fully-qualified-moc-types.md index 099044b..43f3405 100644 --- a/src/checks/level0/README-fully-qualified-moc-types.md +++ b/src/checks/level0/README-fully-qualified-moc-types.md @@ -1,23 +1,26 @@ # fully-qualified-moc-types Warns when a signal, slot or invokable declaration is not using fully-qualified type names, which will break old-style connects -and interacting with QML. +and interaction with QML. + +Also warns if a Q_PROPERTY of type gadget is not fully-qualified (Enums and QObjects in Q_PROPERTY don't need +to be fully qualified). Example: namespace MyNameSpace { struct MyType { (...) }; class MyObject : public QObject { Q_OBJECT + Q_PROPERTY(MyGadget myprop READ myprop); // Wrong, needs namespace Q_SIGNALS: void mySignal(MyType); // Wrong void mySignal(MyNameSpace::MyType); // OK }; } -For Q_PROPERTIES it's not implemented yet. Beware that fixing these type names might break user code if they are connecting to them via old style connects, since the users might have worked around your bug and not included the namespace in their connect statement diff --git a/src/checks/level0/fully-qualified-moc-types.cpp b/src/checks/level0/fully-qualified-moc-types.cpp index c2db425..a62a9bb 100644 --- a/src/checks/level0/fully-qualified-moc-types.cpp +++ b/src/checks/level0/fully-qualified-moc-types.cpp @@ -1,73 +1,150 @@ /* This file is part of the clazy static checker. Copyright (C) 2018 Sergio Martins This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "fully-qualified-moc-types.h" #include "Utils.h" #include "HierarchyUtils.h" #include "QtUtils.h" #include "TypeUtils.h" #include "ClazyContext.h" #include "AccessSpecifierManager.h" #include using namespace clang; using namespace std; FullyQualifiedMocTypes::FullyQualifiedMocTypes(const std::string &name, ClazyContext *context) : CheckBase(name, context) { context->enableAccessSpecifierManager(); + enablePreProcessorCallbacks(); } void FullyQualifiedMocTypes::VisitDecl(clang::Decl *decl) { auto method = dyn_cast(decl); if (!method) return; - if (method->isThisDeclarationADefinition() && !method->hasInlineBody()) - return; - AccessSpecifierManager *accessSpecifierManager = m_context->accessSpecifierManager; if (!accessSpecifierManager) return; + if (handleQ_PROPERTY(method)) + return; + + if (method->isThisDeclarationADefinition() && !method->hasInlineBody()) + return; + QtAccessSpecifierType qst = accessSpecifierManager->qtAccessSpecifierType(method); if (qst != QtAccessSpecifier_Signal && qst != QtAccessSpecifier_Slot && qst != QtAccessSpecifier_Invokable) return; for (auto param : method->parameters()) { QualType t = TypeUtils::pointeeQualType(param->getType()); if (!t.isNull()) { std::string typeName = clazy::name(t, lo(), /*asWritten=*/ true); if (typeName == "QPrivateSignal") continue; std::string qualifiedTypeName = clazy::name(t, lo(), /*asWritten=*/ false); if (typeName != qualifiedTypeName) { emitWarning(method, string(accessSpecifierManager->qtAccessSpecifierTypeStr(qst)) + " arguments need to be fully-qualified (" + qualifiedTypeName + " instead of " + typeName + ")"); } } } } + +bool FullyQualifiedMocTypes::isGadget(CXXRecordDecl *record) const +{ + SourceLocation startLoc = record->getLocStart(); + for (const SourceLocation &loc : m_qgadgetMacroLocations) { + if (sm().getFileID(loc) != sm().getFileID(startLoc)) + continue; // Different file + + if (sm().isBeforeInSLocAddrSpace(startLoc, loc) && sm().isBeforeInSLocAddrSpace(loc, record->getLocEnd())) + return true; // We found a Q_GADGET after start and before end, it's ours. + } + return false; +} + +bool FullyQualifiedMocTypes::handleQ_PROPERTY(CXXMethodDecl *method) +{ + if (clazy::name(method) != "qt_static_metacall" || !method->hasBody() || method->getDefinition() != method) + return false; + /** + * Basically diffed a .moc file with and without a namespaced property, + * the difference is one reinterpret_cast, under an if (_c == QMetaObject::ReadProperty), so + * that's what we cheak. + * + * The AST doesn't have the Q_PROPERTIES as they expand to nothing, so we have + * to do it this way. + */ + + auto ifs = clazy::getStatements(method->getBody()); + + for (auto iff : ifs) { + auto bo = dyn_cast(iff->getCond()); + if (!bo) + continue; + + auto enumRefs = clazy::getStatements(bo->getRHS()); + if (enumRefs.size() == 1) { + auto enumerator = dyn_cast(enumRefs.at(0)->getDecl()); + if (enumerator && enumerator->getName() == "ReadProperty") { + auto reinterprets = clazy::getStatements(iff); + for (auto reinterpret : reinterprets) { + QualType qt = TypeUtils::pointeeQualType(reinterpret->getTypeAsWritten()); + auto record = qt->getAsCXXRecordDecl(); + if (!record || !isGadget(record)) + continue; + + string nameAsWritten = clazy::name(qt, lo(), /*asWritten=*/ true); + string fullyQualifiedName = clazy::name(qt, lo(), /*asWritten=*/ false); + if (nameAsWritten != fullyQualifiedName) { + // warn in the cxxrecorddecl, since we don't want to warn in the .moc files. + // Ideally we would do some cross checking with the Q_PROPERTIES, but that's not in the AST + emitWarning(method->getParent()->getLocStart(), "Q_PROPERTY of type " + nameAsWritten + " should use full qualification (" + fullyQualifiedName + ")"); + } + } + return true; + } + } + } + + return true; // true, so processing doesn't continue, it's a qt_static_metacall, nothing interesting here unless the properties above +} + +void FullyQualifiedMocTypes::VisitMacroExpands(const clang::Token &MacroNameTok, + const clang::SourceRange &range, const MacroInfo *) +{ + IdentifierInfo *ii = MacroNameTok.getIdentifierInfo(); + if (ii && ii->getName() == "Q_GADGET") + registerQ_GADGET(range.getBegin()); +} + +void FullyQualifiedMocTypes::registerQ_GADGET(SourceLocation loc) +{ + m_qgadgetMacroLocations.push_back(loc); +} diff --git a/src/checks/level0/fully-qualified-moc-types.h b/src/checks/level0/fully-qualified-moc-types.h index 81102f4..f955d92 100644 --- a/src/checks/level0/fully-qualified-moc-types.h +++ b/src/checks/level0/fully-qualified-moc-types.h @@ -1,37 +1,44 @@ /* This file is part of the clazy static checker. Copyright (C) 2018 Sergio Martins This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef CLAZY_FULLY_QUALIFIED_MOC_TYPES_H #define CLAZY_FULLY_QUALIFIED_MOC_TYPES_H #include "checkbase.h" - +#include /** * See README-fully-qualified-moc-types.md for more info. */ class FullyQualifiedMocTypes : public CheckBase { public: explicit FullyQualifiedMocTypes(const std::string &name, ClazyContext *context); void VisitDecl(clang::Decl *) override; +private: + bool isGadget(clang::CXXRecordDecl *record) const; + bool handleQ_PROPERTY(clang::CXXMethodDecl *); + void VisitMacroExpands(const clang::Token &MacroNameTok, + const clang::SourceRange &range, const clang::MacroInfo *minfo = nullptr) override; + void registerQ_GADGET(clang::SourceLocation); + std::vector m_qgadgetMacroLocations; }; #endif diff --git a/tests/fully-qualified-moc-types/main.cpp b/tests/fully-qualified-moc-types/main.cpp index be86407..3f0859f 100644 --- a/tests/fully-qualified-moc-types/main.cpp +++ b/tests/fully-qualified-moc-types/main.cpp @@ -1,40 +1,62 @@ #include struct A {}; +struct NonNamespacedGadget { + Q_GADGET +}; + namespace NS { struct MyType {}; + + struct NamespacedGadget { + Q_GADGET + }; + + enum EnumFoo { EnumFoo1 }; + class MyObject : public QObject { Q_OBJECT + Q_PROPERTY(NS::MyType foo READ foo) // OK, not gadget + Q_PROPERTY(MyType foo1 READ foo) // OK, not gadget + Q_PROPERTY(EnumFoo enumFoo READ enumFoo CONSTANT) // OK + Q_PROPERTY(NamespacedGadget namespacedGadget READ namespacedGadget CONSTANT) // Warn, gadget + Q_PROPERTY(NS::NamespacedGadget namespacedGadget2 READ namespacedGadget2 CONSTANT) // OK + Q_PROPERTY(NonNamespacedGadget nonNamespacedGadget READ nonNamespacedGadget CONSTANT) // OK Q_SIGNALS: void mysig(NS::MyType); void mysig2(MyType); // Warn void mysig3(NS::MyType); void mysig4(const NS::MyType &); void mysig5(A); void mysig6(const A); void mysig7(const A *); void mysig8(A *); public Q_SLOTS: void myslot1(NS::MyType); void myslot2(MyType); // Warn void myslot3(NS::MyType); void myslot4(const NS::MyType &); void myslot5(A); void myslot6(const A); void myslot7(const A *); void myslot8(A *); public: Q_INVOKABLE void myinvokable1(NS::MyType); Q_INVOKABLE void myinvokable2(MyType); // Warn Q_INVOKABLE void myinvokable3(NS::MyType); Q_INVOKABLE void myinvokable4(const NS::MyType &); Q_INVOKABLE void myinvokable5(A); Q_INVOKABLE void myinvokable6(const A); Q_INVOKABLE void myinvokable7(const A *); Q_INVOKABLE void myinvokable8(A *); + NS::MyType foo(); + NamespacedGadget namespacedGadget() const; + NamespacedGadget namespacedGadget2() const; + NonNamespacedGadget nonNamespacedGadget() const; + EnumFoo enumFoo() const; }; } #include "main.moc_" diff --git a/tests/fully-qualified-moc-types/main.cpp.expected b/tests/fully-qualified-moc-types/main.cpp.expected index 544342b..9fd5279 100644 --- a/tests/fully-qualified-moc-types/main.cpp.expected +++ b/tests/fully-qualified-moc-types/main.cpp.expected @@ -1,3 +1,4 @@ -fully-qualified-moc-types/main.cpp:12:9: warning: signal arguments need to be fully-qualified (NS::MyType instead of MyType) [-Wclazy-fully-qualified-moc-types] -fully-qualified-moc-types/main.cpp:21:9: warning: slot arguments need to be fully-qualified (NS::MyType instead of MyType) [-Wclazy-fully-qualified-moc-types] -fully-qualified-moc-types/main.cpp:30:21: warning: invokable arguments need to be fully-qualified (NS::MyType instead of MyType) [-Wclazy-fully-qualified-moc-types] +fully-qualified-moc-types/main.cpp:29:9: warning: signal arguments need to be fully-qualified (NS::MyType instead of MyType) [-Wclazy-fully-qualified-moc-types] +fully-qualified-moc-types/main.cpp:38:9: warning: slot arguments need to be fully-qualified (NS::MyType instead of MyType) [-Wclazy-fully-qualified-moc-types] +fully-qualified-moc-types/main.cpp:47:21: warning: invokable arguments need to be fully-qualified (NS::MyType instead of MyType) [-Wclazy-fully-qualified-moc-types] +fully-qualified-moc-types/main.cpp:18:5: warning: Q_PROPERTY of type NamespacedGadget should use full qualification (NS::NamespacedGadget) [-Wclazy-fully-qualified-moc-types] diff --git a/tests/fully-qualified-moc-types/main.moc_ b/tests/fully-qualified-moc-types/main.moc_ index a9e7a13..69ae3d0 100644 --- a/tests/fully-qualified-moc-types/main.moc_ +++ b/tests/fully-qualified-moc-types/main.moc_ @@ -1,299 +1,472 @@ /**************************************************************************** ** Meta object code from reading C++ file 'main.cpp' ** -** Created by: The Qt Meta Object Compiler version 67 (Qt 5.9.4) +** Created by: The Qt Meta Object Compiler version 67 (Qt 5.9.5) ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/ #include #include #if !defined(Q_MOC_OUTPUT_REVISION) #error "The header file 'main.cpp' doesn't include ." #elif Q_MOC_OUTPUT_REVISION != 67 -#error "This file was generated using the moc from 5.9.4. It" +#error "This file was generated using the moc from 5.9.5. It" #error "cannot be used with the include files from this version of Qt." #error "(The moc has changed too much.)" #endif QT_BEGIN_MOC_NAMESPACE QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED +struct qt_meta_stringdata_NonNamespacedGadget_t { + QByteArrayData data[1]; + char stringdata0[20]; +}; +#define QT_MOC_LITERAL(idx, ofs, len) \ + Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ + qptrdiff(offsetof(qt_meta_stringdata_NonNamespacedGadget_t, stringdata0) + ofs \ + - idx * sizeof(QByteArrayData)) \ + ) +static const qt_meta_stringdata_NonNamespacedGadget_t qt_meta_stringdata_NonNamespacedGadget = { + { +QT_MOC_LITERAL(0, 0, 19) // "NonNamespacedGadget" + + }, + "NonNamespacedGadget" +}; +#undef QT_MOC_LITERAL + +static const uint qt_meta_data_NonNamespacedGadget[] = { + + // content: + 7, // revision + 0, // classname + 0, 0, // classinfo + 0, 0, // methods + 0, 0, // properties + 0, 0, // enums/sets + 0, 0, // constructors + 4, // flags + 0, // signalCount + + 0 // eod +}; + +const QMetaObject NonNamespacedGadget::staticMetaObject = { + { nullptr, qt_meta_stringdata_NonNamespacedGadget.data, + qt_meta_data_NonNamespacedGadget, nullptr, nullptr, nullptr} +}; + +struct qt_meta_stringdata_NS__NamespacedGadget_t { + QByteArrayData data[1]; + char stringdata0[21]; +}; +#define QT_MOC_LITERAL(idx, ofs, len) \ + Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ + qptrdiff(offsetof(qt_meta_stringdata_NS__NamespacedGadget_t, stringdata0) + ofs \ + - idx * sizeof(QByteArrayData)) \ + ) +static const qt_meta_stringdata_NS__NamespacedGadget_t qt_meta_stringdata_NS__NamespacedGadget = { + { +QT_MOC_LITERAL(0, 0, 20) // "NS::NamespacedGadget" + + }, + "NS::NamespacedGadget" +}; +#undef QT_MOC_LITERAL + +static const uint qt_meta_data_NS__NamespacedGadget[] = { + + // content: + 7, // revision + 0, // classname + 0, 0, // classinfo + 0, 0, // methods + 0, 0, // properties + 0, 0, // enums/sets + 0, 0, // constructors + 4, // flags + 0, // signalCount + + 0 // eod +}; + +const QMetaObject NS::NamespacedGadget::staticMetaObject = { + { nullptr, qt_meta_stringdata_NS__NamespacedGadget.data, + qt_meta_data_NS__NamespacedGadget, nullptr, nullptr, nullptr} +}; + struct qt_meta_stringdata_NS__MyObject_t { - QByteArrayData data[23]; - char stringdata0[165]; + QByteArrayData data[41]; + char stringdata0[407]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ qptrdiff(offsetof(qt_meta_stringdata_NS__MyObject_t, stringdata0) + ofs \ - idx * sizeof(QByteArrayData)) \ ) static const qt_meta_stringdata_NS__MyObject_t qt_meta_stringdata_NS__MyObject = { { QT_MOC_LITERAL(0, 0, 12), // "NS::MyObject" QT_MOC_LITERAL(1, 13, 5), // "mysig" QT_MOC_LITERAL(2, 19, 0), // "" QT_MOC_LITERAL(3, 20, 10), // "NS::MyType" QT_MOC_LITERAL(4, 31, 6), // "mysig2" QT_MOC_LITERAL(5, 38, 6), // "MyType" QT_MOC_LITERAL(6, 45, 6), // "mysig3" QT_MOC_LITERAL(7, 52, 6), // "mysig4" QT_MOC_LITERAL(8, 59, 6), // "mysig5" QT_MOC_LITERAL(9, 66, 1), // "A" QT_MOC_LITERAL(10, 68, 6), // "mysig6" QT_MOC_LITERAL(11, 75, 6), // "mysig7" QT_MOC_LITERAL(12, 82, 8), // "const A*" QT_MOC_LITERAL(13, 91, 6), // "mysig8" QT_MOC_LITERAL(14, 98, 2), // "A*" QT_MOC_LITERAL(15, 101, 7), // "myslot1" QT_MOC_LITERAL(16, 109, 7), // "myslot2" QT_MOC_LITERAL(17, 117, 7), // "myslot3" QT_MOC_LITERAL(18, 125, 7), // "myslot4" QT_MOC_LITERAL(19, 133, 7), // "myslot5" QT_MOC_LITERAL(20, 141, 7), // "myslot6" QT_MOC_LITERAL(21, 149, 7), // "myslot7" -QT_MOC_LITERAL(22, 157, 7) // "myslot8" +QT_MOC_LITERAL(22, 157, 7), // "myslot8" +QT_MOC_LITERAL(23, 165, 12), // "myinvokable1" +QT_MOC_LITERAL(24, 178, 12), // "myinvokable2" +QT_MOC_LITERAL(25, 191, 12), // "myinvokable3" +QT_MOC_LITERAL(26, 204, 12), // "myinvokable4" +QT_MOC_LITERAL(27, 217, 12), // "myinvokable5" +QT_MOC_LITERAL(28, 230, 12), // "myinvokable6" +QT_MOC_LITERAL(29, 243, 12), // "myinvokable7" +QT_MOC_LITERAL(30, 256, 12), // "myinvokable8" +QT_MOC_LITERAL(31, 269, 3), // "foo" +QT_MOC_LITERAL(32, 273, 4), // "foo1" +QT_MOC_LITERAL(33, 278, 7), // "enumFoo" +QT_MOC_LITERAL(34, 286, 7), // "EnumFoo" +QT_MOC_LITERAL(35, 294, 16), // "namespacedGadget" +QT_MOC_LITERAL(36, 311, 16), // "NamespacedGadget" +QT_MOC_LITERAL(37, 328, 17), // "namespacedGadget2" +QT_MOC_LITERAL(38, 346, 20), // "NS::NamespacedGadget" +QT_MOC_LITERAL(39, 367, 19), // "nonNamespacedGadget" +QT_MOC_LITERAL(40, 387, 19) // "NonNamespacedGadget" }, "NS::MyObject\0mysig\0\0NS::MyType\0mysig2\0" "MyType\0mysig3\0mysig4\0mysig5\0A\0mysig6\0" "mysig7\0const A*\0mysig8\0A*\0myslot1\0" "myslot2\0myslot3\0myslot4\0myslot5\0myslot6\0" - "myslot7\0myslot8" + "myslot7\0myslot8\0myinvokable1\0myinvokable2\0" + "myinvokable3\0myinvokable4\0myinvokable5\0" + "myinvokable6\0myinvokable7\0myinvokable8\0" + "foo\0foo1\0enumFoo\0EnumFoo\0namespacedGadget\0" + "NamespacedGadget\0namespacedGadget2\0" + "NS::NamespacedGadget\0nonNamespacedGadget\0" + "NonNamespacedGadget" }; #undef QT_MOC_LITERAL static const uint qt_meta_data_NS__MyObject[] = { // content: 7, // revision 0, // classname 0, 0, // classinfo - 16, 14, // methods - 0, 0, // properties + 24, 14, // methods + 6, 206, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags 8, // signalCount // signals: name, argc, parameters, tag, flags - 1, 1, 94, 2, 0x06 /* Public */, - 4, 1, 97, 2, 0x06 /* Public */, - 6, 1, 100, 2, 0x06 /* Public */, - 7, 1, 103, 2, 0x06 /* Public */, - 8, 1, 106, 2, 0x06 /* Public */, - 10, 1, 109, 2, 0x06 /* Public */, - 11, 1, 112, 2, 0x06 /* Public */, - 13, 1, 115, 2, 0x06 /* Public */, + 1, 1, 134, 2, 0x06 /* Public */, + 4, 1, 137, 2, 0x06 /* Public */, + 6, 1, 140, 2, 0x06 /* Public */, + 7, 1, 143, 2, 0x06 /* Public */, + 8, 1, 146, 2, 0x06 /* Public */, + 10, 1, 149, 2, 0x06 /* Public */, + 11, 1, 152, 2, 0x06 /* Public */, + 13, 1, 155, 2, 0x06 /* Public */, // slots: name, argc, parameters, tag, flags - 15, 1, 118, 2, 0x0a /* Public */, - 16, 1, 121, 2, 0x0a /* Public */, - 17, 1, 124, 2, 0x0a /* Public */, - 18, 1, 127, 2, 0x0a /* Public */, - 19, 1, 130, 2, 0x0a /* Public */, - 20, 1, 133, 2, 0x0a /* Public */, - 21, 1, 136, 2, 0x0a /* Public */, - 22, 1, 139, 2, 0x0a /* Public */, + 15, 1, 158, 2, 0x0a /* Public */, + 16, 1, 161, 2, 0x0a /* Public */, + 17, 1, 164, 2, 0x0a /* Public */, + 18, 1, 167, 2, 0x0a /* Public */, + 19, 1, 170, 2, 0x0a /* Public */, + 20, 1, 173, 2, 0x0a /* Public */, + 21, 1, 176, 2, 0x0a /* Public */, + 22, 1, 179, 2, 0x0a /* Public */, + + // methods: name, argc, parameters, tag, flags + 23, 1, 182, 2, 0x02 /* Public */, + 24, 1, 185, 2, 0x02 /* Public */, + 25, 1, 188, 2, 0x02 /* Public */, + 26, 1, 191, 2, 0x02 /* Public */, + 27, 1, 194, 2, 0x02 /* Public */, + 28, 1, 197, 2, 0x02 /* Public */, + 29, 1, 200, 2, 0x02 /* Public */, + 30, 1, 203, 2, 0x02 /* Public */, // signals: parameters QMetaType::Void, 0x80000000 | 3, 2, QMetaType::Void, 0x80000000 | 5, 2, QMetaType::Void, 0x80000000 | 3, 2, QMetaType::Void, 0x80000000 | 3, 2, QMetaType::Void, 0x80000000 | 9, 2, QMetaType::Void, 0x80000000 | 9, 2, QMetaType::Void, 0x80000000 | 12, 2, QMetaType::Void, 0x80000000 | 14, 2, // slots: parameters QMetaType::Void, 0x80000000 | 3, 2, QMetaType::Void, 0x80000000 | 5, 2, QMetaType::Void, 0x80000000 | 3, 2, QMetaType::Void, 0x80000000 | 3, 2, QMetaType::Void, 0x80000000 | 9, 2, QMetaType::Void, 0x80000000 | 9, 2, QMetaType::Void, 0x80000000 | 12, 2, QMetaType::Void, 0x80000000 | 14, 2, + // methods: parameters + QMetaType::Void, 0x80000000 | 3, 2, + QMetaType::Void, 0x80000000 | 5, 2, + QMetaType::Void, 0x80000000 | 3, 2, + QMetaType::Void, 0x80000000 | 3, 2, + QMetaType::Void, 0x80000000 | 9, 2, + QMetaType::Void, 0x80000000 | 9, 2, + QMetaType::Void, 0x80000000 | 12, 2, + QMetaType::Void, 0x80000000 | 14, 2, + + // properties: name, type, flags + 31, 0x80000000 | 3, 0x00095009, + 32, 0x80000000 | 5, 0x00095009, + 33, 0x80000000 | 34, 0x00095409, + 35, 0x80000000 | 36, 0x00095409, + 37, 0x80000000 | 38, 0x00095409, + 39, 0x80000000 | 40, 0x00095409, + 0 // eod }; void NS::MyObject::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { if (_c == QMetaObject::InvokeMetaMethod) { MyObject *_t = static_cast(_o); Q_UNUSED(_t) switch (_id) { case 0: _t->mysig((*reinterpret_cast< NS::MyType(*)>(_a[1]))); break; case 1: _t->mysig2((*reinterpret_cast< MyType(*)>(_a[1]))); break; case 2: _t->mysig3((*reinterpret_cast< NS::MyType(*)>(_a[1]))); break; case 3: _t->mysig4((*reinterpret_cast< const NS::MyType(*)>(_a[1]))); break; case 4: _t->mysig5((*reinterpret_cast< A(*)>(_a[1]))); break; case 5: _t->mysig6((*reinterpret_cast< const A(*)>(_a[1]))); break; case 6: _t->mysig7((*reinterpret_cast< const A*(*)>(_a[1]))); break; case 7: _t->mysig8((*reinterpret_cast< A*(*)>(_a[1]))); break; case 8: _t->myslot1((*reinterpret_cast< NS::MyType(*)>(_a[1]))); break; case 9: _t->myslot2((*reinterpret_cast< MyType(*)>(_a[1]))); break; case 10: _t->myslot3((*reinterpret_cast< NS::MyType(*)>(_a[1]))); break; case 11: _t->myslot4((*reinterpret_cast< const NS::MyType(*)>(_a[1]))); break; case 12: _t->myslot5((*reinterpret_cast< A(*)>(_a[1]))); break; case 13: _t->myslot6((*reinterpret_cast< const A(*)>(_a[1]))); break; case 14: _t->myslot7((*reinterpret_cast< const A*(*)>(_a[1]))); break; case 15: _t->myslot8((*reinterpret_cast< A*(*)>(_a[1]))); break; + case 16: _t->myinvokable1((*reinterpret_cast< NS::MyType(*)>(_a[1]))); break; + case 17: _t->myinvokable2((*reinterpret_cast< MyType(*)>(_a[1]))); break; + case 18: _t->myinvokable3((*reinterpret_cast< NS::MyType(*)>(_a[1]))); break; + case 19: _t->myinvokable4((*reinterpret_cast< const NS::MyType(*)>(_a[1]))); break; + case 20: _t->myinvokable5((*reinterpret_cast< A(*)>(_a[1]))); break; + case 21: _t->myinvokable6((*reinterpret_cast< const A(*)>(_a[1]))); break; + case 22: _t->myinvokable7((*reinterpret_cast< const A*(*)>(_a[1]))); break; + case 23: _t->myinvokable8((*reinterpret_cast< A*(*)>(_a[1]))); break; default: ; } } else if (_c == QMetaObject::IndexOfMethod) { int *result = reinterpret_cast(_a[0]); { typedef void (MyObject::*_t)(NS::MyType ); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&MyObject::mysig)) { *result = 0; return; } } { typedef void (MyObject::*_t)(MyType ); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&MyObject::mysig2)) { *result = 1; return; } } { typedef void (MyObject::*_t)(NS::MyType ); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&MyObject::mysig3)) { *result = 2; return; } } { typedef void (MyObject::*_t)(const NS::MyType & ); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&MyObject::mysig4)) { *result = 3; return; } } { typedef void (MyObject::*_t)(A ); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&MyObject::mysig5)) { *result = 4; return; } } { typedef void (MyObject::*_t)(const A ); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&MyObject::mysig6)) { *result = 5; return; } } { typedef void (MyObject::*_t)(const A * ); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&MyObject::mysig7)) { *result = 6; return; } } { typedef void (MyObject::*_t)(A * ); if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&MyObject::mysig8)) { *result = 7; return; } } } +#ifndef QT_NO_PROPERTIES + else if (_c == QMetaObject::ReadProperty) { + MyObject *_t = static_cast(_o); + Q_UNUSED(_t) + void *_v = _a[0]; + switch (_id) { + case 0: *reinterpret_cast< NS::MyType*>(_v) = _t->foo(); break; + case 1: *reinterpret_cast< MyType*>(_v) = _t->foo(); break; + case 2: *reinterpret_cast< EnumFoo*>(_v) = _t->enumFoo(); break; + case 3: *reinterpret_cast< NamespacedGadget*>(_v) = _t->namespacedGadget(); break; + case 4: *reinterpret_cast< NS::NamespacedGadget*>(_v) = _t->namespacedGadget2(); break; + case 5: *reinterpret_cast< NonNamespacedGadget*>(_v) = _t->nonNamespacedGadget(); break; + default: break; + } + } else if (_c == QMetaObject::WriteProperty) { + } else if (_c == QMetaObject::ResetProperty) { + } +#endif // QT_NO_PROPERTIES } const QMetaObject NS::MyObject::staticMetaObject = { { &QObject::staticMetaObject, qt_meta_stringdata_NS__MyObject.data, qt_meta_data_NS__MyObject, qt_static_metacall, nullptr, nullptr} }; const QMetaObject *NS::MyObject::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; } void *NS::MyObject::qt_metacast(const char *_clname) { if (!_clname) return nullptr; if (!strcmp(_clname, qt_meta_stringdata_NS__MyObject.stringdata0)) return static_cast(this); return QObject::qt_metacast(_clname); } int NS::MyObject::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { - if (_id < 16) + if (_id < 24) qt_static_metacall(this, _c, _id, _a); - _id -= 16; + _id -= 24; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { - if (_id < 16) + if (_id < 24) *reinterpret_cast(_a[0]) = -1; - _id -= 16; + _id -= 24; + } +#ifndef QT_NO_PROPERTIES + else if (_c == QMetaObject::ReadProperty || _c == QMetaObject::WriteProperty + || _c == QMetaObject::ResetProperty || _c == QMetaObject::RegisterPropertyMetaType) { + qt_static_metacall(this, _c, _id, _a); + _id -= 6; + } else if (_c == QMetaObject::QueryPropertyDesignable) { + _id -= 6; + } else if (_c == QMetaObject::QueryPropertyScriptable) { + _id -= 6; + } else if (_c == QMetaObject::QueryPropertyStored) { + _id -= 6; + } else if (_c == QMetaObject::QueryPropertyEditable) { + _id -= 6; + } else if (_c == QMetaObject::QueryPropertyUser) { + _id -= 6; } +#endif // QT_NO_PROPERTIES return _id; } // SIGNAL 0 void NS::MyObject::mysig(NS::MyType _t1) { void *_a[] = { nullptr, const_cast(reinterpret_cast(&_t1)) }; QMetaObject::activate(this, &staticMetaObject, 0, _a); } // SIGNAL 1 void NS::MyObject::mysig2(MyType _t1) { void *_a[] = { nullptr, const_cast(reinterpret_cast(&_t1)) }; QMetaObject::activate(this, &staticMetaObject, 1, _a); } // SIGNAL 2 void NS::MyObject::mysig3(NS::MyType _t1) { void *_a[] = { nullptr, const_cast(reinterpret_cast(&_t1)) }; QMetaObject::activate(this, &staticMetaObject, 2, _a); } // SIGNAL 3 void NS::MyObject::mysig4(const NS::MyType & _t1) { void *_a[] = { nullptr, const_cast(reinterpret_cast(&_t1)) }; QMetaObject::activate(this, &staticMetaObject, 3, _a); } // SIGNAL 4 void NS::MyObject::mysig5(A _t1) { void *_a[] = { nullptr, const_cast(reinterpret_cast(&_t1)) }; QMetaObject::activate(this, &staticMetaObject, 4, _a); } // SIGNAL 5 void NS::MyObject::mysig6(const A _t1) { void *_a[] = { nullptr, const_cast(reinterpret_cast(&_t1)) }; QMetaObject::activate(this, &staticMetaObject, 5, _a); } // SIGNAL 6 void NS::MyObject::mysig7(const A * _t1) { void *_a[] = { nullptr, const_cast(reinterpret_cast(&_t1)) }; QMetaObject::activate(this, &staticMetaObject, 6, _a); } // SIGNAL 7 void NS::MyObject::mysig8(A * _t1) { void *_a[] = { nullptr, const_cast(reinterpret_cast(&_t1)) }; QMetaObject::activate(this, &staticMetaObject, 7, _a); } QT_WARNING_POP QT_END_MOC_NAMESPACE