Files
swift-mirror/stdlib/core/Mirrors.swift.gyb
2014-06-25 23:36:52 +00:00

34 lines
1.2 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','.Logical','$0'))
% Types.append(('Int','.Int','Int64($0)'))
% Types.append(('UInt','.UInt','UInt64($0)'))
% Types.append(('Character','.Text','String($0)'))
% for Type in Types:
extension ${Type[0]} : Reflectable {
@public func getMirror() -> Mirror {
return _LeafMirror(self, { "\($0)" }, { .Some(${Type[1]}(${Type[2]})) })
}
}