|
17 | 17 | /// reference its contents, we know that the pointer's contents won't get
|
18 | 18 | /// deallocated while being accessed and thus we can add an unchecked `Sendable`
|
19 | 19 | /// conformance.
|
20 |
| -@_spi(RawSyntax) public struct SyntaxArenaAllocatedPointer<Element: Sendable>: @unchecked Sendable { |
| 20 | +@_spi(RawSyntax) |
| 21 | +public struct SyntaxArenaAllocatedPointer<Element: Sendable>: @unchecked Sendable { |
21 | 22 | private let pointer: UnsafePointer<Element>
|
22 | 23 |
|
23 | 24 | /// Create a pointer from an `UnsafePointer` that was allocated inside a
|
@@ -61,22 +62,21 @@ public struct SyntaxArenaAllocatedBufferPointer<Element: Sendable>: RandomAccess
|
61 | 62 | /// - Important: The client needs to ensure sure that the buffer is indeed
|
62 | 63 | /// allocated by a ``SyntaxArena`` and that the ``SyntaxArena`` will outlive
|
63 | 64 | /// any users of this ``SyntaxArenaAllocatedBufferPointer``.
|
64 |
| - @_spi(RawSyntax) public init(_ buffer: UnsafeBufferPointer<Element>) { |
| 65 | + public init(_ buffer: UnsafeBufferPointer<Element>) { |
65 | 66 | self.buffer = buffer
|
66 | 67 | }
|
67 | 68 |
|
68 |
| - @_spi(RawSyntax) |
69 | 69 | public subscript<RangeType: RangeExpression<Int>>(
|
70 | 70 | range: RangeType
|
71 | 71 | ) -> SyntaxArenaAllocatedBufferPointer<Element> {
|
72 | 72 | return SyntaxArenaAllocatedBufferPointer(UnsafeBufferPointer(rebasing: self.buffer[range]))
|
73 | 73 | }
|
74 | 74 |
|
75 |
| - @_spi(RawSyntax) public subscript(_ index: Int) -> Element { |
| 75 | + public subscript(_ index: Int) -> Element { |
76 | 76 | return self.buffer[index]
|
77 | 77 | }
|
78 | 78 |
|
79 |
| - @_spi(RawSyntax) public func makeIterator() -> UnsafeBufferPointer<Element>.Iterator { |
| 79 | + public func makeIterator() -> UnsafeBufferPointer<Element>.Iterator { |
80 | 80 | return buffer.makeIterator()
|
81 | 81 | }
|
82 | 82 |
|
@@ -111,4 +111,8 @@ public struct SyntaxArenaAllocatedBufferPointer<Element: Sendable>: RandomAccess
|
111 | 111 | public func withContiguousStorageIfAvailable<R>(_ body: (UnsafeBufferPointer<Element>) throws -> R) rethrows -> R? {
|
112 | 112 | try body(buffer)
|
113 | 113 | }
|
| 114 | + |
| 115 | + public func _copyContents(initializing ptr: UnsafeMutableBufferPointer<Element>) -> (Iterator, Int) { |
| 116 | + buffer._copyContents(initializing: ptr) |
| 117 | + } |
114 | 118 | }
|
0 commit comments