Skip to content

[RFC] Sync NSStringAPI.swift from overlay #1167

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

Closed
wants to merge 1 commit into from

Conversation

ianpartridge
Copy link
Contributor

Over time, NSStringAPI.swift has diverged from the version in the overlay.

This PR brings them back into sync, by copying the overlay version into swift-corelibs-foundation, then fixing the resulting breakages so it builds and passes TestFoundation on Linux and in Xcode.

Hopefully this will make it easier to port changes between the two in future.

Comments please - is this worth doing and have I made a mess of it? 🙂

@ianpartridge
Copy link
Contributor Author

Go to https://www.diffchecker.com/ysVPYFqr to see the diff of NSStringAPI.swift between the overlay and swift-corelibs-foundation after this PR.

@alblue
Copy link
Contributor

alblue commented Aug 11, 2017

@parkera @phausler Given the upcoming merge of future changes does this make sense to get in for the Swift 4 branch?

@spevans
Copy link
Contributor

spevans commented Aug 15, 2017

As a general question, shouldnt all of the APIs in the Foundation SDK overlay be kept in sync with the corelibs-foundation ones (excepting macOS/iOS specific ones) or should we expect some differences?
Is it currently just kept updated in an ad-hoc manner?

@ianpartridge
Copy link
Contributor Author

Yes they should be in sync. Complications arise because the overlay is missing some public API (because part of the Darwin implementation is closed source Objective-C), and also has extra API that's deliberately not in swift-corelibs-foundation because it doesn't make sense on Linux.

@ianpartridge
Copy link
Contributor Author

Rebased and fixed merge conflicts.

@phausler
Copy link
Contributor

Can you ifdef the deletions/changes from the overlay? That way we can copy/paste back and forth

@ianpartridge
Copy link
Contributor Author

Yes. What should the #if be? os(Linux) or DEPLOYMENT_RUNTIME_SWIFT?

@phausler
Copy link
Contributor

Probably DEPLOYMENT_RUNTIME_SWIFT is appropriate in most if not all of the cases. We want the Xcode build of swift-corelibs-foundation to behave as close to the linux one as possible. Also we want the Darwin overlay to share the same code; any differential should be a objc differential. So it might even be good to remove as? casts and replace them with the compiler runtime call that turns into such as _bridgeToObjectiveC() etc

@ianpartridge
Copy link
Contributor Author

Sounds good. Do you know what that compiler runtime call is? Or where I should look to find it?

@phausler
Copy link
Contributor

str as NSString will emit str._bridgeToObjectiveC()

nsString as? String will emit String._conditionallyBridgeFromObjectiveC(nsString, &res)

@ianpartridge
Copy link
Contributor Author

OK I'll have a crack and see how I get on. Thanks.

@ianpartridge
Copy link
Contributor Author

Closing in favour of #1178

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