Files
swift-mirror/stdlib/core/RangeMirrors.swift.gyb
Dave Abrahams 953f740949 [stdlib] Trivial comment fixups
Swift SVN r19649
2014-07-07 23:17:49 +00:00

50 lines
2.0 KiB
Swift

//===- 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
%TMirrorDecl = gyb.parseTemplate("../common/MirrorDecl.gyb")
%TMirrorConformance = gyb.parseTemplate("../common/MirrorConformance.gyb")
%TMirrorBoilerplate = gyb.parseTemplate("../common/MirrorBoilerplate.gyb")
% for Type in [['Range','ForwardIndex','startIndex','endIndex'],\
% ['RandomAccessRange','RandomAccessIndex','startIndex','endIndex'],\
% ['ReverseRange','BidirectionalIndex','_bounds.0','_bounds.1']]:
% Self = Type[0]
% Protocol = Type[1]
% StartIndex = Type[2]
% EndIndex = Type[3]
% MirrorDecl = gyb.executeTemplate(TMirrorDecl,introspecteeType=Self,genericArgs=['T'],genericConstraints={'T':Protocol},disposition='Struct')
% MirrorConformance = gyb.executeTemplate(TMirrorConformance,introspecteeType=Self,genericArgs=['T'],genericConstraints={'T':Protocol},disposition='Struct')
% MirrorBoilerplate = gyb.executeTemplate(TMirrorBoilerplate,introspecteeType=Self,genericArgs=['T'],genericConstraints={'T':Protocol},disposition='Struct')
${MirrorDecl} {
${MirrorBoilerplate}
@public var count: Int { return 2 }
@public subscript(i: Int) -> (String, Mirror) {
switch i {
case 0: return ("startIndex",reflect(_value.${StartIndex}))
case 1: return ("endIndex",reflect(_value.${EndIndex}))
default: _preconditionFailure("cannot extract this child index")
}
}
@public var summary: String {
return "${Self}(\(self[0].1.summary),\(self[1].1.summary))"
}
@public var quickLookObject: QuickLookObject? { return .Some(.Text(summary)) }
}
${MirrorConformance}