Skip to content

Commit 439b692

Browse files
Only rename __DataStorage.replaceBytes symbol on FOUNDATION_FRAMEWORK (#1619)
* Only rename __DataStorage.replaceBytes symbol on FOUNDATION_FRAMEWORK * Update Sources/FoundationEssentials/Data/Representations/DataStorage.swift Co-authored-by: Guillaume Lessard <glessard@tffenterprises.com> --------- Co-authored-by: Guillaume Lessard <glessard@tffenterprises.com>
1 parent 00563e2 commit 439b692

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Sources/FoundationEssentials/Data/Representations/DataStorage.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,12 @@ internal final class __DataStorage : @unchecked Sendable {
342342
self.replaceBytes(in: (range_.lowerBound, range_.upperBound &- range_.lowerBound), with: replacementBytes, length: replacementLength)
343343
}
344344

345-
// This ABI entrypoint was original written using NSRange instead of Range<Int>. The ABI contract of this function must continue to accept NSRange values from code inlined into callers
346-
// To avoid using the real NSRange type at the source level, we use a tuple that is layout-compatible with NSRange instead and use @_silgen_name to preserve the original symbol name that includes "NSRange"
345+
// This utility function was originally written in terms of NSRange instead of Range<Int>. On Darwin platforms, it is also an ABI entry point so we need to continue accepting NSRange values from code that has been inlined into callers.
346+
// To avoid requiring the use of NSRange in source, we instead use a tuple that is layout-compatible with NSRange. On Darwin platforms, we can use `@_silgen_name to preserve the original symbol name that refers to NSRange.
347347
@usableFromInline
348+
#if FOUNDATION_FRAMEWORK
348349
@_silgen_name("$s10Foundation13__DataStorageC12replaceBytes2in4with6lengthySo8_NSRangeV_SVSgSitF")
350+
#endif
349351
internal func replaceBytes(in range_: (location: Int, length: Int), with replacementBytes: UnsafeRawPointer?, length replacementLength: Int) {
350352
let range = (location: range_.location - _offset, length: range_.length)
351353
let currentLength = _length

0 commit comments

Comments
 (0)