Skip to content

Commit

Permalink
add new swift interop macros.
Browse files Browse the repository at this point in the history
Signed-off-by: furby™ <[email protected]>
  • Loading branch information
furby-tm committed Dec 1, 2024
1 parent 9868326 commit 5dd6c3d
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Sources/Arch/include/Arch/swiftInterop.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,28 @@
__attribute__((swift_attr("mutating")))
#endif /* SWIFT_MUTATING */

#if !defined(SWIFT_UNCHECKED_SENDABLE)
/// Specifies that a specific c++ type such class or struct should be imported as type marked
/// as `@unchecked Sendable` type in swift. If this annotation is used, the type is therefore allowed to
/// use safely across async contexts.
///
/// For example
/// ```
/// class SWIFT_UNCHECKED_SENDABLE CustomUserType
/// { ... }
/// ```
/// Will be imported as `struct CustomUserType: @unchecked Sendable`
#define SWIFT_UNCHECKED_SENDABLE \
__attribute__((swift_attr("@Sendable")))
#endif /* SWIFT_UNCHECKED_SENDABLE */

#if !defined(SWIFT_NONCOPYABLE)
/// Specifies that a specific c++ type such class or struct should be imported
/// as a non-copyable Swift value type.
#define SWIFT_NONCOPYABLE \
__attribute__((swift_attr("~Copyable")))
#endif /* SWIFT_NONCOPYABLE */

#else /* !_CXX_INTEROP_HAS_ATTRIBUTE */

// Empty defines for compilers that don't support `attribute(swift_attr)`.
Expand Down Expand Up @@ -249,6 +271,14 @@
#define SWIFT_MUTATING
#endif // SWIFT_MUTATING

#if !defined(SWIFT_UNCHECKED_SENDABLE)
#define SWIFT_UNCHECKED_SENDABLE
#endif // SWIFT_UNCHECKED_SENDABLE

#if !defined(SWIFT_NONCOPYABLE)
#define SWIFT_NONCOPYABLE
#endif // SWIFT_NONCOPYABLE

#endif /* !_CXX_INTEROP_HAS_ATTRIBUTE */

#if defined(_CXX_INTEROP_HAS_ATTRIBUTE)
Expand Down

0 comments on commit 5dd6c3d

Please sign in to comment.