10
10
//
11
11
//===----------------------------------------------------------------------===//
12
12
13
- public enum _PrintForDebugger {
14
-
13
+ public enum _DebuggerSupport {
15
14
internal enum CollectionStatus {
16
15
case NotACollection
17
16
case CollectionOfElements
@@ -39,15 +38,15 @@ public enum _PrintForDebugger {
39
38
}
40
39
}
41
40
42
- internal static func asObjectIdentifier( value: Any ) -> ObjectIdentifier ? {
41
+ internal static func asObjectIdentifier( _ value: Any ) -> ObjectIdentifier ? {
43
42
if let ao = value as? AnyObject {
44
43
return ObjectIdentifier ( ao)
45
44
} else {
46
45
return nil
47
46
}
48
47
}
49
48
50
- internal static func asNumericValue( value: Any ) -> Int {
49
+ internal static func asNumericValue( _ value: Any ) -> Int {
51
50
if let ao = value as? AnyObject {
52
51
return unsafeBitCast ( ao, to: Int . self)
53
52
} else {
@@ -62,54 +61,54 @@ public enum _PrintForDebugger {
62
61
) -> String ? {
63
62
let ds = mirror. displayStyle ?? . `struct`
64
63
switch ds {
65
- case . optional:
64
+ case . optional:
66
65
if count > 0 {
67
- return " \( mirror. subjectType) "
66
+ return " \( mirror. subjectType) "
68
67
}
69
68
else {
70
- if let x = value {
71
- return String ( reflecting: x)
72
- }
69
+ if let x = value {
70
+ return String ( reflecting: x)
71
+ }
73
72
}
74
- case . collection:
73
+ case . collection:
75
74
fallthrough
76
- case . dictionary:
75
+ case . dictionary:
77
76
fallthrough
78
- case . set:
77
+ case . set:
79
78
fallthrough
80
- case . tuple:
79
+ case . tuple:
81
80
return " \( Int ( mirror. children. count) ) elements "
82
- case . `struct`:
81
+ case . `struct`:
83
82
fallthrough
84
- case . `enum`:
83
+ case . `enum`:
85
84
if let x = value {
86
- if let cdsc = ( x as? CustomDebugStringConvertible ) {
87
- return cdsc. debugDescription
88
- }
89
- if let csc = ( x as? CustomStringConvertible ) {
90
- return csc. description
91
- }
85
+ if let cdsc = ( x as? CustomDebugStringConvertible ) {
86
+ return cdsc. debugDescription
87
+ }
88
+ if let csc = ( x as? CustomStringConvertible ) {
89
+ return csc. description
90
+ }
92
91
}
93
92
if count > 0 {
94
93
return " \( mirror. subjectType) "
95
94
}
96
- case . `class`:
95
+ case . `class`:
97
96
if let x = value {
98
- if let cdsc = ( x as? CustomDebugStringConvertible ) {
99
- return cdsc. debugDescription
100
- }
101
- if let csc = ( x as? CustomStringConvertible ) {
102
- return csc. description
103
- }
104
- // for a Class with no custom summary, mimic the Foundation default
105
- return " < \( x. dynamicType) : 0x \( String ( asNumericValue ( value : x) , radix: 16 , uppercase: false ) ) > "
97
+ if let cdsc = ( x as? CustomDebugStringConvertible ) {
98
+ return cdsc. debugDescription
99
+ }
100
+ if let csc = ( x as? CustomStringConvertible ) {
101
+ return csc. description
102
+ }
103
+ // for a Class with no custom summary, mimic the Foundation default
104
+ return " < \( x. dynamicType) : 0x \( String ( asNumericValue ( x) , radix: 16 , uppercase: false ) ) > "
106
105
} else {
107
- // but if I can't provide a value, just use the type anyway
108
- return " \( mirror. subjectType) "
106
+ // but if I can't provide a value, just use the type anyway
107
+ return " \( mirror. subjectType) "
109
108
}
110
109
}
111
110
if let x = value {
112
- return String ( reflecting: x)
111
+ return String ( reflecting: x)
113
112
}
114
113
return nil
115
114
}
@@ -139,7 +138,7 @@ public enum _PrintForDebugger {
139
138
}
140
139
}
141
140
142
- internal static func printForDebuggerImpl< StreamType: OutputStream > (
141
+ internal static func printForDebuggerImpl< StreamType : OutputStream > (
143
142
value: Any ? ,
144
143
mirror: Mirror ,
145
144
name: String ? ,
@@ -204,7 +203,7 @@ public enum _PrintForDebugger {
204
203
}
205
204
206
205
if let x = value {
207
- if let valueIdentifier = asObjectIdentifier ( value : x) {
206
+ if let valueIdentifier = asObjectIdentifier ( x) {
208
207
if refsAlreadySeen. contains ( valueIdentifier) {
209
208
print ( " { ... } " , to: & targetStream)
210
209
return
@@ -266,7 +265,7 @@ public enum _PrintForDebugger {
266
265
}
267
266
}
268
267
269
- public static func printForDebugger ( value: Any ) -> String {
268
+ public static func stringForPrintObject ( _ value: Any ) -> String {
270
269
var maxItemCounter = Int . max
271
270
var refs = Set < ObjectIdentifier > ( )
272
271
var targetStream = " "
0 commit comments