summaryrefslogtreecommitdiffstats
path: root/src/tools/moc/moc.h
Commit message (Collapse)AuthorAgeFilesLines
* moc: store the FQN in JSON superClass objectsMarc Mutz2024-01-261-0/+3
| | | | | | | | | | | Tooling can then use this information to find the correct base class, even absent C++ scoping information. Pick-to: 6.7 6.6 6.5 Task-number: QTBUG-101141 Change-Id: I5350da8d2d9aaf5ec86027357131ebac1eb50372 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Dissociate QTypeRevision from QVersionNumberMarc Mutz2024-01-101-1/+1
| | | | | | | | | | | | | | | | They have nothing to do with each other, so give QTypeRevision its own header and implementation file instead of piggy-backing on QVersionNumber's. Picking back to current LTS to incur the merge conflict only once, not per (expected) follow-up change. Amends ed080c64ae21d22115d16780a5903d7cc4fd1546. Pick-to: 6.7 6.6 6.5 Change-Id: I2fa5d0e68f95864126bc95e3d8154134eee85553 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* moc: port from pair<> to a struct SuperClassMarc Mutz2023-12-131-2/+7
| | | | | | | | | | | | ... with properly-named members. This is in preparation of adding a new member in order to fix QTBUG-101141 (namespaced base classes). Pick-to: 6.7 6.6 6.5 Task-number: QTBUG-101141 Change-Id: I2309e425ac94ad275b54a898fd33a2891e5d1453 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Moc: port to qsizetypeAhmad Samir2023-06-201-3/+3
| | | | | | | Pick-to: 6.6 6.5 Change-Id: Ibacc9b4bd6c26b890a09f689c730286c2aa0894c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Moc: fix generated code for nested enum class corner caseAhmad Samir2023-06-181-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes an issue with generated code where the name of an enclosing namespace is identical to an enum class type, when Q_ENUM_NS is used. Consider: namespace a { Q_NAMESPACE namespace b { enum class b { Key, Key2 }; Q_ENUM_NS(b); } } moc generated code such as: Q_CONSTINIT const QMetaObject a::b::staticMetaObject = { { ... qt_incomplete_metaTypeArray<qt_meta_stringdata_CLASSaSCOPEbENDCLASS_t, // enum 'TestEnum' QtPrivate::TypeAndForceComplete<b::b, std::true_type>, // Q_OBJECT / Q_GADGET QtPrivate::TypeAndForceComplete<void, std::true_type> >, nullptr } }; which confused the compiler: error: ‘b’ is not a member of ‘a::b::b 83 | QtPrivate::TypeAndForceComplete<b::b, std::true_type>, Fixes: QTBUG-112996 Pick-to: 6.6 Change-Id: I37aee83c32efe96cc9d6c2bd0bdb9ba80bb7b8a7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* moc: Handle attributes after meta-method tagFabian Kosmale2023-06-161-0/+1
| | | | | | | | | | | | | | We so far only handled them if they came at the very start of the method declaration. This patch ensures that we also handle them after the meta-method tag (but before the actual type). Unifying parseFunction and parseMaybeFunction to avoid the need to munally keep them in sync is left for another day. Fixes: QTBUG-111330 Pick-to: 6.6 6.5 6.5.2 6.2 Change-Id: Ic94edb69f04b9150aea2c8e6d004a8b9e5cf12ec Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Moc: check sizes of specific member QLists are within INT_MAX rangeAhmad Samir2023-06-061-0/+2
| | | | | | | | | | | | | | Parts of the public API, e.g. QMetaMethod::methodIndex and similar functions return int, and other parts of the code expect int values, at least for Qt6 this can't be changed, so use qsizetype internally and assert the values fit in an int. As pointed out in code review, not many people will build moc in debug mode, so asserts aren't that useful here. Instead print error messages and exit, like is already done in other parts of the code. Change-Id: Id305165caa996c899f30770a757098fe2f9a96f6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Moc: fix some narrowing conversion warnings by using reverse iteratorsAhmad Samir2023-05-181-0/+2
| | | | | | | | And de-duplicating some code. Pick-to: 6.5 Change-Id: Ibfb581cd296a120ff8328ae672020cc36ca5d328 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* moc: Record types of enumerationsUlf Hermann2023-03-311-0/+1
| | | | | | | | | | | This will be helpful in a number of places, in particular in order to support enums of different sizes in QML. We record the type as string in the JSON output and as QMetaTypeInterface in the generated C++. Task-number: QTBUG-112180 Change-Id: I943fac67f8b25b013d3860301416cdd293c0c69e Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* moc: Allow anonymous propertiesUlf Hermann2023-03-161-3/+9
| | | | | | | | | | | | This is private for now. It's very handy to have anonymous properties for the QML model/delegate adaptors. There are models with only "singular" model data that doesn't have any sub-properties. Such model data should be available from the model object via an empty string as role. This way we can get rid of a lot of special casing. Task-number: QTBUG-104752 Change-Id: I229e355a7cab064ee1c9f89557bc0244a5d0c90a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtMiscUtils: add missing toAsciiUpper(), use it in mocMarc Mutz2022-12-181-2/+3
| | | | | | | | | | | | | | | | | | | | | | ... to make moc code locale-independent. The C toupper function is locale-dependent. Given the right locale (Türkiye, e.g.), toupper('i') is either - İ (LATIN CAPITAL LETTER I WITH DOT ABOVE; if representable) or - i (unchanged; if it isn't) Both results are wrong for the present use-case. Fix by adding QtMiscTools::toAsciiUpper(), complementing existing toAsciiLower(), and using that. It's private API, but moc.h, despite the name, is not a public header. Pick-to: 6.5 6.4 6.2 5.15 Task-number: QTBUG-109235 Change-Id: Iaf071ba2113b672aa0aed3da6a4e1d47fb659365 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Port from container.count()/length() to size()Marc Mutz2022-10-041-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is semantic patch using ClangTidyTransformator: auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o) makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'. <classes> are: // sequential: "QByteArray", "QList", "QQueue", "QStack", "QString", "QVarLengthArray", "QVector", // associative: "QHash", "QMultiHash", "QMap", "QMultiMap", "QSet", // Qt has no QMultiSet Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-27/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* moc: Add relative property index to JSON output of PropertyDefAndrei Golubev2021-06-021-1/+2
| | | | | | | | Needed for QML compiler to know property index of C++ type at compile time without going through QMetaObject::indexOfProperty Change-Id: I404e71d6071d36812661df17d12b879a8dcbd146 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Replace discouraged Q_MOVABLE_TYPE by Q_RELOCATABLE_TYPEAndreas Buhr2020-11-301-10/+10
| | | | | | | | | | | | | | Q_MOVABLE_TYPE was conceived before C++ had move semantics. Now, with move semantics, its name is misleading. Q_RELOCATABLE_TYPE was introduced as a synonym to Q_MOVABLE_TYPE. Usage of Q_MOVABLE_TYPE is discouraged now. This patch replaces all usages of Q_MOVABLE_TYPE by Q_RELOCATABLE_TYPE in QtBase. As the two are synonymous, this patch should have no impact on users. Pick-to: 6.0 Change-Id: Ie653984363198c1aeb1f70f8e0fa189aae38eb5c Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Enforce complete method types of QML registered classesFabian Kosmale2020-09-031-1/+4
| | | | | | | | | | | For QML, we like to avoid doing string to type lookups at runtime as much as possible. Therefore, QML registration macros like QML_ELEMENT now cause moc to require complete types not only for properties, but also for all methods known to the metatype system. Change-Id: Ied3d940c102719db4852d3a748d05be1f415b353 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Make bindings introspectable through mocLars Knoll2020-09-021-2/+1
| | | | | | | | | | | | | | | Add a new BINDABLE declaration to the Q_PROPERTY() macro that tells moc where to find the QBindable for the property. Add a QUntypedBindable base class to QBindable<T> that gives access to generic functionality and checks argument compatibility at runtime. QBindable<T> will still do static checking at compile time. Add QMetaProperty::isBindable() and QMetaProperty::bindable() to be able to dynamically access the binding functionality. Change-Id: Ic7b08ae2cde83fd43e627d813a886e1de01fa3dc Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove QNotifiedProperty and Q_PRIVATE_QPROPERTYLars Knoll2020-09-021-7/+1
| | | | | | | | | | | | | And all related functionality. This is being replaced by Q_BINDABLE_PROPERTY and Q_OBJECT_BINDABLE_PROPERTY in the next few commits. The new infrastructure coming will play nicer along with the existing property system. Commented out some autotests, that will get reimplemented with the updated infrastructure. Change-Id: I50c30bd4d5c6c6b6471f8eb93870e27d86f5a009 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* moc: allow wrapper generation for QProperty in pimpl classFabian Kosmale2020-07-141-0/+1
| | | | | | | | | | | Previously, only QNotifiedProperty was supported. As moc cannot determine by itself whether the backing property is a QProperty or a QNotifiedProperty, allow NOTIFY false to indicate that it is a plain QProperty. For symmetry, NOTIFY true is also allowed and means that the backing property is a QNotifiedProperty. Change-Id: I66f3105c976ef084198ce8658bc07499a3cb1cd8 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* moc: Allow out-of-line storage for Q_PRIVATE_QPROPERTYUlf Hermann2020-07-081-0/+1
| | | | | | | | | | If you pass "STORED false" the name is interpreted as function to be invoked in order to access the property. This allows storage of a property in a lazily allocated data type. Change-Id: I4d3a9cac6985c6419ce687868cb74b91921595a6 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* moc: Fix QProperty code generationFabian Kosmale2020-06-251-1/+1
| | | | | | | | | | | | | | | | This addresses two issues: 1. The generated code for QNotifiedProperty<T, ...> was broken when T is a pointer. Notably, const S* & is not a constant reference to S*. This is addressed by consistently using T const& instead of const T&. 2. The Q_PRIVATE_QPROPERTY approach assumed that the property name and the getter are equal. This does break when they are not, and we are unable to change either of them due to API compatibility concerns. An example of this would be QQuickItem's parent property with a parentItem getter. Therefore, we now allow the usage of NAME to override the name of the property. Change-Id: Idf2e85576c74371b5b0f6db15dbe6f2d17c5e33d Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Use QList instead of QVector in mocJarek Kobus2020-06-221-16/+16
| | | | | | Task-number: QTBUG-84469 Change-Id: Id95a656e6277a7c348c02c3267a45ac176c1643b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Add support for QNotifiedProperty to the mocSimon Hausmann2020-06-181-1/+2
| | | | | | | | | | | Change the meaning of Q_PRIVATE_QPROPERTY to imply that the property is implemented using a QNotifiedProperty. That requires passing the owner object instance to the value and binding setters. Similarly, detect QNotifiedProperty members like QProperty. Change-Id: If49bbb04c8ccd4a661973888c50d2d556c25034f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Get rid of the obsolete isEditable flag for propertiesLars Knoll2020-06-111-1/+1
| | | | | | Change-Id: I54411bd8e223671523c9c8fad5c80bfa6b5b7097 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Cleanups in QMetaPropertyFabian Kosmale2020-06-111-2/+0
| | | | | | | | | This changes the layout of the meta object data, so also bump the meta object revision. Original-patch-by: Lars Knoll <lars.knoll@qt.io> Change-Id: I176fb16c207e8ebe59e358e69554be813406232f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* MetaObject: Store the QMetaType of the methodsFabian Kosmale2020-06-021-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | This does the analog of 46f407126ef3e94d59254012cdc34d6a4ad2faf2 for the methods we care about (signals, slots, Q_INVOKABLEs). In addition to the actual QMetaType, we store an array with offsets so that we later can do a mapping from methodIndex to metatype. The newly added QMetaMethod::{return,parameter}MetaType methods can then be used to retrieve the metatypes. This does however require that all involved types are complete. This is unfortunately not a feasible requirement. Thus, we only populate the metatype array on a best effort basis. For any incomplete type, we store QMetaType::Unknown. Then, when accessing the metatype, we fall back to the old string based code base if it's Unknown. Squashes "moc: support incomplete types" and "Fix compile failures after QMetaMethod change" Fixes: QTBUG-82932 Change-Id: I6b7a587cc364b7cad0c158d6de54e8a204289ad4 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Provide a way of exposing private QProperties with a fake APISimon Hausmann2020-04-301-0/+12
| | | | | | | | | | | | The API reduces the amount of manual plumbing required to offer a conceptual property through the traditional setter/getter API as well as through QProperty<T> API. Since the latter would require inlining the type and thus making it impossible to add new properties without breaking binary compatibility, this patch introduces a fake API that behaves similar but does not contain the property by value. Change-Id: Ib9bccd867f0e4e36a520e5583ba348e728284253 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Add support for exposing public QProperty members in the meta-object systemSimon Hausmann2020-03-181-0/+5
| | | | | | | | | | At the moment this makes the type as well as the setter/getter available through the meta-call as well as the ability to register observers and bindings. Only QProperty members that are annotated with Q_PROPERTY(type name) are made public through the meta-object. Change-Id: I16b98fd318122c722b85ce61e39975284e0c2404 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-02-261-0/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: examples/network/bearermonitor/CMakeLists.txt examples/network/CMakeLists.txt src/corelib/tools/qlinkedlist.h src/sql/kernel/qsqldriver_p.h src/sql/kernel/qsqlresult_p.h src/widgets/kernel/qwidget.cpp src/widgets/kernel/qwidget_p.h tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp tests/auto/tools/moc/allmocs_baseline_in.json Change-Id: I21a3c34570ae79ea9d30107fae71759d7eac17d9
| * moc: Record whether a meta object is an object, gadget, or namespaceUlf Hermann2020-02-131-0/+1
| | | | | | | | | | | | | | | | | | | | So far, objects had no identification, and both gadgets and namespaces were called "gadget". qmltyperegistrar, however, is especially interested in the distinction between namespaces and anything else. Task-number: QTBUG-68796 Change-Id: Ic5739727bdef7766de6e535c6568920198fadb2b Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | moc: Extend revision markers to allow for major and minor versionUlf Hermann2020-02-071-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | As we want Qt's own revisions to follow the Qt versioning scheme, we need to allow for the minor version to reset to 0 now. In order to facilitate this, we interpret the argument passed the current Q_REVISION macro as major version and allow for an optional minor version. Both are encoded it into the resulting revision number. Change-Id: I3519fe20233d473f34a24ec9589d045cdd162a12 Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-01-281-0/+1
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qsettings.cpp src/corelib/kernel/qvariant.cpp src/corelib/serialization/qjsoncbor.cpp src/corelib/serialization/qjsonvalue.cpp src/corelib/tools/tools.pri src/gui/image/qimage.cpp src/gui/kernel/qguivariant.cpp src/widgets/kernel/qshortcut.cpp tests/auto/tools/moc/allmocs_baseline_in.json tests/auto/tools/moc/tst_moc.cpp src/opengl/qglframebufferobject.cpp Done-With: Edward Welbourne <edward.welbourne@qt.io> Done-With: Leander Beernaert <leander.beernaert@qt.io> Change-Id: Ie7f5fa646c607fe70c314bf7195f7578ded1d271
| * Introduce Q_PROPERTY attribute REQUIREDFabian Kosmale2020-01-231-0/+1
| | | | | | | | | | | | | | | | This is meant to correspond to required properties in QML. Change-Id: I2645981e13f7423bc86b48370c165b3cfe2aaa62 Task-number: QTBUG-81561 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | Introduce Q_MOC_INCLUDEOlivier Goffart2020-01-171-0/+1
| | | | | | | | | | | | | | | | A new macro that can be added in the header file parsed by moc to tell moc to include that file in the generated file Change-Id: I03ad702c3fcd8380371015f226ee4b7456daf132 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge remote-tracking branch 'origin/5.15' into devLiang Qi2020-01-041-0/+1
|\| | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/tools/qvector.h Make QVector(DataPointer dd) public to be able to properly merge 5b4b437b30b320e2cd7c9a566999a39772e5d431 from 5.15 into dev. src/widgets/kernel/qapplication.cpp tests/auto/tools/moc/allmocs_baseline_in.json Done-With: Christian Ehrlicher <ch.ehrlicher@gmx.de> Change-Id: I929ba7c036d570382d0454c2c75f6f0d96ddbc01
| * Teach moc to output a Make-style depfileAlexandru Croitor2019-12-171-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If moc is invoked with the --output-dep-file option, it will generate a "moc_<source_file_name>.d" dep file which contains dependency entries that can be consumed by a Makefile / Ninja build system. This is useful for build tools (like CMake) to know when moc should be re-ran. In the future, it might also be useful for ccache (teach ccache not to re-run moc when not necessary). The dependency list contains: the original source file, the passed --include files (like moc_predefs.h), the include files that were discovered while preprocessing the source file, and the plugin metadata json files listed in Q_PLUGIN_METADATA macros. The file paths are encoded using QFile::encodeName, so using the local 8-bit encoding. The paths are also escaped (so ' ' replaced by '\ ', '$' by '$$', etc) according to the Make-style rules as described in clang's dep file generator https://github.com/llvm/llvm-project/blob/release/9.x/clang/lib/Frontend/DependencyFile.cpp#L233 For reference, the equivalent Ninja depfile parser source code can be found at https://github.com/ninja-build/ninja/blob/v1.9.0/src/depfile_parser.in.cc#L37 Additional options that can be passed: --dep-file-path - to change the location where the dep file should be generated. --dep-file-rule-name - to change the rule name (first line) of the dep file (useful when no -o option is specified, so output goes to stdout). Encoding story. Note that moc doesn't handle non-local-8-bit characters properly when processing include directives at the preprocessor step. Specifically the content of the main input file is read as a raw byte array (which can be UTF-8 encoded) and then each include directive is resolved via Preprocessor::resolveInclude(), which calls QString::fromLocal8Bit(). Because moc uses the QtBootstrap library, only a limited set of codecs are available: various UTF 8 / 16 / 32 codecs and QLatin1Codec (ISO-8859-15). This means that on Windows, if the source input file is UTF-8 encoded, and contains include names with UTF-8 characters (like an emoji or any character >= 127 that is not in the QLatin1 codec), moc will fail to resolve and process that include, and thus no dep file entry will be created either. On macOS / QNX / WASM the main locale is UTF-8, so file content and paths will be processed correctly (hardcoded via QT_LOCALE_IS_UTF8 in src/corelib/codecs/qtextcodec_p.h). On Linux it will depend on the current locale / encoding set, and if that encoding is one of the ones supported above. UTF-8 should work fine. [ChangeLog][QtCore][moc] moc can now output a ".d" dep file that can be consumed by other build systems. Task-number: QTBUG-74521 Task-number: QTBUG-76598 Change-Id: I5585631ff1bbbae4e2875cade9cb6c20ed018c0a Reviewed-by: Leander Beernaert <leander.beernaert@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* | Add support for slots to receive the raw void ** arguments arrayLars Knoll2019-10-071-0/+1
|/ | | | | | | | | | | This is currently being used by dbus und our state machine framework, and supported by hand editing moc generated code. Get rid of that hack, and instead add support to moc to forward the raw arguments array to the slot. Change-Id: I0e36626f91eb01041464e6d931dc1d4660de91d2 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add support for machine-readable JSON output to the MOCSimon Hausmann2019-10-041-1/+11
| | | | | | | | | | | The --output-json parameter will make moc produce a .json file next to the regular output file. With --collect-json the .json files for a module can be merged into a single one. Task-number: QTBUG-68796 Change-Id: I0e8fb802d47bd22da219701a8df947973d4bd7b5 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* moc: Add a standard way of specifying a URI as part of Q_PLUGIN_METADATAUlf Hermann2019-04-111-0/+1
| | | | | | | | | | | | | | | | | | | | | | Usually, when you load a plugin, you don't want to load just any plugin that fulfills a given interface, but rather a specific one. When loading dynamic plugins you can differentiate the plugins by file name. This doesn't work in the static case, and file names are also separate from the plugin metadata shipped inside the plugin files. To solve this problem, different hacks have been developed in various places. QML extension plugins add a special property "uri" via the -M option of moc, QML debug plugins expect you to add a json file with an array of "Keys", Qt Creator plugins have a "Name" in their json files, etc. By allowing the identifier for the plugin to be specified inline with the metadata declaration we can make many of the above workarounds obsolete and provide a clean way for users to find their plugins. Task-number: QTBUG-74775 Change-Id: Ie2af16c49d4c5aa5a77fab0fae1e0a4449bd7a39 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* Add support for C++ functions attributes in mocJędrzej Nowacki2019-03-071-0/+2
| | | | | | | Done-with: Ryan Chu <ryan.chu@qt.io> Change-Id: Id7f2ba35ccea79e0a0c316ca2736101b8cd57f97 Fixes: QTBUG-58628 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* moc: Parse namespaces from other filesUlf Hermann2019-02-211-0/+1
| | | | | | | | | | | | We can parse the namespaces in order to find the enums in them and populate the related metaobjects of the current file's classes. The symbol clashes are avoided by only generating metaobjects for namespaces defined in the same file. Fixes: QTBUG-71966 Fixes: QTBUG-72069 Change-Id: Ibdf21c3f9dae48d95b0952b3e220b4c29e30ecb8 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* Repack some classes in Moc to avoid padding holesThiago Macieira2018-12-141-38/+34
| | | | | Change-Id: I8f261579aad648fdb4f0fffd155385477abadf9e Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* Moc: use QVector more oftenThiago Macieira2018-09-091-3/+3
| | | | | | | | It's more optimised and it vectorizes better, due to one level of indirection fewer. Change-Id: I495bc19409f348069f5bfffd1551e85092ed8dc2 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* Fix QMetaObject naming of class enum flagAllan Sandfeld Jensen2018-08-111-1/+1
| | | | | | | | | Adds an enumName to QMetaEnum to carry the name of the enum since for flags that doesn't match the name of the Qt type, but is needed if the flag is scoped. Change-Id: I1c0f77eb9e40e6fd1eb6a59bea77caf0f33fcf43 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* Fix moc'ing of enum class flagsAllan Sandfeld Jensen2018-07-261-0/+1
| | | | | | | | | Keep the original class name around for a little longer so we can generate the correct scoped enum in the moc output. Task-number: QTBUG-47652 Change-Id: Ib5934316fa786cc475335b03c86b8ec2dc239055 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* moc: Allow NOTIFY signals defined in parent classesAlbert Astals Cid2017-05-231-1/+2
| | | | | | | | | | Limitation is that the signal needs to be parameter-less [ChangeLog][moc] moc now supports NOTIFY signals of parent classes in Q_PROPERTY Change-Id: Iad64c96c3ec65d4be8ad9ff1a9f889938ab9bf45 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Brett Stottlemyer <bstottle@ford.com>
* Say hello to Q_NAMESPACEBogDan Vatra2016-08-191-22/+20
| | | | | | | | | | | | Q_NAMESPACE is useful to add Q_ENUM_NS/Q_ENUMS, Q_FLAG_NS/Q_FLAGS and Q_CLASSINFO to a namespace. [ChangeLog] Added Q_NAMESPACE which can be used to add Q_ENUM_NS/ Q_ENUMS, Q_FLAG_NS/Q_FLAGS and Q_CLASSINFO to a namespace Task-number: QTBUG-54981 Change-Id: Ic61b972794063e77134681fb347d6c4acddcdb44 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* moc: replace inefficient QLists with QVectorsMarc Mutz2016-02-101-9/+19
| | | | | | | | | | | | | | These types are larger than a void*, so holding them in QLists is needlessly inefficient. Worse, the code could come to depend on the fragile property of (inefficient) QLists that references to elements therein never are invalidated. Fix by marking them movable, and holding them in a QVector instead. Change-Id: I42f494ed87854eadc33d78db4479203ff5e0370f Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com> Reviewed-by: Milian Wolff <milian.wolff@kdab.com> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* Updated license headersJani Heikkinen2016-01-211-17/+12
| | | | | | | | | | | | | From Qt 5.7 -> tools & applications are lisenced under GPL v3 with some exceptions, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new GPL-EXCEPT header instead of LGPL21 one (in those files which will be under GPL 3 with exceptions) Change-Id: I42a473ddc97101492a60b9287d90979d9eb35ae1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Update copyright headersJani Heikkinen2015-02-111-7/+7
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>