1 | // RUN: rm -rf %t |
2 | // RUN: %clang_cc1 -objcmt-migrate-ns-macros -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 |
3 | // RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result |
4 | // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result |
5 | |
6 | typedef signed char int8_t; |
7 | typedef short int16_t; |
8 | typedef int int32_t; |
9 | typedef long NSInteger; |
10 | typedef long long int64_t; |
11 | |
12 | typedef unsigned char uint8_t; |
13 | typedef unsigned short uint16_t; |
14 | typedef unsigned int uint32_t; |
15 | typedef unsigned long NSUInteger; |
16 | typedef unsigned long long uint64_t; |
17 | |
18 | #define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type |
19 | #define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type |
20 | #define DEPRECATED __attribute__((deprecated)) |
21 | |
22 | typedef NS_ENUM(NSInteger, wibble) { |
23 | blah, |
24 | blarg |
25 | }; |
26 | |
27 | typedef NS_ENUM(NSUInteger, UITableViewCellStyle) { |
28 | UIViewAutoresizingNone = 0, |
29 | UIViewAutoresizingFlexibleLeftMargin, |
30 | UIViewAutoresizingFlexibleWidth, |
31 | UIViewAutoresizingFlexibleRightMargin, |
32 | UIViewAutoresizingFlexibleTopMargin, |
33 | UIViewAutoresizingFlexibleHeight, |
34 | UIViewAutoresizingFlexibleBottomMargin |
35 | }; |
36 | |
37 | typedef NS_ENUM(unsigned int, UIViewAnimationTransition) { |
38 | UIViewAnimationTransitionNone, |
39 | UIViewAnimationTransitionFlipFromLeft, |
40 | UIViewAnimationTransitionFlipFromRight, |
41 | UIViewAnimationTransitionCurlUp, |
42 | UIViewAnimationTransitionCurlDown, |
43 | }; |
44 | |
45 | typedef NS_OPTIONS(unsigned int, UITableView) { |
46 | UIViewOne = 0, |
47 | UIViewTwo = 1 << 0, |
48 | UIViewThree = 1 << 1, |
49 | UIViewFour = 1 << 2, |
50 | UIViewFive = 1 << 3, |
51 | UIViewSix = 1 << 4, |
52 | UIViewSeven = 1 << 5 |
53 | }; |
54 | |
55 | typedef NS_OPTIONS(NSUInteger, UI) { |
56 | UIOne = 0, |
57 | UITwo = 0x1, |
58 | UIthree = 0x8, |
59 | UIFour = 0x100 |
60 | }; |
61 | |
62 | typedef NS_OPTIONS(unsigned int, UIPOWER2) { |
63 | UIP2One = 0, |
64 | UIP2Two = 0x1, |
65 | UIP2three = 0x8, |
66 | UIP2Four = 0x100 |
67 | }; |
68 | |
69 | enum { |
70 | UNOne, |
71 | UNTwo |
72 | }; |
73 | |
74 | // Should use NS_ENUM even though it is all power of 2. |
75 | typedef NS_ENUM(NSInteger, UIK) { |
76 | UIKOne = 1, |
77 | UIKTwo = 2, |
78 | }; |
79 | |
80 | typedef NS_ENUM(unsigned int, NSTickMarkPosition) { |
81 | NSTickMarkBelow = 0, |
82 | NSTickMarkAbove = 1, |
83 | NSTickMarkLeft = NSTickMarkAbove, |
84 | NSTickMarkRight = NSTickMarkBelow |
85 | }; |
86 | |
87 | typedef NS_OPTIONS(NSUInteger, UITableStyle) { |
88 | UIViewNone = 0x0, |
89 | UIViewMargin = 0x1, |
90 | UIViewWidth = 0x2, |
91 | UIViewRightMargin = 0x3, |
92 | UIViewBottomMargin = 0xbadbeef |
93 | }; |
94 | |
95 | typedef NS_OPTIONS(NSUInteger, UIStyle) { |
96 | UIView0 = 0, |
97 | UIView1 = 0XBADBEEF |
98 | }; |
99 | |
100 | typedef NS_ENUM(NSUInteger, NSBitmapImageFileType) { |
101 | NSTIFFFileType, |
102 | NSBMPFileType, |
103 | NSGIFFileType, |
104 | NSJPEGFileType, |
105 | NSPNGFileType, |
106 | NSJPEG2000FileType |
107 | }; |
108 | |
109 | typedef NS_ENUM(NSUInteger, NSAlertStyle) { |
110 | NSWarningAlertStyle = 0, |
111 | NSInformationalAlertStyle = 1, |
112 | NSCriticalAlertStyle = 2 |
113 | }; |
114 | |
115 | enum { |
116 | D_NSTIFFFileType, |
117 | D_NSBMPFileType, |
118 | D_NSGIFFileType, |
119 | D_NSJPEGFileType, |
120 | D_NSPNGFileType, |
121 | D_NSJPEG2000FileType |
122 | }; |
123 | typedef NSUInteger D_NSBitmapImageFileType DEPRECATED; |
124 | |
125 | typedef enum { |
126 | D_NSTickMarkBelow = 0, |
127 | D_NSTickMarkAbove = 1 |
128 | } D_NSTickMarkPosition DEPRECATED; |
129 | |
130 | |
131 | #define NS_ENUM_AVAILABLE(X,Y) |
132 | |
133 | |
134 | typedef NS_OPTIONS(NSUInteger, NSFOptions) { |
135 | NSFStrongMemory NS_ENUM_AVAILABLE(10_5, 6_0) = (0UL << 0), |
136 | NSFOpaqueMemory NS_ENUM_AVAILABLE(10_5, 6_0) = (2UL << 0), |
137 | NSFMallocMemory NS_ENUM_AVAILABLE(10_5, 6_0) = (3UL << 0), |
138 | NSFMachVirtualMemory NS_ENUM_AVAILABLE(10_5, 6_0) = (4UL << 0), |
139 | NSFWeakMemory NS_ENUM_AVAILABLE(10_8, 6_0) = (5UL << 0), |
140 | |
141 | NSFObjectPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (0UL << 8), |
142 | NSFOpaquePersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (1UL << 8), |
143 | NSFObjectPointerPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (2UL << 8), |
144 | NSFCStringPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (3UL << 8), |
145 | NSFStructPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (4UL << 8), |
146 | NSFIntegerPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (5UL << 8), |
147 | NSFCopyIn NS_ENUM_AVAILABLE(10_5, 6_0) = (1UL << 16), |
148 | }; |
149 | |
150 | typedef NS_ENUM(unsigned int, UIP) { |
151 | UIP0One = 0, |
152 | UIP0Two = 1, |
153 | UIP0Three = 2, |
154 | UIP0Four = 10, |
155 | UIP0Last = 0x100 |
156 | }; |
157 | |
158 | typedef NS_OPTIONS(unsigned int, UIP_3) { |
159 | UIPZero = 0x0, |
160 | UIPOne = 0x1, |
161 | UIPTwo = 0x2, |
162 | UIP10 = 0x10, |
163 | UIPHundred = 0x100 |
164 | }; |
165 | |
166 | typedef NS_ENUM(unsigned int, UIP4_3) { |
167 | UIP4Zero = 0x0, |
168 | UIP4One = 0x1, |
169 | UIP4Two = 0x2, |
170 | UIP410 = 0x10, |
171 | UIP4Hundred = 100 |
172 | }; |
173 | |
174 | typedef NS_OPTIONS(unsigned int, UIP5_3) { |
175 | UIP5Zero = 0x0, |
176 | UIP5Two = 0x2, |
177 | UIP510 = 0x3, |
178 | UIP5Hundred = 0x4 |
179 | }; |
180 | |
181 | typedef NS_ENUM(unsigned int, UIP6_3) { |
182 | UIP6Zero = 0x0, |
183 | UIP6One = 0x1, |
184 | UIP6Two = 0x2, |
185 | UIP610 = 10, |
186 | UIP6Hundred = 0x100 |
187 | }; |
188 | |
189 | typedef NS_ENUM(unsigned int, UIP7_3) { |
190 | UIP7Zero = 0x0, |
191 | UIP7One = 1, |
192 | UIP7Two = 0x2, |
193 | UIP710 = 10, |
194 | UIP7Hundred = 100 |
195 | }; |
196 | |
197 | |
198 | typedef NS_ENUM(unsigned int, UIP8_3) { |
199 | Random = 0, |
200 | Random1 = 2, |
201 | Random2 = 4, |
202 | Random3 = 0x12345, |
203 | Random4 = 0x3444444, |
204 | Random5 = 0xbadbeef, |
205 | Random6 |
206 | }; |
207 | |
208 | // rdar://15200602 |
209 | #define NS_AVAILABLE_MAC(X) __attribute__((availability(macosx,introduced=X))) |
210 | #define NS_ENUM_AVAILABLE_MAC(X) __attribute__((availability(macosx,introduced=X))) |
211 | |
212 | typedef NS_ENUM(NSInteger, NSModalResponse) { |
213 | NSModalResponseStop = (-1000), // Also used as the default response for sheets |
214 | NSModalResponseAbort = (-1001), |
215 | NSModalResponseContinue = (-1002), |
216 | } NS_ENUM_AVAILABLE_MAC(10.9); |
217 | |
218 | // rdar://15201056 |
219 | typedef NSUInteger FarFarAwayOptions; |
220 | |
221 | // rdar://15200915 |
222 | typedef NS_OPTIONS(NSUInteger, FarAwayOptions) { |
223 | FarAway1 = 1 << 1, |
224 | FarAway2 = 1 << 2 |
225 | }; |
226 | typedef NS_OPTIONS(NSUInteger, NSWorkspaceLaunchOptions) { |
227 | NSWorkspaceLaunchAndPrint = 0x00000002, |
228 | NSWorkspaceLaunchWithErrorPresentation = 0x00000040, |
229 | NSWorkspaceLaunchInhibitingBackgroundOnly = 0x00000080, |
230 | NSWorkspaceLaunchWithoutAddingToRecents = 0x00000100, |
231 | NSWorkspaceLaunchWithoutActivation = 0x00000200, |
232 | NSWorkspaceLaunchAsync = 0x00010000, |
233 | NSWorkspaceLaunchAllowingClassicStartup = 0x00020000, |
234 | NSWorkspaceLaunchPreferringClassic = 0x00040000, |
235 | NSWorkspaceLaunchNewInstance = 0x00080000, |
236 | NSWorkspaceLaunchAndHide = 0x00100000, |
237 | NSWorkspaceLaunchAndHideOthers = 0x00200000, |
238 | NSWorkspaceLaunchDefault = NSWorkspaceLaunchAsync | |
239 | NSWorkspaceLaunchAllowingClassicStartup |
240 | }; |
241 | |
242 | typedef NS_OPTIONS(NSUInteger, NSExcludeOptions) { |
243 | NSExcludeQuickDrawElementsIconCreationOption = 1 << 1, |
244 | NSExclude10_4ElementsIconCreationOption = 1 << 2 |
245 | }; |
246 | |
247 | typedef NS_OPTIONS(NSUInteger, NSExcludeCreationOption) { |
248 | NSExcludeQuickDrawElementsCreationOption = 1 << 1, |
249 | NSExclude10_4ElementsCreationOption = 1 << 2 |
250 | }; |
251 | |
252 | |
253 | typedef NS_OPTIONS(NSUInteger, NSExcludeIconOptions) { |
254 | NSExcludeQuickDrawElementsIconOption = 1 << 1, |
255 | NSExclude10_4ElementsIconOption = 1 << 2 |
256 | }; |
257 | |
258 | @interface INTF { |
259 | NSExcludeIconOptions I1; |
260 | NSExcludeIconOptions I2; |
261 | } |
262 | @end |
263 | |
264 | enum { |
265 | FarFarAway1 = 1 << 1, |
266 | FarFarAway2 = 1 << 2 |
267 | }; |
268 | |
269 | // rdar://15200915 |
270 | typedef NS_OPTIONS(NSUInteger, NSWindowOcclusionState) { |
271 | NSWindowOcclusionStateVisible = 1UL << 1, |
272 | }; |
273 | |
274 | typedef NS_ENUM(NSUInteger, NSWindowNumberListOptions) { |
275 | NSWindowCloseButton, |
276 | NSWindowMiniaturizeButton, |
277 | NSWindowZoomButton, |
278 | NSWindowToolbarButton, |
279 | NSWindowDocumentIconButton |
280 | }; |
281 | |
282 | typedef NS_ENUM(NSUInteger, NSSelectionDirection) { |
283 | NSDirectSelection = 0, |
284 | NSSelectingNext, |
285 | NSSelectingPrevious |
286 | }; |
287 | |
288 | // standard window buttons |
289 | |
290 | // rdar://18262255 |
291 | typedef NS_ENUM(NSUInteger, Thing) { |
292 | ThingOne, |
293 | ThingTwo, |
294 | ThingThree, |
295 | }; |
296 | |
297 | // rdar://18498539 |
298 | typedef NS_ENUM(unsigned int, NumericEnum) { |
299 | one = 1 |
300 | }; |
301 | |
302 | typedef NS_ENUM(unsigned int, NumericEnum2) { |
303 | Two = 2 |
304 | }; |
305 | |
306 | typedef NS_ENUM(unsigned int, NumericEnum3) { |
307 | Three = 3 |
308 | }; |
309 | |
310 | typedef NS_OPTIONS(unsigned int, NumericEnum4) { |
311 | Four = 4 |
312 | }; |
313 | |
314 | // rdar://18532199 |
315 | typedef NS_ENUM(int8_t, MyEnumeratedType) |
316 | { |
317 | UI8one = 1 |
318 | }; |
319 | |
320 | |
321 | typedef NS_OPTIONS(uint16_t, UI16) { |
322 | UI16One = 0, |
323 | UI16Two = 0x1, |
324 | UI16three = 0x8, |
325 | UI16Four = 0x100 |
326 | }; |
327 | |
328 | typedef NS_ENUM(uint32_t, UI32TableViewCellStyle) { |
329 | UI32ViewAutoresizingNone = 0, |
330 | UI32ViewAutoresizingFlexibleLeftMargin, |
331 | UI32ViewAutoresizingFlexibleWidth, |
332 | UI32ViewAutoresizingFlexibleRightMargin, |
333 | UI32ViewAutoresizingFlexibleTopMargin, |
334 | UI32ViewAutoresizingFlexibleHeight, |
335 | UI32ViewAutoresizingFlexibleBottomMargin |
336 | }; |
337 | |
338 | typedef NS_ENUM(uint8_t, UI8Type) |
339 | { |
340 | UIU8one = 1 |
341 | }; |
342 | |
343 | // rdar://19352510 |
344 | typedef NS_ENUM(NSInteger, MyEnum) {zero}; |
345 | |
346 | typedef NS_ENUM(NSUInteger, MyEnumNSUInteger) {two}; |
347 | |
348 | typedef NS_ENUM(int, MyEnumint) {three, four}; |
349 | |
350 | typedef NS_ENUM(unsigned long, MyEnumlonglong) {five}; |
351 | |
352 | typedef NS_ENUM(unsigned long long, MyEnumunsignedlonglong) { |
353 | ll1, |
354 | ll2= 0xff, |
355 | ll3, |
356 | ll4 |
357 | }; |
358 | |
359 | // rdar://19994496 |
360 | typedef NS_ENUM(int8_t, MyOneEnum) {int8_one}; |
361 | |
362 | typedef NS_ENUM(int16_t, Myint16_tEnum) { |
363 | int16_t_one, |
364 | int16_t_two }; |
365 | |