Commit Graph

31 Commits

Author SHA1 Message Date
Alex Lorenz
3a9b6dce9d [interop][SwiftToCxx] add support for emitting Swift stdlib dependency in one header file
This is the default behavior. You can disable this by specifying the -clang-header-expose-decls= flag explicitly when generating the header
2022-09-28 08:08:48 -07:00
Alex Lorenz
2a05109c58 [interop][SwiftToCxx] Declare the generic usability type trait before the C++ class that represents the Swift type
This allows you to import a method that returns the type of the context in which the method is declared when such
type is a generic parameter in another type. This means that it's now possible to bridge the initializer for
RawRepresentable enums.
2022-09-21 07:57:32 -07:00
Alex Lorenz
88913c1d65 [interop][SwiftToCxx] expose generic type traits for C++ types in generated header before it's used first 2022-09-13 07:47:30 -07:00
Alex Lorenz
d5c531fefc [interop][SwiftToCxx] experimentally expose exposable Swift's Array members to C++ 2022-09-12 20:42:16 -07:00
Alex Lorenz
1a449f5904 [interop][SwiftToCxx] emit members in extensions for same-type 2022-09-12 20:38:21 -07:00
Alex Lorenz
26e5742fe7 [interop][SwiftToCxx] emit generic type traits for C++ types bridged into Swift and then back to C++ 2022-09-12 12:39:30 -07:00
Alex Lorenz
b4d7a0c208 [interop][SwiftToCxx] bridge returned C++ record types back to C++ from Swift 2022-09-11 18:42:41 -07:00
Tongjie Wang
cbc23cbafc [Interop][SwiftToCxx] Support enum creation from Cxx 2022-08-29 20:16:52 -07:00
Alex Lorenz
e9450cf80b [interop][SwiftToCxx] add a test to print out empty Swift stdlib module 2022-08-24 15:10:11 -07:00
Alex Lorenz
8de79390be [interop][SwiftToCxx] add @_expose(Cxx) attribute support
This attribute instructs the compiler that this declaration should be included in the generated C++ bindings
2022-08-24 10:14:07 -07:00
Alex Lorenz
489c16e906 [interop][SwiftToCxx] fix the circular depedency issue for struct emission 2022-08-19 15:02:56 -07:00
Alex Lorenz
94f6496431 [interop][SwiftToCxx] NFC,do not require definition of protocols for classes in C++ generation mode 2022-08-16 10:44:18 -07:00
Alex Lorenz
26d55a2b83 [interop][SwiftToCxx] start emitting bindings for Swift class types
This includes release on destruction, and correctly returning class values from Swift to C++.
2022-08-02 09:25:35 +01:00
Alex Lorenz
32723f7e67 [interop][SwiftToCxx] initial generic function support: pass generic parameters
Only primitive types are supported at the moment from C++ as the type traits aren't emitted for all types yet
2022-07-28 22:52:21 +01:00
Becca Royal-Gordon
dfb8d7452a Merge pull request #59672 from beccadax/what-is-the-protocol-for-generating-sendable
Ignore Sendable conformances in PrintAsClang
2022-06-23 17:15:09 -07:00
Becca Royal-Gordon
8a8e71ea09 Ignore Sendable conformances in PrintAsClang
PrintAsClang previously tried to print Sendable conformances, which tripped an assertion and failed. Skip them instead.

Fixes rdar://95241184.
2022-06-23 13:16:41 -07:00
Tongjie Wang
890ef3d269 clang-format on TODO 2022-06-21 20:25:02 -07:00
Tongjie Wang
c26e6b062b Improve test cases and change a FIXME to TODO 2022-06-21 15:56:49 -07:00
Tongjie Wang
00598e8019 [interop][SwiftToCxx] add initial support for passing/returning enums 2022-06-20 00:45:07 -07:00
Alex Lorenz
d7fd1233a9 [interop][SwiftToCxx] emit instance property getters for structs 2022-06-14 17:20:37 -07:00
Alex Lorenz
9254c47b2c [interop][SwiftToCxx] emit swift type metadata access function declaration for structs 2022-06-13 09:16:17 -07:00
Alex Lorenz
132729906c [interop][SwiftToCxx] pass / return Swift struct values between C/C++ and Swift 2022-06-08 07:03:24 -07:00
Alex Lorenz
42c6ff63b8 [interop][SwiftToCxx] Gather initial struct layout information and emit struct stubs with storage in C++
This change extends the clang header printer to start emitting C++ classes for Swift struct types with the correct struct layout in them (size + alignment)
2022-06-01 14:06:25 -07:00
Alex Lorenz
a7053e458f [interop][swiftToCxx] emit empty skeleton C++ classes for Swift struct decls 2022-05-25 12:26:25 -07:00
Alex Lorenz
9d56de1c0c [interop] NFC, create ClangSyntaxPrinter class 2022-03-24 09:07:09 -07:00
Alex Lorenz
81a9cade88 [interop] generate C interfaces for Swift top-level functions that use primitive types 2022-03-22 16:13:42 -07:00
Alex Lorenz
86f9162606 [PrintAsClang] NFC, refactor primitive type mapping logic out from DeclAndTypePrinter
This will allow us to use type mappings in the C ABI function printer.
2022-03-21 11:26:58 -07:00
Alex Lorenz
80bc75ab9b [cxx-interop] Emit C++ declarations only when '-clang-header-expose-public-decl' is enabled
This fix also ensures that we only emit C++ functions for now
2022-03-20 20:22:02 -07:00
Alex Lorenz
fcdcb2a9f1 [interop][SwiftToC++] print C++ interface for top-level Swift functions 2022-03-09 14:53:12 -08:00
Alex Lorenz
54b466f983 [interop] emit a parsable C++ header for a module that includes namespace declaration for the module interface 2022-01-21 07:14:56 -08:00
Alex Lorenz
e106551028 [NFC][interop] rename the PrintAsObjC library to PrintAsClang
We're starting to support emission of C++ header interfaces, so a language-agnostic name makes more sense
2022-01-20 11:31:58 -08:00