-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[cxx-interop] Instantiate C++ class templates from Swift #33284
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
Merged
Merged
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
7eabc27
This change makes it possible to instantiate C++ class templates from…
hlopko c719f9c
Bump SWIFTMODULE_VERSION
hlopko 0a96791
Remove unreachable diagnostics
hlopko e20c02a
Rename instantiateTemplates
hlopko 2ef9409
Fix tests
hlopko d6db3b6
Add failing test for defaulted params
hlopko 1298f8b
Add more failing tests
hlopko 0194ace
Cleanup module interface test
hlopko 7feb939
Merge branch 'main' into class_templates
hlopko 53fcea6
Fixes
hlopko 156f2ed
Use getClangTemplateArguments
hlopko 5f2a2a5
Merge branch 'main' into class_templates
hlopko 1d98588
Fix symbol visitibity test
hlopko 712b0d6
Merge branch 'main' into class_templates
hlopko 4cb3724
Dont use String because on mac it will turn to be NSString
hlopko 4126fd9
Add CInt test
hlopko c75d5e9
Add test
hlopko 2b01aec
Update include/swift/AST/DiagnosticsSema.def
dda24ec
Update lib/ClangImporter/ClangImporter.cpp
e79199a
Address comments
hlopko 9f8f8da
Merge branch 'main' into class_templates
hlopko 27b6990
Update test/Interop/Cxx/templates/Inputs/SwiftClassInstantiationModul…
fd1c618
Address comments
hlopko 51ca547
Merge branch 'class_templates' of github.com:hlopko/swift into class_…
hlopko 0101196
Merge main
hlopko 16493b3
Merge branch 'main' into class_templates
hlopko fb7974a
Add some header guards
hlopko 1ba9340
Fix bad merge
hlopko dafab23
Add simple tests for templates with namespaces
hlopko 090f159
WIP
hlopko c89f07c
WIP
hlopko b5ecc40
Serialize clang template type before instantiation
hlopko e3641c1
Cleanup
hlopko 4e5fb25
Polish
hlopko e9a44d4
Polish
hlopko 71a9065
Add (failing) test for nested types
hlopko 4d09706
Merge branch 'main' into class_templates
hlopko c082a8c
Fix test
hlopko 3bfdce6
Merge branch 'main' into class_templates
hlopko 22e8eda
Update lib/Serialization/Deserialization.cpp
435a796
Update test/Interop/Cxx/templates/class-template-instantiation-existi…
ff7cdc3
Addressing comments.
hlopko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
test/Interop/Cxx/templates/Inputs/SwiftClassInstantiationModule.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import ClassTemplateForSwiftModule | ||
|
||
public func makeWrappedMagicNumber() -> MagicWrapper<IntWrapper> { | ||
let t = IntWrapper(value: 42) | ||
return MagicWrapper<IntWrapper>(t: t) | ||
} | ||
|
||
public func readWrappedMagicNumber(_ i: inout MagicWrapper<IntWrapper>) -> CInt { | ||
return i.getValuePlusArg(13) | ||
} |
13 changes: 13 additions & 0 deletions
13
test/Interop/Cxx/templates/Inputs/SwiftClassTemplateInNamespaceModule.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import ClassTemplateInNamespaceForSwiftModule | ||
|
||
public func receiveShip(_ i: inout Space.Ship<Bool>) {} | ||
|
||
public func returnShip() -> Space.Ship<Bool> { | ||
return Space.Ship<Bool>() | ||
} | ||
|
||
public func receiveShipWithEngine(_ i: inout Space.Ship<Engine.Turbojet>) {} | ||
|
||
public func returnShipWithEngine() -> Space.Ship<Engine.Turbojet> { | ||
return Space.Ship<Engine.Turbojet>() | ||
} |
7 changes: 7 additions & 0 deletions
7
test/Interop/Cxx/templates/Inputs/SwiftClassTemplateNestedTypeModule.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import ClassTemplateNestedTypeForSwiftModule | ||
|
||
public func receiveShipEngine(_ i: inout Ship<Bool>.Engine) {} | ||
|
||
public func returnShipEngine() -> Ship<Bool>.Engine { | ||
return Ship<Bool>.Engine() | ||
} |
15 changes: 15 additions & 0 deletions
15
test/Interop/Cxx/templates/Inputs/class-template-for-swift-module.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#ifndef TEST_INTEROP_CXX_TEMPLATES_INPUTS_CLASS_TEMPLATE_FOR_SWIFT_MODULE_H | ||
#define TEST_INTEROP_CXX_TEMPLATES_INPUTS_CLASS_TEMPLATE_FOR_SWIFT_MODULE_H | ||
|
||
struct IntWrapper { | ||
int value; | ||
int getValue() const { return value; } | ||
}; | ||
|
||
template<class T> | ||
struct MagicWrapper { | ||
T t; | ||
int getValuePlusArg(int arg) const { return t.getValue() + arg; } | ||
}; | ||
|
||
#endif // TEST_INTEROP_CXX_TEMPLATES_INPUTS_CLASS_TEMPLATE_FOR_SWIFT_MODULE_H |
12 changes: 12 additions & 0 deletions
12
test/Interop/Cxx/templates/Inputs/class-template-in-namespace-for-swift-module.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#ifndef TEST_INTEROP_CXX_TEMPLATES_INPUTS_CLASS_TEMPLATE_IN_NAMESPACE_FOR_SWIFT_MODULE_H | ||
#define TEST_INTEROP_CXX_TEMPLATES_INPUTS_CLASS_TEMPLATE_IN_NAMESPACE_FOR_SWIFT_MODULE_H | ||
|
||
namespace Space { | ||
template <class T> struct Ship { T t; }; | ||
} // namespace Space | ||
|
||
namespace Engine { | ||
struct Turbojet {}; | ||
} // namespace Engine | ||
|
||
#endif // TEST_INTEROP_CXX_TEMPLATES_INPUTS_CLASS_TEMPLATE_IN_NAMESPACE_FOR_SWIFT_MODULE_H |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.