Skip to content

Commit

Permalink
Parity: Port, PortMessage and SocketPort
Browse files Browse the repository at this point in the history
 - Implement Port as a top-level abstract class, like Darwin’s.
 - Implement PortMessage.
 - Implement SocketPort, our only cross-platform port. Note that Distributed Objects is not available in s-c-f, and thus NSConnection-related functionality is not available nor implemented.

A few differences with Darwin:

 - PortCoder is not available. Classes that ‘support coding only through a NSPortCoder’ do not conform to NSCoding in swift-corelibs-foundation.

 - MessagePort is not available in s-c-f. It is noted as a to-avoid API in the documentation and relies on Mach ports, which are not available everywhere. The default implementation of Port’s initializer would return a MessagePort as a factory initializer on Darwin if invoked directly; this is not the case here, and we diagnose that use.

 - Similarly, NSMachPort is also unavailable.

 - SocketPort uses a factory initializer on Darwin to return the same instance for the same remote port signature (uniquing). This is not the case in Swift. The return value of == and .isEqual(_:) will match Darwin’s behavior and return true for uniqued SocketPorts, but certain swift-corelibs-foundation uniqued SocketPorts will be different instances as reported by the === and !== operators.
  • Loading branch information
millenomi committed Aug 13, 2019
1 parent 84d6a68 commit 340f7ea
Show file tree
Hide file tree
Showing 8 changed files with 1,120 additions and 61 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@ if(ENABLE_TESTING)
TestFoundation/TestPropertyListSerialization.swift
TestFoundation/TestRunLoop.swift
TestFoundation/TestScanner.swift
TestFoundation/TestSocketPort.swift
TestFoundation/TestStream.swift
TestFoundation/TestThread.swift
TestFoundation/TestTimer.swift
Expand Down
4 changes: 4 additions & 0 deletions Foundation.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
15B80442228F38E400B30FF6 /* Configuration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B1FD9C81D6D16580080E83C /* Configuration.swift */; };
15B80443228F38E400B30FF6 /* Message.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6105D30E1FEBC5FC0022865A /* Message.swift */; };
15F10CDC218909BF00D88114 /* TestNSCalendar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15F10CDB218909BF00D88114 /* TestNSCalendar.swift */; };
15FCF4E323021C020095E52E /* TestSocketPort.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15FCF4E223021C020095E52E /* TestSocketPort.swift */; };
15FF004B229348F2004AD205 /* CFURLSessionInterface.c in Sources */ = {isa = PBXBuildFile; fileRef = 5B1FD9C11D6D160F0080E83C /* CFURLSessionInterface.c */; };
15FF00CB22934A3C004AD205 /* CFURLSessionInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 5B1FD9C21D6D160F0080E83C /* CFURLSessionInterface.h */; settings = {ATTRIBUTES = (Private, ); }; };
15FF00CC22934AD7004AD205 /* libCFURLSessionInterface.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 15FF00CA229348F2004AD205 /* libCFURLSessionInterface.a */; };
Expand Down Expand Up @@ -728,6 +729,7 @@
159884911DCC877700E3314C /* TestHTTPCookieStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestHTTPCookieStorage.swift; sourceTree = "<group>"; };
15B8043A228F376000B30FF6 /* SwiftFoundationNetworking.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftFoundationNetworking.framework; sourceTree = BUILT_PRODUCTS_DIR; };
15F10CDB218909BF00D88114 /* TestNSCalendar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestNSCalendar.swift; sourceTree = "<group>"; };
15FCF4E223021C020095E52E /* TestSocketPort.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestSocketPort.swift; sourceTree = "<group>"; };
15FF00CA229348F2004AD205 /* libCFURLSessionInterface.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libCFURLSessionInterface.a; sourceTree = BUILT_PRODUCTS_DIR; };
15FF00CD22934B49004AD205 /* module.map */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.module-map"; name = module.map; path = CoreFoundation/URL.subproj/module.map; sourceTree = SOURCE_ROOT; };
22B9C1E01C165D7A00DECFF9 /* TestDate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestDate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1858,6 +1860,7 @@
61E0117B1C1B554D000037DD /* TestRunLoop.swift */,
844DC3321C17584F005611F9 /* TestScanner.swift */,
EA66F6411BF1619600136161 /* TestNSSet.swift */,
15FCF4E223021C020095E52E /* TestSocketPort.swift */,
0383A1741D2E558A0052E5D1 /* TestStream.swift */,
EA66F6421BF1619600136161 /* TestNSString.swift */,
5FE52C941D147D1C00F7D270 /* TestNSTextCheckingResult.swift */,
Expand Down Expand Up @@ -3008,6 +3011,7 @@
B90C57BC1EEEEA5A005208AE /* TestThread.swift in Sources */,
B90C57BB1EEEEA5A005208AE /* TestFileManager.swift in Sources */,
A058C2021E529CF100B07AA1 /* TestMassFormatter.swift in Sources */,
15FCF4E323021C020095E52E /* TestSocketPort.swift in Sources */,
5B13B3381C582D4C00651CE2 /* TestNotificationQueue.swift in Sources */,
CC5249C01D341D23007CB54D /* TestUnitConverter.swift in Sources */,
5B13B3331C582D4C00651CE2 /* TestJSONSerialization.swift in Sources */,
Expand Down
1 change: 0 additions & 1 deletion Foundation/NSObjCRuntime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ internal let _NSClassesRenamedByObjCAPINotesInNetworkingOrXML: [(swiftName: Stri
internal let _NSClassesRenamedByObjCAPINotes: [(class: AnyClass, objCName: String)] = {
var map: [(AnyClass, String)] = [
(ProcessInfo.self, "NSProcessInfo"),
(MessagePort.self, "NSMessagePort"),
(Port.self, "NSPort"),
(PortMessage.self, "NSPortMessage"),
(SocketPort.self, "NSSocketPort"),
Expand Down
Loading

0 comments on commit 340f7ea

Please sign in to comment.