From 027d45cb57a7cf20b2714509250a87f1e8842b9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Sat, 5 Oct 2019 13:22:42 +0200 Subject: macOS: Simplify Objective-C namespacing We only need to use the QT_MANGLE_NAMESPACE macro when declaring the interface of the class. As long as we couple that with an alias declaration using QT_NAMESPACE_ALIAS_OBJC_CLASS, any further uses of the class name can be un-namespaced, including declaring categories on the class. The only snag with QT_NAMESPACE_ALIAS_OBJC_CLASS is that it can only be used once per class and translation unit, so forward declarations get hairy, but we can avoid that by just including the headers instead. Change-Id: I333bcd18fe1e18d81fbd560b0941c98b1c32460e Reviewed-by: Timur Pocheptsov --- src/plugins/bearer/corewlan/qcorewlanengine.mm | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/plugins/bearer') diff --git a/src/plugins/bearer/corewlan/qcorewlanengine.mm b/src/plugins/bearer/corewlan/qcorewlanengine.mm index 4644b5af9f..66f2ed017b 100644 --- a/src/plugins/bearer/corewlan/qcorewlanengine.mm +++ b/src/plugins/bearer/corewlan/qcorewlanengine.mm @@ -62,12 +62,11 @@ extern "C" { // Otherwise it won't find CWKeychain* symbols at link time #include @interface QT_MANGLE_NAMESPACE(QNSListener) : NSObject - @property (assign) QCoreWlanEngine* engine; - @end +QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSListener); -@implementation QT_MANGLE_NAMESPACE(QNSListener) { +@implementation QNSListener { NSNotificationCenter *notificationCenter; CWWiFiClient *client; QCoreWlanEngine *engine; @@ -88,7 +87,7 @@ extern "C" { // Otherwise it won't find CWKeychain* symbols at link time return self; } -static QT_MANGLE_NAMESPACE(QNSListener) *listener = 0; +static QNSListener *listener = 0; -(void)dealloc { @@ -415,7 +414,7 @@ void QCoreWlanEngine::initialize() QMacAutoReleasePool pool; if ([[CWWiFiClient interfaceNames] count] > 0 && !listener) { - listener = [[QT_MANGLE_NAMESPACE(QNSListener) alloc] init]; + listener = [QNSListener alloc] init]; listener.engine = this; hasWifi = true; } else { -- cgit v1.2.3