mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Runtime] Remove old-style mirrors in ReflectionLegacy.swift.
The old-style mirrors were the basis for non-custom, reflection based Mirrors. As part of removing old-style mirrors, reflection based Mirrors are reimplemented without them. Reflection.mm is deleted and replaced with ReflectionMirror.mm, which borrows a chunk of the old code but presents a simpler API to the Swift side. ReflectionMirror.swift then uses that API to implement a reflection-based Mirror init. rdar://problem/20356017
This commit is contained in:
@@ -81,15 +81,15 @@ dump(NSURL(fileURLWithPath: "/Volumes", isDirectory: true))
|
||||
switch PlaygroundQuickLook(reflecting: "woozle wuzzle" as NSString) {
|
||||
case .text("woozle wuzzle"):
|
||||
print("got the expected quick look text")
|
||||
case _:
|
||||
print("got something else")
|
||||
case let x:
|
||||
print("NSString: got something else: \(x)")
|
||||
}
|
||||
|
||||
// CHECK-NEXT: foobar
|
||||
let somesubclassofnsstring = ("foo" + "bar") as NSString
|
||||
switch PlaygroundQuickLook(reflecting: somesubclassofnsstring) {
|
||||
case .text(let text): print(text)
|
||||
default: print("not the expected quicklook")
|
||||
case let x: print("not the expected quicklook: \(x)")
|
||||
}
|
||||
|
||||
// CHECK-NEXT: got the expected quick look attributed string
|
||||
@@ -98,40 +98,40 @@ switch PlaygroundQuickLook(reflecting: astr) {
|
||||
case .attributedString(let astr2 as NSAttributedString)
|
||||
where astr == astr2:
|
||||
print("got the expected quick look attributed string")
|
||||
case _:
|
||||
print("got something else")
|
||||
case let x:
|
||||
print("NSAttributedString: got something else: \(x)")
|
||||
}
|
||||
|
||||
// CHECK-NEXT: got the expected quick look int
|
||||
switch PlaygroundQuickLook(reflecting: Int.max as NSNumber) {
|
||||
case .int(+Int64(Int.max)):
|
||||
print("got the expected quick look int")
|
||||
case _:
|
||||
print("got something else")
|
||||
case let x:
|
||||
print("NSNumber(Int.max): got something else: \(x)")
|
||||
}
|
||||
|
||||
// CHECK-NEXT: got the expected quick look uint
|
||||
switch PlaygroundQuickLook(reflecting: NSNumber(value: UInt64.max)) {
|
||||
case .uInt(UInt64.max):
|
||||
print("got the expected quick look uint")
|
||||
case _:
|
||||
print("got something else")
|
||||
case let x:
|
||||
print("NSNumber(Int64.max): got something else: \(x)")
|
||||
}
|
||||
|
||||
// CHECK-NEXT: got the expected quick look double
|
||||
switch PlaygroundQuickLook(reflecting: 22.5 as NSNumber) {
|
||||
case .double(22.5):
|
||||
print("got the expected quick look double")
|
||||
case _:
|
||||
print("got something else")
|
||||
case let x:
|
||||
print("NSNumber(22.5): got something else: \(x)")
|
||||
}
|
||||
|
||||
// CHECK-NEXT: got the expected quick look float
|
||||
switch PlaygroundQuickLook(reflecting: Float32(1.25)) {
|
||||
case .float(1.25):
|
||||
print("got the expected quick look float")
|
||||
case _:
|
||||
print("got something else")
|
||||
case let x:
|
||||
print("NSNumber(Float32(1.25)): got something else: \(x)")
|
||||
}
|
||||
|
||||
// CHECK-NEXT: got the expected quick look image
|
||||
@@ -142,24 +142,24 @@ let image = OSImage(contentsOfFile:CommandLine.arguments[1])!
|
||||
switch PlaygroundQuickLook(reflecting: image) {
|
||||
case .image(let image2 as OSImage) where image === image2:
|
||||
print("got the expected quick look image")
|
||||
case _:
|
||||
print("got something else")
|
||||
case let x:
|
||||
print("OSImage: got something else: \(x)")
|
||||
}
|
||||
|
||||
let color = OSColor.black
|
||||
switch PlaygroundQuickLook(reflecting: color) {
|
||||
case .color(let color2 as OSColor) where color === color2:
|
||||
print("got the expected quick look color")
|
||||
case _:
|
||||
print("got something else")
|
||||
case let x:
|
||||
print("OSColor: got something else: \(x)")
|
||||
}
|
||||
|
||||
let path = OSBezierPath()
|
||||
switch PlaygroundQuickLook(reflecting: path) {
|
||||
case .bezierPath(let path2 as OSBezierPath) where path === path2:
|
||||
print("got the expected quick look bezier path")
|
||||
case _:
|
||||
print("got something else")
|
||||
case let x:
|
||||
print("OSBezierPath: got something else: \(x)")
|
||||
}
|
||||
|
||||
// CHECK-LABEL: Reflecting NSArray:
|
||||
|
||||
Reference in New Issue
Block a user