Update master to build with Xcode 9.3 beta 1

This commit is contained in:
Mishal Shah
2018-01-25 16:03:11 -08:00
parent d13f83df14
commit fdbf76e9f5
7 changed files with 153 additions and 9 deletions

View File

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

View File

@@ -27,6 +27,10 @@ extension ARCamera {
/** Tracking is limited due to a lack of features visible to the camera. */
case insufficientFeatures
/** Tracking is limited due to a relocalization in progress. */
@available(iOS, introduced: 11.3)
case relocalizing
}
/** Tracking is not available. */
@@ -49,10 +53,20 @@ extension ARCamera {
case .limited:
let reason: TrackingState.Reason
switch __trackingStateReason {
case .initializing: reason = .initializing
case .excessiveMotion: reason = .excessiveMotion
default: reason = .insufficientFeatures
if #available(iOS 11.3, *) {
switch __trackingStateReason {
case .initializing: reason = .initializing
case .relocalizing: reason = .relocalizing
case .excessiveMotion: reason = .excessiveMotion
default: reason = .insufficientFeatures
}
}
else {
switch __trackingStateReason {
case .initializing: reason = .initializing
case .excessiveMotion: reason = .excessiveMotion
default: reason = .insufficientFeatures
}
}
return .limited(reason)
@@ -105,3 +119,38 @@ extension ARFaceGeometry {
return Array(buffer)
}
}
@available(iOS, introduced: 11.3)
extension ARPlaneGeometry {
/**
The mesh vertices of the geometry.
*/
@nonobjc public var vertices: [vector_float3] {
let buffer = UnsafeBufferPointer(start: __vertices, count: Int(__vertexCount))
return Array(buffer)
}
/**
The texture coordinates of the geometry.
*/
@nonobjc public var textureCoordinates: [vector_float2] {
let buffer = UnsafeBufferPointer(start: __textureCoordinates, count: Int(__textureCoordinateCount))
return Array(buffer)
}
/**
The triangle indices of the geometry.
*/
@nonobjc public var triangleIndices: [Int16] {
let buffer = UnsafeBufferPointer(start: __triangleIndices, count: Int(triangleCount * 3))
return Array(buffer)
}
/**
The vertices of the geometry's outermost boundary.
*/
@nonobjc public var boundaryVertices: [vector_float3] {
let buffer = UnsafeBufferPointer(start: __boundaryVertices, count: Int(__boundaryVertexCount))
return Array(buffer)
}
}

View File

@@ -167,6 +167,25 @@ extension NSKeyedUnarchiver {
try resolveError(error)
return result
}
@nonobjc
@available(OSX 10.13, iOS 11.0, watchOS 4.0, tvOS 11.0, *)
public static func unarchivedObject<DecodedObjectType>(ofClass cls: DecodedObjectType.Type, from data: Data) throws -> DecodedObjectType? {
var error: NSError?
let result = __NSKeyedUnarchiverSecureUnarchiveObjectOfClass(cls as! AnyClass, data, &error)
try resolveError(error)
return result as? DecodedObjectType
}
@nonobjc
@available(OSX 10.13, iOS 11.0, watchOS 4.0, tvOS 11.0, *)
public static func unarchivedObject(ofClasses classes: [AnyClass], from data: Data) throws -> Any? {
var error: NSError?
let classesAsNSObjects = NSSet(array: classes.map { $0 as AnyObject })
let result = __NSKeyedUnarchiverSecureUnarchiveObjectOfClasses(classesAsNSObjects, data, &error)
try resolveError(error)
return result
}
@nonobjc
private static let __plistClasses: [AnyClass] = [

View File

@@ -14,7 +14,6 @@
NS_BEGIN_DECLS
NS_INLINE NS_RETURNS_RETAINED _Nullable id __NSKeyedUnarchiverUnarchiveObject(id Self_, NS_NON_BRIDGED(NSData *)data, NSError **_Nullable error) {
if (error) {
return [Self_ unarchiveTopLevelObjectWithData:(NSData *)data error:error];
@@ -23,4 +22,18 @@ NS_INLINE NS_RETURNS_RETAINED _Nullable id __NSKeyedUnarchiverUnarchiveObject(id
}
}
// Re-exposed here until all SDKs contain the relevant methods publicly.
@interface NSKeyedUnarchiver (SecureMethods)
+ (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));
+ (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));
@end
NS_INLINE NS_RETURNS_RETAINED id _Nullable __NSKeyedUnarchiverSecureUnarchiveObjectOfClass(Class cls, NSData *data, NSError * _Nullable * _Nullable error) {
return [NSKeyedUnarchiver unarchivedObjectOfClass:cls fromData:data error:error];
}
NS_INLINE NS_RETURNS_RETAINED id _Nullable __NSKeyedUnarchiverSecureUnarchiveObjectOfClasses(NS_NON_BRIDGED(NSSet *) classes, NSData *data, NSError * _Nullable * _Nullable error) {
return [NSKeyedUnarchiver unarchivedObjectOfClasses:classes fromData:data error:error];
}
NS_END_DECLS

