mirror of
https://github.com/apple/swift.git
synced 2026-10-26 20:15:53 +01:00
A C function returning a foreign reference or CoreFoundation type unretained cannot be safely implemented, because there is no way to ensure that the result object lives past the return. However, such C functions do exist, and we would like to be able to implement them via `@c @implementation`. Extend the signature-matching logic for `@implementation` to permit an `Unmanaged<T>` result even when the signature comes in an `T` to allow the use of `@implementation` here. Implements rdar://188429740
34 lines
996 B
C
34 lines
996 B
C
@import Foundation;
|
|
|
|
#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
|
|
#define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained))
|
|
#define CF_CONSUMED __attribute__((cf_consumed))
|
|
|
|
CF_RETURNS_RETAINED
|
|
CFStringRef returns_retained(void);
|
|
|
|
CF_RETURNS_NOT_RETAINED
|
|
CFStringRef returns_not_retained(void);
|
|
|
|
void passes_borrowed(CFStringRef string);
|
|
|
|
void passes_consumed(CF_CONSUMED CFStringRef string);
|
|
|
|
// Not ownership-audited, so this is imported as returning
|
|
// 'Unmanaged<CFString>?'.
|
|
CFStringRef returns_unaudited(void);
|
|
|
|
// 'CFTypeRef' is imported as 'AnyObject', and uses the same reference counting.
|
|
void passes_any_borrowed(CFTypeRef obj);
|
|
|
|
CF_RETURNS_RETAINED
|
|
CFTypeRef returns_any_retained(void);
|
|
|
|
// Audited results can be implemented as returning 'Unmanaged', which is
|
|
// returned without any retain or autorelease.
|
|
CF_RETURNS_NOT_RETAINED
|
|
CFStringRef returns_not_retained_unmanaged(void);
|
|
|
|
CF_RETURNS_RETAINED
|
|
CFStringRef returns_retained_unmanaged(void);
|