Skip to content

Commit aa03580

Browse files
committed
edits
1 parent 04bb606 commit aa03580

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

documentation/cxx-interop/index.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,7 +1282,8 @@ let object = SharedObject(42)
12821282

12831283
Note that if a C++ constructor and a user-annotated static factory (using `SWIFT_NAME`) have identical parameter signatures, Swift favors the static factory when resolving initializer calls.
12841284
This is particularly useful when you want to use a custom allocator or want to disable direct construction entirely and expose only factories.
1285-
### Inference of Shared Reference behaviour in Derived Types
1285+
1286+
#### Inference of Shared Reference behaviour in Derived Types
12861287

12871288
When a C++ type inherits from a `SWIFT_SHARED_REFERENCE` base type, the Swift compiler automatically infers `SWIFT_SHARED_REFERENCE` annotation for the derived type.
12881289
The derived type also gets imported as a reference type, and uses the same `retain` and `release` functions as its base class.
@@ -1322,7 +1323,7 @@ unOwned.doSomething()
13221323
Note that the Swift compiler will automatically infer the ownership conventons for Swift functions returning `SWIFT_SHARED_REFERENCE` types.
13231324
See [Exposing C++ Shared Reference Types back from Swift](#exposing-c-shared-reference-types-back-from-swift) for calling Swift functions returning `SWIFT_SHARED_REFERENCE` types from C++.
13241325

1325-
### Calling conventions when passing Shared Reference Types from Swift to C++
1326+
#### Calling conventions when passing Shared Reference Types from Swift to C++
13261327

13271328
If a C++ shared reference type is passed as an argument to a C++ API from Swift, the Swift compiler guarantees that the passed value would be alive.
13281329
Swift also retains the ownership of the value.
@@ -1360,15 +1361,15 @@ However, the C++ function is responsible for releasing the old value, and ensuri
13601361
Adhering to these rules is necessary to safely and correctly pass around `SWIFT_SHARED_REFERENCE` between Swift and C++.
13611362
These rules are also generally recommended conventions to manage shared objects that use reference counting.
13621363

1363-
### Inheritance and Virtual Member Functions
1364+
#### Inheritance and Virtual Member Functions
13641365

13651366
Similar to value types, casting an instance of a derived reference type to a
13661367
base reference type, or vice versa, is not yet supported by Swift.
13671368

13681369
If a reference type has virtual methods, you can call those methods from Swift.
13691370
This includes pure virtual methods.
13701371

1371-
### Exposing C++ Shared Reference Types back from Swift
1372+
#### Exposing C++ Shared Reference Types back from Swift
13721373

13731374
C++ can call into Swift APIs that take or return C++ Shared Reference Types. Objects of these types are always created on the C++ side,
13741375
but their references can be passed back and forth between Swift and C++. This section explains the conventions of incrementing and decrementing

0 commit comments

Comments
 (0)