Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions lib/ClangImporter/SwiftBridging/swift/bridging
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@
/// automatic reference counting.
///
/// This example shows how to use this macro to let Swift know that
/// a non-copyable reference counted C++ class can be imported as a reference counted type in Swift:
/// a reference counted C++ class can be imported as a reference counted type in Swift:
/// ```c++
/// class SWIFT_SHARED_REFERENCE(retainSharedObject, releaseSharedObject)
/// SharedObject : NonCopyable, IntrusiveReferenceCounted<SharedObject> {
/// SharedObject : IntrusiveReferenceCounted<SharedObject> {
/// public:
/// static SharedObject* create();
/// void doSomething();
Expand All @@ -71,7 +71,7 @@
/// object.doSomething()
/// // The Swift compiler will release object here.
/// ```
#define SWIFT_SHARED_REFERENCE(_retain, _release) \
#define SWIFT_SHARED_REFERENCE(_retain, _release) \
__attribute__((swift_attr("import_reference"))) \
__attribute__((swift_attr(_CXX_INTEROP_STRINGIFY(retain:_retain)))) \
__attribute__((swift_attr(_CXX_INTEROP_STRINGIFY(release:_release))))
Expand All @@ -82,10 +82,9 @@
/// type in Swift.
////
/// This example shows how to use this macro to let Swift know that
/// a non-copyable singleton C++ class can be imported as a reference type in Swift:
/// a singleton C++ class can be imported as a reference type in Swift:
/// ```c++
/// class SWIFT_IMMORTAL_REFERENCE
/// LoggerSingleton : NonCopyable {
/// class SWIFT_IMMORTAL_REFERENCE LoggerSingleton {
/// public:
/// static LoggerSingleton &getInstance();
/// void log(int x);
Expand All @@ -98,18 +97,18 @@
/// let logger = LoggerSingleton.getInstance()
/// logger.log(123)
/// ```
#define SWIFT_IMMORTAL_REFERENCE \
__attribute__((swift_attr("import_reference"))) \
__attribute__((swift_attr(_CXX_INTEROP_STRINGIFY(retain:immortal)))) \
__attribute__((swift_attr(_CXX_INTEROP_STRINGIFY(release:immortal))))
#define SWIFT_IMMORTAL_REFERENCE \
__attribute__((swift_attr("import_reference"))) \
__attribute__((swift_attr("retain:immortal"))) \
__attribute__((swift_attr("release:immortal")))

/// Specifies that a `class` or `struct` is a reference type whose lifetime
/// is not managed automatically. The programmer must validate that any reference
/// to such object is valid themselves. This annotation lets Swift import such a type as a reference type in Swift.
#define SWIFT_UNSAFE_REFERENCE \
__attribute__((swift_attr("import_reference"))) \
__attribute__((swift_attr(_CXX_INTEROP_STRINGIFY(retain:immortal)))) \
__attribute__((swift_attr(_CXX_INTEROP_STRINGIFY(release:immortal)))) \
#define SWIFT_UNSAFE_REFERENCE \
__attribute__((swift_attr("import_reference"))) \
__attribute__((swift_attr("retain:immortal"))) \
__attribute__((swift_attr("release:immortal"))) \
__attribute__((swift_attr("unsafe")))

/// Specifies a name that will be used in Swift for this declaration instead of its original name.
Expand Down