Files
Doug Gregor f2340ec9af [C interop] Allow an Unmanaged<T> result in a @c @implementation function
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
2026-09-29 07:49:36 -07:00

30 lines
945 B
C

#include <CoreFoundation.h>
#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
#define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained))
#define CF_CONSUMED __attribute__((cf_consumed))
void CImplTakesCFArray(CFArrayRef arr);
void CImplTakesCFTree(CFTreeRef tree);
void CImplTakesConsumedCFString(CF_CONSUMED CFStringRef string);
CF_RETURNS_RETAINED
CFStringRef CImplReturnsRetainedCFString(void);
CF_RETURNS_NOT_RETAINED
CFStringRef CImplReturnsNotRetainedCFString(void);
// Not ownership-audited: imported as returning 'Unmanaged<CFString>?'.
CFStringRef CImplReturnsUnauditedCFString(void);
// 'CFTypeRef' is imported as 'AnyObject'.
void CImplTakesCFTypeRef(CFTypeRef obj);
CF_RETURNS_RETAINED
CFTypeRef CImplReturnsRetainedCFTypeRef(void);
// Not ownership-audited: imported as returning 'Unmanaged<CFTypeRef>?'.
CFTypeRef CImplReturnsUnauditedCFTypeRef(void);
#include "c_implementation_cf_audited.h"