Skip to content

Commit df24e7b

Browse files
committed
edits
1 parent 0e6bb12 commit df24e7b

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

documentation/cxx-interop/index.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,20 +1257,22 @@ object.doSomething()
12571257

12581258
### Calling conventions when passing Shared Reference Types from Swift to C++
12591259

1260-
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, and retains the ownership of the value.
1260+
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.
1261+
Swift also retains the ownership of the value.
12611262
In other words, the argument is passed at `+0` and there is no transfer of ownership.
1262-
The C++ function is responsible for ensuring that the value pointed to by the parameter is alive during and at the end of the call.
1263-
The C++ function should not assume it has ownership of the value and should do necessary retain operations if it is needs to take ownership.
1263+
The C++ function should not assume that it has the ownership of the value and should do necessary retain operations if it is needs to take ownership.
1264+
The C++ function is responsible for ensuring that the value pointed to by the parameter is alive during and at the end of the function call.
1265+
12641266

12651267
```swift
12661268
var obj = SharedObject.create()
1267-
receiveSharedObject(obj) // Swift guarantees that obj is alive
1269+
receiveSharedObject(obj) // Swift guarantees that obj is alive and it is passed at +0
12681270
```
12691271

12701272
```c++
12711273
void receiveSharedObject(SharedObject *sobj) {
12721274
...
1273-
// Swift assumes that sobj is valid, non-null object at the end of this function
1275+
// Swift assumes that sobj is a valid, non-null object at the end of this function
12741276
}
12751277
```
12761278

0 commit comments

Comments
 (0)