Revert "Merge pull request #1058 from austinzheng/az-port-mirror"

This pull request broke the following tests on several build configurations
(eg --preset=buildbot,tools=RA,stdlib=DA)

    1_stdlib/Reflection.swift
    1_stdlib/ReflectionHashing.swift
    1_stdlib/UnsafePointer.swift.gyb

This reverts commit c223a3bf06, reversing
changes made to 5c2bb09b09.
This commit is contained in:
Andrew Trick
2016-01-27 10:43:08 -08:00
parent 88b7d02e6a
commit 182bb7f812
54 changed files with 1610 additions and 919 deletions

View File

@@ -72,7 +72,7 @@ extension String.CharacterView : CollectionType {
}
/// A character position.
public struct Index : BidirectionalIndexType, Comparable, CustomPlaygroundQuickLookable {
public struct Index : BidirectionalIndexType, Comparable, _Reflectable {
public // SPI(Foundation)
init(_base: String.UnicodeScalarView.Index) {
self._base = _base
@@ -203,8 +203,9 @@ extension String.CharacterView : CollectionType {
return endIndexUTF16 - graphemeClusterStartUTF16
}
public func customPlaygroundQuickLook() -> PlaygroundQuickLook {
return .Int(Int64(_utf16Index))
/// Returns a mirror that reflects `self`.
public func _getMirror() -> _MirrorType {
return _IndexMirror(self)
}
}
@@ -230,6 +231,34 @@ extension String.CharacterView : CollectionType {
public subscript(i: Index) -> Character {
return Character(String(unicodeScalars[i._base..<i._endBase]))
}
internal struct _IndexMirror : _MirrorType {
var _value: Index
init(_ x: Index) {
_value = x
}
var value: Any { return _value }
var valueType: Any.Type { return (_value as Any).dynamicType }
var objectIdentifier: ObjectIdentifier? { return nil }
var disposition: _MirrorDisposition { return .Aggregate }
var count: Int { return 0 }
subscript(i: Int) -> (String, _MirrorType) {
_preconditionFailure("_MirrorType access out of bounds")
}
var summary: String { return "\(_value._utf16Index)" }
var quickLookObject: PlaygroundQuickLook? {
return .Int(Int64(_value._utf16Index))
}
}
}
extension String.CharacterView : RangeReplaceableCollectionType {