From 14583137ae445fbfdc82922266f5c0736454f6c4 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sat, 10 Dec 2011 10:53:39 +0100 Subject: Introduce Q_ENUM and Q_FLAG macros MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In replacement for Q_ENUMS and Q_FLAGS. Q_ENUM(Foo) has to be put after the declaration of Foo in an object. It will tell moc to include the enum in the meta object (just like Q_ENUMS) and will allow templated code to get the metaobject for that enum. Will be used by QDebug and QMetaType Change-Id: Iefaf8ae07dc0359828102bf384809346629b3e23 Reviewed-by: Jędrzej Nowacki --- src/corelib/kernel/qobjectdefs.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h index 84e7a65a54..af99546f04 100644 --- a/src/corelib/kernel/qobjectdefs.h +++ b/src/corelib/kernel/qobjectdefs.h @@ -84,6 +84,10 @@ class QString; #define Q_OVERRIDE(text) #define Q_ENUMS(x) #define Q_FLAGS(x) +#define Q_ENUM(ENUM) \ + friend Q_DECL_CONSTEXPR const QMetaObject *qt_getEnumMetaObject(ENUM) Q_DECL_NOEXCEPT { return &staticMetaObject; } \ + friend Q_DECL_CONSTEXPR const char *qt_getEnumName(ENUM) Q_DECL_NOEXCEPT { return #ENUM; } +#define Q_FLAG(ENUM) Q_ENUM(ENUM) #define Q_SCRIPTABLE #define Q_INVOKABLE #define Q_SIGNAL @@ -185,6 +189,8 @@ private: \ #define Q_REVISION(v) Q_REVISION(v) #define Q_OVERRIDE(text) Q_OVERRIDE(text) #define Q_ENUMS(x) Q_ENUMS(x) +#define Q_FLAGS(x) Q_FLAGS(x) +#define Q_ENUM(x) Q_ENUM(x) #define Q_FLAGS(x) Q_FLAGS(x) /* qmake ignore Q_OBJECT */ #define Q_OBJECT Q_OBJECT -- cgit v1.2.3