Commit Graph

25 Commits

Author SHA1 Message Date
Egor Zhdan
0e1be7769b Merge pull request #83701 from ludwwwig/interop-strcpy
[cxx-interop] Copy lazily bridged Cocoa strings correctly without hanging
2025-08-27 22:13:53 +01:00
Gabor Horvath
ad502146b3 [cxx-interop] Make reverse interop header compile in embedded mode
These are the minimal changes to make the reverse interop header compile
when embedded Swift is used. Previously, the _SwiftStdlibCxxOverlay.h
and the generated interop header disagreed on the mangling of a symbol.

This is not sufficient yet to use the embedded Swift standard library from
reverse interop, there are some missing symbols while linking. But this
PR enables doing reverse interop without using the stdlib types like
swift::String in C++. Follow-up PRs will fix the rest of the issues.

rdar://154740225
2025-08-18 13:11:43 +01:00
Ludwig Hollmann
54f315348f Copy lazily bridged Cocoa strings correctly without hanging 2025-08-14 23:45:37 +02:00
Ludwig Hollmann
39aa950660 Update file header comments for headers in lib. 2025-05-04 22:26:26 +02:00
Becca Royal-Gordon
a02698ba06 [PrintAsClang] Fix thunks for throwing Never funcs
Extend the previous commit’s support for functions that return Never to also properly generate code for *throwing* Never functions. This is a little subtle because:

• At the SWIFT_CALL level, throwing Never functions are *not* noreturn
• At the thunk level, throwing Never functions are noreturn *only* if you’re using exceptions; if you’re using swift::Expected, they should throw
• In either case, the compiler cannot statically prove that thunks are noreturn except on the error path, so we need to add an abort() call on the success path
2024-03-29 22:12:20 -07:00
Alex Lorenz
c41774188c [interop][SwiftToCxx] add swift::String overlay constructor for constructing it directly from a C string literal
resolves https://github.com/apple/swift/issues/63448
2023-05-05 06:29:59 -07:00
Alex Lorenz
30f1912cf8 [interop][SwiftToCxx] use unconditional noexcept for C++ collection overlay
accessing collection in noexcept is wrong
2023-03-14 11:41:39 -07:00
Alex Lorenz
0b265c725c [interop][SwiftToCxx] CollectionIterator in the stdlib overlay should have 'noexcept' annotations 2023-03-12 11:49:14 -07:00
Alex Lorenz
75fd11cffc [interop][SwiftToCxx] hide swift::Error APIs by default in C++ Swift stdlib overlay
They're still experimental
2023-03-10 08:34:45 -08:00
Alex Lorenz
0dc90d38c1 [interop][SwiftToCxx] emit Swift's stdlib inside of 'swift' namespace 2023-03-09 17:32:43 -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
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
0b0cc99c98 [interop][SwiftToCxx] avoid -Wshadow warning for C++ representation of enum member parameters 2023-02-08 12:33:18 -08:00
Alex Lorenz
2c83ff7643 Merge pull request #61823 from Robertorosmaninho/interop/ExpectedClassForErrorHandling
[Interop][SwiftToCxx] Introduces swift::Expected
2022-12-16 17:47:28 -08:00
Alex Lorenz
6d0dd0e7cb [interop][SwiftToCxx] workaround windows failure with Error new use in SwiftToCxxToSwift/hide-swift-module-namespace-in-swift.swift 2022-12-16 11:55:56 -08:00
Alex Lorenz
c77249c38d [interop][SwiftToCxx] NFC, use elif defined instead of elifdef for _SwiftStdlibCxxOverlay.h 2022-12-14 16:36:13 -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
Roberto Rosmaninho
80e75469bf [Interop][SwiftToCxx] Replacing static by inline on _SwiftStdlibCxxOverlay.h and fixing code duplication on PrintClangFunction.cpp 2022-12-14 12:07:43 -03:00
Roberto Rosmaninho
ce666ac592 [Interop][SwiftToCxx] Adding support to return Swift::Expected when exceptions are not available. 2022-12-14 12:07:43 -03:00
Roberto Rosmaninho
782bc6aa6f [Interop][SwiftToCxx] Moving swift::Expected to _SwiftStdlibCxxOverlay.h 2022-12-14 12:07:43 -03:00
Roberto Rosmaninho
f652c8ef63 [Interop][SwiftToCxx] Passing swift::Error declaration from _SwiftCxxInteroperability.h to Swift::Error in _SwiftStdlibCxxOverlay.h 2022-11-18 22:16:00 -03:00
Alex Lorenz
e6806ab745 [interop][SwiftToCxx] NFC, adopt SWIFT_INLINE_THUNK in the stdlib overlay 2022-11-03 15:12:41 -07:00
Alex Lorenz
391b92fff7 [interop][SwiftToCxx] add some helper methods to work with Swift's Optional in C++ 2022-10-05 14:21:13 -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