[Interop][SwiftToCxx] Implement enum case switching#59744
[Interop][SwiftToCxx] Implement enum case switching#59744hyp merged 4 commits intoswiftlang:mainfrom
Conversation
|
@hyp Could you please review this PR? Thanks! I have a question regarding naming predicate functions: is |
|
@swift-ci please test |
There was a problem hiding this comment.
Please also disable it on arm64e : ‘// UNSUPPORTED: CPU=arm64e’
There was a problem hiding this comment.
Oh yeah I forgot this.
There was a problem hiding this comment.
Why do we need a default case here?
There was a problem hiding this comment.
I want to silence the non-exhaustive switch warning from the compiler.
There was a problem hiding this comment.
For sure. Unfortunately I don’t think the default case should map to a specific case. I think by default it should abort as that’s an unexpected path for fixed enums. Resilient enums are more complicated as they could have an unknown case, but we can handle them in a follow up.
There was a problem hiding this comment.
How did you determine that this is the correct ordering? Is the compiler doing this kind of sort anywhere else? We might want to reuse this if thins is already being done elsewhere
There was a problem hiding this comment.
I got it from the memory layout doc, but yeah it's better to reuse existing functionality. I'll ask this in the office hour meeting.
|
Can you also add check lines for implementation of ‘_getEnumTag’ |
For now it’s fine, we already use it for properties. It might not handle Unicode correctly, but we will refactor and fix name transformations later. |
|
@egorzhdan Could you please help me invoke the testing? Thanks! |
|
@swift-ci please test |
029dc2f to
7ebcb7b
Compare
|
@swift-ci please test |
|
Looks good apart from one request |
|
@swift-ci please test |
|
@swift-ci please test source compatibility |
|
@swift-ci please test windows platform |
|
Also change the return type of |
|
@swift-ci please test |
|
@swift-ci please test source compatibility |
|
@swift-ci please test |
This is a follow-up of pull request #59669. This pull request implements
operator cases()and various predicates.For example, following Swift enum
will have member functions in the generated C++ header file like this
Other changes:
EnumValueWitnessTablestruct when printing C++ interop scaffold;_getEnumTaghelper function for retrieving the tag from enum value witness table.