Skip to content

Commit fdbf76e

Browse files
committed
Update master to build with Xcode 9.3 beta 1
1 parent d13f83d commit fdbf76e

File tree

7 files changed

+153
-9
lines changed

7 files changed

+153
-9
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ supported host development operating systems.
5454

5555
#### macOS
5656

57-
To build for macOS, you need [Xcode 9.2](https://developer.apple.com/xcode/downloads/).
57+
To build for macOS, you need [Xcode 9.3 beta](https://developer.apple.com/xcode/downloads/).
5858
The required version of Xcode changes frequently, and is often a beta release.
5959
Check this document or the host information on <https://ci.swift.org> for the
6060
current required version.

stdlib/public/SDK/ARKit/ARKit.swift

+53-4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ extension ARCamera {
2727

2828
/** Tracking is limited due to a lack of features visible to the camera. */
2929
case insufficientFeatures
30+
31+
/** Tracking is limited due to a relocalization in progress. */
32+
@available(iOS, introduced: 11.3)
33+
case relocalizing
3034
}
3135

3236
/** Tracking is not available. */
@@ -49,10 +53,20 @@ extension ARCamera {
4953
case .limited:
5054
let reason: TrackingState.Reason
5155

52-
switch __trackingStateReason {
53-
case .initializing: reason = .initializing
54-
case .excessiveMotion: reason = .excessiveMotion
55-
default: reason = .insufficientFeatures
56+
if #available(iOS 11.3, *) {
57+
switch __trackingStateReason {
58+
case .initializing: reason = .initializing
59+
case .relocalizing: reason = .relocalizing
60+
case .excessiveMotion: reason = .excessiveMotion
61+
default: reason = .insufficientFeatures
62+
}
63+
}
64+
else {
65+
switch __trackingStateReason {
66+
case .initializing: reason = .initializing
67+
case .excessiveMotion: reason = .excessiveMotion
68+
default: reason = .insufficientFeatures
69+
}
5670
}
5771

5872
return .limited(reason)
@@ -105,3 +119,38 @@ extension ARFaceGeometry {
105119
return Array(buffer)
106120
}
107121
}
122+
123+
@available(iOS, introduced: 11.3)
124+
extension ARPlaneGeometry {
125+
/**
126+
The mesh vertices of the geometry.
127+
*/
128+
@nonobjc public var vertices: [vector_float3] {
129+
let buffer = UnsafeBufferPointer(start: __vertices, count: Int(__vertexCount))
130+
return Array(buffer)
131+
}
132+
133+
/**
134+
The texture coordinates of the geometry.
135+
*/
136+
@nonobjc public var textureCoordinates: [vector_float2] {
137+
let buffer = UnsafeBufferPointer(start: __textureCoordinates, count: Int(__textureCoordinateCount))
138+
return Array(buffer)
139+
}
140+
141+
/**
142+
The triangle indices of the geometry.
143+
*/
144+
@nonobjc public var triangleIndices: [Int16] {
145+
let buffer = UnsafeBufferPointer(start: __triangleIndices, count: Int(triangleCount * 3))
146+
return Array(buffer)
147+
}
148+
149+
/**
150+
The vertices of the geometry's outermost boundary.
151+
*/
152+
@nonobjc public var boundaryVertices: [vector_float3] {
153+
let buffer = UnsafeBufferPointer(start: __boundaryVertices, count: Int(__boundaryVertexCount))
154+
return Array(buffer)
155+
}
156+
}

stdlib/public/SDK/Foundation/NSCoder.swift

+19
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,25 @@ extension NSKeyedUnarchiver {
167167
try resolveError(error)
168168
return result
169169
}
170+
171+
@nonobjc
172+
@available(OSX 10.13, iOS 11.0, watchOS 4.0, tvOS 11.0, *)
173+
public static func unarchivedObject<DecodedObjectType>(ofClass cls: DecodedObjectType.Type, from data: Data) throws -> DecodedObjectType? {
174+
var error: NSError?
175+
let result = __NSKeyedUnarchiverSecureUnarchiveObjectOfClass(cls as! AnyClass, data, &error)
176+
try resolveError(error)
177+
return result as? DecodedObjectType
178+
}
179+
180+
@nonobjc
181+
@available(OSX 10.13, iOS 11.0, watchOS 4.0, tvOS 11.0, *)
182+
public static func unarchivedObject(ofClasses classes: [AnyClass], from data: Data) throws -> Any? {
183+
var error: NSError?
184+
let classesAsNSObjects = NSSet(array: classes.map { $0 as AnyObject })
185+
let result = __NSKeyedUnarchiverSecureUnarchiveObjectOfClasses(classesAsNSObjects, data, &error)
186+
try resolveError(error)
187+
return result
188+
}
170189

171190
@nonobjc
172191
private static let __plistClasses: [AnyClass] = [

stdlib/public/SwiftShims/NSKeyedArchiverShims.h

+14-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
NS_BEGIN_DECLS
1616

17-
1817
NS_INLINE NS_RETURNS_RETAINED _Nullable id __NSKeyedUnarchiverUnarchiveObject(id Self_, NS_NON_BRIDGED(NSData *)data, NSError **_Nullable error) {
1918
if (error) {
2019
return [Self_ unarchiveTopLevelObjectWithData:(NSData *)data error:error];
@@ -23,4 +22,18 @@ NS_INLINE NS_RETURNS_RETAINED _Nullable id __NSKeyedUnarchiverUnarchiveObject(id
2322
}
2423
}
2524

25+
// Re-exposed here until all SDKs contain the relevant methods publicly.
26+
@interface NSKeyedUnarchiver (SecureMethods)
27+
+ (nullable id)unarchivedObjectOfClass:(Class)cls fromData:(NSData *)data error:(NSError **)error API_AVAILABLE(macos(10.13), ios(11.0), watchos(4.0), tvos(11.0));
28+
+ (nullable id)unarchivedObjectOfClasses:(NSSet<Class> *)classes fromData:(NSData *)data error:(NSError **)error API_AVAILABLE(macos(10.13), ios(11.0), watchos(4.0), tvos(11.0));
29+
@end
30+
31+
NS_INLINE NS_RETURNS_RETAINED id _Nullable __NSKeyedUnarchiverSecureUnarchiveObjectOfClass(Class cls, NSData *data, NSError * _Nullable * _Nullable error) {
32+
return [NSKeyedUnarchiver unarchivedObjectOfClass:cls fromData:data error:error];
33+
}
34+
35+
NS_INLINE NS_RETURNS_RETAINED id _Nullable __NSKeyedUnarchiverSecureUnarchiveObjectOfClasses(NS_NON_BRIDGED(NSSet *) classes, NSData *data, NSError * _Nullable * _Nullable error) {
36+
return [NSKeyedUnarchiver unarchivedObjectOfClasses:classes fromData:data error:error];
37+
}
38+
2639
NS_END_DECLS

test/stdlib/DispatchRenames.swift

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,9 @@ _ = dispatch_get_global_queue(0, 0) // expected-error {{'dispatch_get_global_que
1111

1212
_ = dispatch_source_create(OpaquePointer(bitPattern: ~0)!, 0, 0, nil) // expected-error {{'dispatch_source_create' is unavailable: Use DispatchSource class methods}}
1313

14-
_ = dispatch_get_main_queue() // expected-error {{'dispatch_get_main_queue()' has been replaced by property 'DispatchQueue.main'}}
14+
// Next test is disabled pending what to do about libdispatch change to the signature of dispatch_get_main_queue(): rdar://problem/36528231.
15+
// To re-enable, remove the #if/#endif and remove "FIXME-" from 'expected-FIXME-error'
16+
#if false
17+
_ = dispatch_get_main_queue() // expected-FIXME-error {{'dispatch_get_main_queue()' has been replaced by property 'DispatchQueue.main'}}
18+
#endif
1519
_ = DispatchQueue.main

test/stdlib/Foundation_NewGenericAPIs.swift

+12
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,15 @@ func test_NSKeyedUnarchiver_decodeObjectForKey(
6363
expectType(Optional<Any>.self, &r)
6464
}
6565

66+
67+
@available(OSX 10.13, iOS 11.0, watchOS 4.0, tvOS 11.0, *)
68+
func test_NSKeyedUnarchiver_unarchivedObjectOfClass(from data: Data) throws {
69+
var r = try NSKeyedUnarchiver.unarchivedObject(ofClass: NSString.self, from: data)
70+
expectType(NSString?.self, &r)
71+
}
72+
73+
@available(OSX 10.13, iOS 11.0, watchOS 4.0, tvOS 11.0, *)
74+
func test_NSKeyedUnarchiver_unarchivedObjectOfClasses(from data: Data) throws {
75+
var r = try NSKeyedUnarchiver.unarchivedObject(ofClasses: [NSString.self, NSData.self, NSArray.self], from: data)
76+
expectType(Any?.self, &r)
77+
}

test/stdlib/NSKeyedArchival.swift

+49-2
Original file line numberDiff line numberDiff line change
@@ -163,21 +163,68 @@ func test_toplevelAPIVariants() {
163163
}
164164
}
165165

166+
@available(OSX 10.13, iOS 11.0, watchOS 4.0, tvOS 11.0, *)
167+
func test_unarchiveObjectOfClass() {
168+
let topLevel = NSArray()
169+
let data = NSKeyedArchiver.archivedData(withRootObject: topLevel)
170+
171+
// Should be able to decode an NSArray back out.
172+
expectNoError {
173+
guard let result = try NSKeyedUnarchiver.unarchivedObject(ofClass: NSArray.self, from: data) else {
174+
expectUnreachable("Unable to decode top-level array.")
175+
return
176+
}
177+
178+
expectEqual(result, topLevel)
179+
}
180+
181+
// Shouldn't be able to decode an NSString out of an NSArray.
182+
expectError {
183+
let _ = try NSKeyedUnarchiver.unarchivedObject(ofClass: NSString.self, from: data)
184+
}
185+
}
186+
187+
@available(OSX 10.13, iOS 11.0, watchOS 4.0, tvOS 11.0, *)
188+
func test_unarchiveObjectOfClasses() {
189+
let topLevel = NSArray()
190+
let data = NSKeyedArchiver.archivedData(withRootObject: topLevel)
191+
192+
// Should be able to unarchive an array back out.
193+
expectNoError {
194+
guard let result = try NSKeyedUnarchiver.unarchivedObject(ofClasses: [NSArray.self], from: data) as? NSArray else {
195+
expectUnreachable("Unable to decode top-level array.")
196+
return
197+
}
198+
199+
expectEqual(result, topLevel)
200+
}
201+
202+
// Shouldn't be able to decode an NSString out of an NSArray.
203+
expectError {
204+
let _ = try NSKeyedUnarchiver.unarchivedObject(ofClasses: [NSString.self], from: data)
205+
}
206+
}
207+
166208
// MARK: - Run Tests
167209

168210
#if !FOUNDATION_XCTEST
169211
if #available(OSX 10.11, iOS 9.0, *) {
170212
let NSKeyedArchiverTest = TestSuite("TestNSKeyedArchiver")
171-
let tests = [
213+
var tests = [
172214
"NSKeyedArchival.simpleCodableSupportInNSKeyedArchival": test_simpleCodableSupport,
173215
"NSKeyedArchival.encodableErrorHandling": test_encodableErrorHandling,
174216
"NSKeyedArchival.readingNonCodableFromDecodeDecodable": test_readingNonCodableFromDecodeDecodable,
175217
"NSKeyedArchival.toplevelAPIVariants": test_toplevelAPIVariants
176218
]
219+
220+
if #available(OSX 10.13, iOS 11.0, watchOS 4.0, tvOS 11.0, *) {
221+
tests["NSKeyedArchival.unarchiveObjectOfClass"] = test_unarchiveObjectOfClass
222+
tests["NSKeyedArchival.unarchiveObjectOfClasses"] = test_unarchiveObjectOfClasses
223+
}
177224

178225
for (name, test) in tests {
179226
NSKeyedArchiverTest.test(name) { test() }
180227
}
181228
runAllTests()
182229
}
183-
#endif
230+
#endif

0 commit comments

Comments
 (0)