Pass QMetaType by value

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>
This commit is contained in:
Lars Knoll 2020-07-27 17:34:10 +02:00
parent 369cb1470d
commit 700e6341e5
7 changed files with 17 additions and 18 deletions

View File

@ -806,7 +806,7 @@ void QMetaType::unregisterMetaType(QMetaType type)
Returns the QMetaType corresponding to the type in the template parameter.
*/
/*! \fn bool operator==(const QMetaType &a, const QMetaType &b)
/*! \fn bool operator==(QMetaType a, QMetaType b)
\since 5.15
\relates QMetaType
\overload
@ -815,7 +815,7 @@ void QMetaType::unregisterMetaType(QMetaType type)
as the QMetaType \a b, otherwise returns \c false.
*/
/*! \fn bool operator!=(const QMetaType &a, const QMetaType &b)
/*! \fn bool operator!=(QMetaType a, QMetaType b)
\since 5.15
\relates QMetaType
\overload
@ -1714,7 +1714,7 @@ static QMetaEnum metaEnumFromType(QMetaType t)
}
#endif
static bool convertFromEnum(const QMetaType &fromType, const void *from, QMetaType toType, void *to)
static bool convertFromEnum(QMetaType fromType, const void *from, QMetaType toType, void *to)
{
qlonglong ll;
if (fromType.flags() & QMetaType::IsUnsignedEnumeration) {
@ -1966,7 +1966,7 @@ static bool convertToAssociativeIterable(QMetaType fromType, const void *from, v
#ifndef QT_BOOTSTRAPPED
static bool canConvertMetaObject(const QMetaType &fromType, const QMetaType &toType)
static bool canConvertMetaObject(QMetaType fromType, QMetaType toType)
{
if ((fromType.flags() & QMetaType::PointerToQObject) && (toType.flags() & QMetaType::PointerToQObject)) {
return fromType.metaObject()->inherits(toType.metaObject()) ||
@ -2128,7 +2128,7 @@ bool QMetaType::convert(QMetaType fromType, const void *from, QMetaType toType,
\sa convert(), QSequentialIterable, Q_DECLARE_SEQUENTIAL_CONTAINER_METATYPE(), QAssociativeIterable,
Q_DECLARE_ASSOCIATIVE_CONTAINER_METATYPE()
*/
bool QMetaType::canConvert(const QMetaType &fromType, const QMetaType &toType)
bool QMetaType::canConvert(QMetaType fromType, QMetaType toType)
{
int fromTypeId = fromType.id();
int toTypeId = toType.id();

View File

@ -438,8 +438,8 @@ public:
static QMetaType fromType();
static QMetaType fromName(QByteArrayView name);
friend bool operator==(const QMetaType &a, const QMetaType &b) { return a.id() == b.id(); }
friend bool operator!=(const QMetaType &a, const QMetaType &b) { return !(a == b); }
friend bool operator==(QMetaType a, QMetaType b) { return a.id() == b.id(); }
friend bool operator!=(QMetaType a, QMetaType b) { return !(a == b); }
public:
@ -538,7 +538,7 @@ public:
#endif
static bool convert(QMetaType fromType, const void *from, QMetaType toType, void *to);
static bool canConvert(const QMetaType &fromType, const QMetaType &toType);
static bool canConvert(QMetaType fromType, QMetaType toType);
#if QT_DEPRECATED_SINCE(6, 0)
QT_DEPRECATED_VERSION_6_0
static bool convert(const void *from, int fromTypeId, void *to, int toTypeId)

View File

@ -150,7 +150,7 @@ bool QPropertyBindingPrivate::evaluateIfDirtyAndReturnTrueIfValueChanged()
QUntypedPropertyBinding::QUntypedPropertyBinding() = default;
QUntypedPropertyBinding::QUntypedPropertyBinding(const QMetaType &metaType, QUntypedPropertyBinding::BindingEvaluationFunction function,
QUntypedPropertyBinding::QUntypedPropertyBinding(QMetaType metaType, QUntypedPropertyBinding::BindingEvaluationFunction function,
const QPropertyBindingSourceLocation &location)
{
d = new QPropertyBindingPrivate(metaType, std::move(function), std::move(location));

View File

@ -43,7 +43,6 @@
#include <QtCore/qglobal.h>
#include <QtCore/QSharedDataPointer>
#include <QtCore/QString>
#include <QtCore/qmetatype.h>
#include <functional>
#include <type_traits>
#include <variant>
@ -123,7 +122,7 @@ public:
using BindingEvaluationFunction = QtPrivate::QPropertyBindingFunction;
QUntypedPropertyBinding();
QUntypedPropertyBinding(const QMetaType &metaType, BindingEvaluationFunction function, const QPropertyBindingSourceLocation &location);
QUntypedPropertyBinding(QMetaType metaType, BindingEvaluationFunction function, const QPropertyBindingSourceLocation &location);
QUntypedPropertyBinding(QUntypedPropertyBinding &&other);
QUntypedPropertyBinding(const QUntypedPropertyBinding &other);
QUntypedPropertyBinding &operator=(const QUntypedPropertyBinding &other);
@ -151,7 +150,7 @@ class QPropertyBinding : public QUntypedPropertyBinding
struct BindingAdaptor
{
Functor impl;
bool operator()(const QMetaType &/*metaType*/, void *dataPtr)
bool operator()(QMetaType /*metaType*/, void *dataPtr)
{
PropertyType *propertyPtr = static_cast<PropertyType *>(dataPtr);
PropertyType newValue = impl();

View File

@ -166,7 +166,7 @@ public:
// public because the auto-tests access it, too.
size_t dependencyObserverCount = 0;
QPropertyBindingPrivate(const QMetaType &metaType, QUntypedPropertyBinding::BindingEvaluationFunction evaluationFunction,
QPropertyBindingPrivate(QMetaType metaType, QUntypedPropertyBinding::BindingEvaluationFunction evaluationFunction,
const QPropertyBindingSourceLocation &location)
: isBool(metaType.id() == QMetaType::Bool)
, evaluationFunction(std::move(evaluationFunction))

View File

@ -54,6 +54,7 @@
#include <QtCore/qglobal.h>
#include <QtCore/QExplicitlySharedDataPointer>
#include <QtCore/qtaggedpointer.h>
#include <QtCore/qmetatype.h>
#include <functional>
@ -63,14 +64,13 @@ class QUntypedPropertyBinding;
class QPropertyBindingPrivate;
using QPropertyBindingPrivatePtr = QExplicitlySharedDataPointer<QPropertyBindingPrivate>;
struct QPropertyBasePointer;
class QMetaType;
namespace QtPrivate {
// writes binding result into dataPtr
using QPropertyBindingFunction = std::function<bool(const QMetaType &metaType, void *dataPtr)>;
using QPropertyBindingFunction = std::function<bool(QMetaType metaType, void *dataPtr)>;
using QPropertyGuardFunction = bool(*)(const QMetaType &, void *dataPtr,
using QPropertyGuardFunction = bool(*)(QMetaType, void *dataPtr,
QPropertyBindingFunction, void *owner);
using QPropertyObserverCallback = void (*)(void *, void *);
@ -242,7 +242,7 @@ struct QPropertyGuardFunctionHelper
template<typename T, typename Class, auto Guard>
struct QPropertyGuardFunctionHelper<T, Class, Guard, false>
{
static auto guard(const QMetaType &metaType, void *dataPtr,
static auto guard(const QMetaType metaType, void *dataPtr,
QPropertyBindingFunction eval, void *owner) -> bool
{
T t = T();

View File

@ -443,7 +443,7 @@ class Q_CORE_EXPORT QVariant
quintptr packedType : sizeof(QMetaType) * 8 - 2;
Private() noexcept : is_shared(false), is_null(true), packedType(0) {}
explicit Private(const QMetaType &type) noexcept : is_shared(false), is_null(false)
explicit Private(QMetaType type) noexcept : is_shared(false), is_null(false)
{
quintptr mt = quintptr(type.d_ptr);
Q_ASSERT((mt & 0x3) == 0);