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