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