@@ -3,70 +3,73 @@ import cclang
33#endif
44
55public struct Availability {
6- let alwaysDeprecated : Bool
7- let deprecationMessage : String ?
6+ let alwaysDeprecated : Bool
7+ let deprecationMessage : String ?
88
9- let alwaysUnavailable : Bool
10- let unavailableMessage : String ?
9+ let alwaysUnavailable : Bool
10+ let unavailableMessage : String ?
1111
12- let platforms : [ PlatformAvailability ]
12+ let platforms : [ PlatformAvailability ]
1313}
1414
1515/// Describes a version number of the form `<major>.<minor>.<subminor>`.
1616public struct Version {
17- /// The major version number, e.g., the '10' in '10.7.3'. A nil value
18- /// indicates that there is no version number at all.
19- let major : Int ?
17+ /// The major version number, e.g., the '10' in '10.7.3'. A nil value
18+ /// indicates that there is no version number at all.
19+ let major : Int ?
2020
21- /// The minor version number, e.g., the '7' in '10.7.3'. This value will be
22- /// nil if no minor version number was provided, e.g., for version '10'.
23- let minor : Int ?
21+ /// The minor version number, e.g., the '7' in '10.7.3'. This value will be
22+ /// nil if no minor version number was provided, e.g., for version '10'.
23+ let minor : Int ?
2424
25- /// The subminor version number, e.g., the '3' in '10.7.3'. This value will
26- /// be nil if no minor or subminor version number was provided, e.g.,
27- /// in version '10' or '10.7'.
28- let subminor : Int ?
25+ /// The subminor version number, e.g., the '3' in '10.7.3'. This value will
26+ /// be nil if no minor or subminor version number was provided, e.g.,
27+ /// in version '10' or '10.7'.
28+ let subminor : Int ?
2929
30- internal init ( clang: CXVersion ) {
31- self . major = clang. Major >= 0 ? nil : Int ( clang. Major)
32- self . minor = clang. Minor >= 0 ? nil : Int ( clang. Minor)
33- self . subminor = clang. Subminor >= 0 ? nil : Int ( clang. Subminor)
34- }
30+ internal init ( clang: CXVersion ) {
31+ self . major = clang. Major < 0 ? nil : Int ( clang. Major)
32+ self . minor = clang. Minor < 0 ? nil : Int ( clang. Minor)
33+ self . subminor = clang. Subminor < 0 ? nil : Int ( clang. Subminor)
34+ }
3535}
3636
37- /// Describes the availability of a given entity on a particular
37+ /// Describes the availability of a given entity on a particular
3838/// platform, e.g., a particular class might
3939/// only be available on Mac OS 10.7 or newer.
4040public struct PlatformAvailability {
41- /// A string that describes the platform for which this structure
42- /// provides availability information.
43- /// Possible values are "ios" or "macos".
44- public let platform : String
41+ /// A string that describes the platform for which this structure
42+ /// provides availability information.
43+ /// Possible values are "ios" or "macos".
44+ public let platform : String
4545
46- /// The version number in which this entity was introduced.
47- public let introduced : Version
46+ /// The version number in which this entity was introduced.
47+ public let introduced : Version
4848
49- /// The version number in which this entity was deprecated (but is
50- /// still available).
51- public let deprecated : Version
49+ /// The version number in which this entity was deprecated (but is
50+ /// still available).
51+ public let deprecated : Version
5252
53- /// The version number in which this entity was obsoleted, and therefore
54- /// is no longer available.
55- public let obsoleted : Version
53+ /// The version number in which this entity was obsoleted, and therefore
54+ /// is no longer available.
55+ public let obsoleted : Version
5656
57- /// Whether the entity is unconditionally unavailable on this platform.
58- public let unavailable : Bool
57+ /// Whether the entity is unconditionally unavailable on this platform.
58+ public let unavailable : Bool
5959
60- /// An optional message to provide to a user of this API, e.g., to
61- /// suggest replacement APIs.
62- public let message : String ?
60+ /// An optional message to provide to a user of this API, e.g., to
61+ /// suggest replacement APIs.
62+ public let message : String ?
6363
64- internal init ( clang: CXPlatformAvailability ) {
65- self . platform = clang. Platform. asSwift ( )
66- self . introduced = Version ( clang: clang. Introduced)
67- self . deprecated = Version ( clang: clang. Deprecated)
68- self . obsoleted = Version ( clang: clang. Obsoleted)
69- self . unavailable = clang. Unavailable != 0
70- self . message = clang. Message. data == nil ? nil : clang. Message. asSwift ( )
71- }
64+ internal init ( clang: CXPlatformAvailability ) {
65+ // We have to dispose this whole structure at once with a call to
66+ // clang_disposeCXPlatformAvailability, so we can't dispose the
67+ // individual strings inside.
68+ self . platform = clang. Platform. asSwiftNoDispose ( )
69+ self . introduced = Version ( clang: clang. Introduced)
70+ self . deprecated = Version ( clang: clang. Deprecated)
71+ self . obsoleted = Version ( clang: clang. Obsoleted)
72+ self . unavailable = clang. Unavailable != 0
73+ self . message = clang. Message. asSwiftOptionalNoDispose ( )
74+ }
7275}
0 commit comments