|
1 | 1 | @import Foundation;
|
| 2 | +@import CoreFoundation; |
| 3 | + |
| 4 | +typedef NSString *__nonnull SNTErrorDomain __attribute((swift_newtype(struct))) |
| 5 | +__attribute((swift_name("ErrorDomain"))); |
| 6 | + |
| 7 | +extern void SNTErrorDomainProcess(SNTErrorDomain d) |
| 8 | + __attribute((swift_name("ErrorDomain.process(self:)"))); |
| 9 | + |
| 10 | +typedef struct {} Food; |
| 11 | + |
| 12 | +extern const SNTErrorDomain SNTErrOne |
| 13 | + __attribute((swift_name("ErrorDomain.one"))); |
| 14 | +extern const SNTErrorDomain SNTErrTwo; |
| 15 | +extern const SNTErrorDomain SNTErrorDomainThree; |
| 16 | +extern const SNTErrorDomain SNTFourErrorDomain; |
| 17 | +extern const SNTErrorDomain SNTFive |
| 18 | + __attribute((swift_name("stillAMember"))); |
| 19 | +extern const SNTErrorDomain SNTElsewhere |
| 20 | + __attribute((swift_name("Food.err"))); |
| 21 | + |
| 22 | +typedef NSString *__nullable SNTClosedEnum __attribute((swift_newtype(enum))) |
| 23 | +__attribute((swift_name("ClosedEnum"))); |
| 24 | + |
| 25 | +extern const SNTClosedEnum SNTFirstClosedEntryEnum; |
| 26 | +extern const SNTClosedEnum SNTSecondEntry; |
| 27 | +extern const SNTClosedEnum SNTClosedEnumThirdEntry; |
| 28 | + |
| 29 | +typedef NSString * IUONewtype __attribute((swift_newtype(struct))); |
| 30 | + |
| 31 | +typedef float MyFloat __attribute((swift_newtype(struct))); |
| 32 | +extern const MyFloat globalFloat; |
| 33 | +extern const MyFloat kPI; |
| 34 | +extern const MyFloat kVersion; |
| 35 | + |
| 36 | +typedef int MyInt __attribute((swift_newtype(struct))); |
| 37 | +extern const MyInt kMyIntZero; |
| 38 | +extern const MyInt kMyIntOne; |
| 39 | +extern const int kRawInt; |
| 40 | +extern void takesMyInt(MyInt); |
| 41 | + |
| 42 | +typedef NSString * NSURLResourceKey __attribute((swift_newtype(struct))); |
| 43 | +extern NSURLResourceKey const NSURLIsRegularFileKey; |
| 44 | +extern NSURLResourceKey const NSURLIsDirectoryKey; |
| 45 | +extern NSURLResourceKey const NSURLLocalizedNameKey; |
| 46 | + |
| 47 | +// Special case: Notifications |
| 48 | +extern const NSString *FooNotification; |
| 49 | +extern const NSString *kBarNotification; |
| 50 | +extern const NSString *NSWibbleNotification; |
| 51 | + |
| 52 | +// But not just 'Notification' |
| 53 | +extern const NSString *kNotification; |
| 54 | +extern const NSString *Notification; |
| 55 | + |
| 56 | +// Nor when explicitly swift_name-ed |
| 57 | +extern const NSString *kSNNotification |
| 58 | + __attribute((swift_name("swiftNamedNotification"))); |
| 59 | + |
| 60 | +// Test CFStringRef |
| 61 | +typedef CFStringRef CFNewType __attribute((swift_newtype(struct))); |
| 62 | + |
| 63 | +// CF audited |
| 64 | +_Pragma("clang arc_cf_code_audited begin") |
| 65 | +extern const CFNewType MyCFNewTypeValue; |
| 66 | +extern CFNewType FooAudited(void); |
| 67 | +_Pragma("clang arc_cf_code_audited end") |
| 68 | +extern const CFNewType MyCFNewTypeValueUnauditedButConst; |
| 69 | + |
| 70 | +// un-audited CFStringRef |
| 71 | +extern CFNewType MyCFNewTypeValueUnaudited; |
| 72 | +extern CFNewType FooUnaudited(void); |
| 73 | + |
| 74 | +// Tests to show identical calling convention / binary representation for |
| 75 | +// new_type and non-new_type |
| 76 | +typedef CFStringRef MyABINewType __attribute((swift_newtype(struct))); |
| 77 | +typedef CFStringRef MyABIOldType; |
| 78 | +_Pragma("clang arc_cf_code_audited begin") |
| 79 | +extern const MyABINewType kMyABINewTypeGlobal; |
| 80 | +extern const MyABIOldType kMyABIOldTypeGlobal; |
| 81 | +extern MyABINewType getMyABINewType(void); |
| 82 | +extern MyABIOldType getMyABIOldType(void); |
| 83 | +extern void takeMyABINewType(MyABINewType); |
| 84 | +extern void takeMyABIOldType(MyABIOldType); |
| 85 | + |
| 86 | +extern void takeMyABINewTypeNonNull(__nonnull MyABINewType); |
| 87 | +extern void takeMyABIOldTypeNonNull(__nonnull MyABIOldType); |
| 88 | +_Pragma("clang arc_cf_code_audited end") |
| 89 | + |
| 90 | +typedef NSString *MyABINewTypeNS __attribute((swift_newtype(struct))); |
| 91 | +typedef NSString *MyABIOldTypeNS; |
| 92 | +extern MyABINewTypeNS getMyABINewTypeNS(void); |
| 93 | +extern MyABIOldTypeNS getMyABIOldTypeNS(void); |
| 94 | +extern void takeMyABINewTypeNonNullNS(__nonnull MyABINewTypeNS); |
| 95 | +extern void takeMyABIOldTypeNonNullNS(__nonnull MyABIOldTypeNS); |
| 96 | + |
| 97 | +// Nested types |
| 98 | +typedef struct {int i;} NSSomeContext; |
| 99 | + |
| 100 | +typedef NSString *NSSomeContextName __attribute((swift_newtype(struct))) |
| 101 | +__attribute((swift_name("NSSomeContext.Name"))); |
| 102 | + |
| 103 | +extern const NSSomeContextName NSMyContextName; |
2 | 104 |
|
3 |
| -typedef NSString *__nonnull SNTErrorDomain __attribute((swift_newtype(struct))); |
4 |
| -typedef NSInteger MyInt __attribute((swift_newtype(struct))); |
|
0 commit comments