mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge pull request #84527 from hnrklssn/bridging-cleanup
[Interop] Bridging cleanup
This commit is contained in:
@@ -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();
|
||||
@@ -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))))
|
||||
@@ -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);
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user