@@ -101,241 +101,60 @@ extension NSImage : _ExpressibleByImageLiteral {
101
101
102
102
public typealias _ImageLiteralType = NSImage
103
103
104
- // Extensions for common numeric enum operations
104
+ // Numeric backed types
105
105
106
106
@available ( swift 4 )
107
- public protocol _AppKitNumericWrapper : RawRepresentable { }
108
- extension _AppKitNumericWrapper where RawValue == Float {
109
- public static func + ( lhs: Self , rhs: Double ) -> Self {
110
- return Self ( rawValue: lhs. rawValue + Float( rhs) ) !
111
- }
112
- public static func - ( lhs: Self , rhs: Double ) -> Self {
113
- return Self ( rawValue: lhs. rawValue - Float( rhs) ) !
114
- }
115
- public static func + ( lhs: Self , rhs: Float ) -> Self {
116
- return Self ( rawValue: lhs. rawValue + rhs) !
117
- }
118
- public static func - ( lhs: Self , rhs: Float ) -> Self {
119
- return Self ( rawValue: lhs. rawValue - rhs) !
120
- }
121
- public static func + ( lhs: Self , rhs: Int ) -> Self {
122
- return Self ( rawValue: lhs. rawValue + Float( rhs) ) !
123
- }
124
- public static func - ( lhs: Self , rhs: Int ) -> Self {
125
- return Self ( rawValue: lhs. rawValue - Float( rhs) ) !
126
- }
127
- public static func + ( lhs: Float , rhs: Self ) -> Self {
128
- return Self ( rawValue: lhs + rhs. rawValue) !
129
- }
130
- public static func + ( lhs: Int , rhs: Self ) -> Self {
131
- return Self ( rawValue: Float ( lhs) + rhs. rawValue) !
132
- }
133
- public static func + ( lhs: Double , rhs: Self ) -> Self {
134
- return Self ( rawValue: Float ( lhs) + rhs. rawValue) !
135
- }
136
- public static func += ( lhs: inout Self , rhs: Double ) {
137
- lhs = Self ( rawValue: lhs. rawValue + Float( rhs) ) !
138
- }
139
- public static func += ( lhs: inout Self , rhs: Float ) {
140
- lhs = Self ( rawValue: lhs. rawValue + rhs) !
141
- }
142
- public static func += ( lhs: inout Self , rhs: Int ) {
143
- lhs = Self ( rawValue: lhs. rawValue + Float( rhs) ) !
144
- }
145
- public static func -= ( lhs: inout Self , rhs: Double ) {
146
- lhs = Self ( rawValue: lhs. rawValue - Float( rhs) ) !
147
- }
148
- public static func -= ( lhs: inout Self , rhs: Float ) {
149
- lhs = Self ( rawValue: lhs. rawValue - rhs) !
150
- }
151
- public static func -= ( lhs: inout Self , rhs: Int ) {
152
- lhs = Self ( rawValue: lhs. rawValue - Float( rhs) ) !
153
- }
154
- }
155
- extension _AppKitNumericWrapper where RawValue == CGFloat {
156
- public static func + ( lhs: Self , rhs: Double ) -> Self {
157
- return Self ( rawValue: lhs. rawValue + CGFloat( rhs) ) !
158
- }
159
- public static func - ( lhs: Self , rhs: Double ) -> Self {
160
- return Self ( rawValue: lhs. rawValue - CGFloat( rhs) ) !
161
- }
162
- public static func + ( lhs: Self , rhs: Float ) -> Self {
163
- return Self ( rawValue: lhs. rawValue + CGFloat( rhs) ) !
164
- }
165
- public static func - ( lhs: Self , rhs: Float ) -> Self {
166
- return Self ( rawValue: lhs. rawValue - CGFloat( rhs) ) !
167
- }
168
- public static func + ( lhs: Self , rhs: CGFloat ) -> Self {
169
- return Self ( rawValue: lhs. rawValue + rhs) !
170
- }
171
- public static func - ( lhs: Self , rhs: CGFloat ) -> Self {
172
- return Self ( rawValue: lhs. rawValue - rhs) !
173
- }
174
- public static func + ( lhs: Self , rhs: Int ) -> Self {
175
- return Self ( rawValue: lhs. rawValue + CGFloat( rhs) ) !
176
- }
177
- public static func - ( lhs: Self , rhs: Int ) -> Self {
178
- return Self ( rawValue: lhs. rawValue - CGFloat( rhs) ) !
179
- }
180
- public static func + ( lhs: Float , rhs: Self ) -> Self {
181
- return Self ( rawValue: CGFloat ( lhs) + rhs. rawValue) !
182
- }
183
- public static func + ( lhs: Int , rhs: Self ) -> Self {
184
- return Self ( rawValue: CGFloat ( lhs) + rhs. rawValue) !
185
- }
186
- public static func + ( lhs: Double , rhs: Self ) -> Self {
187
- return Self ( rawValue: CGFloat ( lhs) + rhs. rawValue) !
188
- }
189
- public static func += ( lhs: inout Self , rhs: Double ) {
190
- lhs = Self ( rawValue: lhs. rawValue + CGFloat( rhs) ) !
191
- }
192
- public static func += ( lhs: inout Self , rhs: Float ) {
193
- lhs = Self ( rawValue: lhs. rawValue + CGFloat( rhs) ) !
194
- }
195
- public static func += ( lhs: inout Self , rhs: CGFloat ) {
196
- lhs = Self ( rawValue: lhs. rawValue + rhs) !
197
- }
198
- public static func += ( lhs: inout Self , rhs: Int ) {
199
- lhs = Self ( rawValue: lhs. rawValue + CGFloat( rhs) ) !
200
- }
201
- public static func -= ( lhs: inout Self , rhs: Double ) {
202
- lhs = Self ( rawValue: lhs. rawValue - CGFloat( rhs) ) !
203
- }
204
- public static func -= ( lhs: inout Self , rhs: Float ) {
205
- lhs = Self ( rawValue: lhs. rawValue - CGFloat( rhs) ) !
206
- }
207
- public static func -= ( lhs: inout Self , rhs: CGFloat ) {
208
- lhs = Self ( rawValue: lhs. rawValue - rhs) !
209
- }
210
- public static func -= ( lhs: inout Self , rhs: Int ) {
211
- lhs = Self ( rawValue: lhs. rawValue - CGFloat( rhs) ) !
107
+ public protocol _AppKitKitNumericRawRepresentable : RawRepresentable , Comparable
108
+ where RawValue: Comparable & Numeric { }
109
+
110
+ extension _AppKitKitNumericRawRepresentable {
111
+ public static func < ( lhs: Self , rhs: Self ) -> Bool {
112
+ return lhs. rawValue < rhs. rawValue
212
113
}
213
- }
214
- extension _AppKitNumericWrapper where RawValue == Double {
215
- public static func + ( lhs: Self , rhs: Double ) -> Self {
114
+
115
+ public static func + ( lhs: Self , rhs: RawValue ) -> Self {
216
116
return Self ( rawValue: lhs. rawValue + rhs) !
217
117
}
218
- public static func - ( lhs: Self , rhs: Double ) -> Self {
219
- return Self ( rawValue: lhs. rawValue - rhs) !
220
- }
221
- public static func + ( lhs: Self , rhs: Float ) -> Self {
222
- return Self ( rawValue: lhs. rawValue + Double( rhs) ) !
223
- }
224
- public static func - ( lhs: Self , rhs: Float ) -> Self {
225
- return Self ( rawValue: lhs. rawValue - Double( rhs) ) !
226
- }
227
- public static func + ( lhs: Self , rhs: Int ) -> Self {
228
- return Self ( rawValue: lhs. rawValue + Double( rhs) ) !
229
- }
230
- public static func - ( lhs: Self , rhs: Int ) -> Self {
231
- return Self ( rawValue: lhs. rawValue - Double( rhs) ) !
232
- }
233
- public static func + ( lhs: Float , rhs: Self ) -> Self {
234
- return Self ( rawValue: Double ( lhs) + rhs. rawValue) !
235
- }
236
- public static func + ( lhs: Int , rhs: Self ) -> Self {
237
- return Self ( rawValue: Double ( lhs) + rhs. rawValue) !
238
- }
239
- public static func + ( lhs: Double , rhs: Self ) -> Self {
118
+
119
+ public static func + ( lhs: RawValue , rhs: Self ) -> Self {
240
120
return Self ( rawValue: lhs + rhs. rawValue) !
241
121
}
242
- public static func += ( lhs: inout Self , rhs: Double ) {
243
- lhs = Self ( rawValue: lhs. rawValue + rhs) !
244
- }
245
- public static func += ( lhs: inout Self , rhs: Float ) {
246
- lhs = Self ( rawValue: lhs. rawValue + Double( rhs) ) !
247
- }
248
- public static func += ( lhs: inout Self , rhs: Int ) {
249
- lhs = Self ( rawValue: lhs. rawValue + Double( rhs) ) !
250
- }
251
- public static func -= ( lhs: inout Self , rhs: Double ) {
252
- lhs = Self ( rawValue: lhs. rawValue - rhs) !
253
- }
254
- public static func -= ( lhs: inout Self , rhs: Float ) {
255
- lhs = Self ( rawValue: lhs. rawValue - Double( rhs) ) !
256
- }
257
- public static func -= ( lhs: inout Self , rhs: Int ) {
258
- lhs = Self ( rawValue: lhs. rawValue - Double( rhs) ) !
259
- }
260
- }
261
- extension _AppKitNumericWrapper where RawValue == Int {
262
- public static func + ( lhs: Self , rhs: Int ) -> Self {
263
- return Self ( rawValue: lhs. rawValue + rhs) !
264
- }
265
- public static func - ( lhs: Self , rhs: Int ) -> Self {
122
+
123
+ public static func - ( lhs: Self , rhs: RawValue ) -> Self {
266
124
return Self ( rawValue: lhs. rawValue - rhs) !
267
125
}
268
- public static func + ( lhs: Int , rhs: Self ) -> Self {
269
- return Self ( rawValue: lhs + rhs. rawValue) !
126
+
127
+ public static func - ( lhs: Self , rhs: Self ) -> RawValue {
128
+ return lhs. rawValue - rhs. rawValue
270
129
}
271
- public static func += ( lhs: inout Self , rhs: Int ) {
272
- lhs = Self ( rawValue: lhs. rawValue + rhs) !
130
+
131
+ public static func += ( lhs: inout Self , rhs: RawValue ) {
132
+ lhs = Self ( rawValue: lhs. rawValue + rhs) !
273
133
}
274
- public static func -= ( lhs: inout Self , rhs: Int ) {
275
- lhs = Self ( rawValue: lhs. rawValue - rhs) !
134
+
135
+ public static func -= ( lhs: inout Self , rhs: RawValue ) {
136
+ lhs = Self ( rawValue: lhs. rawValue - rhs) !
276
137
}
277
138
}
278
139
279
140
@available ( swift 4 )
280
- extension NSAppKitVersion : _AppKitNumericWrapper , Comparable {
281
- public static func < ( lhs: NSAppKitVersion , rhs: NSAppKitVersion ) -> Bool {
282
- return lhs. rawValue < rhs. rawValue
283
- }
284
- public static func > ( lhs: NSAppKitVersion , rhs: NSAppKitVersion ) -> Bool {
285
- return lhs. rawValue > rhs. rawValue
286
- }
287
- }
141
+ extension NSAppKitVersion : _AppKitKitNumericRawRepresentable { }
142
+
288
143
@available ( swift 4 )
289
- extension NSLayoutConstraint . Priority : _AppKitNumericWrapper , Comparable {
290
- public static func < ( lhs: NSLayoutConstraint . Priority , rhs: NSLayoutConstraint . Priority ) -> Bool {
291
- return lhs. rawValue < rhs. rawValue
292
- }
293
- public static func > ( lhs: NSLayoutConstraint . Priority , rhs: NSLayoutConstraint . Priority ) -> Bool {
294
- return lhs. rawValue > rhs. rawValue
295
- }
296
- }
144
+ extension NSLayoutConstraint . Priority : _AppKitKitNumericRawRepresentable { }
145
+
297
146
@available ( swift 4 )
298
- extension NSStackView . VisibilityPriority : _AppKitNumericWrapper , Comparable {
299
- public static func < ( lhs: NSStackView . VisibilityPriority , rhs: NSStackView . VisibilityPriority ) -> Bool {
300
- return lhs. rawValue < rhs. rawValue
301
- }
302
- public static func > ( lhs: NSStackView . VisibilityPriority , rhs: NSStackView . VisibilityPriority ) -> Bool {
303
- return lhs. rawValue > rhs. rawValue
304
- }
305
- }
147
+ extension NSStackView . VisibilityPriority : _AppKitKitNumericRawRepresentable { }
148
+
306
149
@available ( swift 4 )
307
- extension NSToolbarItem . VisibilityPriority : _AppKitNumericWrapper , Comparable {
308
- public static func < ( lhs: NSToolbarItem . VisibilityPriority , rhs: NSToolbarItem . VisibilityPriority ) -> Bool {
309
- return lhs. rawValue < rhs. rawValue
310
- }
311
- public static func > ( lhs: NSToolbarItem . VisibilityPriority , rhs: NSToolbarItem . VisibilityPriority ) -> Bool {
312
- return lhs. rawValue > rhs. rawValue
313
- }
314
- }
315
- @available ( swift 4 ) @available ( macOS 10 . 12 . 2 , * )
316
- extension NSTouchBarItem . Priority : _AppKitNumericWrapper , Comparable {
317
- public static func < ( lhs: NSTouchBarItem . Priority , rhs: NSTouchBarItem . Priority ) -> Bool {
318
- return lhs. rawValue < rhs. rawValue
319
- }
320
- public static func > ( lhs: NSTouchBarItem . Priority , rhs: NSTouchBarItem . Priority ) -> Bool {
321
- return lhs. rawValue > rhs. rawValue
322
- }
323
- }
150
+ extension NSToolbarItem . VisibilityPriority : _AppKitKitNumericRawRepresentable { }
151
+
152
+ @available ( macOS 10 . 12 . 2 , * )
324
153
@available ( swift 4 )
325
- extension NSWindow . Level : _AppKitNumericWrapper , Comparable {
326
- public static func < ( lhs: NSWindow . Level , rhs: NSWindow . Level ) -> Bool {
327
- return lhs. rawValue < rhs. rawValue
328
- }
329
- public static func > ( lhs: NSWindow . Level , rhs: NSWindow . Level ) -> Bool {
330
- return lhs. rawValue > rhs. rawValue
331
- }
332
- }
154
+ extension NSTouchBarItem . Priority : _AppKitKitNumericRawRepresentable { }
155
+
333
156
@available ( swift 4 )
334
- extension NSFont . Weight : _AppKitNumericWrapper , Comparable {
335
- public static func < ( lhs: NSFont . Weight , rhs: NSFont . Weight ) -> Bool {
336
- return lhs. rawValue < rhs. rawValue
337
- }
338
- public static func > ( lhs: NSFont . Weight , rhs: NSFont . Weight ) -> Bool {
339
- return lhs. rawValue > rhs. rawValue
340
- }
341
- }
157
+ extension NSWindow . Level : _AppKitKitNumericRawRepresentable { }
158
+
159
+ @available ( swift 4 )
160
+ extension NSFont . Weight : _AppKitKitNumericRawRepresentable { }
0 commit comments