Skip to content

[Interop][SwiftToCxx] Emit helper cases class in C++ for Swift enum#59669

Merged
hyp merged 3 commits intoswiftlang:mainfrom
WANGJIEKE:cxx-interop-enum-cases-class
Jun 25, 2022
Merged

[Interop][SwiftToCxx] Emit helper cases class in C++ for Swift enum#59669
hyp merged 3 commits intoswiftlang:mainfrom
WANGJIEKE:cxx-interop-enum-cases-class

Conversation

@WANGJIEKE
Copy link
Copy Markdown
Contributor

Emit Swift enum cases inside generated C++ class. For example, following Swift enum

public enum Foo { case x, y, z }

will have cases in generated C++ header file like this

class Foo final {
public:
  enum class cases { x, y, z };
};

@hyp Could you review this pull request?

@hyp hyp added the c++ interop Feature: Interoperability with C++ label Jun 23, 2022
@hyp
Copy link
Copy Markdown
Contributor

hyp commented Jun 23, 2022

@swift-ci please test

@hyp
Copy link
Copy Markdown
Contributor

hyp commented Jun 23, 2022

@swift-ci please test source compatibility

@hyp
Copy link
Copy Markdown
Contributor

hyp commented Jun 24, 2022

Looks good. The only thing I was wondering about if the cases should be printed out separately on new lines, instead if all being on the same line. Wdyt?

@WANGJIEKE
Copy link
Copy Markdown
Contributor Author

WANGJIEKE commented Jun 24, 2022

Yeah maybe it's better to print one line per case so that if there's an enum with lots of cases, it can be more human-readable. I think it's typically easier to scroll vertically than horizontally.

@hyp
Copy link
Copy Markdown
Contributor

hyp commented Jun 24, 2022

@swift-ci please test

@hyp
Copy link
Copy Markdown
Contributor

hyp commented Jun 24, 2022

@swift-ci please test source compatibility

@hyp hyp merged commit 0dae896 into swiftlang:main Jun 25, 2022
@WANGJIEKE WANGJIEKE deleted the cxx-interop-enum-cases-class branch July 13, 2022 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ interop Feature: Interoperability with C++

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants