mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[stdlib] Propagate LiteralConvertible docs
219 undocumented public APIs remain in core Swift SVN r22213
This commit is contained in:
@@ -289,10 +289,12 @@ public struct ${Self}<T> : MutableCollectionType, Sliceable {
|
||||
extension ${Self} : ArrayLiteralConvertible {
|
||||
%if Self == 'Array':
|
||||
// Optimized implementation for Array
|
||||
/// Create an instance containing `elements`.
|
||||
public init(arrayLiteral elements: Element...) {
|
||||
self = elements
|
||||
}
|
||||
%else:
|
||||
/// Create an instance containing `elements`.
|
||||
public init(arrayLiteral elements: Element...) {
|
||||
self.init(_extractOrCopyToNativeArrayBuffer(elements._buffer))
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ extension Bool : _BuiltinBooleanLiteralConvertible, BooleanLiteralConvertible {
|
||||
self.value = value
|
||||
}
|
||||
|
||||
/// Create an instance initialized to `value`.
|
||||
@transparent
|
||||
public init(booleanLiteral value: Bool) {
|
||||
self = value
|
||||
|
||||
@@ -51,6 +51,7 @@ public enum Character :
|
||||
UTF32.self, input: CollectionOfOne(UInt32(value))))
|
||||
}
|
||||
|
||||
/// Create an instance initialized to `value`.
|
||||
public init(unicodeScalarLiteral value: Character) {
|
||||
self = value
|
||||
}
|
||||
@@ -67,6 +68,7 @@ public enum Character :
|
||||
isASCII: isASCII))
|
||||
}
|
||||
|
||||
/// Create an instance initialized to `value`.
|
||||
public init(extendedGraphemeClusterLiteral value: Character) {
|
||||
self = value
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ public protocol _BuiltinIntegerLiteralConvertible {
|
||||
/// Conforming types can be initialized with integer literals
|
||||
public protocol IntegerLiteralConvertible {
|
||||
typealias IntegerLiteralType : _BuiltinIntegerLiteralConvertible
|
||||
/// Create an instance initialized with `value`.
|
||||
/// Create an instance initialized to `value`.
|
||||
init(integerLiteral value: IntegerLiteralType)
|
||||
}
|
||||
|
||||
@@ -273,7 +273,7 @@ public protocol _BuiltinFloatLiteralConvertible {
|
||||
/// Conforming types can be initialized with floating point literals
|
||||
public protocol FloatLiteralConvertible {
|
||||
typealias FloatLiteralType : _BuiltinFloatLiteralConvertible
|
||||
/// Create an instance initialized with `value`.
|
||||
/// Create an instance initialized to `value`.
|
||||
init(floatLiteral value: FloatLiteralType)
|
||||
}
|
||||
|
||||
@@ -285,7 +285,7 @@ public protocol _BuiltinBooleanLiteralConvertible {
|
||||
/// `true` and `false`.
|
||||
public protocol BooleanLiteralConvertible {
|
||||
typealias BooleanLiteralType : _BuiltinBooleanLiteralConvertible
|
||||
/// Create an instance initialized with `value`.
|
||||
/// Create an instance initialized to `value`.
|
||||
init(booleanLiteral value: BooleanLiteralType)
|
||||
}
|
||||
|
||||
@@ -295,6 +295,7 @@ internal protocol _BuiltinCharacterLiteralConvertible {
|
||||
|
||||
internal protocol CharacterLiteralConvertible {
|
||||
typealias CharacterLiteralType : _BuiltinCharacterLiteralConvertible
|
||||
/// Create an instance initialized to `value`.
|
||||
init(characterLiteral value: CharacterLiteralType)
|
||||
}
|
||||
|
||||
@@ -307,7 +308,7 @@ public protocol _BuiltinUnicodeScalarLiteralConvertible {
|
||||
/// <http://www.unicode.org/glossary/#unicode_scalar_value>`_.
|
||||
public protocol UnicodeScalarLiteralConvertible {
|
||||
typealias UnicodeScalarLiteralType : _BuiltinUnicodeScalarLiteralConvertible
|
||||
/// Create an instance initialized with `value`.
|
||||
/// Create an instance initialized to `value`.
|
||||
init(unicodeScalarLiteral value: UnicodeScalarLiteralType)
|
||||
}
|
||||
|
||||
@@ -328,7 +329,7 @@ public protocol ExtendedGraphemeClusterLiteralConvertible
|
||||
|
||||
typealias ExtendedGraphemeClusterLiteralType
|
||||
: _BuiltinExtendedGraphemeClusterLiteralConvertible
|
||||
/// Create an instance initialized with `value`.
|
||||
/// Create an instance initialized to `value`.
|
||||
init(extendedGraphemeClusterLiteral value: ExtendedGraphemeClusterLiteralType)
|
||||
}
|
||||
|
||||
@@ -356,7 +357,7 @@ public protocol StringLiteralConvertible
|
||||
// an implementation of init(extendedGraphemeClusterLiteral:).
|
||||
|
||||
typealias StringLiteralType : _BuiltinStringLiteralConvertible
|
||||
/// Create an instance initialized with `value`.
|
||||
/// Create an instance initialized to `value`.
|
||||
init(stringLiteral value: StringLiteralType)
|
||||
}
|
||||
|
||||
|
||||
@@ -2076,6 +2076,7 @@ public struct Dictionary<
|
||||
//
|
||||
// DictionaryLiteralConvertible conformance
|
||||
//
|
||||
/// Create an instance initialized with `elements`.
|
||||
@effects(readnone)
|
||||
public init(dictionaryLiteral elements: (Key, Value)...) {
|
||||
self.init(_nativeStorage: _NativeDictionaryStorage.fromArray(elements))
|
||||
|
||||
@@ -186,6 +186,7 @@ public struct ${Self}
|
||||
self = ${Self}(Builtin.s_to_${sign}_checked_trunc_Int${builtinIntLiteralBits}_${BuiltinName}(value).0)
|
||||
}
|
||||
|
||||
/// Create an instance initialized to `value`.
|
||||
@transparent public
|
||||
init(integerLiteral value: ${Self}) {
|
||||
self = value
|
||||
|
||||
@@ -294,6 +294,7 @@ extension ${Self} : _BuiltinIntegerLiteralConvertible, IntegerLiteralConvertible
|
||||
self = ${Self}(Builtin.itofp_with_overflow_Int${builtinIntLiteralBits}_FPIEEE${bits}(value))
|
||||
}
|
||||
|
||||
/// Create an instance initialized to `value`.
|
||||
public init(integerLiteral value: Int64) {
|
||||
self = ${Self}(Builtin.uitofp_Int64_FPIEEE${bits}(value.value))
|
||||
}
|
||||
@@ -339,6 +340,7 @@ extension ${Self} : _BuiltinFloatLiteralConvertible {
|
||||
|
||||
@transparent
|
||||
extension ${Self} : FloatLiteralConvertible {
|
||||
/// Create an instance initialized to `value`.
|
||||
public init(floatLiteral value: ${Self}) {
|
||||
self = value
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public protocol FloatingPointType : Strideable {
|
||||
|
||||
% for src_ty in all_integer_types(word_bits):
|
||||
|
||||
/// Create an instance initialized with `value`.
|
||||
/// Create an instance initialized to `value`.
|
||||
init(_ value: ${src_ty.stdlib_name})
|
||||
|
||||
% end
|
||||
|
||||
@@ -133,6 +133,7 @@ public struct StaticString
|
||||
self = StaticString(unicodeScalar: value)
|
||||
}
|
||||
|
||||
/// Create an instance initialized to `value`.
|
||||
@effects(readonly)
|
||||
@transparent
|
||||
public init(unicodeScalarLiteral value: StaticString) {
|
||||
@@ -153,6 +154,7 @@ public struct StaticString
|
||||
)
|
||||
}
|
||||
|
||||
/// Create an instance initialized to `value`.
|
||||
@effects(readonly)
|
||||
@transparent
|
||||
public init(extendedGraphemeClusterLiteral value: StaticString) {
|
||||
@@ -169,6 +171,7 @@ public struct StaticString
|
||||
self = StaticString(start: start, byteSize: byteSize, isASCII: isASCII)
|
||||
}
|
||||
|
||||
/// Create an instance initialized to `value`.
|
||||
@effects(readonly)
|
||||
@transparent
|
||||
public init(stringLiteral value: StaticString) {
|
||||
|
||||
@@ -70,6 +70,7 @@ extension String : _BuiltinUnicodeScalarLiteralConvertible {
|
||||
}
|
||||
|
||||
extension String : UnicodeScalarLiteralConvertible {
|
||||
/// Create an instance initialized to `value`.
|
||||
public init(unicodeScalarLiteral value: String) {
|
||||
self = value
|
||||
}
|
||||
@@ -92,6 +93,7 @@ extension String : _BuiltinExtendedGraphemeClusterLiteralConvertible {
|
||||
}
|
||||
|
||||
extension String : ExtendedGraphemeClusterLiteralConvertible {
|
||||
/// Create an instance initialized to `value`.
|
||||
public init(extendedGraphemeClusterLiteral value: String) {
|
||||
self = value
|
||||
}
|
||||
@@ -143,6 +145,7 @@ extension String : _BuiltinStringLiteralConvertible {
|
||||
}
|
||||
|
||||
extension String : StringLiteralConvertible {
|
||||
/// Create an instance initialized to `value`.
|
||||
public init(stringLiteral value: String) {
|
||||
self = value
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ public struct UnicodeScalar :
|
||||
self._value = value
|
||||
}
|
||||
|
||||
/// Create an instance initialized to `value`.
|
||||
@transparent
|
||||
public init(unicodeScalarLiteral value: UnicodeScalar) {
|
||||
self = value
|
||||
|
||||
@@ -160,15 +160,15 @@ extension CGFloat : Reflectable {
|
||||
}
|
||||
|
||||
@transparent extension CGFloat : FloatLiteralConvertible {
|
||||
public
|
||||
init(floatLiteral value: NativeType) {
|
||||
/// Create an instance initialized to `value`.
|
||||
public init(floatLiteral value: NativeType) {
|
||||
self = CGFloat(value)
|
||||
}
|
||||
}
|
||||
|
||||
@transparent extension CGFloat : IntegerLiteralConvertible {
|
||||
public
|
||||
init(integerLiteral value: Int) {
|
||||
/// Create an instance initialized to `value`.
|
||||
public init(integerLiteral value: Int) {
|
||||
self = CGFloat(value)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,6 +92,7 @@ public func _convertNSStringToString(nsstring: NSString) -> String {
|
||||
}
|
||||
|
||||
extension NSString : StringLiteralConvertible {
|
||||
/// Create an instance initialized to `value`.
|
||||
public required convenience init(unicodeScalarLiteral value: StaticString) {
|
||||
self.init(stringLiteral: value)
|
||||
}
|
||||
@@ -102,6 +103,7 @@ extension NSString : StringLiteralConvertible {
|
||||
self.init(stringLiteral: value)
|
||||
}
|
||||
|
||||
/// Create an instance initialized to `value`.
|
||||
public required convenience init(stringLiteral value: StaticString) {
|
||||
var immutableResult: NSString
|
||||
if value.hasPointerRepresentation {
|
||||
@@ -577,14 +579,17 @@ extension CGFloat : _ObjectiveCBridgeable {
|
||||
// Literal support for NSNumber
|
||||
extension NSNumber : FloatLiteralConvertible, IntegerLiteralConvertible,
|
||||
BooleanLiteralConvertible {
|
||||
/// Create an instance initialized to `value`.
|
||||
public required convenience init(integerLiteral value: Int) {
|
||||
self.init(integer: value)
|
||||
}
|
||||
|
||||
/// Create an instance initialized to `value`.
|
||||
public required convenience init(floatLiteral value: Double) {
|
||||
self.init(double: value)
|
||||
}
|
||||
|
||||
/// Create an instance initialized to `value`.
|
||||
public required convenience init(booleanLiteral value: Bool) {
|
||||
self.init(bool: value)
|
||||
}
|
||||
@@ -597,6 +602,7 @@ public let NSNotFound: Int = .max
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
extension NSArray : ArrayLiteralConvertible {
|
||||
/// Create an instance initialized with `elements`.
|
||||
public required convenience init(arrayLiteral elements: AnyObject...) {
|
||||
// + (instancetype)arrayWithObjects:(const id [])objects count:(NSUInteger)cnt;
|
||||
let x = _extractOrCopyToNativeArrayBuffer(elements._buffer)
|
||||
|
||||
@@ -53,6 +53,7 @@ public struct ObjCBool : BooleanType, BooleanLiteralConvertible {
|
||||
#endif
|
||||
}
|
||||
|
||||
/// Create an instance initialized to `value`.
|
||||
@transparent
|
||||
public init(booleanLiteral value: Bool) {
|
||||
self.init(value)
|
||||
@@ -95,19 +96,19 @@ public struct Selector : StringLiteralConvertible, NilLiteralConvertible {
|
||||
ptr = str.withCString { sel_registerName($0).ptr }
|
||||
}
|
||||
|
||||
/// Create an instance initialized to `value`.
|
||||
public init(unicodeScalarLiteral value: String) {
|
||||
self.init(value)
|
||||
}
|
||||
|
||||
/// Construct a selector from a string literal.
|
||||
/// Construct a selector from `value`.
|
||||
public init(extendedGraphemeClusterLiteral value: String) {
|
||||
self.init(value)
|
||||
}
|
||||
|
||||
/// Construct a selector from a string literal.
|
||||
///
|
||||
/// FIXME: Fast-path this in the compiler, so we don't end up with
|
||||
/// the sel_registerName call at compile time.
|
||||
// FIXME: Fast-path this in the compiler, so we don't end up with
|
||||
// the sel_registerName call at compile time.
|
||||
/// Create an instance initialized to `value`.
|
||||
public init(stringLiteral value: String) {
|
||||
self = sel_registerName(value)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user