mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
61 lines
1.8 KiB
Swift
61 lines
1.8 KiB
Swift
//===--- Mirrors.swift.gyb - Common _Mirror implementations ---*- swift -*-===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See https://swift.org/LICENSE.txt for license information
|
|
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
%{
|
|
|
|
from SwiftIntTypes import all_integer_types
|
|
|
|
# Number of bits in the Builtin.Word type
|
|
word_bits = int(CMAKE_SIZEOF_VOID_P) * 8
|
|
|
|
Types = [
|
|
('Float', '.float', 'self'),
|
|
('Double', '.double', 'self'),
|
|
('Bool', '.bool', 'self'),
|
|
('String', '.text', 'self'),
|
|
('Character', '.text', 'String(self)'),
|
|
('Unicode.Scalar', '.uInt', 'UInt64(self)'),
|
|
]
|
|
|
|
for self_ty in all_integer_types(word_bits):
|
|
Self = self_ty.stdlib_name
|
|
if self_ty.is_signed:
|
|
Types.append( (Self, '.int', 'Int64(self)') )
|
|
else:
|
|
Types.append( (Self, '.uInt', 'UInt64(self)') )
|
|
|
|
}%
|
|
|
|
%for Type in Types:
|
|
|
|
extension ${Type[0]} : CustomReflectable {
|
|
/// A mirror that reflects the `${Type[0]}` instance.
|
|
@inlinable // FIXME(sil-serialize-all)
|
|
public var customMirror: Mirror {
|
|
return Mirror(self, unlabeledChildren: EmptyCollection<Void>())
|
|
}
|
|
}
|
|
|
|
extension ${Type[0]} : CustomPlaygroundQuickLookable {
|
|
/// A custom playground Quick Look for the `${Type[0]}` instance.
|
|
@inlinable // FIXME(sil-serialize-all)
|
|
@available(*, deprecated, message: "${Type[0]}.customPlaygroundQuickLook will be removed in a future Swift version")
|
|
public var customPlaygroundQuickLook: PlaygroundQuickLook {
|
|
return ${Type[1]}(${Type[2]})
|
|
}
|
|
}
|
|
% end
|
|
|
|
// ${'Local Variables'}:
|
|
// eval: (read-only-mode 1)
|
|
// End:
|