summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qmetatype.h
Commit message (Collapse)AuthorAgeFilesLines
* Replace discouraged Q_MOVABLE_TYPE by Q_RELOCATABLE_TYPEAndreas Buhr2020-11-301-1/+1
| | | | | | | | | | | | | | 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>
* QMetaType: Track whether type is QML list typeFabian Kosmale2020-11-231-0/+5
| | | | | | | | | This information is required in the QML engine to handle list properties (instances of QQmlListproperty<T> and list<T> types from QML). Pick-to: 6.0.0 6.0 Change-Id: I1e30572f1c91f58b290cb9b4b07433af99a1db6f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Make QMetaTypeInterface constexpr on WindowsLars Knoll2020-11-191-44/+40
| | | | | | | | | | | | | | | | This was so far problematic as it gave various link errors. The solution to that seems to be to make the default constructor of QPairVariantInterfaceImpl constexpr to get around one set of problems. The other problem to solve where undefined references to metaobjects. The reason for that is apparently that QMetaTypeInterface contains a direct pointer to the meta object, something the linker doesn't like. Adding a level of indirection by using a function that returns the pointer seems to solve that problem. Fixes: QTBUG-88468 Change-Id: I5612ae807ea3b7e49bc40349d8d1fca1be9bd7ee Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Clean up container metatype declarations in QMetaTypeLars Knoll2020-11-031-12/+0
| | | | | | | | | Remove forward declarations, we have those already from qcontainerfwd.h. Change-Id: I1b8a91ece912e6cdf747f4e2a750f0e85bcb5b2a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Clean up qcontainerfwd.hLars Knoll2020-11-031-10/+0
| | | | | | | | | | | | Add missing declaration of QVariantList and friends. Replace class with typename for template parameters. Remove some left-over forward declarations in other headers. Change-Id: I31d443019d48b619e02834395dafa40182cac7b9 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Whitespace cleanup in corelib/kernelAllan Sandfeld Jensen2020-10-241-46/+45
| | | | | Change-Id: If061ef0af5ced4384e20a82afcea3712fa7e45d7 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Make some QMetaType members constexpr and inlineLars Knoll2020-10-231-5/+30
| | | | | | | | | Since QMetaType::fromType() is constexpr, it makes sense to also make some of it's members constexpr. Change-Id: Ia2d63a904abb680ed63c1f88cb68f1d0309d029c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Rename the QMetaType::MovableType flag to RelocatableTypeLars Knoll2020-10-231-2/+5
| | | | | | | Keep this in sync with the changes we have done in QTypeInfo. Change-Id: Iaacb0f3cc5c46d3486084a1f6eca480a233d5e1a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Make most of QMetaTypeInterface constexprUlf Hermann2020-10-181-50/+62
| | | | | | | | | | | | | | | | | | The only thing we need to modify at runtime is the typeId and that can be mutable. This way we can have a constexpr ctor for QMetaType which hopefully makes the importing and exporting of related symbols less fickle. On Windows we cannot make QMetaTypeForType constexpr as that leads to mysterious errors in other places. Until we figure out why that is, we just leave this class as non-constexpr. This reveals that qcoreapplication.h and qvariant.h are using QDebug without including it. We now get template instantiation errors. Include qdebug.h to avoid that. Change-Id: If1bf0437ada52459c59c6fa45bab3d22dfb0bc92 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QMetaType: Silence float comparison warnings in QEqualityOperatorForTypeUlf Hermann2020-10-161-0/+3
| | | | | | | | We actually do want to invoke the original equality operator there. If that is unsafe, we cannot do much about it at this point. Change-Id: Iadb2eaba1156828d89022d282c41bda57b500b13 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix compile time type normalization codeLars Knoll2020-10-141-81/+146
| | | | | | | | | | | | | | | | | | | | | Use a simpler constexpr to generate type name on gcc This works around an ICE on gcc in release mode when compiling with PCH enabled. As the type we're getting from Q_FUNC_INFO is already in a somewhat normalized form, this requires significanlty less processing and esp. not a recursive constexpr method which I suspect triggers the ICE. Fix integer type conversions to also properly normalize long long values (to q(u)longlong. Make sure the mapping also works on MSVC, where long long types get mapped to __int64. Also, normalize unsigned short and unsigned char to ushort and uchar, respectively, to follow the convention set by uint and ulong. Add some test cases to verify the mappings. Change-Id: I3dec5764450bf22ab6f066597803c3f46c2cd5ac Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QMetaType: fix warning messageFabian Kosmale2020-10-141-1/+1
| | | | | Change-Id: I93c8b0d6b490cfed944a2a6a2b64361258a50141 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QMetaType: Avoid combination of extern and declspec(__dllexport) on MSVCUlf Hermann2020-10-121-4/+9
| | | | | | | | | MSVC does strange things with this, and it actually tells us so via a warning. We can, however, attach the dllexport to the definition, rather than the declaration of the symbols in order to resolve the problem. Change-Id: I9971e13afc6d8840c49ec20d21820a72c5407200 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix compilation on MSVC with /std:c++latestLars Knoll2020-10-081-6/+1
| | | | | | | | | | Inline the definition of QMetaTypeForType::name and make it constexpr. The old code was conflicting in it's definition (only const in the declaration, constexpr in the definition), something MSVC didn't like. Fixes: QTBUG-87225 Change-Id: I7182c421c9f7612e4ff3d538829b2daee0fe4c5c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QMetaType: Allow registration of mutable views and register iterablesUlf Hermann2020-09-191-55/+175
| | | | | | | | | | | | | | | In order to modify a container through an iterable, we need the original container to be mutable. The iterable, then, is not a conversion of the container, but rather a view on the container. The concept may be extended to other types. In order to facilitate this, provide a set of methods in QMetaType and QVariant similar to the convert family. The new methods are non-const and expect the original value to stay available during the life time of the view. Change-Id: I363621033f7fc600edcea2acb786820ccba49c86 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Extend QSequentialIterable and add QAssociativeIterableUlf Hermann2020-09-191-272/+46
| | | | | | | | | And add mutable iterators. This requires some refactoring of the existing iterators. Task-number: QTBUG-81716 Change-Id: I61b3a3e8c0df5fd449679257a29d9f0c3d19c4f0 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Make QStringList an alias to QList<QString>Lars Knoll2020-09-121-1/+2
| | | | | | | | | | | | | | | | | | Fix our API, so that QStringList and QList<QString> are the same thing. This required a bit of refactoring in QList and moving the indexOf(), lastIndexOf() and contains() method into QListSpecialMethods. In addition, we need to ensure that the QStringList(const QString&) constructor is still available for compatibility with Qt 5. Once those two are done, all methods in QStringList can be moved into QListSpecialMethods<QString>. Change-Id: Ib8afbf5b6d9df4d0d47051252233506f62335fa3 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remap QMetaType ids to create more space for builtin typesLars Knoll2020-09-121-32/+32
| | | | | | | | | | | We were starting to run out of space for builtin core types. Remap the type id's to create lots of additional space. We now reserve the first 64k id's for Qt, and have 16k id's for Qt Core. That should hopfully be enough for a while ;-) Fixes: QTBUG-85914 Change-Id: I0dab6bf23652e46a9557d9b38af7990b68c572b6 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* QMetaType: optimize comparisonFabian Kosmale2020-09-051-1/+1
| | | | | | | We can skip the id calls if we know that the pointers are equal. Change-Id: I62f9cac557d7b82b640a143965f9056a8cd46028 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Remove some comments that are no longer relevantEdward Welbourne2020-09-051-1/+0
| | | | | | | Task-number: QTBUG-85700 Change-Id: I5ce368e8edca2b9483a0f0ef34bc9eb6b4e44574 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Reimplement QSequentialIterable using QMetaSequenceUlf Hermann2020-09-031-230/+0
| | | | | Change-Id: Ie721a5f0caa697c4bf15a81f3762cf79d3c54f5a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmetatype.h: Rename ValueTypeIsMetaType to SequentialValueTypeIsMetaTypeUlf Hermann2020-08-281-5/+5
| | | | | | | It is only used for sequential containers. Change-Id: Id6e01e03d36222605c56b6db935fcf78815d383f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Cleanup QTypeInfoLars Knoll2020-08-261-1/+1
| | | | | | | | | | | | | | | Remove QTypeInfo::isStatic, as that's not used anymore in Qt 6. Also remove sizeOf, it's unused, and we have QMetaType for that if required. Remove all typeinfo declaractions for trivial types, as the default template covers them correctly nowadays. Finally set up a better default for isPointer, and do some smaller cleanups all over the place. Change-Id: I6758ed37dfc701feaaf0ff105cc95e32da9f9c33 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Pass QMetaType by valueLars Knoll2020-08-241-3/+3
| | | | | | | | Now that QMetaType is not refcounted anymore, we can and should pass it by value. Change-Id: I848db65070713762f548ca949097c27783aacad4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Clean up int based convert() APILars Knoll2020-08-241-1/+4
| | | | | | | Pass QMetaType instances instead. Change-Id: I07366cea566fdebf5bb793aa8087f8109216ec0c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Return a qsizetype from QMetaType::sizeOf()/alignOf()Lars Knoll2020-08-241-2/+2
| | | | | | | Object sizes in Qt 6 should use qsizetype. Change-Id: I76ceb5faf361d7f6be88d88c772358ad6d701d54 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Deprecate the static int based API in QMetaTypeLars Knoll2020-08-241-15/+37
| | | | | | | | | | | | | And remove one of the type id to name mapping that still existed in QMetaType. QMetaTypeInterface can provide that, so there's no need to have a second copy of the data. qMetaTypeTypeInternal() can still map all the names of all builtin types to ids. That functionality is for now still required by moc and can't be removed yet. Change-Id: Ib4f8e9c71e1e7d99d52da9e44477c9a1f1805e57 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Remove refcounting of QMetaTypeInterfaceLars Knoll2020-08-241-28/+13
| | | | | | | | | It's only used for dynamic types in DBUS and QML, where we control things good enough to be able to handle the lifetime of those interfaces there. Change-Id: Ia7f8970d17a85b195db85fcdc2d8f1febd8753f4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Cleanup the qRegisterMetaType functionLars Knoll2020-08-241-49/+13
| | | | | | | Remove the arguments that are nowadays unused. Change-Id: I97ed983b158aba57653f35e7e2f91f5c79dace8c Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* Remove an unused enum value and document another oneLars Knoll2020-08-241-2/+1
| | | | | Change-Id: If9fed4f20242d789c1251b8798d7378d2d6911a6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Move conversions to and from *Iterables into QMetaTypeLars Knoll2020-08-241-2/+5
| | | | | | | | Those were not yet supported by QMetaType. Change-Id: I9f85476049f200e35939ac58ef7e8b4e7cbe0b77 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Implement QMetaType::canConvert() and use it in QVariantLars Knoll2020-08-241-0/+1
| | | | | | | | | | | | | | | | | | | | Use the fact that we return the conversion function as a lambda to find out reliably whether a conversion between two types can be done. This requires some minor adjustments to our tests: * Nothing can convert to an unknown type and vice versa * Adjust results to the fact that we don't convert from char to QString anymore (where the old method was incorrect) * QStringList->QString requires some adjustments, as we only convert if the string list has exactly one element. For now we return true in canConvert(), but the conversion behavior in this case is something we should rethink, as it is very surprising. Change-Id: I3f5f87ee9cb99d690f5a7d13b13d6a6313d8038e Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* Move enum conversions over into QMetaTypeLars Knoll2020-08-241-0/+7
| | | | | | | | Take the opportunity to properly handle the underlying type (size and signed vs unsigned). Change-Id: I0cb8cf40acac6de03c24ed3fe570db68268952c8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Clean up the converter function handlingLars Knoll2020-08-241-118/+33
| | | | | | | | Use std::function to register the converter functions instead of our own handrolled interface. Change-Id: Ifc1d1d383d21ee8d4239dbc3970c1f31bf0f4037 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Cleanup unused codeLars Knoll2020-08-241-1/+0
| | | | | Change-Id: I27821ca7e63fccd5353c48eebfde19756846dd2e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Generate less code when creating QMetaTypeInterfacesLars Knoll2020-08-241-3/+3
| | | | | | | | | There is no need to generate wrapper functions for equals, lessThan or debugStream for pointer types, as those can easily be handled by a few lines of code in QMetaType itself. Change-Id: If79b3bc3a629249c1d17c9e592202f08b59f80ef Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Refactor Q*IterableLars Knoll2020-08-241-105/+47
| | | | | | | | | | | | Refactor the methods retrieving data in Q*Iterable so that we don't return pointers with unclear ownership. Instead, copy the data into a out pointer provided by the caller. This also means there is no need for the metatype flags anymore and we can remove those. Change-Id: I517de23a8ccfd608585ca00403aca0df2955f14b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Cleanups in the Iterable classesLars Knoll2020-08-241-39/+33
| | | | | | | Store a QMetaType, not a meta type id in the classes. Change-Id: If27a60512a46fa029cc914d65b8cad7f89d7f3b0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Clean up a custom void_t implementationLars Knoll2020-08-241-8/+3
| | | | | Change-Id: I30fcaef2a242cc2daee82d37debdb97e59a9a8f2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Cleanups in QSequentialIterableLars Knoll2020-08-241-24/+10
| | | | | | | | | Remove the old revision of the interface, this is not required with Qt 6 anymore, as everything is being recompiled anyway. Change-Id: I66070c4dc6b5e2a6d22f5a9ebea7688ed38333fe Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Remove some dead codeLars Knoll2020-08-241-40/+0
| | | | | | | | This code is now unused, as streaming operators are registered automatically. Change-Id: I0e48944c33a92cf1f2f158fb2dc0ca49256d7938 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Automatically register data/debug stream operations in QMetaTypeLars Knoll2020-08-241-88/+67
| | | | | | | | | | | | | | | | | | | | | | And remove the old manual registration code for those operators. Add some special handling for long/ulong, as these types could be streamed as a QVariant so far, but are not directly streamable through QDataStream. [ChangeLog][QtCore][QMetaType] The QMetaType::registerStreamOperators() and QMetaType::registerDebugStreamOperator() methods have been removed. The streaming operators for a type are now automatically registered together with the type registration. This implies that the operators should be visible wherever the type is visible and being used. [ChangeLog][Behavior Incompatible Changes] Because the QDataStream and QDebug serialization operators are automatically registered with QMetaType, the declarations of those functions must be present at any point where the type is used with QMetaType and QVariant. Change-Id: I4a0732651b20319af4a8397ff90b848ca4580d99 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QMetaType: specialize typenameHelper for std::pairFabian Kosmale2020-08-191-27/+68
| | | | | | | | | | | | The string representation of std::pair<T1,T2> is now always "std::pair<T1,T2>". This is in line with how we translate QPair, avoiding typename mismatches that would previoulsy occur, because the full name of pair on libc++ was "std::__1::pair". Fixes: QTBUG-84924 Change-Id: Ia6c044a7327d69e4b4f4a31496c6b2408d85ebb9 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Disentangle QIODevice dependenciesLars Knoll2020-08-151-0/+1
| | | | | | | | | | | | | | | | | Move the QIODevice::OpenMode enum into a base class, so that we can remove the full QIODevice (and thus QObject) dependency from qdatastream.h and qtextstream.h. This is required so that we can include QDataStream in qmetatype.h without getting circular dependencies. As a nice side effect, QDataStream and QTextStream can now inherit QIODeviceBase and provide the OpenMode enum directly in their class scope. Change-Id: Ifa68b7b1d8d95687ed032f6c9206f92e63bfacdf Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* Replace Qt CONSTEXPR defines with constexprAllan Sandfeld Jensen2020-08-141-9/+9
| | | | | | | | Both normal and relaxed constexpr are required by our new minimum of C++17. Change-Id: Ic028b88a2e7a6cb7d5925f3133b9d54859a81744 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Expose QMetaTypeInterface::alignof in QMetaTypeFabian Kosmale2020-07-311-0/+1
| | | | | | | | | | We already have the information in the QMetaTypeInterface, and provide functions to access sizeof. Adding alignof support seems natural, and should make it easier to handle over-aligned types. This should also be helpful in QVariant. Change-Id: I166be76f4b7d2d2e524a3a1e513bd2f361e887c1 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QMetaType: force properties to have a complete type againFabian Kosmale2020-07-241-2/+11
| | | | | | | | | | | | | | When the compile time metatype support for methods was introduced, we needed to allow incomplete types to avoid breaking a large amount of code. However, this mistakenly enabled using incomplete types for properties, too. In contrast to methods, properties lack the fallback code to retrieve the metatype at runtime. Thus, this commit restores the completeness requirement for properties again. This is done by always calling QMetaTypeForType for properties in qTryMetaTypeForType. Amends fa987d44417528856d5e80ed7b48ba99e19fa307 Change-Id: I5f66ff289631c056eecebe40926bf321d283eea7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QAssociativeIterableImpl::advanceImpl(): remove deprecation protectionEdward Welbourne2020-07-211-3/+0
| | | | | | | | The comment claims it is needed for "the deprecated QHash::iterator::operator--()", which has been removed already. Change-Id: I90f5abdcd14e6cac4ed7144e96eb26bf34477391 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Use QList instead of QVectorJarek Kobus2020-07-091-4/+3
| | | | | | Task-number: QTBUG-84469 Change-Id: Ia365c958e3b2d0c8210f5d693d907bb2012887c2 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Automatically register comparison operators in QMetaTypeFabian Kosmale2020-07-081-86/+64
| | | | | | | | | | | | | | | | | This removes the fully manual registration of comparison operators in QMetaType and replaces it with an automatic registration through Q_DECLARE_METATYPE(). [ChangeLog][QMetaType] The QMetaType::registerComparator() and QMetaType::registerEqualsComparator() have been removed. Q_DECLARE_METATYPE() now automatically registers any operator==() and/or operator<() for a type visible where it is used on that type, as part of declaring its meta-type. Change-Id: I3df451b652b735c093533838bf32f3cc785439f8 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>