mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
This adds to and expands upon documentation for some core parts of the standard library, including Optional, ErrorProtocol, AnyObject, and Bool.
57 lines
1.5 KiB
Swift
57 lines
1.5 KiB
Swift
//===--- Mirrors.swift.gyb - Common _Mirror implementations ---*- swift -*-===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2014 - 2016 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
%{
|
|
|
|
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)'),
|
|
('UnicodeScalar', '.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.
|
|
public var customMirror: Mirror {
|
|
return Mirror(self, unlabeledChildren: EmptyCollection<Void>())
|
|
}
|
|
}
|
|
|
|
extension ${Type[0]} : CustomPlaygroundQuickLookable {
|
|
public var customPlaygroundQuickLook: PlaygroundQuickLook {
|
|
return ${Type[1]}(${Type[2]})
|
|
}
|
|
}
|
|
% end
|
|
|
|
// ${'Local Variables'}:
|
|
// eval: (read-only-mode 1)
|
|
// End:
|