mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Still to do: test and fix up the use of multiple enum_extensibility annotations, possibly with API notes. This is important because the definition of NS/CF_ENUM /includes/ enum_extensibility(open) as of Xcode 9.0; there should be a convenient out people can use to declare exhaustive enums in C that's backwards-compatible.
37 lines
961 B
Objective-C
37 lines
961 B
Objective-C
#import <Foundation/Foundation.h>
|
|
|
|
#define MY_ERROR_ENUM(_type, _name, _domain) \
|
|
enum _name : _type _name; \
|
|
enum __attribute__((ns_error_domain(_domain))) _name : _type
|
|
|
|
@class NSString;
|
|
extern NSString *const TestErrorDomain;
|
|
typedef MY_ERROR_ENUM(int, TestError, TestErrorDomain) {
|
|
TENone,
|
|
TEOne,
|
|
TETwo,
|
|
};
|
|
|
|
extern NSString *const ExhaustiveErrorDomain;
|
|
typedef MY_ERROR_ENUM(int, ExhaustiveError, ExhaustiveErrorDomain) {
|
|
EENone,
|
|
EEOne,
|
|
EETwo,
|
|
} __attribute__((enum_extensibility(closed)));
|
|
|
|
extern NSString *const OtherErrorDomain;
|
|
typedef MY_ERROR_ENUM(int, OtherErrorCode, OtherErrorDomain) {
|
|
OtherA,
|
|
OtherB,
|
|
OtherC,
|
|
};
|
|
|
|
extern NSString *TypedefOnlyErrorDomain;
|
|
typedef enum __attribute__((ns_error_domain(TypedefOnlyErrorDomain))) {
|
|
TypedefOnlyErrorBadness
|
|
} TypedefOnlyError;
|
|
|
|
|
|
TestError getErr(void);
|
|
ExhaustiveError getExhaustiveErr(void);
|