-
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
Changes from 9 commits
7eabc27
c719f9c
0a96791
e20c02a
2ef9409
d6db3b6
1298f8b
0194ace
7feb939
53fcea6
156f2ed
5f2a2a5
1d98588
712b0d6
4cb3724
4126fd9
c75d5e9
2b01aec
dda24ec
e79199a
9f8f8da
27b6990
fd1c618
51ca547
0101196
16493b3
fb7974a
1ba9340
dafab23
090f159
c89f07c
b5ecc40
e3641c1
4e5fb25
e9a44d4
71a9065
4d09706
c082a8c
3bfdce6
22e8eda
435a796
ff7cdc3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,7 +56,7 @@ const uint16_t SWIFTMODULE_VERSION_MAJOR = 0; | |
/// describe what change you made. The content of this comment isn't important; | ||
/// it just ensures a conflict if two people change the module format. | ||
/// Don't worry about adhering to the 80-column limit for this line. | ||
const uint16_t SWIFTMODULE_VERSION_MINOR = 584; // builtin protocol conformances | ||
const uint16_t SWIFTMODULE_VERSION_MINOR = 585; // XRefClangTemplateInstantiation added | ||
|
||
/// A standard hash seed used for all string hashes in a serialized module. | ||
/// | ||
|
@@ -1711,6 +1711,12 @@ namespace decls_block { | |
BCVBR<5> // index | ||
>; | ||
|
||
using XRefClangTemplateInstantiationLayout = BCRecordLayout< | ||
hlopko marked this conversation as resolved.
Show resolved
Hide resolved
|
||
XREF_CLANG_TEMPLATE_INSTANTIATION, | ||
IdentifierIDField, // template name | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The template may be in a namespace. |
||
BCArray<IdentifierIDField> // template args | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Template args are not necessarily single identifiers -- the types may be nested in namespaces, may be template specializations themselves, and even can be non-type template parameters. Is there an existing way to serialize a Clang type? |
||
>; | ||
|
||
using SILGenNameDeclAttrLayout = BCRecordLayout< | ||
SILGenName_DECL_ATTR, | ||
BCFixed<1>, // implicit flag | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import MagicWrapper | ||
|
||
public func makeWrappedMagicNumber() -> MagicWrapper<IntWrapper> { | ||
let t = IntWrapper(value: 42) | ||
return MagicWrapper<IntWrapper>(t: t) | ||
} | ||
|
||
public func readWrappedMagicNumber(_ i : inout MagicWrapper<IntWrapper>) -> CInt { | ||
hlopko marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return i.getValuePlusArg(13) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#ifndef TEST_INTEROP_CXX_TEMPLATES_INPUTS_CLASS_TEMPLATE_INSTANTIATION_ERRORS_H | ||
#define TEST_INTEROP_CXX_TEMPLATES_INPUTS_CLASS_TEMPLATE_INSTANTIATION_ERRORS_H | ||
|
||
hlopko marked this conversation as resolved.
Show resolved
Hide resolved
|
||
template<class T> | ||
struct MagicWrapper { | ||
T t; | ||
int getValuePlusArg(int arg) const { return t.getValue() + arg; } | ||
}; | ||
|
||
struct IntWrapper { | ||
int value; | ||
int getValue() const { return value; } | ||
}; | ||
|
||
template<class T> | ||
struct CannotBeInstantianted { | ||
void willFailInstantiating(T t) { | ||
t.doesNotExist(); | ||
} | ||
}; | ||
|
||
#endif // TEST_INTEROP_CXX_TEMPLATES_INPUTS_CLASS_TEMPLATE_INSTANTIATION_ERRORS_H |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#ifndef TEST_INTEROP_CXX_TEMPLATES_INPUTS_MAGIC_WRAPPER_H | ||
#define TEST_INTEROP_CXX_TEMPLATES_INPUTS_MAGIC_WRAPPER_H | ||
|
||
template<class T> | ||
struct MagicWrapper { | ||
hlopko marked this conversation as resolved.
Show resolved
Hide resolved
|
||
T t; | ||
int getValuePlusArg(int arg) const { return t.getValue() + arg; } | ||
}; | ||
|
||
struct IntWrapper { | ||
int value; | ||
int getValue() const { return value; } | ||
}; | ||
|
||
#endif // TEST_INTEROP_CXX_TEMPLATES_INPUTS_MAGIC_WRAPPER_H |
Uh oh!
There was an error while loading. Please reload this page.