Files
swift-mirror/stdlib/core/Mirrors.swift.gyb
Enrico Granata 942676abb2 Everyone loves a good Mirror, and this commit has plenty of them!
With this check-in, we get Mirrors for IntXX, UIntXX, Float32, and we don't lose the existing ones for Double, Int, String and Bool

This fixes rdar://16517273 and will make playgrounds able to display more data more often more consistently!



Swift SVN r16418
2014-04-16 17:16:06 +00:00

32 lines
1.1 KiB
Swift

%# -*- mode: swift -*-
//===--- Mirrors.swift.gyb - Mirror implementations for common types ------===//
//
// 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','.Text','"\($0)"'))
% Types.append(('Int','.Int','Int64($0)'))
% for Type in Types:
extension ${Type[0]} : Reflectable {
func getMirror() -> Mirror {
return _LeafMirror(self, { "\($0)" }, { .Some(${Type[1]}(${Type[2]})) })
}
}