forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRangeMirrors.swift.gyb
45 lines (39 loc) · 1.33 KB
/
RangeMirrors.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
//===- RangeMirrors.swift.gyb ---------------------------------*- swift -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
% import gyb
%
% common_args = dict(
% introspecteeType='Range',
% genericArgs=['T'],
% genericConstraints={'T':'ForwardIndexType'},
% disposition='Struct')
%
% for x in ('Decl', 'Conformance', 'Boilerplate'):
% locals()['Mirror' + x] = gyb.executeTemplate(
% gyb.parseTemplate('../common/Mirror%s.gyb' % x), **common_args)
% end
${MirrorDecl} {
${MirrorBoilerplate}
var count: Int { return 2 }
subscript(i: Int) -> (String, _MirrorType) {
switch i {
case 0: return ("startIndex",_reflect(_value.startIndex))
case 1: return ("endIndex",_reflect(_value.endIndex))
default: _preconditionFailure("cannot extract this child index")
}
}
var summary: String {
return "\(self[0].1.summary)..<\(self[1].1.summary)"
}
var quickLookObject: PlaygroundQuickLook? { return nil }
}
${MirrorConformance}