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