Skip to content

Commit a766fb6

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

14 files changed

+171
-170
lines changed

Sources/System/FilePath/FilePath.swift

Lines changed: 3 additions & 3 deletions
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

Lines changed: 10 additions & 10 deletions
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

Lines changed: 31 additions & 31 deletions
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>(
@@ -126,22 +126,22 @@ extension SystemString {
126126
}
127127

128128
// Unifying protocol for common functionality between roots, components,
129-
// 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 }
129+
// and views onto_SystemString and FilePath.
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

0 commit comments

Comments
 (0)