-
Notifications
You must be signed in to change notification settings - Fork 95
/
Copy pathUnrarKitMacros.h
126 lines (96 loc) · 4.57 KB
/
UnrarKitMacros.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
//
// UnrarKitMacros.h
// UnrarKit
//
// Created by Dov Frankel on 8/8/17.
// Copyright © 2017 Abbey Code. All rights reserved.
//
#ifndef UnrarKitMacros_h
#define UnrarKitMacros_h
//#import "Availability.h"
//#import "AvailabilityInternal.h"
#define _stringify(a) #a
#define RarHppIgnore \
_Pragma( _stringify( clang diagnostic push ) ) \
_Pragma( _stringify( clang diagnostic ignored "-Wcast-align" ) ) \
_Pragma( _stringify( clang diagnostic ignored "-Wextra-semi" ) ) \
_Pragma( _stringify( clang diagnostic ignored "-Wold-style-cast" ) ) \
_Pragma( _stringify( clang diagnostic ignored "-Wpadded" ) ) \
_Pragma( _stringify( clang diagnostic ignored "-Wreserved-id-macro" ) ) \
_Pragma( _stringify( clang diagnostic ignored "-Wshorten-64-to-32" ) ) \
_Pragma( _stringify( clang diagnostic ignored "-Wcast-qual" ) ) \
_Pragma( _stringify( clang diagnostic ignored "-Wundef" ) ) \
#define DllHppIgnore \
_Pragma( _stringify( clang diagnostic push ) ) \
_Pragma( _stringify( clang diagnostic ignored "-Wreserved-id-macro" ) ) \
_Pragma( _stringify( clang diagnostic ignored "-Wstrict-prototypes" ) ) \
#define RarosHppIgnore \
_Pragma( _stringify( clang diagnostic push ) ) \
_Pragma( _stringify( clang diagnostic ignored "-Wreserved-id-macro" ) ) \
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wundef"
#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
// iOS 10, macOS 10.12, tvOS 10.0, watchOS 3.0
#define UNIFIED_LOGGING_SUPPORTED \
__IPHONE_OS_VERSION_MIN_REQUIRED >= 100000 \
|| __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200 \
|| __TV_OS_VERSION_MIN_REQUIRED >= 100000 \
|| __WATCH_OS_VERSION_MIN_REQUIRED >= 30000
#if TARGET_OS_IPHONE
#define SDK_10_13_MAJOR 11
#define SDK_10_13_MINOR 0
#else
#define SDK_10_13_MAJOR 10
#define SDK_10_13_MINOR 13
#endif
#if UNIFIED_LOGGING_SUPPORTED
#import <os/log.h>
#import <os/activity.h>
// Called from +[UnrarKit initialize] and +[URKArchiveTestCase setUp]
extern os_log_t unrarkit_log; // Declared in URKArchive.mm
extern BOOL unrarkitIsAtLeast10_13SDK; // Declared in URKArchive.m
#define URKLogInit() \
unrarkit_log = os_log_create("com.abbey-code.UnrarKit", "General"); \
\
NSOperatingSystemVersion minVersion; \
minVersion.majorVersion = SDK_10_13_MAJOR; \
minVersion.minorVersion = SDK_10_13_MINOR; \
minVersion.patchVersion = 0; \
unrarkitIsAtLeast10_13SDK = [[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion:minVersion]; \
URKLogDebug("Is >= 10.13 (or iOS 11): %@", unrarkitIsAtLeast10_13SDK ? @"YES" : @"NO");
#define URKLog(format, ...) os_log(unrarkit_log, format, ##__VA_ARGS__);
#define URKLogInfo(format, ...) os_log_info(unrarkit_log, format, ##__VA_ARGS__);
#define URKLogDebug(format, ...) os_log_debug(unrarkit_log, format, ##__VA_ARGS__);
#define URKLogError(format, ...) \
if (unrarkitIsAtLeast10_13SDK) os_log_error(unrarkit_log, format, ##__VA_ARGS__); \
else os_log_with_type(unrarkit_log, OS_LOG_TYPE_ERROR, format, ##__VA_ARGS__);
#define URKLogFault(format, ...) \
if (unrarkitIsAtLeast10_13SDK) os_log_fault(unrarkit_log, format, ##__VA_ARGS__); \
else os_log_with_type(unrarkit_log, OS_LOG_TYPE_FAULT, format, ##__VA_ARGS__);
#define URKCreateActivity(name) \
os_activity_t activity = os_activity_create(name, OS_ACTIVITY_CURRENT, OS_ACTIVITY_FLAG_DEFAULT); \
os_activity_scope(activity);
#else // Fall back to regular NSLog
// No-op, as nothing needs to be initialized
#define URKLogInit() (void)0
// Only used below
#define _removeLogFormatTokens(format) [[@format \
stringByReplacingOccurrencesOfString:@"{public}" withString:@""] \
stringByReplacingOccurrencesOfString:@"{iec-bytes}" withString:@""]
#define _nsLogWithoutWarnings(format, ...) \
_Pragma( _stringify( clang diagnostic push ) ) \
_Pragma( _stringify( clang diagnostic ignored "-Wformat-nonliteral" ) ) \
_Pragma( _stringify( clang diagnostic ignored "-Wformat-security" ) ) \
NSLog(_removeLogFormatTokens(format), ##__VA_ARGS__); \
_Pragma( _stringify( clang diagnostic pop ) )
// All levels do the same thing
#define URKLog(format, ...) _nsLogWithoutWarnings(format, ##__VA_ARGS__);
#define URKLogInfo(format, ...) _nsLogWithoutWarnings(format, ##__VA_ARGS__);
#define URKLogDebug(format, ...) _nsLogWithoutWarnings(format, ##__VA_ARGS__);
#define URKLogError(format, ...) _nsLogWithoutWarnings(format, ##__VA_ARGS__);
#define URKLogFault(format, ...) _nsLogWithoutWarnings(format, ##__VA_ARGS__);
// No-op, as no equivalent to Activities exists
#define URKCreateActivity(name) (void)0
#pragma clang diagnostic pop
#endif // UNIFIED_LOGGING_SUPPORTED
#endif /* UnrarKitMacros_h */