Skip to content

Commit fce135d

Browse files
committed
Only compile old ABI for FOUNDATION_FRAMEWORK
1 parent 70cef22 commit fce135d

File tree

6 files changed

+30
-6
lines changed

6 files changed

+30
-6
lines changed

Sources/FoundationEssentials/Data/Data.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,12 +350,14 @@ public struct Data : RandomAccessCollection, MutableCollection, RangeReplaceable
350350
try _representation.withUnsafeBytes(body)
351351
}
352352

353+
#if FOUNDATION_FRAMEWORK
353354
@abi(func withUnsafeBytes<R>(_: (UnsafeRawBufferPointer) throws -> R) rethrows -> R)
354355
@_spi(FoundationLegacyABI)
355356
@usableFromInline
356357
internal func _legacy_withUnsafeBytes<ResultType>(_ body: (UnsafeRawBufferPointer) throws -> ResultType) rethrows -> ResultType {
357358
try withUnsafeBytes(body)
358359
}
360+
#endif // FOUNDATION_FRAMEWORK
359361

360362
@available(macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2, *)
361363
@_alwaysEmitIntoClient
@@ -485,12 +487,14 @@ public struct Data : RandomAccessCollection, MutableCollection, RangeReplaceable
485487
try _representation.withUnsafeMutableBytes(body)
486488
}
487489

490+
#if FOUNDATION_FRAMEWORK
488491
@abi(mutating func withUnsafeMutableBytes<R>(_: (UnsafeMutableRawBufferPointer) throws -> R) rethrows -> R)
489492
@_spi(FoundationLegacyABI)
490493
@usableFromInline
491494
internal mutating func _legacy_withUnsafeMutableBytes<ResultType>(_ body: (UnsafeMutableRawBufferPointer) throws -> ResultType) rethrows -> ResultType {
492495
try withUnsafeMutableBytes(body)
493496
}
497+
#endif // FOUNDATION_FRAMEWORK
494498

495499
// MARK: -
496500

Sources/FoundationEssentials/Data/Representations/Data+Inline.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,15 @@ extension Data {
132132
try apply(UnsafeRawBufferPointer(start: rawBuffer.baseAddress, count: count))
133133
}
134134
}
135-
135+
136+
#if FOUNDATION_FRAMEWORK
136137
@abi(func withUnsafeBytes<R>(_: (UnsafeRawBufferPointer) throws -> R) rethrows -> R)
137138
@_spi(FoundationLegacyABI)
138139
@usableFromInline
139140
internal func _legacy_withUnsafeBytes<ResultType>(_ body: (UnsafeRawBufferPointer) throws -> ResultType) rethrows -> ResultType {
140141
try withUnsafeBytes(body)
141142
}
143+
#endif // FOUNDATION_FRAMEWORK
142144

143145
@_alwaysEmitIntoClient
144146
mutating func withUnsafeMutableBytes<E, Result: ~Copyable>(_ apply: (UnsafeMutableRawBufferPointer) throws(E) -> Result) throws(E) -> Result {
@@ -147,12 +149,14 @@ extension Data {
147149
}
148150
}
149151

152+
#if FOUNDATION_FRAMEWORK
150153
@abi(mutating func withUnsafeMutableBytes<R>(_: (UnsafeMutableRawBufferPointer) throws -> R) rethrows -> R)
151154
@_spi(FoundationLegacyABI)
152155
@usableFromInline
153156
internal mutating func _legacy_withUnsafeMutableBytes<ResultType>(_ body: (UnsafeMutableRawBufferPointer) throws -> ResultType) rethrows -> ResultType {
154157
try withUnsafeMutableBytes(body)
155158
}
159+
#endif // FOUNDATION_FRAMEWORK
156160

