diff options
author | Jake Petroules <jake.petroules@petroules.com> | 2013-06-26 08:22:34 -0400 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-06-26 14:43:59 +0200 |
commit | 509edd3e13cddb6f6b22ec014c1af90bb6f5479b (patch) | |
tree | 4558c93a602f36c3f446e4d56c3b2cece37685d2 | |
parent | 882ac6469100d56eaa174daa5d1adc69e4932914 (diff) |
Introduce a macro for forward declaring Objective-C classes.
Change-Id: I2334aac6c70861ef18875a4b5ef4116b9eb5592e
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
-rw-r--r-- | src/macextras/qmaccocoaviewcontainer.h | 6 | ||||
-rw-r--r-- | src/macextras/qmacextrasglobal.h | 15 | ||||
-rw-r--r-- | src/macextras/qmacfunctions.h | 18 | ||||
-rw-r--r-- | src/macextras/qmacnativetoolbar.h | 6 | ||||
-rw-r--r-- | src/macextras/qmacnativewidget.h | 6 |
5 files changed, 23 insertions, 28 deletions
diff --git a/src/macextras/qmaccocoaviewcontainer.h b/src/macextras/qmaccocoaviewcontainer.h index 50fa394..8dcb91f 100644 --- a/src/macextras/qmaccocoaviewcontainer.h +++ b/src/macextras/qmaccocoaviewcontainer.h @@ -47,11 +47,7 @@ QT_BEGIN_NAMESPACE -#ifdef __OBJC__ -@class NSView; -#else -typedef struct objc_object NSView; -#endif +Q_FORWARD_DECLARE_OBJC_CLASS(NSView); class QMacCocoaViewContainerPrivate; class Q_MACEXTRAS_EXPORT QMacCocoaViewContainer : public QWidget diff --git a/src/macextras/qmacextrasglobal.h b/src/macextras/qmacextrasglobal.h index c1fca69..f6a6f99 100644 --- a/src/macextras/qmacextrasglobal.h +++ b/src/macextras/qmacextrasglobal.h @@ -52,6 +52,21 @@ QT_BEGIN_NAMESPACE # define Q_MACEXTRAS_EXPORT Q_DECL_IMPORT #endif +/*! + * \macro Q_FORWARD_DECLARE_OBJC_CLASS(classname) + * + * Forward-declares an Objective-C class name in a manner such that it can be + * compiled as either Objective-C or C++. + * + * This is primarily intended for use in header files that may be included by + * both Objective-C and C++ source files. + */ +#ifdef __OBJC__ +#define Q_FORWARD_DECLARE_OBJC_CLASS(classname) @class classname +#else +#define Q_FORWARD_DECLARE_OBJC_CLASS(classname) typedef struct objc_object classname +#endif + QT_END_NAMESPACE #endif // QMACEXTRASGLOBAL_H diff --git a/src/macextras/qmacfunctions.h b/src/macextras/qmacfunctions.h index 4b7500a..d5972d1 100644 --- a/src/macextras/qmacfunctions.h +++ b/src/macextras/qmacfunctions.h @@ -51,19 +51,11 @@ typedef struct CGImage *CGImageRef; typedef struct CGContext *CGContextRef; -#ifdef __OBJC__ -@class NSData; -@class NSImage; -@class NSString; -@class NSMenu; -@class NSURL; -#else -typedef struct objc_object NSData; -typedef struct objc_object NSImage; -typedef struct objc_object NSString; -typedef struct objc_object NSMenu; -typedef struct objc_object NSURL; -#endif +Q_FORWARD_DECLARE_OBJC_CLASS(NSData); +Q_FORWARD_DECLARE_OBJC_CLASS(NSImage); +Q_FORWARD_DECLARE_OBJC_CLASS(NSString); +Q_FORWARD_DECLARE_OBJC_CLASS(NSMenu); +Q_FORWARD_DECLARE_OBJC_CLASS(NSURL); QT_BEGIN_NAMESPACE diff --git a/src/macextras/qmacnativetoolbar.h b/src/macextras/qmacnativetoolbar.h index 6ecfb1c..c4ad010 100644 --- a/src/macextras/qmacnativetoolbar.h +++ b/src/macextras/qmacnativetoolbar.h @@ -64,11 +64,7 @@ Q_MACEXTRAS_EXPORT QMacNativeToolBar* setNativeToolBar(QToolBar *toolbar, const class QAction; class QWindow; -#ifdef __OBJC__ -@class NSToolbar; -#else -typedef struct objc_object NSToolbar; -#endif +Q_FORWARD_DECLARE_OBJC_CLASS(NSToolbar); class QMacNativeToolBarPrivate; class Q_MACEXTRAS_EXPORT QMacNativeToolBar : public QObject diff --git a/src/macextras/qmacnativewidget.h b/src/macextras/qmacnativewidget.h index 994a9d8..22bdddf 100644 --- a/src/macextras/qmacnativewidget.h +++ b/src/macextras/qmacnativewidget.h @@ -50,11 +50,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Gui) -#ifdef __OBJC__ -@class NSView; -#else -typedef struct objc_object NSView; -#endif +Q_FORWARD_DECLARE_OBJC_CLASS(NSView); class Q_MACEXTRAS_EXPORT QMacNativeWidget : public QWidget { |