Skip to content

Commit f9e8b63

Browse files
committed
[gardening] Make edits for stdlib style [NFC]
1 parent a8a8bdc commit f9e8b63

File tree

3 files changed

+167
-179
lines changed

3 files changed

+167
-179
lines changed

stdlib/public/SwiftShims/CoreFoundationShims.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ _swift_stdlib_NSStringCStringUsingEncodingTrampoline(id _Nonnull obj,
134134
SWIFT_RUNTIME_STDLIB_API
135135
__swift_uint8_t
136136
_swift_stdlib_NSStringGetCStringTrampoline(id _Nonnull obj,
137-
_swift_shims_UInt8 *_Nonnull buffer,
138-
_swift_shims_CFIndex maxLength,
139-
unsigned long encoding);
137+
_swift_shims_UInt8 *_Nonnull buffer,
138+
_swift_shims_CFIndex maxLength,
139+
unsigned long encoding);
140140

141141
SWIFT_RUNTIME_STDLIB_API
142142
__swift_uintptr_t

stdlib/public/core/StringBridge.swift

Lines changed: 31 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -47,8 +47,8 @@ internal func _stdlib_binary_CFStringGetCharactersPtr(
4747
mutating: _swift_stdlib_CFStringGetCharactersPtr(source))
4848
}
4949

50-
/// Copies a slice of a _CocoaString into contiguous storage of
51-
/// sufficient capacity.
50+
/// Copies a slice of a _CocoaString into contiguous storage of sufficient
51+
/// capacity.
5252
@_effects(releasenone)
5353
internal func _cocoaStringCopyCharacters(
5454
from source: _CocoaString,
@@ -81,54 +81,46 @@ internal func _cocoaStringCompare(
8181
@_effects(readonly)
8282
internal func _cocoaHashString(
8383
_ string: _CocoaString
84-
) -> UInt {
84+
) -> UInt {
8585
return _swift_stdlib_CFStringHashNSString(string)
8686
}
8787

8888
@_effects(readonly)
8989
internal func _cocoaHashASCIIBytes(
90-
_ bytes: UnsafePointer<UInt8>,
91-
length: Int
92-
) -> UInt {
90+
_ bytes: UnsafePointer<UInt8>, length: Int
91+
) -> UInt {
9392
return _swift_stdlib_CFStringHashCString(bytes, length)
9493
}
9594

9695
// These "trampolines" are effectively objc_msgSend_super.
97-
// They bypass our implementations to use NSString's
96+
// They bypass our implementations to use NSString's.
9897

9998
@_effects(readonly)
10099
internal func _cocoaCStringUsingEncodingTrampoline(
101-
_ string: _CocoaString,
102-
_ encoding: UInt)
103-
-> UnsafePointer<UInt8>? {
104-
return _swift_stdlib_NSStringCStringUsingEncodingTrampoline(
105-
string,
106-
encoding)
100+
_ string: _CocoaString, _ encoding: UInt
101+
) -> UnsafePointer<UInt8>? {
102+
return _swift_stdlib_NSStringCStringUsingEncodingTrampoline(string, encoding)
107103
}
108104

109-
110-
111-
112105
@_effects(releasenone)
113106
internal func _cocoaGetCStringTrampoline(
114-
_ string: _CocoaString,
115-
_ buffer: UnsafeMutablePointer<UInt8>,
116-
_ maxLength: Int,
117-
_ encoding: UInt)
118-
-> Int8 {
119-
return Int8(_swift_stdlib_NSStringGetCStringTrampoline(string,
120-
buffer,
121-
maxLength,
122-
encoding))
107+
_ string: _CocoaString,
108+
_ buffer: UnsafeMutablePointer<UInt8>,
109+
_ maxLength: Int,
110+
_ encoding: UInt
111+
) -> Int8 {
112+
return Int8(_swift_stdlib_NSStringGetCStringTrampoline(
113+
string, buffer, maxLength, encoding))
123114
}
124115

125116
//
126-
// Conversion from NSString to Swift's native representation
117+
// Conversion from NSString to Swift's native representation.
127118
//
128119

129120
private var kCFStringEncodingASCII : _swift_shims_CFStringEncoding {
130121
@inline(__always) get { return 0x0600 }
131122
}
123+
132124
private var kCFStringEncodingUTF8 : _swift_shims_CFStringEncoding {
133125
@inline(__always) get { return 0x8000100 }
134126
}
@@ -149,12 +141,12 @@ internal enum _KnownCocoaString {
149141
@inline(__always)
150142
init(_ str: _CocoaString) {
151143

152-
#if !(arch(i386) || arch(arm))
144+
#if !(arch(i386) || arch(arm))
153145
if _isObjCTaggedPointer(str) {
154146
self = .tagged
155147
return
156148
}
157-
#endif
149+
#endif
158150

159151
switch _unsafeAddressOfCocoaStringClass(str) {
160152
case unsafeBitCast(_StringStorage.self, to: UInt.self):
@@ -168,7 +160,7 @@ internal enum _KnownCocoaString {
168160
}
169161

170162
#if !(arch(i386) || arch(arm))
171-
// Resiliently write a tagged cocoa string's contents into a buffer
163+
// Resiliently write a tagged _CocoaString's contents into a buffer.
172164
@_effects(releasenone) // @opaque
173165
internal func _bridgeTagged(
174166
_ cocoa: _CocoaString,
@@ -223,32 +215,33 @@ private func _getCocoaStringPointer(
223215
internal func _bridgeCocoaString(_ cocoaString: _CocoaString) -> _StringGuts {
224216
switch _KnownCocoaString(cocoaString) {
225217
case .storage:
226-
return _unsafeUncheckedDowncast(cocoaString, to: _StringStorage.self).asString._guts
218+
return _unsafeUncheckedDowncast(
219+
cocoaString, to: _StringStorage.self).asString._guts
227220
case .shared:
228-
return _unsafeUncheckedDowncast(cocoaString, to: _SharedStringStorage.self).asString._guts
221+
return _unsafeUncheckedDowncast(
222+
cocoaString, to: _SharedStringStorage.self).asString._guts
229223
#if !(arch(i386) || arch(arm))
230224
case .tagged:
231-
return _StringGuts(_SmallString(taggedCocoa: cocoaString))
225+
return _StringGuts(_SmallString(taggedCocoa: cocoaString))
232226
#endif
233227
case .cocoa:
234-
// "copy" it into a value to be sure nobody will modify behind
235-
// our backs. In practice, when value is already immutable, this
228+
// "Copy" it into a value to be sure nobody will modify behind
229+
// our backs. In practice, when value is already immutable, this
236230
// just does a retain.
237231
//
238232
// TODO: Only in certain circumstances should we emit this call:
239233
// 1) If it's immutable, just retain it.
240234
// 2) If it's mutable with no associated information, then a copy must
241235
// happen; might as well eagerly bridge it in.
242236
// 3) If it's mutable with associated information, must make the call
243-
//
244237
let immutableCopy
245238
= _stdlib_binary_CFStringCreateCopy(cocoaString) as AnyObject
246239

247-
#if !(arch(i386) || arch(arm))
240+
#if !(arch(i386) || arch(arm))
248241
if _isObjCTaggedPointer(immutableCopy) {
249242
return _StringGuts(_SmallString(taggedCocoa: immutableCopy))
250243
}
251-
#endif
244+
#endif
252245

253246
let (fastUTF8, isASCII): (Bool, Bool)
254247
switch _getCocoaStringPointer(immutableCopy) {

0 commit comments

Comments
 (0)