|
1 | | -// -*- C++ -*- |
2 | | -//===------------------ bridging - C++ and Swift Interop --------*- C++ -*-===// |
| 1 | +// -*- C -*- |
| 2 | +//===------------------ bridging - C and Swift Interop ----------*- C++ -*-===// |
3 | 3 | // |
4 | 4 | // This source file is part of the Swift.org open source project |
5 | 5 | // |
|
32 | 32 | /// that return a `class` or `struct` type that is annotated with this macro. |
33 | 33 | #define SWIFT_SELF_CONTAINED __attribute__((swift_attr("import_owned"))) |
34 | 34 |
|
35 | | -/// Specifies that a C++ method returns a value that is presumed to contain |
| 35 | +/// Specifies that a method returns a value that is presumed to contain |
36 | 36 | /// objects whose lifetime is not dependent on `this` or other parameters passed |
37 | 37 | /// to the method. |
38 | 38 | #define SWIFT_RETURNS_INDEPENDENT_VALUE __attribute__((swift_attr("import_unsafe"))) |
|
45 | 45 | #define _CXX_INTEROP_CONCAT(...) \ |
46 | 46 | _CXX_INTEROP_CONCAT_(__VA_ARGS__,,,,,,,,,,,,,,,,,) |
47 | 47 |
|
48 | | -/// Specifies that a C `class` or `struct` is reference-counted using |
| 48 | +/// Specifies that a `class` or `struct` is reference-counted using |
49 | 49 | /// the given `retain` and `release` functions. This annotation lets Swift import |
50 | 50 | /// such a type as reference counted type in Swift, taking advantage of Swift's |
51 | 51 | /// automatic reference counting. |
|
103 | 103 | __attribute__((swift_attr(_CXX_INTEROP_STRINGIFY(retain:immortal)))) \ |
104 | 104 | __attribute__((swift_attr(_CXX_INTEROP_STRINGIFY(release:immortal)))) |
105 | 105 |
|
106 | | -/// Specifies that a C++ `class` or `struct` is a reference type whose lifetime |
| 106 | +/// Specifies that a `class` or `struct` is a reference type whose lifetime |
107 | 107 | /// is not managed automatically. The programmer must validate that any reference |
108 | 108 | /// to such object is valid themselves. This annotation lets Swift import such a type as a reference type in Swift. |
109 | 109 | #define SWIFT_UNSAFE_REFERENCE \ |
|
115 | 115 | /// Specifies a name that will be used in Swift for this declaration instead of its original name. |
116 | 116 | #define SWIFT_NAME(_name) __attribute__((swift_name(#_name))) |
117 | 117 |
|
118 | | -/// Specifies that a specific C++ `class` or `struct` conforms to a |
| 118 | +/// Specifies that a specific `class` or `struct` conforms to a |
119 | 119 | /// a specific Swift protocol. |
120 | 120 | /// |
121 | 121 | /// This example shows how to use this macro to conform a class template to a Swift protocol: |
|
147 | 147 | #define SWIFT_MUTATING \ |
148 | 148 | __attribute__((swift_attr("mutating"))) |
149 | 149 |
|
150 | | -/// Specifies that a specific c++ type such class or struct should be imported as type marked |
| 150 | +/// Specifies that a specific class or struct should be imported as type marked |
151 | 151 | /// as `@unchecked Sendable` type in swift. If this annotation is used, the type is therefore allowed to |
152 | 152 | /// use safely across async contexts. |
153 | 153 | /// |
|
160 | 160 | #define SWIFT_UNCHECKED_SENDABLE \ |
161 | 161 | __attribute__((swift_attr("@Sendable"))) |
162 | 162 |
|
163 | | -/// Specifies that a class or struct should be imported as a non-copyable |
| 163 | +/// Specifies that a `class` or `struct` should be imported as a non-copyable |
164 | 164 | /// Swift value type. |
165 | 165 | #define SWIFT_NONCOPYABLE \ |
166 | 166 | __attribute__((swift_attr("~Copyable"))) |
167 | 167 |
|
168 | | -/// Specifies that a class or struct should be imported as a non-copyable |
169 | | -/// Swift value type that calls the given _destroy function when a value is no |
| 168 | +/// Specifies that a `class` or `struct` should be imported as a non-copyable |
| 169 | +/// Swift value type that calls the given `_destroy` function when a value is no |
170 | 170 | /// longer used. |
171 | 171 | /// |
172 | 172 | /// This example shows how to use this macro to let Swift know that |
|
185 | 185 | /// let mt = mytypeCreate() |
186 | 186 | /// let mt2 = mt // consumes mt |
187 | 187 | /// // once mt2 is unused, Swift will call mytypeFreeMembers(mt2) |
| 188 | +/// ``` |
188 | 189 | #define SWIFT_NONCOPYABLE_WITH_DESTROY(_destroy) \ |
189 | 190 | __attribute__((swift_attr("~Copyable"))) \ |
190 | 191 | __attribute__((swift_attr(_CXX_INTEROP_STRINGIFY(destroy:_destroy)))) |
191 | 192 |
|
192 | | -/// Specifies that a specific c++ type such class or struct should be imported |
193 | | -/// as a non-escapable Swift value type when the non-escapable language feature |
194 | | -/// is enabled. |
| 193 | +/// Specifies that a specific class or struct should be imported |
| 194 | +/// as a non-escapable Swift value type. |
195 | 195 | #define SWIFT_NONESCAPABLE \ |
196 | 196 | __attribute__((swift_attr("~Escapable"))) |
197 | 197 |
|
198 | | -/// Specifies that a specific c++ type such class or struct should be imported |
199 | | -/// as a escapable Swift value. While this matches the default behavior, |
| 198 | +/// Specifies that a specific class or struct should be imported |
| 199 | +/// as an escapable Swift value. While this matches the default behavior, |
200 | 200 | /// in safe mode interop mode it ensures that the type is not marked as |
201 | 201 | /// unsafe. |
202 | 202 | #define SWIFT_ESCAPABLE \ |
|
207 | 207 | #define SWIFT_ESCAPABLE_IF(...) \ |
208 | 208 | __attribute__((swift_attr("escapable_if:" _CXX_INTEROP_CONCAT(__VA_ARGS__)))) |
209 | 209 |
|
210 | | -/// Specifies that the return value is passed as owned for C++ functions and |
| 210 | +/// Specifies that the return value is passed as owned for functions and |
211 | 211 | /// methods returning types annotated as `SWIFT_SHARED_REFERENCE` |
212 | 212 | #define SWIFT_RETURNS_RETAINED __attribute__((swift_attr("returns_retained"))) |
213 | | -/// Specifies that the return value is passed as unowned for C++ functions and |
| 213 | +/// Specifies that the return value is passed as unowned for functions and |
214 | 214 | /// methods returning types annotated as `SWIFT_SHARED_REFERENCE` |
215 | 215 | #define SWIFT_RETURNS_UNRETAINED \ |
216 | 216 | __attribute__((swift_attr("returns_unretained"))) |
217 | 217 |
|
218 | | -/// Applied to a C++ foreign reference type annotated with |
219 | | -/// SWIFT_SHARED_REFERENCE. Indicates that C++ APIs returning this type are |
| 218 | +/// Applied to a foreign reference type annotated with |
| 219 | +/// SWIFT_SHARED_REFERENCE. Indicates that APIs returning this type are |
220 | 220 | /// assumed to return an unowned (+0) value by default, unless explicitly annotated |
221 | 221 | /// with SWIFT_RETURNS_RETAINED. |
222 | 222 | /// |
|
227 | 227 | /// Bar { ... }; |
228 | 228 | /// ``` |
229 | 229 | /// |
230 | | -/// In Swift, C++ APIs returning `Bar*` will be assumed to return an unowned |
| 230 | +/// In Swift, APIs returning `Bar*` will be assumed to return an unowned |
231 | 231 | /// value. |
232 | 232 | #define SWIFT_RETURNED_AS_UNRETAINED_BY_DEFAULT \ |
233 | 233 | __attribute__((swift_attr("returned_as_unretained_by_default"))) |
|
0 commit comments