diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2022-01-18 16:26:51 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2022-02-01 16:56:02 +0100 |
commit | e05300163ea865f8233e61f8f6a2b341197203e4 (patch) | |
tree | 928dac9789414598f02ab1929fd93f9555e08676 /src/corelib/kernel/qcore_mac_p.h | |
parent | 7d19efa7bb837f45812b13b24891bb718e874012 (diff) |
Move QIOType wrapper for io_object_t to QtCore
Since we require C++17 now we can use auto for the retain and release
template arguments, which allows us to get rid of the wrapper functions
for IOObjectRetain and IOObjectRelease.
Pick-to: 6.2 6.3
Change-Id: Ifc4bf0fe50dfd0eaf6bb2e143acce6df7df17bdc
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/corelib/kernel/qcore_mac_p.h')
-rw-r--r-- | src/corelib/kernel/qcore_mac_p.h | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/corelib/kernel/qcore_mac_p.h b/src/corelib/kernel/qcore_mac_p.h index 7b503d10cc..30e5238cd0 100644 --- a/src/corelib/kernel/qcore_mac_p.h +++ b/src/corelib/kernel/qcore_mac_p.h @@ -54,7 +54,16 @@ #include "private/qglobal_p.h" #include <QtCore/qoperatingsystemversion.h> + +#ifdef Q_OS_MACOS struct mach_header; +typedef int kern_return_t; +typedef mach_port_t io_object_t; +extern "C" { +kern_return_t IOObjectRetain(io_object_t object); +kern_return_t IOObjectRelease(io_object_t object); +} +#endif #ifndef __IMAGECAPTURE__ # define __IMAGECAPTURE__ @@ -104,7 +113,7 @@ Q_FORWARD_DECLARE_OBJC_CLASS(NSObject); Q_FORWARD_DECLARE_OBJC_CLASS(NSString); QT_BEGIN_NAMESPACE -template <typename T, typename U, U (*RetainFunction)(U), void (*ReleaseFunction)(U)> +template <typename T, typename U, auto RetainFunction, auto ReleaseFunction> class QAppleRefCounted { public: @@ -172,6 +181,14 @@ public: } }; +#ifdef Q_OS_MACOS +template <typename T> +class QIOType : public QAppleRefCounted<T, io_object_t, IOObjectRetain, IOObjectRelease> +{ + using QAppleRefCounted<T, io_object_t, IOObjectRetain, IOObjectRelease>::QAppleRefCounted; +}; +#endif + class Q_CORE_EXPORT QCFString : public QCFType<CFStringRef> { public: |