Skip to content

Commit 280feaf

Browse files
gribozavrMax Moiseev
authored andcommitted
public struct RawByte => internal struct _RawByte
1 parent bec37b1 commit 280feaf

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

stdlib/public/core/StringBridge.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ extension String {
162162

163163
// start will hold the base pointer of contiguous storage, if it
164164
// is found.
165-
var start = UnsafeMutablePointer<RawByte>(nulTerminatedASCII)
165+
var start = UnsafeMutablePointer<_RawByte>(nulTerminatedASCII)
166166
let isUTF16 = nulTerminatedASCII._isNull
167167
if (isUTF16) {
168168
start = UnsafeMutablePointer(_swift_stdlib_CFStringGetCharactersPtr(cfImmutableValue))

stdlib/public/core/StringBuffer.swift

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ struct _StringBufferIVars {
1818
}
1919

2020
init(
21-
usedEnd: UnsafeMutablePointer<RawByte>,
21+
usedEnd: UnsafeMutablePointer<_RawByte>,
2222
byteCapacity: Int,
2323
elementWidth: Int
2424
) {
@@ -30,7 +30,7 @@ struct _StringBufferIVars {
3030

3131
// This stored property should be stored at offset zero. We perform atomic
3232
// operations on it using _HeapBuffer's pointer.
33-
var usedEnd: UnsafeMutablePointer<RawByte>
33+
var usedEnd: UnsafeMutablePointer<_RawByte>
3434

3535
var capacityAndElementShift: Int
3636
var byteCapacity: Int {
@@ -127,12 +127,13 @@ public struct _StringBuffer {
127127
}
128128

129129
/// A pointer to the start of this buffer's data area.
130-
public var start: UnsafeMutablePointer<RawByte> {
130+
public // @testable
131+
var start: UnsafeMutablePointer<_RawByte> {
131132
return UnsafeMutablePointer(_storage.baseAddress)
132133
}
133134

134135
/// A past-the-end pointer for this buffer's stored data.
135-
var usedEnd: UnsafeMutablePointer<RawByte> {
136+
var usedEnd: UnsafeMutablePointer<_RawByte> {
136137
get {
137138
return _storage.value.usedEnd
138139
}
@@ -146,7 +147,7 @@ public struct _StringBuffer {
146147
}
147148

148149
/// A past-the-end pointer for this buffer's available storage.
149-
var capacityEnd: UnsafeMutablePointer<RawByte> {
150+
var capacityEnd: UnsafeMutablePointer<_RawByte> {
150151
return start + _storage.value.byteCapacity
151152
}
152153

@@ -172,7 +173,7 @@ public struct _StringBuffer {
172173
// "grow()," below.
173174
@warn_unused_result
174175
func hasCapacity(
175-
cap: Int, forSubRange r: Range<UnsafePointer<RawByte>>
176+
cap: Int, forSubRange r: Range<UnsafePointer<_RawByte>>
176177
) -> Bool {
177178
// The substring to be grown could be pointing in the middle of this
178179
// _StringBuffer.
@@ -191,7 +192,7 @@ public struct _StringBuffer {
191192
/// to extend.
192193
/// - parameter newUsedCount: The desired size of the substring.
193194
mutating func grow(
194-
bounds: Range<UnsafePointer<RawByte>>, newUsedCount: Int
195+
bounds: Range<UnsafePointer<_RawByte>>, newUsedCount: Int
195196
) -> Bool {
196197
var newUsedCount = newUsedCount
197198
// The substring to be grown could be pointing in the middle of this
@@ -220,8 +221,8 @@ public struct _StringBuffer {
220221
// return true
221222
// }
222223
let usedEndPhysicalPtr =
223-
UnsafeMutablePointer<UnsafeMutablePointer<RawByte>>(_storage._value)
224-
var expected = UnsafeMutablePointer<RawByte>(bounds.endIndex)
224+
UnsafeMutablePointer<UnsafeMutablePointer<_RawByte>>(_storage._value)
225+
var expected = UnsafeMutablePointer<_RawByte>(bounds.endIndex)
225226
if _stdlib_atomicCompareExchangeStrongPtr(
226227
object: usedEndPhysicalPtr, expected: &expected, desired: newUsedEnd) {
227228
return true

stdlib/public/core/StringCore.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public struct _StringCore {
9999
func _pointerToNth(n: Int) -> OpaquePointer {
100100
_sanityCheck(hasContiguousStorage && n >= 0 && n <= count)
101101
return OpaquePointer(
102-
UnsafeMutablePointer<RawByte>(_baseAddress) + (n << elementShift))
102+
UnsafeMutablePointer<_RawByte>(_baseAddress) + (n << elementShift))
103103
}
104104

105105
static func _copyElements(
@@ -194,7 +194,7 @@ public struct _StringCore {
194194
}
195195

196196
/// Left shift amount to apply to an offset N so that when
197-
/// added to a UnsafeMutablePointer<RawByte>, it traverses N elements.
197+
/// added to a UnsafeMutablePointer<_RawByte>, it traverses N elements.
198198
var elementShift: Int {
199199
return Int(_countAndFlags >> (UInt._sizeInBits - 1))
200200
}
@@ -494,7 +494,7 @@ public struct _StringCore {
494494
if _fastPath(elementWidth == 1) {
495495
_sanityCheck(
496496
_pointerToNth(count)
497-
== OpaquePointer(UnsafeMutablePointer<RawByte>(destination) + 1))
497+
== OpaquePointer(UnsafeMutablePointer<_RawByte>(destination) + 1))
498498

499499
UnsafeMutablePointer<UTF8.CodeUnit>(destination)[0] = UTF8.CodeUnit(u0)
500500
}
@@ -654,7 +654,7 @@ extension _StringCore : RangeReplaceableCollection {
654654
if _fastPath(!hasCocoaBuffer) {
655655
if _fastPath(isUniquelyReferencedNonObjC(&_owner)) {
656656

657-
let bounds: Range<UnsafePointer<RawByte>>
657+
let bounds: Range<UnsafePointer<_RawByte>>
658658
= UnsafePointer(_pointerToNth(0))..<UnsafePointer(_pointerToNth(count))
659659

660660
if _fastPath(nativeBuffer!.hasCapacity(n, forSubRange: bounds)) {

stdlib/public/core/UnsafePointer.swift.gyb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,8 @@ public func -= <Memory>(inout lhs: ${Self}<Memory>, rhs: Int) {
504504
/// any other types; it makes a decent parameter to
505505
/// `UnsafeMutablePointer<Memory>` when you just want to do bytewise
506506
/// pointer arithmetic.
507-
public struct RawByte {
507+
public // @testable
508+
struct _RawByte {
508509
let _inaccessible: UInt8
509510
}
510511

0 commit comments

Comments
 (0)