Skip to content

Commit a0ffced

Browse files
author
Mohit Athwani
committed
Resolved Merge conflicts
2 parents a0a8f76 + a6e77b4 commit a0ffced

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2186
-249
lines changed

CoreFoundation/Base.subproj/CFRuntime.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -999,9 +999,9 @@ void __CFInitialize(void) {
999999

10001000
#ifndef __CFSwiftGetBaseClass
10011001
#if TARGET_OS_LINUX
1002-
#define __CFSwiftGetBaseClass _TF10Foundation21__CFSwiftGetBaseClassFT_PMPs9AnyObject_
1002+
#define __CFSwiftGetBaseClass _T010Foundation21__CFSwiftGetBaseClasss9AnyObject_pXpyF
10031003
#elif TARGET_OS_MAC
1004-
#define __CFSwiftGetBaseClass _TF15SwiftFoundation21__CFSwiftGetBaseClassFT_PMPs9AnyObject_
1004+
#define __CFSwiftGetBaseClass _T015SwiftFoundation21__CFSwiftGetBaseClasss9AnyObject_pXpyF
10051005
#endif
10061006
#endif
10071007
extern uintptr_t __CFSwiftGetBaseClass();
@@ -1108,9 +1108,9 @@ void __CFInitialize(void) {
11081108
#if DEPLOYMENT_RUNTIME_SWIFT
11091109
#ifndef __CFInitializeSwift
11101110
#if TARGET_OS_LINUX
1111-
#define __CFInitializeSwift _TF10Foundation19__CFInitializeSwiftFT_T_
1111+
#define __CFInitializeSwift _T010Foundation19__CFInitializeSwiftyyF
11121112
#elif TARGET_OS_MAC
1113-
#define __CFInitializeSwift _TF15SwiftFoundation19__CFInitializeSwiftFT_T_
1113+
#define __CFInitializeSwift _T015SwiftFoundation014__CFInitializeA0yyF
11141114
#endif
11151115
#endif
11161116
extern void __CFInitializeSwift();

CoreFoundation/Base.subproj/ForSwiftFoundationOnly.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,12 @@ struct _NSMutableCharacterSetBridge {
224224
void (*_Nonnull invert)(CFTypeRef cset);
225225
};
226226

227+
struct _NSNumberBridge {
228+
CFNumberType (*_Nonnull _cfNumberGetType)(CFTypeRef number);
229+
bool (*_Nonnull boolValue)(CFTypeRef number);
230+
bool (*_Nonnull _getValue)(CFTypeRef number, void *value, CFNumberType type);
231+
};
232+
227233
struct _CFSwiftBridge {
228234
struct _NSObjectBridge NSObject;
229235
struct _NSArrayBridge NSArray;
@@ -238,6 +244,7 @@ struct _CFSwiftBridge {
238244
struct _NSRunLoop NSRunLoop;
239245
struct _NSCharacterSetBridge NSCharacterSet;
240246
struct _NSMutableCharacterSetBridge NSMutableCharacterSet;
247+
struct _NSNumberBridge NSNumber;
241248
};
242249

243250
CF_EXPORT struct _CFSwiftBridge __CFSwiftBridge;

CoreFoundation/NumberDate.subproj/CFNumber.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ CFTypeID CFBooleanGetTypeID(void) {
8282

8383
Boolean CFBooleanGetValue(CFBooleanRef boolean) {
8484
CF_OBJC_FUNCDISPATCHV(CFBooleanGetTypeID(), Boolean, (NSNumber *)boolean, boolValue);
85+
CF_SWIFT_FUNCDISPATCHV(CFBooleanGetTypeID(), Boolean, (CFSwiftRef)boolean, NSNumber.boolValue);
8586
return (boolean == kCFBooleanTrue) ? true : false;
8687
}
8788

@@ -1063,6 +1064,10 @@ CF_PRIVATE void __CFNumberInitialize(void) {
10631064
_CFRuntimeSetInstanceTypeIDAndIsa(& __kCFNumberFloat64One, __kCFNumberTypeID);
10641065
__CFBitfieldSetValue(__kCFNumberFloat64One._base._cfinfo[CF_INFO_BITS], 4, 0, kCFNumberFloat64Type);
10651066
__kCFNumberFloat64One._pad = BITSFORDOUBLEONE;
1067+
#if DEPLOYMENT_RUNTIME_SWIFT
1068+
_CFRuntimeSetInstanceTypeIDAndIsa(& __kCFBooleanTrue, __kCFBooleanTypeID);
1069+
_CFRuntimeSetInstanceTypeIDAndIsa(& __kCFBooleanFalse, __kCFBooleanTypeID);
1070+
#endif
10661071
}
10671072

10681073
CFTypeID CFNumberGetTypeID(void) {
@@ -1256,6 +1261,7 @@ CFLog(kCFLogLevelWarning, CFSTR("+++ Create old number '%@'"), __CFNumberCopyDes
12561261
CFNumberType CFNumberGetType(CFNumberRef number) {
12571262
//printf("+ [%p] CFNumberGetType(%p)\n", pthread_self(), number);
12581263
CF_OBJC_FUNCDISPATCHV(CFNumberGetTypeID(), CFNumberType, (NSNumber *)number, _cfNumberType);
1264+
CF_SWIFT_FUNCDISPATCHV(CFNumberGetTypeID(), CFNumberType, (CFSwiftRef)number, NSNumber._cfNumberGetType);
12591265
__CFAssertIsNumber(number);
12601266
CFNumberType type = __CFNumberGetType(number);
12611267
if (kCFNumberSInt128Type == type) type = kCFNumberSInt64Type; // must hide this type, since it is not public
@@ -1275,6 +1281,7 @@ CFLog(kCFLogLevelWarning, CFSTR("*** TEST FAIL in CFNumberGetType: '%d' '%d'"),
12751281

12761282
CF_EXPORT CFNumberType _CFNumberGetType2(CFNumberRef number) {
12771283
CF_OBJC_FUNCDISPATCHV(CFNumberGetTypeID(), CFNumberType, (NSNumber *)number, _cfNumberType);
1284+
CF_SWIFT_FUNCDISPATCHV(CFNumberGetTypeID(), CFNumberType, (CFSwiftRef)number, NSNumber._cfNumberGetType);
12781285
__CFAssertIsNumber(number);
12791286
return __CFNumberGetType(number);
12801287
}
@@ -1319,6 +1326,7 @@ Boolean CFNumberGetValue(CFNumberRef number, CFNumberType type, void *valuePtr)
13191326
//printf("+ [%p] CFNumberGetValue(%p, %d, %p)\n", pthread_self(), number, type, valuePtr);
13201327

13211328
CF_OBJC_FUNCDISPATCHV(CFNumberGetTypeID(), Boolean, (NSNumber *)number, _getValue:(void *)valuePtr forType:(CFNumberType)__CFNumberTypeTable[type].canonicalType);
1329+
CF_SWIFT_FUNCDISPATCHV(CFNumberGetTypeID(), Boolean, (CFSwiftRef)number, NSNumber._getValue, valuePtr, (CFNumberType)__CFNumberTypeTable[type].canonicalType);
13221330
__CFAssertIsNumber(number);
13231331
__CFAssertIsValidNumberType(type);
13241332
uint8_t localMemory[128];

CoreFoundation/URL.subproj/CFURLComponents.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,8 @@ static CFStringRef __CFURLComponentsCopyDescription(CFTypeRef cf) {
6666
return CFSTR("A really nice CFURLComponents object");
6767
}
6868

69-
static void __CFURLComponentsDeallocate(CFTypeRef cf) {
70-
CFURLComponentsRef instance = (CFURLComponentsRef)cf;
71-
__CFGenericValidateType(cf, _CFURLComponentsGetTypeID());
69+
CF_SWIFT_EXPORT void __CFURLComponentsDeallocate(CFURLComponentsRef instance) {
70+
__CFGenericValidateType(instance, _CFURLComponentsGetTypeID());
7271

7372
if (instance->_urlString) CFRelease(instance->_urlString);
7473
if (instance->_schemeComponent) CFRelease(instance->_schemeComponent);
@@ -78,6 +77,7 @@ static void __CFURLComponentsDeallocate(CFTypeRef cf) {
7877
if (instance->_pathComponent) CFRelease(instance->_pathComponent);
7978
if (instance->_queryComponent) CFRelease(instance->_queryComponent);
8079
if (instance->_fragmentComponent) CFRelease(instance->_fragmentComponent);
80+
if (instance) CFAllocatorDeallocate(kCFAllocatorSystemDefault, instance);
8181
}
8282

8383
static const CFRuntimeClass __CFURLComponentsClass = {

CoreFoundation/URL.subproj/CFURLComponents.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,20 @@ CF_IMPLICIT_BRIDGING_ENABLED
2626
CF_EXTERN_C_BEGIN
2727
CF_ASSUME_NONNULL_BEGIN
2828

29+
#ifndef CF_SWIFT_EXPORT
30+
#if DEPLOYMENT_RUNTIME_SWIFT
31+
#define CF_SWIFT_EXPORT extern
32+
#else
33+
#define CF_SWIFT_EXPORT static __attribute__((used))
34+
#endif
35+
#endif
36+
2937
typedef struct __CFURLComponents *CFURLComponentsRef;
3038

3139
CF_EXPORT CFTypeID _CFURLComponentsGetTypeID(void);
3240

41+
CF_SWIFT_EXPORT void __CFURLComponentsDeallocate(CFURLComponentsRef);
42+
3343
// URLComponents are always mutable.
3444
CF_EXPORT _Nullable CFURLComponentsRef _CFURLComponentsCreate(CFAllocatorRef alloc);
3545

Docs/Status.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ There is no _Complete_ status for test coverage because there are always additio
5757
| `NSMutableURLRequest` | Mostly Complete | Incomplete | |
5858
| `URLResponse` | Mostly Complete | Incomplete | |
5959
| `NSHTTPURLResponse` | Mostly Complete | Substantial | |
60-
| `NSURL` | Mostly Complete | Substantial | `checkResourceIsReachable()`, and resource values remain unimplemented |
60+
| `NSURL` | Mostly Complete | Substantial | Resource values remain unimplemented |
6161
| `NSURLQueryItem` | Mostly Complete | N/A | |
6262
| `URLResourceKey` | Complete | N/A | |
6363
| `URLFileResourceType` | Complete | N/A | |
@@ -100,7 +100,7 @@ There is no _Complete_ status for test coverage because there are always additio
100100
| `MassFormatter` | Unimplemented | None | |
101101
| `NumberFormatter` | Mostly Complete | Substantial | `objectValue(_:range:)` remains unimplemented |
102102
| `PersonNameComponentsFormatter` | Unimplemented | None | |
103-
| `ByteCountFormatter` | Unimplemented | Incomplete | |
103+
| `ByteCountFormatter` | Mostly Complete | Substantial | `init?(coder:)` remains unimplemented |
104104
| `DateFormatter` | Mostly Complete | Incomplete | `objectValue(_:range:)` remain unimplemented |
105105
| `Formatter` | Complete | N/A | |
106106
| `MeasurementFormatter` | Unimplemented | None | |
@@ -168,7 +168,7 @@ There is no _Complete_ status for test coverage because there are always additio
168168
| `NSMutableSet` | Mostly Complete | Incomplete | `init?(coder:)` remains unimplemented |
169169
| `NSCountedSet` | Mostly Complete | Incomplete | `init?(coder:)` remains unimplemented |
170170
| `NSCFSet` | N/A | N/A | For internal use only |
171-
| `NSCache` | Complete | None | |
171+
| `NSCache` | Complete | Incomplete | |
172172
| `NSSortDescriptor` | Unimplemented | None | |
173173

174174
* **RunLoop**: Timers, streams and run loops.

Foundation.xcodeproj/project.pbxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
5B40F9F01C125011000E72E3 /* CFXMLInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 5B40F9EC1C124F45000E72E3 /* CFXMLInterface.h */; settings = {ATTRIBUTES = (Private, ); }; };
9393
5B40F9F41C12524C000E72E3 /* libxml2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5B40F9F31C12524C000E72E3 /* libxml2.dylib */; };
9494
5B424C761D0B6E5B007B39C8 /* IndexPath.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B424C751D0B6E5B007B39C8 /* IndexPath.swift */; };
95+
5B5BFEAC1E6CC0C200AC8D9E /* NSCFBoolean.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B5BFEAB1E6CC0C200AC8D9E /* NSCFBoolean.swift */; };
9596
5B5C5EF01CE61FA4001346BD /* Date.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B5C5EEF1CE61FA4001346BD /* Date.swift */; };
9697
5B5D89761BBDADD300234F36 /* libicucore.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5B5D89751BBDADD300234F36 /* libicucore.dylib */; };
9798
5B5D89781BBDADDB00234F36 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5B5D89771BBDADDB00234F36 /* libz.dylib */; };
@@ -310,6 +311,7 @@
310311
6EB768281D18C12C00D4B719 /* UUID.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EB768271D18C12C00D4B719 /* UUID.swift */; };
311312
7900433B1CACD33E00ECCBF1 /* TestNSCompoundPredicate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 790043391CACD33E00ECCBF1 /* TestNSCompoundPredicate.swift */; };
312313
7900433C1CACD33E00ECCBF1 /* TestNSPredicate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7900433A1CACD33E00ECCBF1 /* TestNSPredicate.swift */; };
314+
90E645DF1E4C89A400D0D47C /* TestNSCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90E645DE1E4C89A400D0D47C /* TestNSCache.swift */; };
313315
AE35A1861CBAC85E0042DB84 /* SwiftFoundation.h in Headers */ = {isa = PBXBuildFile; fileRef = AE35A1851CBAC85E0042DB84 /* SwiftFoundation.h */; settings = {ATTRIBUTES = (Public, ); }; };
314316
BD8042161E09857800487EB8 /* TestNSLengthFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD8042151E09857800487EB8 /* TestNSLengthFormatter.swift */; };
315317
BDBB65901E256BFA001A7286 /* TestNSEnergyFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDBB658F1E256BFA001A7286 /* TestNSEnergyFormatter.swift */; };
@@ -506,6 +508,7 @@
506508
5B40F9F11C125187000E72E3 /* TestNSXMLParser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestNSXMLParser.swift; sourceTree = "<group>"; };
507509
5B40F9F31C12524C000E72E3 /* libxml2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libxml2.dylib; path = usr/lib/libxml2.dylib; sourceTree = SDKROOT; };
508510
5B424C751D0B6E5B007B39C8 /* IndexPath.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IndexPath.swift; sourceTree = "<group>"; };
511+
5B5BFEAB1E6CC0C200AC8D9E /* NSCFBoolean.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSCFBoolean.swift; sourceTree = "<group>"; };
509512
5B5C5EEF1CE61FA4001346BD /* Date.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Date.swift; sourceTree = "<group>"; };
510513
5B5D885D1BBC938800234F36 /* SwiftFoundation.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftFoundation.framework; sourceTree = BUILT_PRODUCTS_DIR; };
511514
5B5D886A1BBC948300234F36 /* CFApplicationPreferences.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CFApplicationPreferences.c; sourceTree = "<group>"; };
@@ -753,6 +756,7 @@
753756
848A30571C137B3500C83206 /* TestNSHTTPCookie.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = TestNSHTTPCookie.swift; path = TestFoundation/TestNSHTTPCookie.swift; sourceTree = SOURCE_ROOT; };
754757
84BA558D1C16F90900F48C54 /* TestNSTimeZone.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestNSTimeZone.swift; sourceTree = "<group>"; };
755758
88D28DE61C13AE9000494606 /* TestNSGeometry.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestNSGeometry.swift; sourceTree = "<group>"; };
759+
90E645DE1E4C89A400D0D47C /* TestNSCache.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestNSCache.swift; sourceTree = "<group>"; };
756760
A5A34B551C18C85D00FD972B /* TestNSByteCountFormatter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestNSByteCountFormatter.swift; sourceTree = "<group>"; };
757761
AE35A1851CBAC85E0042DB84 /* SwiftFoundation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SwiftFoundation.h; sourceTree = "<group>"; };
758762
BD8042151E09857800487EB8 /* TestNSLengthFormatter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestNSLengthFormatter.swift; sourceTree = "<group>"; };
@@ -1401,6 +1405,7 @@
14011405
BF8E65301DC3B3CB005AB5C3 /* TestNotification.swift */,
14021406
BDFDF0A61DFF5B3E00C04CC5 /* TestNSPersonNameComponents.swift */,
14031407
CD1C7F7C1E303B47008E331C /* TestNSError.swift */,
1408+
90E645DE1E4C89A400D0D47C /* TestNSCache.swift */,
14041409
);
14051410
name = Tests;
14061411
sourceTree = "<group>";
@@ -1630,6 +1635,7 @@
16301635
5B7818591D6CB5CD004A01F2 /* CGFloat.swift */,
16311636
EADE0B4D1BD09E0800C49C64 /* NSAffineTransform.swift */,
16321637
5BDC3F3D1BCC5DCB00ED97BB /* NSNumber.swift */,
1638+
5B5BFEAB1E6CC0C200AC8D9E /* NSCFBoolean.swift */,
16331639
D31302001C30CEA900295652 /* NSConcreteValue.swift */,
16341640
D3E8D6D01C367AB600295652 /* NSSpecialValue.swift */,
16351641
5BDC3F4C1BCC5DCB00ED97BB /* NSValue.swift */,
@@ -2074,6 +2080,7 @@
20742080
5B1FD9D61D6D16580080E83C /* HTTPBodySource.swift in Sources */,
20752081
EADE0BB21BD15E0000C49C64 /* Progress.swift in Sources */,
20762082
EADE0B961BD15DFF00C49C64 /* NSDateIntervalFormatter.swift in Sources */,
2083+
5B5BFEAC1E6CC0C200AC8D9E /* NSCFBoolean.swift in Sources */,
20772084
6EB768281D18C12C00D4B719 /* UUID.swift in Sources */,
20782085
5B1FD9D41D6D16580080E83C /* Configuration.swift in Sources */,
20792086
5BF7AEA51BCD51F9008F214A /* NSCalendar.swift in Sources */,
@@ -2237,6 +2244,7 @@
22372244
CC5249C01D341D23007CB54D /* TestUnitConverter.swift in Sources */,
22382245
5B13B3331C582D4C00651CE2 /* TestNSJSONSerialization.swift in Sources */,
22392246
5B13B33C1C582D4C00651CE2 /* TestNSOrderedSet.swift in Sources */,
2247+
90E645DF1E4C89A400D0D47C /* TestNSCache.swift in Sources */,
22402248
5B13B34A1C582D4C00651CE2 /* TestNSURL.swift in Sources */,
22412249
EA54A6FB1DB16D53009E0809 /* TestObjCRuntime.swift in Sources */,
22422250
5B13B34D1C582D4C00651CE2 /* TestNSUUID.swift in Sources */,

Foundation/Bridging.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
import CoreFoundation
14+
1315
// Support protocols for casting
1416
public protocol _ObjectBridgeable {
1517
func _bridgeToAnyObject() -> AnyObject
@@ -83,7 +85,11 @@ internal final class _SwiftValue : NSObject, NSCopying {
8385
}
8486

8587
static func fetch(nonOptional object: AnyObject) -> Any {
86-
if let container = object as? _SwiftValue {
88+
if object === kCFBooleanTrue {
89+
return true
90+
} else if object === kCFBooleanFalse {
91+
return false
92+
} else if let container = object as? _SwiftValue {
8793
return container.value
8894
} else if let val = object as? _StructBridgeable {
8995
return val._bridgeToAny()

0 commit comments

Comments
 (0)