Files
swift-mirror/stdlib/core/Mirrors.swift.gyb
Enrico Granata 729b90e087 Split the floating-point QuickLook object in two: Float and Double for respectively single and double precision values
This allows reflection clients a more detailed perspective on what precision values they are inspecting, and is largely meant to support improvements to the way Xcode represents floating point numbers in the playgrounds UI (rdar://19124310)



Swift SVN r24372
2015-01-12 19:54:58 +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)') )
% Types.append(('Float','.Float','$0'))
% Types.append(('Double','.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: