Commit Graph

12 Commits

Author SHA1 Message Date
Egor Zhdan
71cc1bb6f1 [cxx-interop] NFC: move unsafe iterator types to a separate file
Since the unsafe iterator types are now used throughout the overlay, not just by `CxxSequence` and `CxxRandomAccessCollection`, let's move them to a separate file.
2023-02-10 11:57:57 +00:00
Egor Zhdan
7ec8054064 [cxx-interop] Change the hierarchy of CxxSequence protocols
This makes `CxxConvertibleToCollection` the base protocol in the hierarchy. Both `CxxSequence` and `CxxRandomAccessCollection` now inherit from `CxxConvertibleToCollection`.
2023-02-06 22:41:26 +00:00
Egor Zhdan
ed70f30101 [cxx-interop] Make Element a primary associated type of CxxSequence etc 2023-02-02 12:48:17 +00:00
Egor Zhdan
1745c98dd6 [cxx-interop] Make two overlay functions inlinable 2023-02-02 12:43:29 +00:00
Egor Zhdan
2ac5ccf7c8 [cxx-interop] NFC: Clarify copying semantics 2023-01-12 00:39:32 +00:00
Egor Zhdan
490db497f3 [cxx-interop] NFC: Add documentation comment for CxxSequence.makeIterator
Clarify that calling `makeIterator` on a C++ sequence has `O(n)` complexity.
2023-01-05 16:14:59 +00:00
Egor Zhdan
10b705784b [cxx-interop] Optimize CxxIterator and CxxSequence
1. Instead of storing the C++ collection within `class CxxIterator`, store a boxed C++ collection and make `CxxIterator` a struct. This enables a number of Swift optimizations for iterators, while preserving the guarantee that the C++ collection is not copied or moved in memory (which would invalidate iterators).
2. Make `sequence` parameter shared. This avoids a second copy of the C++ collection when initializing `CxxIterator`.

Credits to Alex Lorenz for this idea!
2022-10-14 16:52:55 +01:00
Egor Zhdan
52ea0d0850 [cxx-interop] Make some CxxSequence methods inlinable 2022-10-07 11:54:53 +01:00
Egor Zhdan
440de8eb87 [cxx-interop] NFC: Add explicit override to associated types 2022-08-08 14:54:28 +01:00
Egor Zhdan
2c43038a29 [cxx-interop] Explicitly require CxxSequence's iterator to be CxxIterator
This is needed for automatic synthesis of conformances to `CxxSequence` protocol.
It also makes typechecker errors easier to understand when they happen.
2022-07-31 22:34:41 +01:00
zoecarver
6acffbbee6 [cxx-interop] Flip the switch: only import safe APIs. 2022-07-18 17:15:15 -04:00
Egor Zhdan
6754c3cf82 [cxx-interop] Add CxxSequence protocol to the stdlib overlay
This change adds basic helper protocols and structs that are going to be used for making C++ sequences and collection safe and Swifty by adding conformances to `Swift.Sequence`, `Swift.Collection`, etc.

This is not meant to be a final design.
2022-06-27 20:40:12 +01:00