Files
swift-mirror/stdlib/public/core/Mirrors.swift.gyb
Nate Cook 0782b482b3 [stdlib] Documentation improvements
- Revise Equatable and Hashable for synthesized requirements
- Complete Strideable and stride(from:...:by:) documentation
- Revise DoubleWidth type docs
- Add complexity notes for Set.index(of:) and .contains(_:)
- Fix typos in Set.formUnion docs
- Add missing axioms for SetAlgebra (SR-6319)
- Improve guidance for description and debugDescription
- Add note about the result of passing duplicate keys to
  Dictionary(uniqueKeysWithValues:)
- Fix typo in BinaryInteger docs
- Update Substring docs with better conversion example
- Improve docs for withMemoryRebound and isKnownUniquelyReferenced
- Add missing docs not propagated from protocols
2018-01-05 17:06:44 -06:00

60 lines
1.7 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.
@_inlineable // 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.
@_inlineable // FIXME(sil-serialize-all)
public var customPlaygroundQuickLook: PlaygroundQuickLook {
return ${Type[1]}(${Type[2]})
}
}
% end
// ${'Local Variables'}:
// eval: (read-only-mode 1)
// End: