Skip to content

[SE-0456, -0467] Data+Span+MutableSpan #1276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

glessard
Copy link
Contributor

Add the properties span, mutableSpan, bytes and mutableBytes to Data, as proposed in SE-0456 and SE-0467.

Addresses rdar://137711067

@glessard
Copy link
Contributor Author

@swift-ci please test

@glessard
Copy link
Contributor Author

@swift-ci please test

@glessard
Copy link
Contributor Author

The Windows test https://ci-external.swift.org/job/swift-foundation-pull-request-windows/717/ ran with swift-DEVELOPMENT-SNAPSHOT-2025-03-10-a, which is too old for this code change.

@glessard
Copy link
Contributor Author

@swift-ci please test macOS platform

@parkera parkera requested a review from jmschonfeld April 30, 2025 23:30
@glessard
Copy link
Contributor Author

@swift-ci please test macOS platform

@glessard
Copy link
Contributor Author

@swift-ci please test

@glessard
Copy link
Contributor Author

@swift-ci please test

@glessard
Copy link
Contributor Author

@swift-ci please test

buffer = UnsafeRawBufferPointer(start: nil, count: 0)
case .inline:
buffer = unsafe UnsafeRawBufferPointer(
start: UnsafeRawPointer(Builtin.addressOfBorrow(self)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we opening the door here for Foundation to use the Builtin module generally? Or is this a placeholder for some stdlib API/SPI cover that's coming down the road?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue with the Builtin module is one of source stability, and as a result we don't want to rely on it in any module not built with the compiler, including Foundation. We can probably replace this with something from the stdlib level: we may be able to model it as a particular Span initializer from which we'd extract the information we need. This is not available but it should be doable now.

@@ -9,7 +9,8 @@ import CompilerPluginSupport
let availabilityTags: [_Availability] = [
_Availability("FoundationPreview"), // Default FoundationPreview availability,
_Availability("FoundationPredicate"), // Predicate relies on pack parameter runtime support
_Availability("FoundationPredicateRegex") // Predicate regexes rely on new stdlib APIs
_Availability("FoundationPredicateRegex"), // Predicate regexes rely on new stdlib APIs
_Availability("FoundationSpan", availability: .future), // Availability of Span types
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the // swift-tools-version: 5.9 above need to be changed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could choose to change that to 6.0, or maybe 6.1, if we wanted but we don't want to make this 6.2 yet so I think it's best to keep it as-is. The tools version is not the same as the compiler version for Xcode/Darwin as the tools version is strictly equivalent to what tools are packaged in Xcode when you build the package in Xcode (and not the tools in your selected toolchain). There isn't yet an Xcode that ships with 6.2 tools, so to support building this project with older Xcodes (even with a downloaded 6.2 OSS toolchain) we'd want to support a lower tools version.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking of doing that in a follow-up PR

@glessard
Copy link
Contributor Author

The Windows CI failure is due to swiftlang/swift#81471.
If we merge this then it would break CI for all swift-foundation changes until that issue is resolved, so we should probably hold off…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants