File tree Expand file tree Collapse file tree 2 files changed +48
-2
lines changed
test/Interop/SwiftToCxx/enums Expand file tree Collapse file tree 2 files changed +48
-2
lines changed Original file line number Diff line number Diff line change @@ -392,8 +392,20 @@ class DeclAndTypePrinter::Implementation
392
392
ClangValueTypePrinter printer (os, owningPrinter.prologueOS ,
393
393
owningPrinter.typeMapping ,
394
394
owningPrinter.interopContext );
395
- printer.printValueTypeDecl (
396
- ED, /* bodyPrinter=*/ [&]() {}); // TODO: (tongjie) print cases
395
+ printer.printValueTypeDecl (ED, /* bodyPrinter=*/ [&]() {
396
+ ClangSyntaxPrinter syntaxPrinter (os);
397
+ os << " enum class cases { " ;
398
+ llvm::interleaveComma (
399
+ ED->getAllCases (), os, [&](const EnumCaseDecl *caseDecl) {
400
+ llvm::interleaveComma (
401
+ caseDecl->getElements (), os,
402
+ [&](const EnumElementDecl *elementDecl) {
403
+ syntaxPrinter.printIdentifier (
404
+ elementDecl->getBaseIdentifier ().str ());
405
+ });
406
+ });
407
+ os << " };\n " ;
408
+ });
397
409
os << outOfLineDefinitions;
398
410
outOfLineDefinitions.clear ();
399
411
return ;
Original file line number Diff line number Diff line change
1
+ // RUN: %empty-directory(%t)
2
+ // RUN: %target-swift-frontend %s -typecheck -module-name Enums -clang-header-expose-public-decls -emit-clang-header-path %t/enums.h
3
+ // RUN: %FileCheck %s < %t/enums.h
4
+
5
+ // RUN: %check-interop-cxx-header-in-clang(%t/enums.h -Wno-unused-private-field -Wno-unused-function)
6
+
7
+ public enum EnumMultipleElementsInSingleCase { case first, second }
8
+
9
+ public enum EnumSingleElementInSingleCase {
10
+ case first
11
+ case second
12
+ }
13
+
14
+ public enum EnumCaseIsSwiftKeyword {
15
+ case first( a: Int )
16
+ case `protocol`( b: Double )
17
+ }
18
+
19
+ public enum EnumCaseIsCxxKeyword {
20
+ case first, second( x: Float )
21
+ case const
22
+ }
23
+
24
+ // CHECK: class EnumCaseIsCxxKeyword final {
25
+ // CHECK: enum class cases { first, second, const_ };
26
+
27
+ // CHECK: class EnumCaseIsSwiftKeyword final {
28
+ // CHECK: enum class cases { first, protocol };
29
+
30
+ // CHECK: class EnumMultipleElementsInSingleCase final {
31
+ // CHECK: enum class cases { first, second };
32
+
33
+ // CHECK: class EnumSingleElementInSingleCase final {
34
+ // CHECK: enum class cases { first, second };
You can’t perform that action at this time.
0 commit comments