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
6typedef long NSInteger;
7typedef unsigned long NSUInteger;
8
9#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
10#define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type
11#define DEPRECATED  __attribute__((deprecated))
12
13typedef NS_ENUM(NSInteger, wibble) {
14  blah,
15  blarg
16};
17
18typedef NS_ENUM(NSUInteger, UITableViewCellStyle) {
19    UIViewAutoresizingNone                 = 0,
20    UIViewAutoresizingFlexibleLeftMargin,
21    UIViewAutoresizingFlexibleWidth,
22    UIViewAutoresizingFlexibleRightMargin,
23    UIViewAutoresizingFlexibleTopMargin,
24    UIViewAutoresizingFlexibleHeight,
25    UIViewAutoresizingFlexibleBottomMargin
26};
27
28typedef NS_ENUM(NSInteger, UIViewAnimationTransition) {
29    UIViewAnimationTransitionNone,
30    UIViewAnimationTransitionFlipFromLeft,
31    UIViewAnimationTransitionFlipFromRight,
32    UIViewAnimationTransitionCurlUp,
33    UIViewAnimationTransitionCurlDown,
34} ;
35
36typedef NS_OPTIONS(NSUInteger, UITableView) {
37    UIViewOne   = 0,
38    UIViewTwo   = 1 << 0,
39    UIViewThree = 1 << 1,
40    UIViewFour  = 1 << 2,
41    UIViewFive  = 1 << 3,
42    UIViewSix   = 1 << 4,
43    UIViewSeven = 1 << 5
44} ;
45
46typedef NS_OPTIONS(NSUInteger, UI) {
47  UIOne = 0,
48  UITwo = 0x1,
49  UIthree = 0x8,
50  UIFour = 0x100
51};
52
53typedef NS_OPTIONS(NSUInteger, UIPOWER2) {
54  UIP2One = 0,
55  UIP2Two = 0x1,
56  UIP2three = 0x8,
57  UIP2Four = 0x100
58} ;
59
60enum {
61  UNOne,
62  UNTwo
63};
64
65// Should use NS_ENUM even though it is all power of 2.
66typedef NS_ENUM(NSInteger, UIK) {
67  UIKOne = 1,
68  UIKTwo = 2,
69};
70
71typedef NS_ENUM(NSInteger, NSTickMarkPosition)  {
72    NSTickMarkBelow = 0,
73    NSTickMarkAbove = 1,
74    NSTickMarkLeft = NSTickMarkAbove,
75    NSTickMarkRight = NSTickMarkBelow
76} ;
77
78typedef NS_OPTIONS(NSUInteger, UITableStyle) {
79    UIViewNone         = 0x0,
80    UIViewMargin       = 0x1,
81    UIViewWidth        = 0x2,
82    UIViewRightMargin  = 0x3,
83    UIViewBottomMargin = 0xbadbeef
84};
85
86typedef NS_OPTIONS(NSUInteger, UIStyle) {
87    UIView0         = 0,
88    UIView1 = 0XBADBEEF
89};
90
91typedef NS_ENUM(NSUInteger, NSBitmapImageFileType) {
92    NSTIFFFileType,
93    NSBMPFileType,
94    NSGIFFileType,
95    NSJPEGFileType,
96    NSPNGFileType,
97    NSJPEG2000FileType
98};
99
100typedef NS_ENUM(NSUInteger, NSAlertStyle) {
101    NSWarningAlertStyle = 0,
102    NSInformationalAlertStyle = 1,
103    NSCriticalAlertStyle = 2
104};
105
106enum {
107    D_NSTIFFFileType,
108    D_NSBMPFileType,
109    D_NSGIFFileType,
110    D_NSJPEGFileType,
111    D_NSPNGFileType,
112    D_NSJPEG2000FileType
113};
114typedef NSUInteger D_NSBitmapImageFileType DEPRECATED;
115
116typedef enum  {
117    D_NSTickMarkBelow = 0,
118    D_NSTickMarkAbove = 1
119} D_NSTickMarkPosition DEPRECATED;
120
121
122#define NS_ENUM_AVAILABLE(X,Y)
123
124
125typedef NS_OPTIONS(NSUInteger, NSFOptions) {
126    NSFStrongMemory NS_ENUM_AVAILABLE(10_5, 6_0) = (0UL << 0),       
127    NSFOpaqueMemory NS_ENUM_AVAILABLE(10_5, 6_0) = (2UL << 0),
128    NSFMallocMemory NS_ENUM_AVAILABLE(10_5, 6_0) = (3UL << 0),       
129    NSFMachVirtualMemory NS_ENUM_AVAILABLE(10_5, 6_0) = (4UL << 0),
130    NSFWeakMemory NS_ENUM_AVAILABLE(10_8, 6_0) = (5UL << 0),         
131
132    NSFObjectPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (0UL << 8),         
133    NSFOpaquePersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (1UL << 8),         
134    NSFObjectPointerPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (2UL << 8),  
135    NSFCStringPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (3UL << 8),        
136    NSFStructPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (4UL << 8),         
137    NSFIntegerPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (5UL << 8),        
138    NSFCopyIn NS_ENUM_AVAILABLE(10_5, 6_0) = (1UL << 16),      
139};
140
141typedef NS_ENUM(NSInteger, UIP) {
142  UIP0One = 0,
143  UIP0Two = 1,
144  UIP0Three = 2,
145  UIP0Four = 10,
146  UIP0Last = 0x100
147} ;
148
149typedef NS_OPTIONS(NSUInteger, UIP_3) {
150  UIPZero = 0x0,
151  UIPOne = 0x1,
152  UIPTwo = 0x2,
153  UIP10 = 0x10,
154  UIPHundred = 0x100
155} ;
156
157typedef NS_ENUM(NSInteger, UIP4_3) {
158  UIP4Zero = 0x0,
159  UIP4One = 0x1,
160  UIP4Two = 0x2,
161  UIP410 = 0x10,
162  UIP4Hundred = 100
163} ;
164
165typedef NS_OPTIONS(NSUInteger, UIP5_3) {
166  UIP5Zero = 0x0,
167  UIP5Two = 0x2,
168  UIP510 = 0x3,
169  UIP5Hundred = 0x4
170} ;
171
172typedef NS_ENUM(NSInteger, UIP6_3) {
173  UIP6Zero = 0x0,
174  UIP6One = 0x1,
175  UIP6Two = 0x2,
176  UIP610 = 10,
177  UIP6Hundred = 0x100
178} ;
179
180typedef NS_ENUM(NSInteger, UIP7_3) {
181  UIP7Zero = 0x0,
182  UIP7One = 1,
183  UIP7Two = 0x2,
184  UIP710 = 10,
185  UIP7Hundred = 100
186} ;
187
188
189typedef NS_ENUM(NSInteger, UIP8_3) {
190  Random = 0,
191  Random1 = 2,
192  Random2 = 4,
193  Random3 = 0x12345,
194  Random4 = 0x3444444,
195  Random5 = 0xbadbeef,
196  Random6
197} ;
198
199// rdar://15200602
200#define NS_AVAILABLE_MAC(X)  __attribute__((availability(macosx,introduced=X)))
201#define NS_ENUM_AVAILABLE_MAC(X) __attribute__((availability(macosx,introduced=X)))
202
203typedef NS_ENUM(NSInteger, NSModalResponse) {
204    NSModalResponseStop                 = (-1000), // Also used as the default response for sheets
205    NSModalResponseAbort                = (-1001),
206    NSModalResponseContinue             = (-1002), 
207} NS_ENUM_AVAILABLE_MAC(10.9);
208
209// rdar://15201056
210typedef NSUInteger FarFarAwayOptions;
211
212// rdar://15200915
213typedef NS_OPTIONS(NSUInteger, FarAwayOptions) {
214  FarAway1    = 1 << 1,
215  FarAway2    = 1 << 2
216};
217typedef NS_OPTIONS(NSUInteger, NSWorkspaceLaunchOptions) {
218     NSWorkspaceLaunchAndPrint =                 0x00000002,
219     NSWorkspaceLaunchWithErrorPresentation    = 0x00000040,
220     NSWorkspaceLaunchInhibitingBackgroundOnly = 0x00000080,
221     NSWorkspaceLaunchWithoutAddingToRecents   = 0x00000100,
222     NSWorkspaceLaunchWithoutActivation        = 0x00000200,
223     NSWorkspaceLaunchAsync                    = 0x00010000,
224     NSWorkspaceLaunchAllowingClassicStartup   = 0x00020000,
225     NSWorkspaceLaunchPreferringClassic        = 0x00040000,
226     NSWorkspaceLaunchNewInstance              = 0x00080000,
227     NSWorkspaceLaunchAndHide                  = 0x00100000,
228     NSWorkspaceLaunchAndHideOthers            = 0x00200000,
229     NSWorkspaceLaunchDefault = NSWorkspaceLaunchAsync | 
230     NSWorkspaceLaunchAllowingClassicStartup
231};
232
233typedef NS_OPTIONS(NSUInteger, NSExcludeOptions) {
234    NSExcludeQuickDrawElementsIconCreationOption    = 1 << 1,
235    NSExclude10_4ElementsIconCreationOption         = 1 << 2
236};
237
238typedef NS_OPTIONS(NSUInteger, NSExcludeCreationOption) {
239    NSExcludeQuickDrawElementsCreationOption    = 1 << 1,
240    NSExclude10_4ElementsCreationOption         = 1 << 2
241};
242
243
244typedef NS_OPTIONS(NSUInteger, NSExcludeIconOptions) {
245    NSExcludeQuickDrawElementsIconOption    = 1 << 1,
246    NSExclude10_4ElementsIconOption         = 1 << 2
247};
248
249@interface INTF {
250  NSExcludeIconOptions I1;
251  NSExcludeIconOptions I2;
252}
253@end
254
255enum {
256  FarFarAway1    = 1 << 1,
257  FarFarAway2    = 1 << 2
258};
259
260// rdar://15200915
261typedef NS_OPTIONS(NSUInteger, NSWindowOcclusionState) {
262    NSWindowOcclusionStateVisible = 1UL << 1,
263};
264
265typedef NS_ENUM(NSUInteger, NSWindowNumberListOptions) {
266    NSWindowCloseButton,
267    NSWindowMiniaturizeButton,
268    NSWindowZoomButton,
269    NSWindowToolbarButton,
270    NSWindowDocumentIconButton
271};
272
273typedef NS_ENUM(NSUInteger, NSSelectionDirection) {
274    NSDirectSelection = 0,
275    NSSelectingNext,
276    NSSelectingPrevious
277};
278
279// standard window buttons
280