-
Notifications
You must be signed in to change notification settings - Fork 10.4k
/
Copy pathMirrors.swift.gyb
67 lines (56 loc) · 1.96 KB
/
Mirrors.swift.gyb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//===--- Mirrors.swift.gyb - Common _Mirror implementations ---*- swift -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
%{
from SwiftIntTypes import all_integer_types
# Number of bits in the Builtin.Word type
word_bits = int(CMAKE_SIZEOF_VOID_P) * 8
Types = [
('Float', '.float', 'self'),
('Double', '.double', 'self'),
('Bool', '.bool', 'self'),
('String', '.text', 'self'),
('Character', '.text', 'String(self)'),
('Unicode.Scalar', '.uInt', 'UInt64(self)'),
]
for self_ty in all_integer_types(word_bits):
Self = self_ty.stdlib_name
if self_ty.is_signed:
Types.append( (Self, '.int', 'Int64(self)') )
else:
Types.append( (Self, '.uInt', 'UInt64(self)') )
}%
%for Type in Types:
extension ${Type[0]} : CustomReflectable {
/// A mirror that reflects the `${Type[0]}` instance.
public var customMirror: Mirror {
return Mirror(self, unlabeledChildren: EmptyCollection<Void>())
}
}
extension ${Type[0]} : _CustomPlaygroundQuickLookable {
/// A custom playground Quick Look for the `${Type[0]}` instance.
@available(*, deprecated, message: "${Type[0]}.customPlaygroundQuickLook will be removed in a future Swift version")
public var customPlaygroundQuickLook: _PlaygroundQuickLook {
return ${Type[1]}(${Type[2]})
}
}
% end
#if !os(Windows) && (arch(i386) || arch(x86_64))
extension Float80 : CustomReflectable {
/// A mirror that reflects the Float80 instance.
public var customMirror: Mirror {
return Mirror(self, unlabeledChildren: EmptyCollection<Void>())
}
}
#endif
// ${'Local Variables'}:
// eval: (read-only-mode 1)
// End: