Files
swift-mirror/stdlib/core/Mirrors.swift.gyb
Dave Abrahams dbde275230 [stdlib] Propagate Reflectable docs
230 undocumented public non-operator APIs remain in core

Swift SVN r22236
2014-09-23 23:08:43 +00:00

39 lines
1.3 KiB
Swift

//===--- Mirrors.swift.gyb - Common MirrorType implementations -*- 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
//
//===----------------------------------------------------------------------===//
% Types = []
% for IntSize in [8,16,32,64]:
% Types.append( ('Int'+str(IntSize),'.Int','Int64($0)') )
% for UIntSize in [8,16,32,64]:
% Types.append( ('UInt'+str(UIntSize),'.UInt','UInt64($0)') )
% for FloatSize in [32,64]:
% Types.append( ('Float'+str(FloatSize),'.Float','Double($0)') )
% Types.append(('String','.Text','$0'))
% Types.append(('Bool','.Logical','$0'))
% Types.append(('Int','.Int','Int64($0)'))
% Types.append(('UInt','.UInt','UInt64($0)'))
% Types.append(('Character','.Text','String($0)'))
% Types.append(('UnicodeScalar','.UInt','UInt64($0)'))
% for Type in Types:
extension ${Type[0]} : Reflectable {
/// Returns a mirror that reflects `self`.
public func getMirror() -> MirrorType {
return _LeafMirror(self, { "\($0)" }, { .Some(${Type[1]}(${Type[2]})) })
}
}
// ${'Local Variables'}:
// eval: (read-only-mode 1)
// End: