Skip to content

Commit 8b9f19d

Browse files
authored
Merge pull request #17773 from apple/update-4.2-xcode-10-beta-3
Update swift 4.2 to build with Xcode 10 beta 3, macOS 10.14, iOS 12, tvOS 12, and watchOS 5 SDKs
2 parents 7699170 + 4763a30 commit 8b9f19d

26 files changed

+1065
-423
lines changed

stdlib/public/SDK/AVFoundation/AVError.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ extension AVError {
5858
}
5959

6060
/// The media type.
61+
@available(swift, obsoleted: 4.2)
62+
public var mediaType: String? {
63+
return userInfo[AVErrorMediaTypeKey] as? String
64+
}
65+
66+
/// The media type.
67+
@available(swift, introduced: 4.2)
6168
public var mediaType: AVMediaType? {
6269
return userInfo[AVErrorMediaTypeKey] as? AVMediaType
6370
}

stdlib/public/SDK/AppKit/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ add_swift_library(swiftAppKit ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES} IS_SDK_OV
55
AppKit.swift
66
AppKit_FoundationExtensions.swift
77
NSError.swift
8+
NSEvent.swift
89
NSGraphics.swift
910
NSOpenGL.swift
1011

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
@_exported import AppKit
14+
15+
extension NSEvent {
16+
public struct SpecialKey : RawRepresentable, Equatable, Hashable {
17+
public init(rawValue: Int) {
18+
self.rawValue = rawValue
19+
}
20+
public let rawValue: Int
21+
public var unicodeScalar: Unicode.Scalar {
22+
return Unicode.Scalar(rawValue)!
23+
}
24+
}
25+
26+
/// Returns nil if the receiver is not a "special" key event.
27+
open var specialKey: SpecialKey? {
28+
guard let unicodeScalars = charactersIgnoringModifiers?.unicodeScalars else {
29+
return nil
30+
}
31+
guard unicodeScalars.count == 1 else {
32+
return nil
33+
}
34+
guard let codePoint = unicodeScalars.first?.value else {
35+
return nil
36+
}
37+
switch codePoint {
38+
case 0x0003:
39+
return .enter
40+
41+
case 0x0008:
42+
return .backspace
43+
44+
case 0x0009:
45+
return .tab
46+
47+
case 0x000a:
48+
return .newline
49+
50+
case 0x000c:
51+
return .formFeed
52+
53+
case 0x000d:
54+
return .carriageReturn
55+
56+
case 0x0019:
57+
return .backTab
58+
59+
case 0x007f:
60+
return .delete
61+
62+
case 0x2028:
63+
return .lineSeparator
64+
65+
case 0x2029:
66+
return .paragraphSeparator
67+
68+
case 0xF700..<0xF900:
69+
return SpecialKey(rawValue: Int(codePoint))
70+
71+
default:
72+
return nil
73+
}
74+
}
75+
}
76+
77+
extension NSEvent.SpecialKey {
78+
79+
static public let upArrow = NSEvent.SpecialKey(rawValue: 0xF700)
80+
static public let downArrow = NSEvent.SpecialKey(rawValue: 0xF701)
81+
static public let leftArrow = NSEvent.SpecialKey(rawValue: 0xF702)
82+
static public let rightArrow = NSEvent.SpecialKey(rawValue: 0xF703)
83+
static public let f1 = NSEvent.SpecialKey(rawValue: 0xF704)
84+
static public let f2 = NSEvent.SpecialKey(rawValue: 0xF705)
85+
static public let f3 = NSEvent.SpecialKey(rawValue: 0xF706)
86+
static public let f4 = NSEvent.SpecialKey(rawValue: 0xF707)
87+
static public let f5 = NSEvent.SpecialKey(rawValue: 0xF708)
88+
static public let f6 = NSEvent.SpecialKey(rawValue: 0xF709)
89+
static public let f7 = NSEvent.SpecialKey(rawValue: 0xF70A)
90+
static public let f8 = NSEvent.SpecialKey(rawValue: 0xF70B)
91+
static public let f9 = NSEvent.SpecialKey(rawValue: 0xF70C)
92+
static public let f10 = NSEvent.SpecialKey(rawValue: 0xF70D)
93+
static public let f11 = NSEvent.SpecialKey(rawValue: 0xF70E)
94+
static public let f12 = NSEvent.SpecialKey(rawValue: 0xF70F)
95+
static public let f13 = NSEvent.SpecialKey(rawValue: 0xF710)
96+
static public let f14 = NSEvent.SpecialKey(rawValue: 0xF711)
97+
static public let f15 = NSEvent.SpecialKey(rawValue: 0xF712)
98+
static public let f16 = NSEvent.SpecialKey(rawValue: 0xF713)
99+
static public let f17 = NSEvent.SpecialKey(rawValue: 0xF714)
100+
static public let f18 = NSEvent.SpecialKey(rawValue: 0xF715)
101+
static public let f19 = NSEvent.SpecialKey(rawValue: 0xF716)
102+
static public let f20 = NSEvent.SpecialKey(rawValue: 0xF717)
103+
static public let f21 = NSEvent.SpecialKey(rawValue: 0xF718)
104+
static public let f22 = NSEvent.SpecialKey(rawValue: 0xF719)
105+
static public let f23 = NSEvent.SpecialKey(rawValue: 0xF71A)
106+
static public let f24 = NSEvent.SpecialKey(rawValue: 0xF71B)
107+
static public let f25 = NSEvent.SpecialKey(rawValue: 0xF71C)
108+
static public let f26 = NSEvent.SpecialKey(rawValue: 0xF71D)
109+
static public let f27 = NSEvent.SpecialKey(rawValue: 0xF71E)
110+
static public let f28 = NSEvent.SpecialKey(rawValue: 0xF71F)
111+
static public let f29 = NSEvent.SpecialKey(rawValue: 0xF720)
112+
static public let f30 = NSEvent.SpecialKey(rawValue: 0xF721)
113+
static public let f31 = NSEvent.SpecialKey(rawValue: 0xF722)
114+
static public let f32 = NSEvent.SpecialKey(rawValue: 0xF723)
115+
static public let f33 = NSEvent.SpecialKey(rawValue: 0xF724)
116+
static public let f34 = NSEvent.SpecialKey(rawValue: 0xF725)
117+
static public let f35 = NSEvent.SpecialKey(rawValue: 0xF726)
118+
static public let insert = NSEvent.SpecialKey(rawValue: 0xF727)
119+
static public let deleteForward = NSEvent.SpecialKey(rawValue: 0xF7028)
120+
static public let home = NSEvent.SpecialKey(rawValue: 0xF729)
121+
static public let begin = NSEvent.SpecialKey(rawValue: 0xF72A)
122+
static public let end = NSEvent.SpecialKey(rawValue: 0xF72B)
123+
static public let pageUp = NSEvent.SpecialKey(rawValue: 0xF72C)
124+
static public let pageDown = NSEvent.SpecialKey(rawValue: 0xF72D)
125+
static public let printScreen = NSEvent.SpecialKey(rawValue: 0xF72E)
126+
static public let scrollLock = NSEvent.SpecialKey(rawValue: 0xF72F)
127+
static public let pause = NSEvent.SpecialKey(rawValue: 0xF730)
128+
static public let sysReq = NSEvent.SpecialKey(rawValue: 0xF731)
129+
static public let `break` = NSEvent.SpecialKey(rawValue: 0xF732)
130+
static public let reset = NSEvent.SpecialKey(rawValue: 0xF733)
131+
static public let stop = NSEvent.SpecialKey(rawValue: 0xF734)
132+
static public let menu = NSEvent.SpecialKey(rawValue: 0xF735)
133+
static public let user = NSEvent.SpecialKey(rawValue: 0xF736)
134+
static public let system = NSEvent.SpecialKey(rawValue: 0xF737)
135+
static public let print = NSEvent.SpecialKey(rawValue: 0xF738)
136+
static public let clearLine = NSEvent.SpecialKey(rawValue: 0xF739)
137+
static public let clearDisplay = NSEvent.SpecialKey(rawValue: 0xF73A)
138+
static public let insertLine = NSEvent.SpecialKey(rawValue: 0xF73B)
139+
static public let deleteLine = NSEvent.SpecialKey(rawValue: 0xF73C)
140+
static public let insertCharacter = NSEvent.SpecialKey(rawValue: 0xF73D)
141+
static public let deleteCharacter = NSEvent.SpecialKey(rawValue: 0xF73E)
142+
static public let prev = NSEvent.SpecialKey(rawValue: 0xF73F)
143+
static public let next = NSEvent.SpecialKey(rawValue: 0xF740)
144+
static public let select = NSEvent.SpecialKey(rawValue: 0xF741)
145+
static public let execute = NSEvent.SpecialKey(rawValue: 0xF742)
146+
static public let undo = NSEvent.SpecialKey(rawValue: 0xF743)
147+
static public let redo = NSEvent.SpecialKey(rawValue: 0xF744)
148+
static public let find = NSEvent.SpecialKey(rawValue: 0xF745)
149+
static public let help = NSEvent.SpecialKey(rawValue: 0xF746)
150+
static public let modeSwitch = NSEvent.SpecialKey(rawValue: 0xF747)
151+
152+
static public let enter = NSEvent.SpecialKey(rawValue: 0x0003)
153+
static public let backspace = NSEvent.SpecialKey(rawValue: 0x0008)
154+
static public let tab = NSEvent.SpecialKey(rawValue: 0x0009)
155+
static public let newline = NSEvent.SpecialKey(rawValue: 0x000a)
156+
static public let formFeed = NSEvent.SpecialKey(rawValue: 0x000c)
157+
static public let carriageReturn = NSEvent.SpecialKey(rawValue: 0x000d)
158+
static public let backTab = NSEvent.SpecialKey(rawValue: 0x0019)
159+
static public let delete = NSEvent.SpecialKey(rawValue: 0x007f)
160+
static public let lineSeparator = NSEvent.SpecialKey(rawValue: 0x2028)
161+
static public let paragraphSeparator = NSEvent.SpecialKey(rawValue: 0x2029)
162+
}

stdlib/public/SDK/CoreMedia/CMTimeRange.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ extension CMTimeRange {
4343
return self.isValid && (self.duration == kCMTimeZero)
4444
}
4545

46+
public var end: CMTime {
47+
return CMTimeRangeGetEnd(self)
48+
}
49+
4650
public func union(_ otherRange: CMTimeRange) -> CMTimeRange {
4751
return CMTimeRangeGetUnion(self, otherRange)
4852
}

stdlib/public/SDK/Foundation/NSCoder.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ extension NSKeyedUnarchiver {
172172
@available(macOS 10.13, iOS 11.0, watchOS 4.0, tvOS 11.0, *)
173173
public static func unarchivedObject<DecodedObjectType>(ofClass cls: DecodedObjectType.Type, from data: Data) throws -> DecodedObjectType? where DecodedObjectType : NSCoding, DecodedObjectType : NSObject {
174174
var error: NSError?
175-
let result = __NSKeyedUnarchiverSecureUnarchiveObjectOfClass(cls as! AnyClass, data, &error)
176-
try resolveError(error)
175+
let result = __NSKeyedUnarchiverSecureUnarchiveObjectOfClass(cls as AnyClass, data, &error)
176+
if let error = error { throw error }
177177
return result as? DecodedObjectType
178178
}
179179

@@ -183,7 +183,7 @@ extension NSKeyedUnarchiver {
183183
var error: NSError?
184184
let classesAsNSObjects = NSSet(array: classes.map { $0 as AnyObject })
185185
let result = __NSKeyedUnarchiverSecureUnarchiveObjectOfClasses(classesAsNSObjects, data, &error)
186-
try resolveError(error)
186+
if let error = error { throw error }
187187
return result
188188
}
189189

stdlib/public/SDK/Metal/Metal.swift

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,20 @@ extension MTLBlitCommandEncoder {
1818
public func fill(buffer: MTLBuffer, range: Range<Int>, value: UInt8) {
1919
__fill(buffer, range: NSRange(location: range.lowerBound, length: range.count), value: value)
2020
}
21+
22+
@available(macOS 10.14, iOS 12.0, tvOS 12.0, *)
23+
public func resetCommandsInBuffer(_ buffer: MTLIndirectCommandBuffer, range: Range<Int>) {
24+
__resetCommands(in: buffer, with: NSRange(location: range.lowerBound, length: range.count))
25+
}
26+
27+
@available(macOS 10.14, iOS 12.0, tvOS 12.0, *)
28+
public func copyIndirectCommandBuffer (_ buffer: MTLIndirectCommandBuffer, sourceRange: Range<Int>, destination: MTLIndirectCommandBuffer, destinationIndex: Int) {
29+
__copy (buffer, sourceRange: NSRange(location: sourceRange.lowerBound, length: sourceRange.count),destination: destination, destinationIndex: destinationIndex)
30+
}
31+
@available(macOS 10.14, iOS 12.0, tvOS 12.0, *)
32+
public func optimizeIndirectCommandBuffer (_ buffer: MTLIndirectCommandBuffer, range: Range<Int>) {
33+
__optimizeIndirectCommandBuffer(buffer, with: NSRange(location: range.lowerBound, length: range.count))
34+
}
2135
}
2236

2337
@available(macOS 10.11, iOS 8.0, tvOS 8.0, *)
@@ -66,7 +80,7 @@ extension MTLComputeCommandEncoder {
6680
}
6781

6882
@available(macOS 10.14, iOS 12.0, tvOS 12.0, *)
69-
public func memoryBarrier(_ resources:[MTLResource]) {
83+
public func memoryBarrier(resources:[MTLResource]) {
7084
__memoryBarrier(resources: resources, count: resources.count)
7185
}
7286
}
@@ -116,6 +130,18 @@ extension MTLArgumentEncoder {
116130
public func setSamplerStates(_ samplers: [MTLSamplerState?], range: Range<Int>) {
117131
__setSamplerStates(samplers, with: NSRange(location: range.lowerBound, length: range.count))
118132
}
133+
134+
#if os(macOS)
135+
@available(macOS 10.14, *)
136+
public func setRenderPipelineStates(_ pipelines: [MTLRenderPipelineState?], range: Range<Int>) {
137+
__setRenderPipelineStates(pipelines, with: NSRange(location: range.lowerBound, length: range.count))
138+
}
139+
#endif
140+
141+
@available(macOS 10.14, iOS 12.0, tvOS 12.0, *)
142+
public func setIndirectCommandBuffers(_ buffers: [MTLIndirectCommandBuffer?], range: Range<Int>) {
143+
__setIndirectCommandBuffers(buffers, with: NSRange(location: range.lowerBound, length: range.count))
144+
}
119145
}
120146

121147
@available(macOS 10.11, iOS 8.0, tvOS 8.0, *)
@@ -200,10 +226,29 @@ extension MTLRenderCommandEncoder {
200226

201227
#if os(macOS)
202228
@available(macOS 10.14, *)
203-
public func memoryBarrier(_ resources: [MTLResource], after: MTLRenderStages, before: MTLRenderStages) {
229+
public func memoryBarrier(resources: [MTLResource], after: MTLRenderStages, before: MTLRenderStages) {
204230
__memoryBarrier(resources: resources, count: resources.count, after: after, before: before)
205231
}
206232
#endif
233+
234+
@available(macOS 10.14, iOS 12.0, tvOS 12.0, *)
235+
public func executeCommandsInBuffer(_ buffer: MTLIndirectCommandBuffer, range: Range<Int>) {
236+
__executeCommands(in: buffer, with: NSRange(location: range.lowerBound, length: range.count))
237+
}
238+
239+
#if os(macOS)
240+
@available(macOS 10.14, *)
241+
public func executeCommandsInBuffer(_ buffer: MTLIndirectCommandBuffer, indirectBuffer indirectRangeBuffer: MTLBuffer, offset: Int) {
242+
__executeCommands(in: buffer, indirectBuffer: indirectRangeBuffer, indirectBufferOffset: offset)
243+
}
244+
#endif
245+
}
246+
247+
@available(macOS 10.14, iOS 12.0, tvOS 12.0, *)
248+
extension MTLIndirectCommandBuffer {
249+
public func reset(_ range: Range<Int>) {
250+
__reset(with: NSRange(location: range.lowerBound, length: range.count))
251+
}
207252
}
208253

209254
@available(macOS 10.11, iOS 8.0, tvOS 8.0, *)

stdlib/public/SDK/NaturalLanguage/CMakeLists.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ add_swift_library(swiftNaturalLanguage ${SWIFT_SDK_OVERLAY_LIBRARY_BUILD_TYPES}
88

99
SWIFT_COMPILE_FLAGS "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}"
1010
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
11-
TARGET_SDKS OSX IOS IOS_SIMULATOR TVOS TVOS_SIMULATOR # WATCHOS WATCHOS_SIMULATOR
12-
SWIFT_MODULE_DEPENDS_OSX Darwin Dispatch Foundation ObjectiveC # auto-updated
13-
SWIFT_MODULE_DEPENDS_IOS Darwin Dispatch Foundation ObjectiveC # auto-updated
14-
SWIFT_MODULE_DEPENDS_TVOS Darwin Dispatch Foundation ObjectiveC # auto-updated
15-
# SWIFT_MODULE_DEPENDS_WATCHOS Darwin Dispatch Foundation ObjectiveC # auto-updated
11+
TARGET_SDKS OSX IOS IOS_SIMULATOR TVOS TVOS_SIMULATOR WATCHOS WATCHOS_SIMULATOR
12+
SWIFT_MODULE_DEPENDS_OSX Darwin Dispatch Foundation ObjectiveC Metal # auto-updated
13+
SWIFT_MODULE_DEPENDS_IOS Darwin Dispatch Foundation ObjectiveC Metal # auto-updated
14+
SWIFT_MODULE_DEPENDS_TVOS Darwin Dispatch Foundation ObjectiveC Metal # auto-updated
15+
SWIFT_MODULE_DEPENDS_WATCHOS Darwin Dispatch Foundation ObjectiveC # auto-updated
1616

1717
FRAMEWORK_DEPENDS_WEAK NaturalLanguage
1818

1919
DEPLOYMENT_VERSION_OSX ${SWIFTLIB_DEPLOYMENT_VERSION_NATURALLANGUAGE_OSX}
2020
DEPLOYMENT_VERSION_IOS ${SWIFTLIB_DEPLOYMENT_VERSION_NATURALLANGUAGE_IOS}
2121
DEPLOYMENT_VERSION_TVOS ${SWIFTLIB_DEPLOYMENT_VERSION_NATURALLANGUAGE_TVOS}
22-
# DEPLOYMENT_VERSION_WATCHOS ${SWIFTLIB_DEPLOYMENT_VERSION_NATURALLANGUAGE_WATCHOS}
22+
DEPLOYMENT_VERSION_WATCHOS ${SWIFTLIB_DEPLOYMENT_VERSION_NATURALLANGUAGE_WATCHOS}
2323
)

stdlib/public/SDK/Network/NWConnection.swift

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ public final class NWConnection : CustomDebugStringConvertible {
287287
}
288288

289289
/// Content Context controls options for how data is sent, and access for metadata to send or receive.
290-
/// All properties of Content Context are valid for sending. For received Content Context, only the protocolMetdata
290+
/// All properties of Content Context are valid for sending. For received Content Context, only the protocolMetadata
291291
/// values will be set.
292292
public class ContentContext {
293293
internal let nw: nw_content_context_t
@@ -458,13 +458,13 @@ public final class NWConnection : CustomDebugStringConvertible {
458458
}
459459
}
460460

461-
/// Receive a complete content from the connection, waiting for the content to be marked complete
461+
/// Receive complete message content from the connection, waiting for the content to be marked complete
462462
/// (or encounter an error) before delivering the callback. This is useful for datagram or message-based
463463
/// protocols like UDP. See receive(minimumIncompleteLength:, maximumLength:, completion:) for a description
464464
/// of the completion handler.
465-
public func receive(completion: @escaping (_ completeContent: Data?,
466-
_ contentContext: NWConnection.ContentContext?,
467-
_ isComplete: Bool, _ error: NWError?) -> Void) {
465+
public func receiveMessage(completion: @escaping (_ completeContent: Data?,
466+
_ contentContext: NWConnection.ContentContext?,
467+
_ isComplete: Bool, _ error: NWError?) -> Void) {
468468
nw_connection_receive_message(self.nw) { (content, context, complete, nwError) in
469469
completion(NWCreateNSDataFromDispatchData(content) as Data?, ContentContext(context), complete, NWError(nwError))
470470
}
@@ -501,7 +501,8 @@ public final class NWConnection : CustomDebugStringConvertible {
501501
/// be sent immediately (if the protocol requires sending bytes serially, like TCP).
502502
/// For datagram protocols, like UDP, isComplete indicates that the content represents
503503
/// a complete datagram.
504-
/// When sending directly on streaming protocols like TCP, isComplete can be used to
504+
/// When sending using streaming protocols like TCP, isComplete can be used to mark the end
505+
/// of a single message on the stream, of which there may be many. However, it can also
505506
/// indicate that the connection should send a "write close" (a TCP FIN) if the sending
506507
/// context is the final context on the connection. Specifically, to send a "write close",
507508
/// pass .finalMessage or .defaultStream for the context (or create a custom context and

stdlib/public/SDK/Network/NWParameters.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,20 @@ public final class NWParameters : CustomDebugStringConvertible {
227227
}
228228
}
229229

230+
/// Allow the inclusion of peer-to-peer interfaces when
231+
/// listening or establishing outbound connections. This parameter
232+
/// will not take effect if a specific interface is required.
233+
/// This parameter is applicable when advertising a Bonjour service
234+
/// on a listener, or connecting to a Bonjour service.
235+
public var includePeerToPeer: Bool {
236+
set {
237+
nw_parameters_set_include_peer_to_peer(self.nw, newValue)
238+
}
239+
get {
240+
return nw_parameters_get_include_peer_to_peer(self.nw)
241+
}
242+
}
243+
230244
/// The ServiceClass represents the network queuing priority to use
231245
/// for traffic generated by a NWConnection.
232246
public enum ServiceClass {

0 commit comments

Comments
 (0)