Karoy Lorentey
21169d12e8
Reinstate generalization of Optional.unsafelyUnwrapped
2025-03-24 12:16:16 -07:00
Gabor Horvath
0e03d342fe
[cxx-interop] Support ObjC protocols in C++ interop
...
This patch introduces handling of ObjC protocols similar to how ObjC
classes work. Since this only works in ObjC++, all declarations
containing ObjC protocols will be protected by the __OBJC__ macro.
This patch results in some `_bridgeObjC` methods being exposed, we might
end up hiding those in the future, but there is no harm having them in
the interop header for the interim period.
rdar://136757913
2024-10-16 18:51:35 +01:00
Gabor Horvath
48ebed6760
[cxx-interop] Support generic types with isValueType trait
...
In some circumstances the missing trait resulted in picking the wrong
branch of some compile time conditionals resulting in code that would
not compile.
rdar://126709253
2024-07-23 09:48:49 +02:00
Gabor Horvath
b5384bc8a6
[cxx-interop] Support optional generic cases in enums
...
This PR implements proper support for optional generic associated values
in enum cases. Most of the code changes are supporting generic types in
more contexts in the printer, the rest are making sure we handle the
null pointer case when we try to get the declaration from the type that
represents a generic parameter.
rdar://131112273
2024-07-09 16:08:27 +01:00
Allan Shortlidge
8f4af40f91
tests: Un-XFAIL some CxxInterop tests that pass now.
2024-03-27 22:20:50 -07:00
Karoy Lorentey
68a8c41e81
[test] Temporarily XFAIL tests that expect swiftinterface files to work when using Optional and other stdlib features
2024-03-18 11:09:08 -07:00
Doug Gregor
b5fc2fc036
[Generated header] Emit members of enum extensions into C++ class
...
As we do with Swift structs, emit the members of extensions of Swift
enums into the corresponding C++ class. This includes exposing more of
the Optional API from the standard library into Swift.
2024-03-05 21:54:47 -08:00
Alex Lorenz
ca95860530
[interop][SwiftToCxx] ensure Swift generic types can be used as template parameters to other Swift generic types in C++
...
rdar://117015962
2023-10-30 12:17:29 -07:00
Alex Lorenz
4e519a8d8b
[interop][SwiftToCxx] consuming parameters should be passed using an additional copy
...
Fixes https://github.com/apple/swift/issues/69372
2023-10-27 17:29:52 -07:00
Ben Barham
e0b976d150
[CxxInterop] Change C++ interop header ordering
...
Consider the case of a toolchain that includes clang is being used to
compile Swift. With the current ordering, the header will be found
relative to that toolchain, which could be out of date as compared to
tip. This is the case today if eg. a 5.7 toolchain is used to build
main/5.9 as the shim header is missing a definition.
2023-08-17 09:46:28 -07:00
Alex Lorenz
de10b4155e
[interop][SwiftToCxx] support copy-assignment operation for Swift value types and prohibit move assignment explicitly
...
Fixes https://github.com/apple/swift/issues/66324
Note: move semantics for Swift value types are not yet supported in C++
2023-06-06 15:55:30 -07:00
Alex Lorenz
39d86bc701
[interop][SwiftToCxx] the not yet implemented move constructor for Swift value types should lead to link error when a move is used in Swift, not runtime error
2023-05-07 08:55:28 -07:00
Alex Lorenz
bf35e3f55a
[interop][SwiftToCxx] provide a clear unavailable message for protocol decls in C++
2023-05-05 17:03:28 -07:00
Alex Lorenz
aff3568a12
[interop][SwiftToCxx] emit unavailable type stubs for top level types that could not be emitted in the C++ section of the generated header
2023-05-05 17:03:26 -07:00
Alex Lorenz
c4cc9e8e42
[interop][SwiftToCxx] do not error out on -Wnon-modular-include-in-framework-module clang diagnostic when importing the generated header as part of a framework back into C++ via a Clang module
2023-03-30 08:40:40 -07:00
Alex Lorenz
f405fb0fa8
[interop][SwiftToCxx] do not expose @alwaysEmitIntoClient properties to C++
2023-03-15 10:01:37 -07:00
Alex Lorenz
94c1de7611
[interop][SwiftToCxx] use 'SWIFT_INLINE_PRIVATE_HELPER' macro for static returnNewValue functions to ensure attribute(used) isn't applied to them
2023-03-15 09:13:38 -07:00
Alex Lorenz
3cce09e769
[interop][SwiftToCxx] annotate several value members types as 'noexcept'
...
C++/clang is more strict about requiring noexcept in templates so we need some explicit annotations
2023-03-12 11:49:14 -07:00
Alex Lorenz
0dc90d38c1
[interop][SwiftToCxx] emit Swift's stdlib inside of 'swift' namespace
2023-03-09 17:32:43 -08:00
Alex Lorenz
3adf16eb28
Merge pull request #64083 from hyp/eng/api-stdlib-arg-labels
...
[interop][SwiftToCxx] incorporate argument labels into Stdlib API nam…
2023-03-03 21:37:40 -08:00
Alex Lorenz
13a63f4b05
[interop][SwiftToCxx] incorporate argument labels into Stdlib API names in C++
...
This allows easier use and more wider API exposure from the Swift stdlib
In the future, all functions and method should incorporate argument labels, but it's not yet clear how
2023-03-03 14:15:48 -08:00
Alex Lorenz
2dcbeb0bc9
[interop][SwiftToCxx] do not require @_expose when generating C++ interface for a Swift module
...
Instead, we emit API bindings for all supported public APIs, when -enable-experimental-cxx-interop is enabled
2023-03-02 14:06:47 -08:00
Alex Lorenz
3948a2a5d3
[interop][SwiftToCxx] annotate inline thunks with SWIFT_INLINE_THUNK
...
This macro applies always_inline in addition to inline. It also applies artificial, which lets debugger know that this is an artificial function. The used attribute is added in debug builds to ensure that the symbol is emitted in the binary so that LLDB can invoke it.
2023-02-24 11:23:46 -08:00
Alex Lorenz
b70ba0963d
[interop][SwiftToCxx] remove extraneous ';' from generated header
2023-02-08 12:43:30 -08:00
Alex Lorenz
0b0cc99c98
[interop][SwiftToCxx] avoid -Wshadow warning for C++ representation of enum member parameters
2023-02-08 12:33:18 -08:00
Alex Lorenz
cc5b557cee
[interop][SwiftToCxx] Attach SWIFT_SYMBOL to C++ enum case declarations
2023-01-12 14:01:30 -08:00
Alex Lorenz
3b3d6c825a
[interop][SwiftToCxx] Annotate emitted declarations with Clang's external_source_symbol attribute
...
Each emitted declaration is annotated with the external_source_symbol with its own USR, to allow Clang's indexer to recognize this declaration as a Swift declaration with a specific USR
2023-01-12 12:15:01 -08:00
Alex Lorenz
15b100784b
[interop][SwiftToCxx] relax the swift-stdlib-in-cxx.swift testcase
2022-12-15 07:15:52 -08:00
Alex Lorenz
a7ec9f1fcb
[interop][SwiftToCxx] also test for UTF8View API in the test
2022-12-14 16:30:59 -08:00
Alex Lorenz
5e09a5c30b
[interop][SwiftToCxx] move std::string -> Swift String constructor to the overlay header
2022-12-14 16:27:29 -08:00
Alex Lorenz
28af8bef55
[interop][SwiftToCxx] make it possible to convert Swift String to a std::string in C++
...
This is done by exposing nested Index and UTF8View type in String. Nested types aren't
supported yet, so we need to employ a number of hacks to emit them.
2022-12-14 16:22:41 -08:00
Alex Lorenz
5c703b4f5c
[interop][SwiftToCxx] support std::string -> Swift::String conversion in C++
2022-12-13 13:13:05 -08:00
Alex Lorenz
cd67584015
[interop][SwiftToCxx] support NSString -> Swift String bridging in C++
2022-11-29 16:52:50 -08:00
Alex Lorenz
83db71b64e
[interop][SwiftToCxx] use the more appropriate String -> NSString bridging invocation
...
This fixes some CI failures
2022-11-29 15:19:26 -08:00
Alex Lorenz
0312e0613d
[interop][SwiftToCxxToSwift] hide reverse interop module namespaces from forward interop
2022-11-07 15:52:04 -08:00
Alex Lorenz
c179e23b19
[interop][SwiftToCxx] add static_assert type checking for generic types in pre-C++20 mode
2022-11-01 17:36:37 -07:00
Alex Lorenz
4b52ae08fa
[interop][SwiftToCxx] check that generics can be built in C++17/C++14 mode
2022-11-01 16:40:42 -07:00
Alex Lorenz
953c124ceb
[interop][SwiftToCxx] guard 'requires' clauses in __cpp_concepts #ifdefs
2022-11-01 16:17:10 -07:00
Alex Lorenz
f6cc59246b
[interop][SwiftToCxx] fix the include path for swiftToCxx shim header for clang in /usr/local/bin/clang
2022-09-30 07:59:46 -07:00
Alex Lorenz
dd7e068391
[interop][SwiftToCxx] add a Swift stdlib overlay header
...
It currently provides begin and end functions for array iteration
2022-09-29 07:41:54 -07:00
Alex Lorenz
ae549531ac
Merge pull request #61225 from hyp/eng/fwd-generic-trait
...
[interop][SwiftToCxx] Declare the generic usability type trait before…
2022-09-21 15:56:14 -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
1d6d3ff970
[interop][SwiftToCxx] trap on moves of Swift values for now
...
Move support will be added later
2022-09-21 06:59:29 -07:00
Alex Lorenz
143ce1e682
[interop][SwiftToCxx] bridge Swift's Optional type in an experimental manner
2022-09-15 12:35:33 -07:00
Alex Lorenz
8c48d268d5
[interop][SwiftToCxx] expose subscript getter for Array's operator []
2022-09-12 21:13:44 -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
1d164039b1
[interop][SwiftToCxx] experimentally expose Swift's Array type
...
This is done without annotations on the stdlib yet while @_expose is still experimental
2022-09-08 11:04:03 -07:00
Alex Lorenz
06d9fd24d4
[interop][SwiftToCxx] add experimental Swift::String -> NSString conversion operator
2022-08-25 15:09:30 -07:00
Alex Lorenz
bd8c874e17
[interop][SwiftToCxx] experimentally expose Swift::String type to C++
...
The only member that's currently exposed is the default initializer, everything else is in extensions
2022-08-25 15:09:30 -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