Skip to content

Expose __SwiftNativeNSString for Foundation's use, as well as an initializer to create Strings from them #39229

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

Merged
merged 1 commit into from
Sep 10, 2021

Conversation

Catfish-Man
Copy link
Contributor

No description provided.

@Catfish-Man Catfish-Man requested a review from milseman September 9, 2021 18:39
@Catfish-Man Catfish-Man self-assigned this Sep 9, 2021
@Catfish-Man
Copy link
Contributor Author

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Sep 9, 2021

Build failed
Swift Test Linux Platform
Git Sha - 6840c588bcedc23c3e5452012287fb4fb96ae615

@swift-ci
Copy link
Contributor

swift-ci commented Sep 9, 2021

Build failed
Swift Test OS X Platform
Git Sha - 6840c588bcedc23c3e5452012287fb4fb96ae615

@Catfish-Man Catfish-Man changed the title Expose __StringStorage and __StringStorageBridge for Foundation's use, as well as an initializer to create them Expose __SwiftNativeNSString for Foundation's use, as well as an initializer to create Strings from them Sep 9, 2021
@Catfish-Man
Copy link
Contributor Author

@swift-ci please smoke test

@Catfish-Man
Copy link
Contributor Author

@swift-ci please smoke benchmark

@Catfish-Man Catfish-Man marked this pull request as draft September 9, 2021 21:14
@Catfish-Man
Copy link
Contributor Author

Marking this as a draft until I see if the devirtualizer is clever enough to do what I wanted

@Catfish-Man
Copy link
Contributor Author

@swift-ci please smoke test

@Catfish-Man Catfish-Man marked this pull request as ready for review September 10, 2021 08:26
@Catfish-Man
Copy link
Contributor Author

@swift-ci please smoke test

@@ -658,7 +658,7 @@ internal func _SwiftCreateBridgedString_DoNotCall(
// This allows us to subclass an Objective-C class and use the fast Swift
// memory allocator.
@objc @_swift_native_objc_runtime_base(__SwiftNativeNSStringBase)
class __SwiftNativeNSString {
@_spi(Foundation) public class __SwiftNativeNSString {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Trying to minimize the ABI exposure here. I could expose __StringStorage and __SharedStringStorage, but since this is their superclass, I would need to expose it anyway, and this is sufficient for hanging @objc implementations off of that operate in terms of the new initializer.

@@ -33,6 +33,7 @@
"StringRangeReplaceableCollection.swift",
"StringGutsRangeReplaceable.swift",
"StringStorage.swift",
"StringStorageBridge.swift",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was apparently missing all along, who knew.

@Catfish-Man Catfish-Man merged commit 8557649 into swiftlang:main Sep 10, 2021
extension String {
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
@_spi(Foundation)
public init?(_nativeStorage: AnyObject) {
Copy link
Member

Choose a reason for hiding this comment

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

What is this used for, and is this tested anywhere? Comments? That's a lot of unsafe unchecked downcasts and it's not clear to me what is assumed about _nativeStorage.

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.

4 participants