From ee709e32366135fb7507b74b8e75d637772b166e Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 30 Apr 2019 09:55:13 +0200 Subject: QMetaMethod: clean up offset handling Centralize the offset handling in one place and avoid lots of magic numbers in various places. Expose the number of ints per method in QMetaObjectPrivate as a constant, so that code in other places can access it via private API. Change-Id: I59790287a17ea47e6160ec65d9c8d0aaee748947 Reviewed-by: Simon Hausmann Reviewed-by: Ulf Hermann Reviewed-by: Lars Knoll --- src/corelib/kernel/qmetaobject.h | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'src/corelib/kernel/qmetaobject.h') diff --git a/src/corelib/kernel/qmetaobject.h b/src/corelib/kernel/qmetaobject.h index 67f5efe6f6..801cf8f6eb 100644 --- a/src/corelib/kernel/qmetaobject.h +++ b/src/corelib/kernel/qmetaobject.h @@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE class Q_CORE_EXPORT QMetaMethod { public: - Q_DECL_CONSTEXPR inline QMetaMethod() : mobj(nullptr), handle(0) {} + Q_DECL_CONSTEXPR inline QMetaMethod() : mobj(nullptr), data({ nullptr }) {} QByteArray methodSignature() const; QByteArray name() const; @@ -72,6 +72,7 @@ public: enum Attributes { Compatibility = 0x1, Cloned = 0x2, Scriptable = 0x4 }; int attributes() const; int methodIndex() const; + int relativeMethodIndex() const; int revision() const; inline const QMetaObject *enclosingMetaObject() const { return mobj; } @@ -184,9 +185,25 @@ private: char *signature(struct renamedInQt5_warning_checkTheLifeTime * = nullptr) = delete; #endif static QMetaMethod fromSignalImpl(const QMetaObject *, void **); + static QMetaMethod fromRelativeMethodIndex(const QMetaObject *mobj, int index); + static QMetaMethod fromRelativeConstructorIndex(const QMetaObject *mobj, int index); + + struct Data { + enum { Size = 6 }; + + uint name() const { return d[0]; } + uint argc() const { return d[1]; } + uint parameters() const { return d[2]; } + uint tag() const { return d[3]; } + uint flags() const { return d[4]; } + uint metaTypeOffset() const { return d[5]; } + bool operator==(const Data &other) const { return d == other.d; } + + const uint *d; + }; const QMetaObject *mobj; - uint handle; + Data data; friend class QMetaMethodPrivate; friend struct QMetaObject; friend struct QMetaObjectPrivate; @@ -197,7 +214,7 @@ private: Q_DECLARE_TYPEINFO(QMetaMethod, Q_MOVABLE_TYPE); inline bool operator==(const QMetaMethod &m1, const QMetaMethod &m2) -{ return m1.mobj == m2.mobj && m1.handle == m2.handle; } +{ return m1.data == m2.data; } inline bool operator!=(const QMetaMethod &m1, const QMetaMethod &m2) { return !(m1 == m2); } -- cgit v1.2.3