Skip to content

Commit c6c32e2

Browse files
committed
---
yaml --- r: 343784 b: refs/heads/master-rebranch c: 2d63ae4 h: refs/heads/master
1 parent 1dfc424 commit c6c32e2

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1455,7 +1455,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-02-a: ddd2b2976aa9bfde5f20fe37f6bd2
14551455
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-03-a: 171cc166f2abeb5ca2a4003700a8a78a108bd300
14561456
refs/heads/benlangmuir-patch-1: baaebaf39d52f3bf36710d4fe40cf212e996b212
14571457
refs/heads/i-do-redeclare: 8c4e6d5de5c1e3f0a2cedccf319df713ea22c48e
1458-
refs/heads/master-rebranch: afecd41904b68e482b3697e6c07d90bedad332b6
1458+
refs/heads/master-rebranch: 2d63ae413314931528369116a05a3e2ce8bb8677
14591459
refs/heads/rdar-53901732: 9bd06af3284e18a109cdbf9aa59d833b24eeca7b
14601460
refs/heads/revert-26776-subst-always-returns-a-type: 1b8e18fdd391903a348970a4c848995d4cdd789c
14611461
refs/heads/tensorflow-merge: 8b854f62f80d4476cb383d43c4aac2001dde3cec

branches/master-rebranch/docs/CToSwiftNameTranslation.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,4 +211,32 @@ Additionally, typedefs for `void *` or `const void *` that are themselves annota
211211

212212
If a typedef's underlying type is itself a "CF pointer" typedef, the "alias" typedef will be imported as a regular typealias, with the suffix "Ref" still dropped from its name (if present) unless doing so would conflict with another declaration in the same module as the typedef.
213213

214+
215+
## `swift_private`
216+
217+
The `swift_private` Clang attribute prepends `__` onto the base name of any declaration being imported except initializers. For initializers with no arguments, a dummy `Void` argument with the name `__` is inserted; otherwise, the label for the first argument has `__` prepended. This transformation takes place after any other name manipulation, unless the declaration has a custom name. It will not occur if the declaration is an override; in that case the name needs to match the overridden declaration.
218+
219+
```objc
220+
@interface Example : NSObject
221+
- (instancetype)initWithValue:(int)value __attribute__((swift_private));
222+
@property(readonly) int value __attribute__((swift_private));
223+
@end
224+
225+
// Usually seen as NS_REFINED_FOR_SWIFT
226+
```
227+
228+
```swift
229+
class Example: NSObject {
230+
init(__value: Int32)
231+
var __value: Int32 { get }
232+
}
233+
```
234+
235+
The purpose of this annotation is to allow a more idiomatic implementation to be provided in Swift. The effect of `swift_private` is inherited from an enum onto its elements if the enum is not imported as an error code enum, an `@objc` enum, or an option set.
236+
237+
_The original intent of the `swift_private` attribute was additionally to limit access to a Swift module with the same name as the owning Clang module, e.g. the Swift half of a mixed-source framework. However, this restriction has not been implemented as of Swift 5.1._
238+
239+
_For "historical reasons", the `swift_private` attribute is ignored on factory methods with no arguments imported as initializers. This is essentially matching the behavior of older Swift compilers for source compatibility in case someone has marked such a factory method as `swift_private`._
240+
241+
214242
## More to come...

0 commit comments

Comments
 (0)