Skip to content

Commit 4e5fb25

Browse files
committed
Polish
1 parent e3641c1 commit 4e5fb25

6 files changed

+65
-18
lines changed

test/Interop/Cxx/templates/Inputs/SwiftClassInstantiationInNamespaceModule.swift renamed to test/Interop/Cxx/templates/Inputs/SwiftClassTemplateInNamespaceModule.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import ClassTemplateInNamespace
1+
import ClassTemplateInNamespaceForSwiftModule
22

33
public func receiveShip(_ i: inout Space.Ship<Bool>) {}
44

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#ifndef TEST_INTEROP_CXX_TEMPLATES_INPUTS_CLASS_TEMPLATE_IN_NAMESPACE_FOR_SWIFT_MODULE_H
2+
#define TEST_INTEROP_CXX_TEMPLATES_INPUTS_CLASS_TEMPLATE_IN_NAMESPACE_FOR_SWIFT_MODULE_H
3+
4+
namespace Space {
5+
template <class T> struct Ship { T t; };
6+
} // namespace Space
7+
8+
namespace Engine {
9+
struct Turbojet {};
10+
} // namespace Engine
11+
12+
#endif // TEST_INTEROP_CXX_TEMPLATES_INPUTS_CLASS_TEMPLATE_IN_NAMESPACE_FOR_SWIFT_MODULE_H
13+
14+
// RUN: %target-swift-ide-test -print-module -module-to-print=ClassTemplateInNamespace -I %S/Inputs -source-filename=x -enable-cxx-interop | %FileCheck %s
15+
16+
// CHECK: enum Space {
17+
// CHECK: struct Ship<T> {
18+
// CHECK: }
19+
// CHECK: }
20+
// CHECK: enum Engine {
21+
// CHECK: struct Turbojet {
22+
// CHECK: init()
23+
// CHECK: }
24+
// CHECK: }

test/Interop/Cxx/templates/Inputs/class-template-in-namespace.h

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,32 @@
22
#define TEST_INTEROP_CXX_TEMPLATES_INPUTS_CLASS_TEMPLATE_IN_NAMESPACE_H
33

44
namespace Space {
5-
template <class T> struct Ship { T t; };
6-
} // namespace Space
75

8-
namespace Engine {
9-
struct Turbojet {};
10-
} // namespace Engine
6+
template <class...> struct Ship;
7+
template <class T, class... Args> struct Ship<T(Args...)> {};
8+
9+
using Orbiter = Ship<void(bool)>;
10+
11+
} // namespace Space
1112

1213
#endif // TEST_INTEROP_CXX_TEMPLATES_INPUTS_CLASS_TEMPLATE_IN_NAMESPACE_H
14+
15+
// namespace Space {
16+
// template <class T> struct Ship { T t; };
17+
// } // namespace Space
18+
19+
// namespace Engine {
20+
// struct Turbojet {};
21+
// } // namespace Engine
22+
23+
// RUN: %target-swift-ide-test -print-module -module-to-print=ClassTemplateInNamespace -I %S/Inputs -source-filename=x -enable-cxx-interop | %FileCheck %s
24+
25+
// CHECK: enum Space {
26+
// CHECK: struct Ship<T> {
27+
// CHECK: }
28+
// CHECK: }
29+
// CHECK: enum Engine {
30+
// CHECK: struct Turbojet {
31+
// CHECK: init()
32+
// CHECK: }
33+
// CHECK: }

test/Interop/Cxx/templates/Inputs/module.modulemap

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
module FunctionTemplates {
2+
header "function-templates.h"
3+
requires cplusplus
4+
}
5+
16
module ClassTemplateWithPrimitiveArgument {
27
header "class-template-with-primitive-argument.h"
38
requires cplusplus
@@ -33,11 +38,6 @@ module ClassTemplateInstantionExistingSpecialization {
3338
requires cplusplus
3439
}
3540

36-
module FunctionTemplates {
37-
header "function-templates.h"
38-
requires cplusplus
39-
}
40-
4141
module UsingDirective {
4242
header "using-directive.h"
4343
requires cplusplus
@@ -98,6 +98,11 @@ module ClassTemplateInNamespace {
9898
requires cplusplus
9999
}
100100

101+
module ClassTemplateInNamespaceForSwiftModule {
102+
header "class-template-in-namespace-for-swift-module.h"
103+
requires cplusplus
104+
}
105+
101106
module MemberTemplates {
102107
header "member-templates.h"
103108
requires cplusplus
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
// RUN: %target-swift-ide-test -print-module -module-to-print=ClassTemplateInNamespace -I %S/Inputs -source-filename=x -enable-cxx-interop | %FileCheck %s
22

33
// CHECK: enum Space {
4-
// CHECK: struct Ship<T> {
5-
// CHECK: }
6-
// CHECK: }
7-
// CHECK: enum Engine {
8-
// CHECK: struct Turbojet {
4+
// CHECK: struct __CxxTemplateInstN5Space4ShipIJFvbEEEE {
95
// CHECK: init()
106
// CHECK: }
7+
// CHECK: typealias Orbiter = Space.__CxxTemplateInstN5Space4ShipIJFvbEEEE
118
// CHECK: }

test/Interop/Cxx/templates/swift-class-instantiation-in-namespace-module-interface.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-swiftxx-frontend -emit-module -o %t/SwiftClassTemplateInNamespaceModule.swiftmodule %S/Inputs/SwiftClassInstantiationInNamespaceModule.swift -I %S/Inputs -enable-library-evolution -swift-version 5
2+
// RUN: %target-swiftxx-frontend -emit-module -o %t/SwiftClassTemplateInNamespaceModule.swiftmodule %S/Inputs/SwiftClassTemplateInNamespaceModule.swift -I %S/Inputs -enable-library-evolution -swift-version 5
33
// RUN: %target-swift-ide-test -print-module -module-to-print=SwiftClassTemplateInNamespaceModule -I %t/ -source-filename=x -enable-cxx-interop | %FileCheck %s
44

5-
// CHECK: import ClassTemplateInNamespace
5+
// CHECK: import ClassTemplateInNamespaceForSwiftModule
66
// CHECK: func receiveShip(_ i: inout Space.__CxxTemplateInstN5Space4ShipIbEE)
77
// CHECK: func receiveShipWithEngine(_ i: inout Space.__CxxTemplateInstN5Space4ShipIN6Engine8TurbojetEEE)
88

0 commit comments

Comments
 (0)