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:
parent
369cb1470d
commit
700e6341e5
@ -806,7 +806,7 @@ void QMetaType::unregisterMetaType(QMetaType type)
|
|||||||
Returns the QMetaType corresponding to the type in the template parameter.
|
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
|
\since 5.15
|
||||||
\relates QMetaType
|
\relates QMetaType
|
||||||
\overload
|
\overload
|
||||||
@ -815,7 +815,7 @@ void QMetaType::unregisterMetaType(QMetaType type)
|
|||||||
as the QMetaType \a b, otherwise returns \c false.
|
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
|
\since 5.15
|
||||||
\relates QMetaType
|
\relates QMetaType
|
||||||
\overload
|
\overload
|
||||||
@ -1714,7 +1714,7 @@ static QMetaEnum metaEnumFromType(QMetaType t)
|
|||||||
}
|
}
|
||||||
#endif
|
#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;
|
qlonglong ll;
|
||||||
if (fromType.flags() & QMetaType::IsUnsignedEnumeration) {
|
if (fromType.flags() & QMetaType::IsUnsignedEnumeration) {
|
||||||
@ -1966,7 +1966,7 @@ static bool convertToAssociativeIterable(QMetaType fromType, const void *from, v
|
|||||||
|
|
||||||
|
|
||||||
#ifndef QT_BOOTSTRAPPED
|
#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)) {
|
if ((fromType.flags() & QMetaType::PointerToQObject) && (toType.flags() & QMetaType::PointerToQObject)) {
|
||||||
return fromType.metaObject()->inherits(toType.metaObject()) ||
|
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,
|
\sa convert(), QSequentialIterable, Q_DECLARE_SEQUENTIAL_CONTAINER_METATYPE(), QAssociativeIterable,
|
||||||
Q_DECLARE_ASSOCIATIVE_CONTAINER_METATYPE()
|
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 fromTypeId = fromType.id();
|
||||||
int toTypeId = toType.id();
|
int toTypeId = toType.id();
|
||||||
|
@ -438,8 +438,8 @@ public:
|
|||||||
static QMetaType fromType();
|
static QMetaType fromType();
|
||||||
static QMetaType fromName(QByteArrayView name);
|
static QMetaType fromName(QByteArrayView name);
|
||||||
|
|
||||||
friend bool operator==(const QMetaType &a, const QMetaType &b) { return a.id() == b.id(); }
|
friend bool operator==(QMetaType a, 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 == b); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -538,7 +538,7 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static bool convert(QMetaType fromType, const void *from, QMetaType toType, void *to);
|
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)
|
#if QT_DEPRECATED_SINCE(6, 0)
|
||||||
QT_DEPRECATED_VERSION_6_0
|
QT_DEPRECATED_VERSION_6_0
|
||||||
static bool convert(const void *from, int fromTypeId, void *to, int toTypeId)
|
static bool convert(const void *from, int fromTypeId, void *to, int toTypeId)
|
||||||
|
@ -150,7 +150,7 @@ bool QPropertyBindingPrivate::evaluateIfDirtyAndReturnTrueIfValueChanged()
|
|||||||
|
|
||||||
QUntypedPropertyBinding::QUntypedPropertyBinding() = default;
|
QUntypedPropertyBinding::QUntypedPropertyBinding() = default;
|
||||||
|
|
||||||
QUntypedPropertyBinding::QUntypedPropertyBinding(const QMetaType &metaType, QUntypedPropertyBinding::BindingEvaluationFunction function,
|
QUntypedPropertyBinding::QUntypedPropertyBinding(QMetaType metaType, QUntypedPropertyBinding::BindingEvaluationFunction function,
|
||||||
const QPropertyBindingSourceLocation &location)
|
const QPropertyBindingSourceLocation &location)
|
||||||
{
|
{
|
||||||
d = new QPropertyBindingPrivate(metaType, std::move(function), std::move(location));
|
d = new QPropertyBindingPrivate(metaType, std::move(function), std::move(location));
|
||||||
|
@ -43,7 +43,6 @@
|
|||||||
#include <QtCore/qglobal.h>
|
#include <QtCore/qglobal.h>
|
||||||
#include <QtCore/QSharedDataPointer>
|
#include <QtCore/QSharedDataPointer>
|
||||||
#include <QtCore/QString>
|
#include <QtCore/QString>
|
||||||
#include <QtCore/qmetatype.h>
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <variant>
|
#include <variant>
|
||||||
@ -123,7 +122,7 @@ public:
|
|||||||
using BindingEvaluationFunction = QtPrivate::QPropertyBindingFunction;
|
using BindingEvaluationFunction = QtPrivate::QPropertyBindingFunction;
|
||||||
|
|
||||||
QUntypedPropertyBinding();
|
QUntypedPropertyBinding();
|
||||||
QUntypedPropertyBinding(const QMetaType &metaType, BindingEvaluationFunction function, const QPropertyBindingSourceLocation &location);
|
QUntypedPropertyBinding(QMetaType metaType, BindingEvaluationFunction function, const QPropertyBindingSourceLocation &location);
|
||||||
QUntypedPropertyBinding(QUntypedPropertyBinding &&other);
|
QUntypedPropertyBinding(QUntypedPropertyBinding &&other);
|
||||||
QUntypedPropertyBinding(const QUntypedPropertyBinding &other);
|
QUntypedPropertyBinding(const QUntypedPropertyBinding &other);
|
||||||
QUntypedPropertyBinding &operator=(const QUntypedPropertyBinding &other);
|
QUntypedPropertyBinding &operator=(const QUntypedPropertyBinding &other);
|
||||||
@ -151,7 +150,7 @@ class QPropertyBinding : public QUntypedPropertyBinding
|
|||||||
struct BindingAdaptor
|
struct BindingAdaptor
|
||||||
{
|
{
|
||||||
Functor impl;
|
Functor impl;
|
||||||
bool operator()(const QMetaType &/*metaType*/, void *dataPtr)
|
bool operator()(QMetaType /*metaType*/, void *dataPtr)
|
||||||
{
|
{
|
||||||
PropertyType *propertyPtr = static_cast<PropertyType *>(dataPtr);
|
PropertyType *propertyPtr = static_cast<PropertyType *>(dataPtr);
|
||||||
PropertyType newValue = impl();
|
PropertyType newValue = impl();
|
||||||
|
@ -166,7 +166,7 @@ public:
|
|||||||
// public because the auto-tests access it, too.
|
// public because the auto-tests access it, too.
|
||||||
size_t dependencyObserverCount = 0;
|
size_t dependencyObserverCount = 0;
|
||||||
|
|
||||||
QPropertyBindingPrivate(const QMetaType &metaType, QUntypedPropertyBinding::BindingEvaluationFunction evaluationFunction,
|
QPropertyBindingPrivate(QMetaType metaType, QUntypedPropertyBinding::BindingEvaluationFunction evaluationFunction,
|
||||||
const QPropertyBindingSourceLocation &location)
|
const QPropertyBindingSourceLocation &location)
|
||||||
: isBool(metaType.id() == QMetaType::Bool)
|
: isBool(metaType.id() == QMetaType::Bool)
|
||||||
, evaluationFunction(std::move(evaluationFunction))
|
, evaluationFunction(std::move(evaluationFunction))
|
||||||
|
@ -54,6 +54,7 @@
|
|||||||
#include <QtCore/qglobal.h>
|
#include <QtCore/qglobal.h>
|
||||||
#include <QtCore/QExplicitlySharedDataPointer>
|
#include <QtCore/QExplicitlySharedDataPointer>
|
||||||
#include <QtCore/qtaggedpointer.h>
|
#include <QtCore/qtaggedpointer.h>
|
||||||
|
#include <QtCore/qmetatype.h>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
@ -63,14 +64,13 @@ class QUntypedPropertyBinding;
|
|||||||
class QPropertyBindingPrivate;
|
class QPropertyBindingPrivate;
|
||||||
using QPropertyBindingPrivatePtr = QExplicitlySharedDataPointer<QPropertyBindingPrivate>;
|
using QPropertyBindingPrivatePtr = QExplicitlySharedDataPointer<QPropertyBindingPrivate>;
|
||||||
struct QPropertyBasePointer;
|
struct QPropertyBasePointer;
|
||||||
class QMetaType;
|
|
||||||
|
|
||||||
namespace QtPrivate {
|
namespace QtPrivate {
|
||||||
|
|
||||||
// writes binding result into dataPtr
|
// 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);
|
QPropertyBindingFunction, void *owner);
|
||||||
using QPropertyObserverCallback = void (*)(void *, void *);
|
using QPropertyObserverCallback = void (*)(void *, void *);
|
||||||
|
|
||||||
@ -242,7 +242,7 @@ struct QPropertyGuardFunctionHelper
|
|||||||
template<typename T, typename Class, auto Guard>
|
template<typename T, typename Class, auto Guard>
|
||||||
struct QPropertyGuardFunctionHelper<T, Class, Guard, false>
|
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
|
QPropertyBindingFunction eval, void *owner) -> bool
|
||||||
{
|
{
|
||||||
T t = T();
|
T t = T();
|
||||||
|
@ -443,7 +443,7 @@ class Q_CORE_EXPORT QVariant
|
|||||||
quintptr packedType : sizeof(QMetaType) * 8 - 2;
|
quintptr packedType : sizeof(QMetaType) * 8 - 2;
|
||||||
|
|
||||||
Private() noexcept : is_shared(false), is_null(true), packedType(0) {}
|
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);
|
quintptr mt = quintptr(type.d_ptr);
|
||||||
Q_ASSERT((mt & 0x3) == 0);
|
Q_ASSERT((mt & 0x3) == 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user