Skip to content

[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 42 commits into from
Jan 27, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 Oct 7, 2020
c719f9c
Bump SWIFTMODULE_VERSION
hlopko Oct 8, 2020
0a96791
Remove unreachable diagnostics
hlopko Oct 8, 2020
e20c02a
Rename instantiateTemplates
hlopko Oct 8, 2020
2ef9409
Fix tests
hlopko Oct 8, 2020
d6db3b6
Add failing test for defaulted params
hlopko Oct 8, 2020
1298f8b
Add more failing tests
hlopko Oct 8, 2020
0194ace
Cleanup module interface test
hlopko Oct 12, 2020
7feb939
Merge branch 'main' into class_templates
hlopko Oct 27, 2020
53fcea6
Fixes
hlopko Oct 27, 2020
156f2ed
Use getClangTemplateArguments
hlopko Oct 28, 2020
5f2a2a5
Merge branch 'main' into class_templates
hlopko Nov 5, 2020
1d98588
Fix symbol visitibity test
hlopko Nov 5, 2020
712b0d6
Merge branch 'main' into class_templates
hlopko Nov 5, 2020
4cb3724
Dont use String because on mac it will turn to be NSString
hlopko Nov 5, 2020
4126fd9
Add CInt test
hlopko Nov 6, 2020
c75d5e9
Add test
hlopko Nov 6, 2020
2b01aec
Update include/swift/AST/DiagnosticsSema.def
Nov 23, 2020
dda24ec
Update lib/ClangImporter/ClangImporter.cpp
Nov 23, 2020
e79199a
Address comments
hlopko Nov 24, 2020
9f8f8da
Merge branch 'main' into class_templates
hlopko Dec 2, 2020
27b6990
Update test/Interop/Cxx/templates/Inputs/SwiftClassInstantiationModul…
Dec 2, 2020
fd1c618
Address comments
hlopko Dec 2, 2020
51ca547
Merge branch 'class_templates' of github.com:hlopko/swift into class_…
hlopko Dec 3, 2020
0101196
Merge main
hlopko Jan 5, 2021
16493b3
Merge branch 'main' into class_templates
hlopko Jan 18, 2021
fb7974a
Add some header guards
hlopko Jan 19, 2021
1ba9340
Fix bad merge
hlopko Jan 19, 2021
dafab23
Add simple tests for templates with namespaces
hlopko Jan 19, 2021
090f159
WIP
hlopko Jan 21, 2021
c89f07c
WIP
hlopko Jan 22, 2021
b5ecc40
Serialize clang template type before instantiation
hlopko Jan 25, 2021
e3641c1
Cleanup
hlopko Jan 25, 2021
4e5fb25
Polish
hlopko Jan 25, 2021
e9a44d4
Polish
hlopko Jan 25, 2021
71a9065
Add (failing) test for nested types
hlopko Jan 25, 2021
4d09706
Merge branch 'main' into class_templates
hlopko Jan 25, 2021
c082a8c
Fix test
hlopko Jan 25, 2021
3bfdce6
Merge branch 'main' into class_templates
hlopko Jan 26, 2021
22e8eda
Update lib/Serialization/Deserialization.cpp
Jan 26, 2021
435a796
Update test/Interop/Cxx/templates/class-template-instantiation-existi…
Jan 26, 2021
ff7cdc3
Addressing comments.
hlopko Jan 26, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add test
  • Loading branch information
hlopko committed Nov 6, 2020
commit c75d5e928c3938263b4903b94f97d88759e63a6c
1 change: 1 addition & 0 deletions test/Interop/Cxx/templates/Inputs/magic-wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ template<class T>
struct MagicWrapper {
T t;
int getValuePlusArg(int arg) const { return t.getValue() + arg; }
int getValuePlusArg(T arg) const { return t.getValue() + arg.getValue(); }
};

template<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@ TemplatesTestSuite.test("with-c++-type") {
}

TemplatesTestSuite.test("with-swift-type") {
let _ = MagicWrapper<CInt>()
var wrappedMagicNumber = MagicWrapper<CInt>(i: 13)
expectEqual(wrappedMagicNumber.getValuePlusArg(8), 21)
}

TemplatesTestSuite.test("with-c++-type-calling-method-on-arg") {
let i1 = IntWrapper(value: 42)
let i2 = IntWrapper(value: 12)
var wrappedMagicNumber = MagicWrapper<IntWrapper>(t: i1)
expectEqual(wrappedMagicNumber.getValuePlusArg(i2), 54)
}

runAllTests()