summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
diff options
context:
space:
mode:
authorRomain Perier <romain.perier@gmail.com>2013-05-11 09:28:53 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-05-16 10:45:04 +0200
commit94c7002df30d931df13b3bae9d4c46ff1e6f714c (patch)
tree17cb12d18eb5437ad4fbf16f5e8d2804924ffcaa /src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
parentadaa50e37da1fddada874a289792a1bd95c5aebc (diff)
Improve Qt-in-namespace implementation in the Cocoa platform plugin
Objective-C++ does not support namespaces. In order to make this work, we decorate each symbol with suffix using the macro QT_MANGLE_NAMESPACE. However, with such a technic each public symbol needs to be explicitly exported through this macro. The use of @compatibility_alias allows to define alias to use it automatically and transparently. Task-number: QTBUG-23946 Change-Id: Id521b8160bab126fda40a9d960277b1c04cc8b66 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm')
-rw-r--r--src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
index e7cf47395b..83bea383d8 100644
--- a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
+++ b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
@@ -128,7 +128,9 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
- (void)finishOffWithCode:(NSInteger)code;
@end
-@implementation QT_MANGLE_NAMESPACE(QNSFontPanelDelegate)
+QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate);
+
+@implementation QNSFontPanelDelegate
- (id)initWithDialogHelper:
(QCocoaFontDialogHelper *)helper
@@ -363,7 +365,7 @@ QCocoaFontDialogHelper::~QCocoaFontDialogHelper()
{
if (!mDelegate)
return;
- [reinterpret_cast<QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) *>(mDelegate) release];
+ [reinterpret_cast<QNSFontPanelDelegate *>(mDelegate) release];
mDelegate = 0;
}
@@ -373,7 +375,7 @@ void QCocoaFontDialogHelper::exec()
// QEventLoop has been interrupted, and the second-most event loop has not
// yet been reactivated (regardless if [NSApp run] is still on the stack)),
// showing a native modal dialog will fail.
- QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) *>(mDelegate);
+ QNSFontPanelDelegate *delegate = static_cast<QNSFontPanelDelegate *>(mDelegate);
if ([delegate runApplicationModalPanel])
emit accept();
else
@@ -393,7 +395,7 @@ void QCocoaFontDialogHelper::hide()
{
if (!mDelegate)
return;
- [reinterpret_cast<QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) *>(mDelegate)->mFontPanel close];
+ [reinterpret_cast<QNSFontPanelDelegate *>(mDelegate)->mFontPanel close];
}
void QCocoaFontDialogHelper::setCurrentFont(const QFont &font)
@@ -421,14 +423,14 @@ void QCocoaFontDialogHelper::setCurrentFont(const QFont &font)
createNSFontPanelDelegate();
[mgr setSelectedFont:const_cast<NSFont *>(nsFont) isMultiple:NO];
- static_cast<QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) *>(mDelegate)->mQtFont = font;
+ static_cast<QNSFontPanelDelegate *>(mDelegate)->mQtFont = font;
}
QFont QCocoaFontDialogHelper::currentFont() const
{
if (!mDelegate)
return QFont();
- return reinterpret_cast<QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) *>(mDelegate)->mQtFont;
+ return reinterpret_cast<QNSFontPanelDelegate *>(mDelegate)->mQtFont;
}
void QCocoaFontDialogHelper::createNSFontPanelDelegate()
@@ -436,7 +438,7 @@ void QCocoaFontDialogHelper::createNSFontPanelDelegate()
if (mDelegate)
return;
- QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) *delegate = [[QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) alloc]
+ QNSFontPanelDelegate *delegate = [[QNSFontPanelDelegate alloc]
initWithDialogHelper:this];
mDelegate = delegate;
@@ -446,7 +448,7 @@ bool QCocoaFontDialogHelper::showCocoaFontPanel(Qt::WindowModality windowModalit
{
Q_UNUSED(parent);
createNSFontPanelDelegate();
- QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) *>(mDelegate);
+ QNSFontPanelDelegate *delegate = static_cast<QNSFontPanelDelegate *>(mDelegate);
if (windowModality == Qt::NonModal)
[delegate showModelessPanel];
// no need to show a Qt::ApplicationModal dialog here, since it will be done in _q_platformRunNativeAppModalPanel()
@@ -458,7 +460,7 @@ bool QCocoaFontDialogHelper::hideCocoaFontPanel()
if (!mDelegate){
return false;
} else {
- QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) *>(mDelegate);
+ QNSFontPanelDelegate *delegate = static_cast<QNSFontPanelDelegate *>(mDelegate);
[delegate closePanel];
return true;
}