Skip to content

Commit 8d8f545

Browse files
committed
fix _StrSlice == method linkage
1 parent 164fe8c commit 8d8f545

13 files changed

+164
-163
lines changed

Sources/System/FilePath/FilePath.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,18 @@
4141
public struct FilePath {
4242
// TODO(docs): Section on all the new syntactic operations, lexical normalization, decomposition,
4343
// components, etc.
44-
internal var _storage: SystemString
44+
internal var _storage: _SystemString
4545

4646
/// Creates an empty, null-terminated path.
4747
public init() {
48-
self._storage = SystemString()
48+
self._storage = _SystemString()
4949
_invariantCheck()
5050
}
5151

5252
// In addition to the empty init, this init will properly normalize
5353
// separators. All other initializers should be implemented by
5454
// ultimately deferring to a normalizing init.
55-
internal init(_ str: SystemString) {
55+
internal init(_ str: _SystemString) {
5656
self._storage = str
5757
self._normalizeSeparators()
5858
_invariantCheck()

Sources/System/FilePath/FilePathComponentView.swift

+10-10
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ extension FilePath {
3030
/// // path is "/home/username/bin/scripts/tree"
3131
public struct ComponentView {
3232
internal var _path: FilePath
33-
internal var _start: SystemString.Index
33+
internal var _start: _SystemString.Index
3434

3535
internal init(_ path: FilePath) {
3636
self._path = path
@@ -50,7 +50,7 @@ extension FilePath {
5050
// TODO(perf): Small-form root (especially on Unix). Have Root
5151
// always copy out (not worth ref counting). Make sure that we're
5252
// not needlessly sliding values around or triggering a COW
53-
let rootStr = self.root?._systemString ?? SystemString()
53+
let rootStr = self.root?._systemString ?? _SystemString()
5454
var comp = ComponentView(self)
5555
self = FilePath()
5656
defer {
@@ -73,7 +73,7 @@ extension FilePath {
7373
// TODO(perf): Small-form root (especially on Unix). Have Root
7474
// always copy out (not worth ref counting). Make sure that we're
7575
// not needlessly sliding values around or triggering a COW
76-
let rootStr = self.root?._systemString ?? SystemString()
76+
let rootStr = self.root?._systemString ?? _SystemString()
7777
var comp = ComponentView(self)
7878
self = FilePath()
7979
defer {
@@ -92,7 +92,7 @@ extension FilePath {
9292
extension FilePath.ComponentView: BidirectionalCollection {
9393
public typealias Element = FilePath.Component
9494
public struct Index: Comparable, Hashable {
95-
internal typealias Storage = SystemString.Index
95+
internal typealias Storage = _SystemString.Index
9696

9797
internal var _storage: Storage
9898

@@ -159,7 +159,7 @@ extension FilePath.ComponentView: RangeReplaceableCollection {
159159
// filling in the bytes ourselves.
160160

161161
// If we're inserting at the end, we need a leading separator.
162-
var str = SystemString()
162+
var str = _SystemString()
163163
let atEnd = subrange.lowerBound == endIndex
164164
if atEnd {
165165
str.append(platformSeparator)
@@ -178,7 +178,7 @@ extension FilePath {
178178
public init<C: Collection>(
179179
root: Root?, _ components: C
180180
) where C.Element == Component {
181-
var str = root?._systemString ?? SystemString()
181+
var str = root?._systemString ?? _SystemString()
182182
str.appendComponents(components: components)
183183
self.init(str)
184184
}
@@ -191,7 +191,7 @@ extension FilePath {
191191
/// Create a file path from an optional root and a slice of another path's
192192
/// components.
193193
public init(root: Root?, _ components: ComponentView.SubSequence) {
194-
var str = root?._systemString ?? SystemString()
194+
var str = root?._systemString ?? _SystemString()
195195
let (start, end) =
196196
(components.startIndex._storage, components.endIndex._storage)
197197
str.append(contentsOf: components.base._slice[start..<end])
@@ -203,11 +203,11 @@ extension FilePath {
203203

204204
@available(/*System 0.0.2: macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0*/iOS 8, *)
205205
extension FilePath.ComponentView: _PathSlice {
206-
internal var _range: Range<SystemString.Index> {
206+
public var _range: Range<_SystemString.Index> {
207207
_start ..< _path._storage.endIndex
208208
}
209209

210-
internal init(_ str: SystemString) {
210+
public init(_ str: _SystemString) {
211211
fatalError("TODO: consider dropping proto req")
212212
}
213213
}
@@ -216,7 +216,7 @@ extension FilePath.ComponentView: _PathSlice {
216216

217217
@available(/*System 0.0.2: macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0*/iOS 8, *)
218218
extension FilePath.ComponentView {
219-
internal func _invariantCheck() {
219+
public func _invariantCheck() {
220220
#if DEBUG
221221
if isEmpty {
222222
precondition(_path.isEmpty == (_path.root == nil))

Sources/System/FilePath/FilePathComponents.swift

+30-30
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ extension FilePath {
3030
/// * `\\?\Volume{12345678-abcd-1111-2222-123445789abc}\`
3131
public struct Root {
3232
internal var _path: FilePath
33-
internal var _rootEnd: SystemString.Index
33+
internal var _rootEnd: _SystemString.Index
3434

35-
internal init(_ path: FilePath, rootEnd: SystemString.Index) {
35+
internal init(_ path: FilePath, rootEnd: _SystemString.Index) {
3636
self._path = path
3737
self._rootEnd = rootEnd
3838
_invariantCheck()
@@ -56,14 +56,14 @@ extension FilePath {
5656
/// path.append(file) // path is "/tmp/foo.txt"
5757
public struct Component {
5858
internal var _path: FilePath
59-
internal var _range: Range<SystemString.Index>
59+
public var _range: Range<_SystemString.Index>
6060

6161
// TODO: Make a small-component form to save on ARC overhead when
6262
// extracted from a path, and especially to save on allocation overhead
6363
// when constructing one from a String literal.
6464

6565
internal init<RE: RangeExpression>(_ path: FilePath, _ range: RE)
66-
where RE.Bound == SystemString.Index {
66+
where RE.Bound == _SystemString.Index {
6767
self._path = path
6868
self._range = range.relative(to: path._storage)
6969
precondition(!self._range.isEmpty, "FilePath components cannot be empty")
@@ -104,7 +104,7 @@ extension FilePath.Root {
104104

105105
// MARK: - Internals
106106

107-
extension SystemString {
107+
extension _SystemString {
108108
// TODO: take insertLeadingSlash: Bool
109109
// TODO: turn into an insert operation with slide
110110
internal mutating func appendComponents<C: Collection>(
@@ -127,21 +127,21 @@ extension SystemString {
127127

128128
// Unifying protocol for common functionality between roots, components,
129129
// and views onto SystemString and FilePath.
130-
internal protocol _StrSlice: _PlatformStringable, Hashable, Codable {
131-
var _storage: SystemString { get }
132-
var _range: Range<SystemString.Index> { get }
130+
public protocol _StrSlice: _PlatformStringable, Hashable, Codable {
131+
var _storage: _SystemString { get }
132+
var _range: Range<_SystemString.Index> { get }
133133

134-
init?(_ str: SystemString)
134+
init?(_ str: _SystemString)
135135

136136
func _invariantCheck()
137137
}
138138
extension _StrSlice {
139-
internal var _slice: Slice<SystemString> {
139+
internal var _slice: Slice<_SystemString> {
140140
Slice(base: _storage, bounds: _range)
141141
}
142142

143143
internal func _withSystemChars<T>(
144-
_ f: (UnsafeBufferPointer<SystemChar>) throws -> T
144+
_ f: (UnsafeBufferPointer<_SystemChar>) throws -> T
145145
) rethrows -> T {
146146
try _storage.withSystemChars {
147147
try f(UnsafeBufferPointer(rebasing: $0[_range]))
@@ -153,17 +153,17 @@ extension _StrSlice {
153153
try _slice.withCodeUnits(f)
154154
}
155155

156-
internal init?(_platformString s: UnsafePointer<CInterop.PlatformChar>) {
157-
self.init(SystemString(platformString: s))
156+
public init?(_platformString s: UnsafePointer<CInterop.PlatformChar>) {
157+
self.init(_SystemString(platformString: s))
158158
}
159159

160-
internal func _withPlatformString<Result>(
160+
public func _withPlatformString<Result>(
161161
_ body: (UnsafePointer<CInterop.PlatformChar>) throws -> Result
162162
) rethrows -> Result {
163163
try _slice.withPlatformString(body)
164164
}
165165

166-
internal var _systemString: SystemString { SystemString(_slice) }
166+
internal var _systemString: _SystemString { _SystemString(_slice) }
167167
}
168168
extension _StrSlice {
169169
public static func == (lhs: Self, rhs: Self) -> Bool {
@@ -180,35 +180,35 @@ internal protocol _PathSlice: _StrSlice {
180180
var _path: FilePath { get }
181181
}
182182
extension _PathSlice {
183-
internal var _storage: SystemString { _path._storage }
183+
public var _storage: _SystemString { _path._storage }
184184
}
185185

186186
@available(/*System 0.0.2: macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0*/iOS 8, *)
187187
extension FilePath.Component: _PathSlice {
188188
}
189189
@available(/*System 0.0.2: macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0*/iOS 8, *)
190190
extension FilePath.Root: _PathSlice {
191-
internal var _range: Range<SystemString.Index> {
191+
public var _range: Range<_SystemString.Index> {
192192
(..<_rootEnd).relative(to: _path._storage)
193193
}
194194
}
195195

196196
@available(/*System 0.0.1: macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0*/iOS 8, *)
197197
extension FilePath: _PlatformStringable {
198-
func _withPlatformString<Result>(_ body: (UnsafePointer<CInterop.PlatformChar>) throws -> Result) rethrows -> Result {
198+
public func _withPlatformString<Result>(_ body: (UnsafePointer<CInterop.PlatformChar>) throws -> Result) rethrows -> Result {
199199
try _storage.withPlatformString(body)
200200
}
201201

202-
init(_platformString: UnsafePointer<CInterop.PlatformChar>) {
203-
self.init(SystemString(platformString: _platformString))
202+
public init(_platformString: UnsafePointer<CInterop.PlatformChar>) {
203+
self.init(_SystemString(platformString: _platformString))
204204
}
205205

206206
}
207207

208208
@available(/*System 0.0.2: macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0*/iOS 8, *)
209209
extension FilePath.Component {
210210
// The index of the `.` denoting an extension
211-
internal func _extensionIndex() -> SystemString.Index? {
211+
internal func _extensionIndex() -> _SystemString.Index? {
212212
guard kind == .regular,
213213
let idx = _slice.lastIndex(of: .dot),
214214
idx != _slice.startIndex
@@ -217,26 +217,26 @@ extension FilePath.Component {
217217
return idx
218218
}
219219

220-
internal func _extensionRange() -> Range<SystemString.Index>? {
220+
internal func _extensionRange() -> Range<_SystemString.Index>? {
221221
guard let idx = _extensionIndex() else { return nil }
222222
return _slice.index(after: idx) ..< _slice.endIndex
223223
}
224224

225-
internal func _stemRange() -> Range<SystemString.Index> {
225+
internal func _stemRange() -> Range<_SystemString.Index> {
226226
_slice.startIndex ..< (_extensionIndex() ?? _slice.endIndex)
227227
}
228228
}
229229

230-
internal func _makeExtension(_ ext: String) -> SystemString {
231-
var result = SystemString()
230+
internal func _makeExtension(_ ext: String) -> _SystemString {
231+
var result = _SystemString()
232232
result.append(.dot)
233-
result.append(contentsOf: ext.unicodeScalars.lazy.map(SystemChar.init))
233+
result.append(contentsOf: ext.unicodeScalars.lazy.map(_SystemChar.init))
234234
return result
235235
}
236236

237237
@available(/*System 0.0.2: macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0*/iOS 8, *)
238238
extension FilePath.Component {
239-
internal init?(_ str: SystemString) {
239+
public init?(_ str: _SystemString) {
240240
// FIXME: explicit null root? Or something else?
241241
let path = FilePath(str)
242242
guard path.root == nil, path.components.count == 1 else {
@@ -249,7 +249,7 @@ extension FilePath.Component {
249249

250250
@available(/*System 0.0.2: macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0*/iOS 8, *)
251251
extension FilePath.Root {
252-
internal init?(_ str: SystemString) {
252+
public init?(_ str: _SystemString) {
253253
// FIXME: explicit null root? Or something else?
254254
let path = FilePath(str)
255255
guard path.root != nil, path.components.isEmpty else {
@@ -265,7 +265,7 @@ extension FilePath.Root {
265265
@available(/*System 0.0.2: macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0*/iOS 8, *)
266266
extension FilePath.Component {
267267
// TODO: ensure this all gets easily optimized away in release...
268-
internal func _invariantCheck() {
268+
public func _invariantCheck() {
269269
#if DEBUG
270270
precondition(!_slice.isEmpty)
271271
precondition(_slice.last != .null)
@@ -277,7 +277,7 @@ extension FilePath.Component {
277277

278278
@available(/*System 0.0.2: macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0*/iOS 8, *)
279279
extension FilePath.Root {
280-
internal func _invariantCheck() {
280+
public func _invariantCheck() {
281281
#if DEBUG
282282
precondition(self._rootEnd > _path._storage.startIndex)
283283

Sources/System/FilePath/FilePathParsing.swift

+13-13
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,30 @@
1111
// manages (and hides) the null terminator
1212

1313
// The separator we use internally
14-
private var genericSeparator: SystemChar { .slash }
14+
private var genericSeparator: _SystemChar { .slash }
1515

1616
// The platform preferred separator
1717
//
1818
// TODO: Make private
19-
internal var platformSeparator: SystemChar {
19+
internal var platformSeparator: _SystemChar {
2020
_windowsPaths ? .backslash : genericSeparator
2121
}
2222

2323
// Whether the character is the canonical separator
2424
// TODO: Make private
25-
internal func isSeparator(_ c: SystemChar) -> Bool {
25+
internal func isSeparator(_ c: _SystemChar) -> Bool {
2626
c == platformSeparator
2727
}
2828

2929
// Whether the character is a pre-normalized separator
30-
internal func isPrenormalSeparator(_ c: SystemChar) -> Bool {
30+
internal func isPrenormalSeparator(_ c: _SystemChar) -> Bool {
3131
c == genericSeparator || c == platformSeparator
3232
}
3333

3434
// Separator normalization, checking, and root parsing is internally hosted
3535
// on SystemString for ease of unit testing.
3636

37-
extension SystemString {
37+
extension _SystemString {
3838
// For invariant enforcing/checking. Should always return false on
3939
// a fully-formed path
4040
fileprivate func _hasTrailingSeparator() -> Bool {
@@ -186,15 +186,15 @@ extension FilePath {
186186
}
187187
}
188188

189-
extension SystemString {
189+
extension _SystemString {
190190
internal var _relativePathStart: Index {
191191
_parseRoot().relativeBegin
192192
}
193193
}
194194

195195
@available(/*System 0.0.1: macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0*/iOS 8, *)
196196
extension FilePath {
197-
internal var _relativeStart: SystemString.Index {
197+
internal var _relativeStart: _SystemString.Index {
198198
_storage._relativePathStart
199199
}
200200
internal var _hasRoot: Bool {
@@ -206,7 +206,7 @@ extension FilePath {
206206

207207
@available(/*System 0.0.1: macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0*/iOS 8, *)
208208
extension FilePath {
209-
internal typealias _Index = SystemString.Index
209+
internal typealias _Index = _SystemString.Index
210210

211211
// Parse a component that starts at `i`. Returns the end
212212
// of the component and the start of the next. Parsing terminates
@@ -271,12 +271,12 @@ extension FilePath {
271271
@available(/*System 0.0.2: macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0*/iOS 8, *)
272272
extension FilePath.ComponentView {
273273
// TODO: Store this...
274-
internal var _relativeStart: SystemString.Index {
274+
internal var _relativeStart: _SystemString.Index {
275275
_path._relativeStart
276276
}
277277
}
278278

279-
extension SystemString {
279+
extension _SystemString {
280280
internal func _parseRoot() -> (
281281
rootEnd: Index, relativeBegin: Index
282282
) {
@@ -303,7 +303,7 @@ extension FilePath.Root {
303303
//
304304
// TODO: public
305305
internal var isAbsolute: Bool {
306-
assert(FilePath(SystemString(self._slice)).root == self, "not a root")
306+
assert(FilePath(_SystemString(self._slice)).root == self, "not a root")
307307

308308
guard _windowsPaths else { return true }
309309

@@ -354,8 +354,8 @@ extension FilePath {
354354

355355
// Perform an append, inseting a separator if needed.
356356
// Note that this will not check whether `content` is a root
357-
internal mutating func _append(unchecked content: Slice<SystemString>) {
358-
assert(FilePath(SystemString(content)).root == nil)
357+
internal mutating func _append(unchecked content: Slice<_SystemString>) {
358+
assert(FilePath(_SystemString(content)).root == nil)
359359
if content.isEmpty { return }
360360
if _needsSeparatorForAppend {
361361
_storage.append(platformSeparator)

0 commit comments

Comments
 (0)