summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qmetaobject.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2019-04-30 09:55:13 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2020-06-11 19:39:52 +0200
commitee709e32366135fb7507b74b8e75d637772b166e (patch)
treedda16876e67078d9fc35b8d3ffdd9bfc8360ada9 /src/corelib/kernel/qmetaobject.h
parent58a7e4f0bc5e9290cc205762d51adc5806b034fd (diff)
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 <hausmann@gmail.com> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/kernel/qmetaobject.h')
-rw-r--r--src/corelib/kernel/qmetaobject.h23
1 files changed, 20 insertions, 3 deletions
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); }