-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
Conversation
@swift-ci please test |
Build failed |
Build failed |
6840c58
to
c2acc41
Compare
@swift-ci please smoke test |
@swift-ci please smoke benchmark |
Marking this as a draft until I see if the devirtualizer is clever enough to do what I wanted |
@swift-ci please smoke test |
…ializer to create Strings from them
5639270
to
30a3b6d
Compare
@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 { |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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.
extension String { | ||
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) | ||
@_spi(Foundation) | ||
public init?(_nativeStorage: AnyObject) { |
There was a problem hiding this comment.
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
.
No description provided.