Skip to content

Commit

Permalink
Move all uses of Core Foundation to be @_implementationOnly except ge…
Browse files Browse the repository at this point in the history
…tCFRunLoop().
  • Loading branch information
millenomi committed Sep 10, 2020
1 parent a69879f commit 75f3bac
Show file tree
Hide file tree
Showing 100 changed files with 493 additions and 293 deletions.
29 changes: 28 additions & 1 deletion CoreFoundation/Base.subproj/CFRuntime.c
Original file line number Diff line number Diff line change
Expand Up @@ -1674,7 +1674,34 @@ static void _CFRelease(CFTypeRef CF_RELEASES_ARGUMENT cf) {
#if DEPLOYMENT_RUNTIME_SWIFT
struct _CFSwiftBridge __CFSwiftBridge = { { NULL } };

struct _NSCFXMLBridge __NSCFXMLBridge = {
struct _NSCFXMLBridgeStrong __NSCFXMLBridgeStrong = {
CFArrayGetCount,
CFArrayGetValueAtIndex,
CFErrorCreate,
CFStringCreateWithCString,
CFStringCreateMutable,
CFStringAppend,
CFStringAppendCString,
CFStringGetLength,
CFStringGetMaximumSizeForEncoding,
CFStringGetCString,
CFDataCreateWithBytesNoCopy,
CFRelease,
CFStringCreateWithBytes,
CFArrayCreateMutable,
CFArrayAppendValue,
CFDataGetLength,
CFDataGetBytePtr,
CFDictionaryCreateMutable,
CFDictionarySetValue,
&kCFAllocatorSystemDefault,
&kCFAllocatorNull,
&kCFCopyStringDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks,
&kCFErrorLocalizedDescriptionKey,
};

struct _NSCFXMLBridgeUntyped __NSCFXMLBridgeUntyped = {
CFArrayGetCount,
CFArrayGetValueAtIndex,
CFErrorCreate,
Expand Down
86 changes: 60 additions & 26 deletions CoreFoundation/Base.subproj/ForSwiftFoundationOnly.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,34 +280,62 @@ struct _CFSwiftBridge {
struct _NSURLBridge NSURL;
};

struct _NSCFXMLBridge {
CFIndex (* _Nonnull CFArrayGetCount)(CFArrayRef);
const void * _Null_unspecified (* _Nonnull CFArrayGetValueAtIndex)(CFArrayRef, CFIndex);
_Null_unspecified CFErrorRef (* _Nonnull CFErrorCreate)(CFAllocatorRef _Nullable, CFStringRef, CFIndex, CFDictionaryRef _Nullable);
_Null_unspecified CFStringRef (* _Nonnull CFStringCreateWithCString)(CFAllocatorRef _Nullable, const char * _Null_unspecified, CFStringEncoding);
_Null_unspecified CFMutableStringRef (* _Nonnull CFStringCreateMutable)(CFAllocatorRef _Nullable, CFIndex);
void (* _Nonnull CFStringAppend)(CFMutableStringRef, CFStringRef);
void (* _Nonnull CFStringAppendCString)(CFMutableStringRef, const char * _Null_unspecified, CFStringEncoding);
CFIndex (* _Nonnull CFStringGetLength)(CFStringRef);
CFIndex (* _Nonnull CFStringGetMaximumSizeForEncoding)(CFIndex, CFStringEncoding);
Boolean (* _Nonnull CFStringGetCString)(CFStringRef, char *, CFIndex, CFStringEncoding);
_Null_unspecified CFDataRef (* _Nonnull CFDataCreateWithBytesNoCopy)(CFAllocatorRef _Nullable, const uint8_t *, CFIndex, CFAllocatorRef);
void (* _Nonnull CFRelease)(CFTypeRef);
_Null_unspecified CFStringRef (* _Nonnull CFStringCreateWithBytes)(CFAllocatorRef _Nullable, const UInt8 *, CFIndex, CFStringEncoding, Boolean);
_Null_unspecified CFMutableArrayRef (* _Nonnull CFArrayCreateMutable)(CFAllocatorRef _Nullable, CFIndex, const CFArrayCallBacks *_Nullable);
void (* _Nonnull CFArrayAppendValue)(CFMutableArrayRef, const void *);
CFIndex (* _Nonnull CFDataGetLength)(CFDataRef);
const uint8_t * _Null_unspecified (* _Nonnull CFDataGetBytePtr)(CFDataRef);
_Null_unspecified CFMutableDictionaryRef (* _Nonnull CFDictionaryCreateMutable)(CFAllocatorRef _Nullable, CFIndex, const CFDictionaryKeyCallBacks *, const CFDictionaryValueCallBacks *);
void (* _Nonnull CFDictionarySetValue)(CFMutableDictionaryRef, const void * _Null_Unspecified, const void * _Null_unspecified);
const _Null_unspecified CFAllocatorRef * _Nonnull kCFAllocatorSystemDefault;
const _Null_unspecified CFAllocatorRef * _Nonnull kCFAllocatorNull;
const CFDictionaryKeyCallBacks * _Nonnull kCFCopyStringDictionaryKeyCallBacks;
const CFDictionaryValueCallBacks * _Nonnull kCFTypeDictionaryValueCallBacks;
_Null_unspecified const CFStringRef * _Nonnull kCFErrorLocalizedDescriptionKey;
struct _NSCFXMLBridgeStrong {
CFIndex (* _Nonnull CFArrayGetCount)(CFArrayRef);
const void * _Null_unspecified (* _Nonnull CFArrayGetValueAtIndex)(CFArrayRef, CFIndex);
_Null_unspecified CFErrorRef (* _Nonnull CFErrorCreate)(CFAllocatorRef _Nullable, CFStringRef, CFIndex, CFDictionaryRef _Nullable);
_Null_unspecified CFStringRef (* _Nonnull CFStringCreateWithCString)(CFAllocatorRef _Nullable, const char * _Null_unspecified, CFStringEncoding);
_Null_unspecified CFMutableStringRef (* _Nonnull CFStringCreateMutable)(CFAllocatorRef _Nullable, CFIndex);
void (* _Nonnull CFStringAppend)(CFMutableStringRef, CFStringRef);
void (* _Nonnull CFStringAppendCString)(CFMutableStringRef, const char * _Null_unspecified, CFStringEncoding);
CFIndex (* _Nonnull CFStringGetLength)(CFStringRef);
CFIndex (* _Nonnull CFStringGetMaximumSizeForEncoding)(CFIndex, CFStringEncoding);
Boolean (* _Nonnull CFStringGetCString)(CFStringRef, char *, CFIndex, CFStringEncoding);
_Null_unspecified CFDataRef (* _Nonnull CFDataCreateWithBytesNoCopy)(CFAllocatorRef _Nullable, const uint8_t *, CFIndex, CFAllocatorRef);
void (* _Nonnull CFRelease)(CFTypeRef);
_Null_unspecified CFStringRef (* _Nonnull CFStringCreateWithBytes)(CFAllocatorRef _Nullable, const UInt8 *, CFIndex, CFStringEncoding, Boolean);
_Null_unspecified CFMutableArrayRef (* _Nonnull CFArrayCreateMutable)(CFAllocatorRef _Nullable, CFIndex, const CFArrayCallBacks *_Nullable);
void (* _Nonnull CFArrayAppendValue)(CFMutableArrayRef, const void *);
CFIndex (* _Nonnull CFDataGetLength)(CFDataRef);
const uint8_t * _Null_unspecified (* _Nonnull CFDataGetBytePtr)(CFDataRef);
_Null_unspecified CFMutableDictionaryRef (* _Nonnull CFDictionaryCreateMutable)(CFAllocatorRef _Nullable, CFIndex, const CFDictionaryKeyCallBacks *, const CFDictionaryValueCallBacks *);
void (* _Nonnull CFDictionarySetValue)(CFMutableDictionaryRef, const void * _Null_Unspecified, const void * _Null_unspecified);
const _Null_unspecified CFAllocatorRef * _Nonnull kCFAllocatorSystemDefault;
const _Null_unspecified CFAllocatorRef * _Nonnull kCFAllocatorNull;
const CFDictionaryKeyCallBacks * _Nonnull kCFCopyStringDictionaryKeyCallBacks;
const CFDictionaryValueCallBacks * _Nonnull kCFTypeDictionaryValueCallBacks;
_Null_unspecified const CFStringRef * _Nonnull kCFErrorLocalizedDescriptionKey;
};

CF_EXPORT struct _NSCFXMLBridge __NSCFXMLBridge;
struct _NSCFXMLBridgeUntyped {
void *CFArrayGetCount;
void *CFArrayGetValueAtIndex;
void *CFErrorCreate;
void *CFStringCreateWithCString;
void *CFStringCreateMutable;
void *CFStringAppend;
void *CFStringAppendCString;
void *CFStringGetLength;
void *CFStringGetMaximumSizeForEncoding;
void *CFStringGetCString;
void *CFDataCreateWithBytesNoCopy;
void *CFRelease;
void *CFStringCreateWithBytes;
void *CFArrayCreateMutable;
void *CFArrayAppendValue;
void *CFDataGetLength;
void *CFDataGetBytePtr;
void *CFDictionaryCreateMutable;
void *CFDictionarySetValue;
void *kCFAllocatorSystemDefault;
void *kCFAllocatorNull;
void *kCFCopyStringDictionaryKeyCallBacks;
void *kCFTypeDictionaryValueCallBacks;
void *kCFErrorLocalizedDescriptionKey;
};

CF_EXPORT struct _NSCFXMLBridgeStrong __NSCFXMLBridgeStrong;
CF_EXPORT struct _NSCFXMLBridgeUntyped __NSCFXMLBridgeUntyped;

CF_EXPORT struct _CFSwiftBridge __CFSwiftBridge;

Expand Down Expand Up @@ -478,6 +506,12 @@ static inline _Bool _withStackOrHeapBuffer(size_t amount, void (__attribute__((n
return true;
}

static inline _Bool _withStackOrHeapBufferWithResultInArguments(size_t amount, void (__attribute__((noescape)) ^ _Nonnull applier)(void *_Nonnull memory, size_t capacity, _Bool onStack)) {
return _withStackOrHeapBuffer(amount, ^(_ConditionalAllocationBuffer *buffer) {
applier(buffer->memory, buffer->capacity, buffer->onStack);
});
}

#pragma mark - Character Set

CF_CROSS_PLATFORM_EXPORT CFIndex __CFCharDigitValue(UniChar ch);
Expand Down

0 comments on commit 75f3bac

Please sign in to comment.