Commit Graph

572 Commits

Author SHA1 Message Date
Alex Lorenz
68fc606510 [interop] NFC, add a method to print out identifier to clang syntax printer 2022-03-24 21:54:44 -07:00
Alex Lorenz
e21abc140b [interop] NFC, extract out isClangKeyword into ClangSyntaxPrinter 2022-03-24 19:20:42 -07:00
Alex Lorenz
146f9e84ee [interop][SwiftToC] print out nullability specifiers for primitive C types 2022-03-24 10:53:48 -07:00
Alex Lorenz
891d7b04ac [interop] NFC, refactor printNullability to ClangSyntaxPrinter
This way it can be reused from ClangFunctionPrinter
2022-03-24 10:12:11 -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
e9091123aa [PrintAsClang] refactor C function signature printer out of DeclAndTypePrinter
This will allow us to print more specific C signatures for C and C++ interop
2022-03-22 11:08:36 -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
2e3aa87737 Revert "Revert "Merge pull request #41831 from hyp/unify-header""
This reverts commit 4c9582c295.
2022-03-19 13:36:28 -07:00
Alex Lorenz
4c9582c295 Revert "Merge pull request #41831 from hyp/unify-header"
This reverts commit cd93d23bac, reversing
changes made to f9f5476e9a.
2022-03-18 10:03:07 -07:00
Alex Lorenz
9d52099d5b [cxx-interop] start to emitting a unified header file for a Swift module
This change removes the -emit-cxx-header option, and adds a new -emit-clang-header-path option instead. It's aliased to -emit-objc-header-path for now, but in the future, -emit-objc-header-path will alias to it. After this change Swift can start emitting a single header file that can be expose declarations to C, Objective-C, or C++. For now C++ interface is generated (for all public decls) only when -enable-cxx-interop flag is passed, but that behavior will change once  attribute is supported.
2022-03-17 10:34:47 -07:00
Alex Lorenz
23e56e314c [cxx-interop] add OBJC and cplusplus conditions for emitted header includes
This will allow us to generate a unified clang header.
2022-03-15 12:34:27 -07:00
Alex Lorenz
6b8108bf59 [cxx-interop] use SWIFT_EXTERN for Swift function prototypes
This will allow these functions to be used from C.
2022-03-13 12:11:35 -07:00
Alex Lorenz
858a847d27 [cxx-interop] use SWIFT_NOEXCEPT for Swift function prototypes
This will allow these functions to be used from C.

Also add a static_assert to verify that noexcept is actually used.
2022-03-13 11:08:32 -07:00
Alex Lorenz
fcdcb2a9f1 [interop][SwiftToC++] print C++ interface for top-level Swift functions 2022-03-09 14:53:12 -08:00
Miguel Salinas
59f29f09d4 Merge pull request #41197 from salinas-miguel/import-CGFloat-APIs-correctly
Import CGFloat APIs correctly
2022-02-08 13:34:35 -08:00
Miguel Salinas
2cd0d9b862 Import CGFloat APIs correctly 2022-02-08 08:05:54 -08:00
Holly Borla
791648bfa2 Revert "[ClangImporter] Decide whether to import Objective-C pointer types as"
This reverts commit fd11d2ec41.
2022-02-04 10:06:38 -08:00
Holly Borla
fd11d2ec41 [ClangImporter] Decide whether to import Objective-C pointer types as
protocol types or existential types based on context.

When an id<P> type is the underlying type of a typedef or a generic
constraint, it should be imported as a protocol or composition. Otherwise,
it should be imported as an existential type. This is similar to how type
resolution resolves existential types using TypeResolverContext.
2022-02-01 20:17:09 -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