157161
@inlinable // This is @inlinable as trivially computable.
158162
mutating func append(byte: UInt8) {

Sources/FoundationEssentials/Data/Representations/Data+InlineSlice.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,26 +161,30 @@ extension Data {
161161
func withUnsafeBytes<E, Result: ~Copyable>(_ apply: (UnsafeRawBufferPointer) throws(E) -> Result) throws(E) -> Result {
162162
try storage.withUnsafeBytes(in: range, apply: apply)
163163
}
164-
164+
165+
#if FOUNDATION_FRAMEWORK
165166
@abi(func withUnsafeBytes<R>(_: (UnsafeRawBufferPointer) throws -> R) rethrows -> R)
166167
@_spi(FoundationLegacyABI)
167168
@usableFromInline
168169
internal func _legacy_withUnsafeBytes<ResultType>(_ body: (UnsafeRawBufferPointer) throws -> ResultType) rethrows -> ResultType {
169170
try withUnsafeBytes(body)
170171
}
172+
#endif // FOUNDATION_FRAMEWORK
171173

172174
@_alwaysEmitIntoClient
173175
mutating func withUnsafeMutableBytes<E, Result: ~Copyable>(_ apply: (UnsafeMutableRawBufferPointer) throws(E) -> Result) throws(E) -> Result {
174176
ensureUniqueReference()
175177
return try storage.withUnsafeMutableBytes(in: range, apply: apply)
176178
}
177179

180+
#if FOUNDATION_FRAMEWORK
178181
@abi(mutating func withUnsafeMutableBytes<R>(_: (UnsafeMutableRawBufferPointer) throws -> R) rethrows -> R)
179182
@_spi(FoundationLegacyABI)
180183
@usableFromInline
181184
internal mutating func _legacy_withUnsafeMutableBytes<ResultType>(_ body: (UnsafeMutableRawBufferPointer) throws -> ResultType) rethrows -> ResultType {
182185
try withUnsafeMutableBytes(body)
183186
}
187+
#endif // FOUNDATION_FRAMEWORK
184188

185189
@inlinable // This is @inlinable as reasonably small.
186190
mutating func append(contentsOf buffer: UnsafeRawBufferPointer) {

Sources/FoundationEssentials/Data/Representations/Data+LargeSlice.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,26 +149,30 @@ extension Data {
149149
func withUnsafeBytes<E, Result: ~Copyable>(_ apply: (UnsafeRawBufferPointer) throws(E) -> Result) throws(E) -> Result {
150150
try storage.withUnsafeBytes(in: range, apply: apply)
151151
}
152-
152+
153+
#if FOUNDATION_FRAMEWORK
153154
@abi(func withUnsafeBytes<R>(_: (UnsafeRawBufferPointer) throws -> R) rethrows -> R)
154155
@_spi(FoundationLegacyABI)
155156
@usableFromInline
156157
internal func _legacy_withUnsafeBytes<ResultType>(_ body: (UnsafeRawBufferPointer) throws -> ResultType) rethrows -> ResultType {
157158
try withUnsafeBytes(body)
158159
}
160+
#endif // FOUNDATION_FRAMEWORK
159161

160162
@_alwaysEmitIntoClient
161163
mutating func withUnsafeMutableBytes<E, Result: ~Copyable>(_ apply: (UnsafeMutableRawBufferPointer) throws(E) -> Result) throws(E) -> Result {
162164
ensureUniqueReference()
163165
return try storage.withUnsafeMutableBytes(in: range, apply: apply)
164166
}
165167

168+
#if FOUNDATION_FRAMEWORK
166169
@abi(mutating func withUnsafeMutableBytes<R>(_: (UnsafeMutableRawBufferPointer) throws -> R) rethrows -> R)
167170
@_spi(FoundationLegacyABI)
168171
@usableFromInline
169172
internal mutating func _legacy_withUnsafeMutableBytes<ResultType>(_ body: (UnsafeMutableRawBufferPointer) throws -> ResultType) rethrows -> ResultType {
170173
try withUnsafeMutableBytes(body)
171174
}
175+
#endif // FOUNDATION_FRAMEWORK
172176

173177
@inlinable // This is @inlinable as reasonably small.
174178
mutating func append(contentsOf buffer: UnsafeRawBufferPointer) {

Sources/FoundationEssentials/Data/Representations/Data+Representation.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,14 @@ extension Data {
228228
}
229229
}
230230

231+
#if FOUNDATION_FRAMEWORK
231232
@abi(func withUnsafeBytes<R>(_: (UnsafeRawBufferPointer) throws -> R) rethrows -> R)
232233
@_spi(FoundationLegacyABI)
233234
@usableFromInline
234235
internal func _legacy_withUnsafeBytes<ResultType>(_ body: (UnsafeRawBufferPointer) throws -> ResultType) rethrows -> ResultType {
235236
try withUnsafeBytes(body)
236237
}
238+
#endif // FOUNDATION_FRAMEWORK
237239

238240
@_alwaysEmitIntoClient
239241
mutating func withUnsafeMutableBytes<E, Result: ~Copyable>(_ apply: (UnsafeMutableRawBufferPointer) throws(E) -> Result) throws(E) -> Result {
@@ -255,12 +257,14 @@ extension Data {
255257
}
256258
}
257259

260+
#if FOUNDATION_FRAMEWORK
258261
@abi(mutating func withUnsafeMutableBytes<R>(_: (UnsafeMutableRawBufferPointer) throws -> R) rethrows -> R)
259262
@_spi(FoundationLegacyABI)
260263
@usableFromInline
261264
internal mutating func _legacy_withUnsafeMutableBytes<ResultType>(_ body: (UnsafeMutableRawBufferPointer) throws -> ResultType) rethrows -> ResultType {
262265
try withUnsafeMutableBytes(body)
263266
}
267+
#endif // FOUNDATION_FRAMEWORK
264268

265269
@usableFromInline // This is not @inlinable as it is a non-trivial, non-generic function.
266270
func enumerateBytes(_ block: (_ buffer: UnsafeBufferPointer<UInt8>, _ byteIndex: Index, _ stop: inout Bool) -> Void) {

Sources/FoundationEssentials/Data/Representations/DataStorage.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,25 +101,29 @@ internal final class __DataStorage : @unchecked Sendable {
101101
func withUnsafeBytes<E, Result: ~Copyable>(in range: Range<Int>, apply: (UnsafeRawBufferPointer) throws(E) -> Result) throws(E) -> Result {
102102
try apply(UnsafeRawBufferPointer(start: _bytes?.advanced(by: range.lowerBound - _offset), count: Swift.min(range.upperBound - range.lowerBound, _length)))
103103
}
104-
104+
105+
#if FOUNDATION_FRAMEWORK
105106
@abi(func withUnsafeBytes<R>(in: Range<Int>, apply: (UnsafeRawBufferPointer) throws -> R) rethrows -> R)
106107
@_spi(FoundationLegacyABI)
107108
@usableFromInline
108109
func _legacy_withUnsafeBytes<Result>(in range: Range<Int>, apply: (UnsafeRawBufferPointer) throws -> Result) rethrows -> Result {
109110
try withUnsafeBytes(in: range, apply: apply)
110111
}
112+
#endif // FOUNDATION_FRAMEWORK
111113

112114
@_alwaysEmitIntoClient
113115
func withUnsafeMutableBytes<E, Result: ~Copyable>(in range: Range<Int>, apply: (UnsafeMutableRawBufferPointer) throws(E) -> Result) throws(E) -> Result {
114116
try apply(UnsafeMutableRawBufferPointer(start: _bytes!.advanced(by:range.lowerBound - _offset), count: Swift.min(range.upperBound - range.lowerBound, _length)))
115117
}
116-
117-
@abi(func withUnsafeMutableBytes<R>(in: Range<Int>, apply: (UnsafeMutableRawBufferPointer) throws -> R) rethrows -> R)
118+
119+
#if FOUNDATION_FRAMEWORK
120+
@abi(func withUnsafeMutableBytes<R>(in: Range<Int>, apply: (UnsafeMutableRawBufferPointer) throws -> R) rethrows -> R)
118121
@_spi(FoundationLegacyABI)
119122
@usableFromInline
120123
internal func _legacy_withUnsafeMutableBytes<ResultType>(in range: Range<Int>, apply: (UnsafeMutableRawBufferPointer) throws -> ResultType) rethrows -> ResultType {
121124
try withUnsafeMutableBytes(in: range, apply: apply)
122125
}
126+
#endif // FOUNDATION_FRAMEWORK
123127

124128
@inlinable // This is @inlinable as trivially computable.
125129
var mutableBytes: UnsafeMutableRawPointer? {

0 commit comments

Comments
 (0)