View File

@@ -11,5 +11,9 @@ _ = dispatch_get_global_queue(0, 0) // expected-error {{'dispatch_get_global_que
_ = dispatch_source_create(OpaquePointer(bitPattern: ~0)!, 0, 0, nil) // expected-error {{'dispatch_source_create' is unavailable: Use DispatchSource class methods}}
_ = dispatch_get_main_queue() // expected-error {{'dispatch_get_main_queue()' has been replaced by property 'DispatchQueue.main'}}
// Next test is disabled pending what to do about libdispatch change to the signature of dispatch_get_main_queue(): rdar://problem/36528231.
// To re-enable, remove the #if/#endif and remove "FIXME-" from 'expected-FIXME-error'
#if false
_ = dispatch_get_main_queue() // expected-FIXME-error {{'dispatch_get_main_queue()' has been replaced by property 'DispatchQueue.main'}}
#endif
_ = DispatchQueue.main

View File

@@ -63,3 +63,15 @@ func test_NSKeyedUnarchiver_decodeObjectForKey(
expectType(Optional<Any>.self, &r)
}
@available(OSX 10.13, iOS 11.0, watchOS 4.0, tvOS 11.0, *)
func test_NSKeyedUnarchiver_unarchivedObjectOfClass(from data: Data) throws {
var r = try NSKeyedUnarchiver.unarchivedObject(ofClass: NSString.self, from: data)
expectType(NSString?.self, &r)
}
@available(OSX 10.13, iOS 11.0, watchOS 4.0, tvOS 11.0, *)
func test_NSKeyedUnarchiver_unarchivedObjectOfClasses(from data: Data) throws {
var r = try NSKeyedUnarchiver.unarchivedObject(ofClasses: [NSString.self, NSData.self, NSArray.self], from: data)
expectType(Any?.self, &r)
}

View File

@@ -163,21 +163,68 @@ func test_toplevelAPIVariants() {
}
}
@available(OSX 10.13, iOS 11.0, watchOS 4.0, tvOS 11.0, *)
func test_unarchiveObjectOfClass() {
let topLevel = NSArray()
let data = NSKeyedArchiver.archivedData(withRootObject: topLevel)
// Should be able to decode an NSArray back out.
expectNoError {
guard let result = try NSKeyedUnarchiver.unarchivedObject(ofClass: NSArray.self, from: data) else {
expectUnreachable("Unable to decode top-level array.")
return
}
expectEqual(result, topLevel)
}
// Shouldn't be able to decode an NSString out of an NSArray.
expectError {
let _ = try NSKeyedUnarchiver.unarchivedObject(ofClass: NSString.self, from: data)
}
}
@available(OSX 10.13, iOS 11.0, watchOS 4.0, tvOS 11.0, *)
func test_unarchiveObjectOfClasses() {
let topLevel = NSArray()
let data = NSKeyedArchiver.archivedData(withRootObject: topLevel)
// Should be able to unarchive an array back out.
expectNoError {
guard let result = try NSKeyedUnarchiver.unarchivedObject(ofClasses: [NSArray.self], from: data) as? NSArray else {
expectUnreachable("Unable to decode top-level array.")
return
}
expectEqual(result, topLevel)
}
// Shouldn't be able to decode an NSString out of an NSArray.
expectError {
let _ = try NSKeyedUnarchiver.unarchivedObject(ofClasses: [NSString.self], from: data)
}
}
// MARK: - Run Tests
#if !FOUNDATION_XCTEST
if #available(OSX 10.11, iOS 9.0, *) {
let NSKeyedArchiverTest = TestSuite("TestNSKeyedArchiver")
let tests = [
var tests = [
"NSKeyedArchival.simpleCodableSupportInNSKeyedArchival": test_simpleCodableSupport,
"NSKeyedArchival.encodableErrorHandling": test_encodableErrorHandling,
"NSKeyedArchival.readingNonCodableFromDecodeDecodable": test_readingNonCodableFromDecodeDecodable,
"NSKeyedArchival.toplevelAPIVariants": test_toplevelAPIVariants
]
if #available(OSX 10.13, iOS 11.0, watchOS 4.0, tvOS 11.0, *) {
tests["NSKeyedArchival.unarchiveObjectOfClass"] = test_unarchiveObjectOfClass
tests["NSKeyedArchival.unarchiveObjectOfClasses"] = test_unarchiveObjectOfClasses
}
for (name, test) in tests {
NSKeyedArchiverTest.test(name) { test() }
}
runAllTests()
}
#endif
#endif