From 2b65bba77d4705d49a01a25350de64d153808504 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Mon, 2 Sep 2013 10:12:07 +0200 Subject: Add Mac type conversion functions to QtCore New API: static QString QString::fromCFString(CFStringRef string); CFStringRef QString::toCFString() const; static QString QString::fromNSString(const NSString *string); NSString *QString::toNSString() const; static QUrl QUrl::fromCFURL(CFURLRef url); CFURLRef QUrl::toCFURL() const; static QUrl QUrl::fromNSURL(const NSURL *url); NSURL * QUrl::toNSURL() const; Add Q_OS_MAC-protected function declarations to header files, add implementation to _mm files. CF and NS types are forward-declared in the header files to avoid including the CoreFoundation and Foundation headers. This prevents accidental use of native types in application code. Add helper macros for forward- declaration to qglobal.h Add cf_returns_retained/ns_returns_autoreleased attributes to toCFString() and toNSURL(). These attributes assists the clang static analyzer. Add Q_DECL_ helper macros to qcompilerdetection.h. Add test functions (in _mac.mm files) to the QString and QUrl tests. Split out the test class declarations into a separate headers files. Change-Id: I60fd5e93f042316196284c3db0595835fe8c4ad4 Reviewed-by: Gabriel de Dietrich --- tests/auto/corelib/tools/qstring/tst_qstring.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests/auto/corelib/tools/qstring/tst_qstring.cpp') diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index e7ad52a257..0148ba6d03 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -170,6 +170,7 @@ private slots: void constructorQByteArray_data(); void constructorQByteArray(); void STL(); + void macTypes(); void isEmpty(); void isNull(); void acc_01(); @@ -939,6 +940,16 @@ void tst_QString::STL() QCOMPARE(stlStr, s.toStdWString()); } +void tst_QString::macTypes() +{ +#ifndef Q_OS_MAC + QSKIP("This is a Mac-only test"); +#else + extern void tst_QString_macTypes(); // in qstring_mac.mm + tst_QString_macTypes(); +#endif +} + void tst_QString::truncate() { QString e("String E"); -- cgit v1.2.3