Skip to content

Commit 75156b1

Browse files
authored
Merge pull request #61497 from apple/eng/docs-interop-clarify
[interop][SwiftToCxx] clarify Swift to C++ status doc
2 parents 73e9f27 + ac3dc6a commit 75156b1

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

docs/CppInteroperability/CppInteroperabilityStatus.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,21 @@ This status table describes which of the following Swift language features have
137137

138138
**Functions**
139139

140+
Swift functions can be called from C++, with some restrictions. See this table for details:
141+
140142
| **Swift Language Feature** | **Implemented Experimental Support For Using It In C++** |
141143
|--------------------------------|----------------------------------------------------------|
142144
| Top-level `@_cdecl` functions | Yes |
143-
| Top-level Swift functions | Partially, only with primitive and Swift struct and enum types. Class, protocol, and SIMD types are not supported. |
145+
| Top-level Swift functions | Yes |
146+
| Swift Methods | Yes (see the **Methods** section below for more details) |
147+
| Primitive parameter or result types | Yes |
148+
| Swift `struct`/`enum`/`class` parameter or result types | Yes |
144149
| `inout` parameters | Yes |
150+
| C++ `struct`/`class` parameter or result types | Yes |
151+
| Objective-C `@interface` parameter or result types | Yes |
152+
| Swift closure parameter or result types | No |
153+
| Swift protocol type parameter or result types | No |
154+
| SIMD type parameter or result types | No |
145155
| Variadic parameters | No |
146156
| Multiple return values | No |
147157

@@ -152,7 +162,7 @@ This status table describes which of the following Swift language features have
152162
| Fixed layout structs | Yes |
153163
| Resilient / opaque structs | Yes |
154164
| Copy and destroy semantics | Yes |
155-
| Initializers | Partially, as static `init` methods. No failable support |
165+
| Initializers | Yes (except for throwing initializers) |
156166

157167
**Enums**
158168

@@ -172,13 +182,13 @@ This status table describes which of the following Swift language features have
172182
|--------------------------------|----------------------------------------------------------|
173183
| Class reference values | Yes |
174184
| ARC semantics | Yes (C++ copy constructor,assignment operator, destructor perform ARC operations) |
175-
| Initializers | Yes |
185+
| Initializers | Yes (except for throwing initializers) |
176186

177187
**Methods**
178188

179189
| **Swift Language Feature** | **Implemented Experimental Support For Using It In C++** |
180190
|--------------------------------|----------------------------------------------------------|
181-
| Instance methods | Yes on structs and enums. Only 'final' method calls on class types are correctly supported though (virtual calls won't be virtual due to a bug right now) |
191+
| Instance methods | Yes on structs and enums. Instance methods on class types are partially supported (virtual calls won't be virtual due to a bug right now) |
182192
| Static methods | No |
183193

184194
**Properties**
@@ -206,6 +216,6 @@ This status table describes which of the following Swift standard library APIs h
206216

207217
| **Swift Library Type** | **Can be used from C++** |
208218
|--------------------------------|----------------------------------------------------------|
209-
| `String` | Can be used as a type in C++. APIs in extensions are not exposed to C++ |
210-
| `Array<T>` | Can be used as a type in C++. Limited set of APIs in some extensions are exposed to C++. |
211-
| `Optional<T>` | Can be used as a type in C++. APIs in extensions are not exposed to C++ |
219+
| `String` | Can be used as a type in C++. APIs in extensions are not exposed to C++. Conversion between `std.string` is not yet supported |
220+
| `Array<T>` | Can be used as a type in C++. Ranged for loops are supported. Limited set of APIs in some extensions are exposed to C++. |
221+
| `Optional<T>` | Can be used as a type in C++. `get` extracts the optional value and it's also implicitly castable to `bool`. Can't be constructed from C++ yet. |

0 commit comments

Comments
 (0)