mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Error domain enums are imported with synthesizing something like this:
struct MyError {
enum Code : Int32 {
case errFirst
case errSecond
}
static var errFirst: MyError.Code { get }
static var errSecond: MyError.Code { get }
}
The clang enum and enum constants are associated with both the
struct/nested enum, and the static vars/enum cases.
But we want unique USRs for the above symbols, so use the clang USR
for the enum and enum cases, and the Swift USR for the struct and vars.
rdar://27550967
15 lines
392 B
Objective-C
15 lines
392 B
Objective-C
@import Foundation;
|
|
|
|
#define NS_ERROR_ENUM(_type, _name, _domain) \
|
|
enum _name : _type _name; enum __attribute__((ns_error_domain(_domain))) _name : _type
|
|
|
|
@class NSString;
|
|
extern const NSString *const MyErrorDomain;
|
|
/// This is my cool error code.
|
|
typedef NS_ERROR_ENUM(int, MyErrorCode, MyErrorDomain) {
|
|
/// This is first error.
|
|
MyErrFirst,
|
|
/// This is second error.
|
|
MyErrSecond,
|
|
};
|