Skip to content
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

Introduce AttributedString #3055

Merged
merged 2 commits into from
Aug 23, 2021
Merged

Introduce AttributedString #3055

merged 2 commits into from
Aug 23, 2021

Conversation

iCharlesHu
Copy link
Contributor

This patch introduces struct AttributedString and tests. Markdown support is not included in this patch as it will be introduced in a separate package.

See Apple's documentation for more information.

@iCharlesHu
Copy link
Contributor Author

@swift-ci please test

@millenomi
Copy link
Contributor

cc @shahmishal @drexin @tomerd This is a large commit that is Delicate in a bunch of ways. I'm going to merge tomorrow after doing a deeper review, but keep an eye out for CI breakage in case we miss something.

Copy link
Contributor

@millenomi millenomi left a comment

Choose a reason for hiding this comment

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

See suggestion + issue with AnyHashable bridging above. We should perhaps check if the AnyHashable is a NSObject-conforming value, and wrap it in a __SwiftValue if it isn't.

@iCharlesHu
Copy link
Contributor Author

Addressed @millenomi 's comments.

@iCharlesHu
Copy link
Contributor Author

@swift-ci please test

@millenomi
Copy link
Contributor

@swift-ci please test and merge

@swift-ci swift-ci merged commit 2db6610 into swiftlang:main Aug 23, 2021
@lxbndr
Copy link
Contributor

lxbndr commented Aug 25, 2021

Looks like _loadScopeAttributes(forSymbol:, from:) -> [String : Any.Type]? in Conversion.swift should be wrapped with #if os(macOS) as well. Windows build is failing:

D:\s\swift-corelibs-foundation\Sources\Foundation\AttributedString\Conversion.swift:295:24: error: cannot find 'dlopen' in scope
    guard let handle = dlopen(path, RTLD_NOLOAD) else {
                       ^~~~~~
D:\s\swift-corelibs-foundation\Sources\Foundation\AttributedString\Conversion.swift:295:37: error: cannot find 'RTLD_NOLOAD' in scope
    guard let handle = dlopen(path, RTLD_NOLOAD) else {
                                    ^~~~~~~~~~~
D:\s\swift-corelibs-foundation\Sources\Foundation\AttributedString\Conversion.swift:298:31: error: cannot find 'dlsym' in scope
    guard let symbolPointer = dlsym(handle, symbol) else {
                              ^~~~~

cc @iCharlesHu

@iCharlesHu iCharlesHu deleted the attributed-string branch August 25, 2021 16:23
@iCharlesHu
Copy link
Contributor Author

Looks like _loadScopeAttributes(forSymbol:, from:) -> [String : Any.Type]? in Conversion.swift should be wrapped with #if os(macOS) as well. Windows build is failing:

D:\s\swift-corelibs-foundation\Sources\Foundation\AttributedString\Conversion.swift:295:24: error: cannot find 'dlopen' in scope
    guard let handle = dlopen(path, RTLD_NOLOAD) else {
                       ^~~~~~
D:\s\swift-corelibs-foundation\Sources\Foundation\AttributedString\Conversion.swift:295:37: error: cannot find 'RTLD_NOLOAD' in scope
    guard let handle = dlopen(path, RTLD_NOLOAD) else {
                                    ^~~~~~~~~~~
D:\s\swift-corelibs-foundation\Sources\Foundation\AttributedString\Conversion.swift:298:31: error: cannot find 'dlsym' in scope
    guard let symbolPointer = dlsym(handle, symbol) else {
                              ^~~~~

cc @iCharlesHu

Thanks @lxbndr ! I have a PR open here: #3060

@xwu
Copy link
Contributor

xwu commented Aug 31, 2021

Hey @iCharlesHu @millenomi, I must be kind of confused, but is it really the case that this project can no longer be run and tested on macOS at all?

Use of @_spi(Reflection) in this file means that one has to use a dev toolchain to compile the project, because the default toolchain distributed with Xcode doesn't include any SPI symbols. However, due to SR-12177, one must simultaneously also not use a dev toolchain but rather the default toolchain distributed with Xcode?

@millenomi
Copy link
Contributor

Merging this will require that you use a matching toolchain; the main (trunk) snapshot toolchain from https://swift.org/download should in fact work.

In general, even on macOS, you should always be working on this code with a matching toolchain, rather than use Xcode's default. On Linux, this is enforced as build-script will build both the toolchain and Foundation for you in one go.

@millenomi
Copy link
Contributor

… and I'll be looking at the SR this coming week because whoops.

I have been able to run recently on macOS despite that SR; I'll investigate.

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