Skip to content

[stdlib] Standardize function signature spacing #3698

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions stdlib/public/core/Bool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ extension Bool : Equatable, Hashable {
}

@_transparent
public static func ==(lhs: Bool, rhs: Bool) -> Bool {
public static func == (lhs: Bool, rhs: Bool) -> Bool {
return Bool(Builtin.cmp_eq_Int1(lhs._value, rhs._value))
}
}
Expand All @@ -167,7 +167,7 @@ extension Bool {
///
/// - Parameter a: The Boolean value to negate.
@_transparent
public static prefix func !(a: Bool) -> Bool {
public static prefix func ! (a: Bool) -> Bool {
return Bool(Builtin.xor_Int1(a._value, true._value))
}
}
Expand Down Expand Up @@ -206,7 +206,7 @@ extension Bool {
/// - lhs: The left-hand side of the operation.
/// - rhs: The right-hand side of the operation.
@inline(__always)
public static func &&(lhs: Bool, rhs: @autoclosure () throws -> Bool) rethrows
public static func && (lhs: Bool, rhs: @autoclosure () throws -> Bool) rethrows
-> Bool{
return lhs ? try rhs() : false
}
Expand Down Expand Up @@ -245,7 +245,7 @@ extension Bool {
/// - lhs: The left-hand side of the operation.
/// - rhs: The right-hand side of the operation.
@inline(__always)
public static func ||(lhs: Bool, rhs: @autoclosure () throws -> Bool) rethrows
public static func || (lhs: Bool, rhs: @autoclosure () throws -> Bool) rethrows
-> Bool {
return lhs ? true : try rhs()
}
Expand Down
8 changes: 5 additions & 3 deletions stdlib/public/core/BridgeObjectiveC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,10 @@ public func _forceBridgeFromObjectiveC<T>(_ x: AnyObject, _: T.Type) -> T {
/// Convert `x` from its Objective-C representation to its Swift
/// representation.
@_silgen_name("_forceBridgeFromObjectiveC_bridgeable")
public func _forceBridgeFromObjectiveC_bridgeable<T:_ObjectiveCBridgeable>
(_ x: T._ObjectiveCType, _: T.Type) -> T {
public func _forceBridgeFromObjectiveC_bridgeable<T:_ObjectiveCBridgeable> (
_ x: T._ObjectiveCType,
_: T.Type
) -> T {
var result: T?
T._forceBridgeFromObjectiveC(x, result: &result)
return result!
Expand Down Expand Up @@ -483,7 +485,7 @@ extension AutoreleasingUnsafeMutablePointer : CustomDebugStringConvertible {
}

@_transparent
public func == <Pointee> (
public func == <Pointee>(
lhs: AutoreleasingUnsafeMutablePointer<Pointee>,
rhs: AutoreleasingUnsafeMutablePointer<Pointee>
) -> Bool {
Expand Down
8 changes: 4 additions & 4 deletions stdlib/public/core/Builtin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,22 +129,22 @@ internal func _reinterpretCastToAnyObject<T>(_ x: T) -> AnyObject {
}

@_transparent
func ==(lhs: Builtin.NativeObject, rhs: Builtin.NativeObject) -> Bool {
func == (lhs: Builtin.NativeObject, rhs: Builtin.NativeObject) -> Bool {
return unsafeBitCast(lhs, to: Int.self) == unsafeBitCast(rhs, to: Int.self)
}

@_transparent
func !=(lhs: Builtin.NativeObject, rhs: Builtin.NativeObject) -> Bool {
func != (lhs: Builtin.NativeObject, rhs: Builtin.NativeObject) -> Bool {
return !(lhs == rhs)
}

@_transparent
func ==(lhs: Builtin.RawPointer, rhs: Builtin.RawPointer) -> Bool {
func == (lhs: Builtin.RawPointer, rhs: Builtin.RawPointer) -> Bool {
return unsafeBitCast(lhs, to: Int.self) == unsafeBitCast(rhs, to: Int.self)
}

@_transparent
func !=(lhs: Builtin.RawPointer, rhs: Builtin.RawPointer) -> Bool {
func != (lhs: Builtin.RawPointer, rhs: Builtin.RawPointer) -> Bool {
return !(lhs == rhs)
}

Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/core/CTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ extension UInt {
}

extension OpaquePointer : Equatable {
public static func ==(lhs: OpaquePointer, rhs: OpaquePointer) -> Bool {
public static func == (lhs: OpaquePointer, rhs: OpaquePointer) -> Bool {
return Bool(Builtin.cmp_eq_RawPointer(lhs._rawValue, rhs._rawValue))
}
}
Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/core/Character.swift
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ internal var _minASCIICharReprBuiltin: Builtin.Int63 {
}

extension Character : Equatable {
public static func ==(lhs: Character, rhs: Character) -> Bool {
public static func == (lhs: Character, rhs: Character) -> Bool {
switch (lhs._representation, rhs._representation) {
case let (.small(lbits), .small(rbits)) where
Bool(Builtin.cmp_uge_Int63(lbits, _minASCIICharReprBuiltin))
Expand All @@ -407,7 +407,7 @@ extension Character : Equatable {
}

extension Character : Comparable {
public static func <(lhs: Character, rhs: Character) -> Bool {
public static func < (lhs: Character, rhs: Character) -> Bool {
switch (lhs._representation, rhs._representation) {
case let (.small(lbits), .small(rbits)) where
// Note: This is consistent with Foundation but unicode incorrect.
Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/core/ClosedRange.swift
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ public struct ClosedRange<
/// - minimum: The lower bound for the range.
/// - maximum: The upper bound for the range.
@_transparent
public func ... <Bound : Comparable> (minimum: Bound, maximum: Bound)
public func ... <Bound : Comparable>(minimum: Bound, maximum: Bound)
-> ClosedRange<Bound> {
_precondition(
minimum <= maximum, "Can't form Range with upperBound < lowerBound")
Expand All @@ -414,7 +414,7 @@ public func ... <Bound : Comparable> (minimum: Bound, maximum: Bound)
/// - minimum: The lower bound for the range.
/// - maximum: The upper bound for the range.
@_transparent
public func ... <Bound> (
public func ... <Bound>(
minimum: Bound, maximum: Bound
) -> CountableClosedRange<Bound>
where
Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/core/Comparable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
/// `Comparable` and implement the `<` operator function.
///
/// extension Date: Comparable {
/// static func <(lhs: Date, rhs: Date) -> Bool {
/// static func < (lhs: Date, rhs: Date) -> Bool {
/// if lhs.year != rhs.year {
/// return lhs.year < rhs.year
/// } else if lhs.month != rhs.month {
Expand All @@ -102,7 +102,7 @@
/// Next, implement the `==` operator function, the requirement inherited from
/// the `Equatable` protocol.
///
/// func ==(lhs: Date, rhs: Date) -> Bool {
/// func == (lhs: Date, rhs: Date) -> Bool {
/// return lhs.year == rhs.year && lhs.month == rhs.month
/// && lhs.day == rhs.day
/// }
Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/core/Equatable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
/// `Equatable`.
///
/// extension StreetAddress: Equatable {
/// static func ==(lhs: StreetAddress, rhs: StreetAddress) -> Bool {
/// static func == (lhs: StreetAddress, rhs: StreetAddress) -> Bool {
/// return
/// lhs.number == rhs.number &&
/// lhs.street == rhs.street &&
Expand Down Expand Up @@ -132,7 +132,7 @@
/// self.value = value
/// }
///
/// static func ==(lhs: IntegerRef, rhs: IntegerRef) -> Bool {
/// static func == (lhs: IntegerRef, rhs: IntegerRef) -> Bool {
/// return lhs.value == rhs.value
/// }
/// }
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/core/FixedPoint.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ public func ${op}(lhs: ${Self}, rhs: ${Self}) -> ${Self} {
///
/// - SeeAlso: `BitwiseOperations`
@_transparent
public prefix func ~(rhs: ${Self}) -> ${Self} {
public prefix func ~ (rhs: ${Self}) -> ${Self} {
let mask = ${Self}.subtractWithOverflow(0, 1).0
return ${Self}(Builtin.xor_${BuiltinName}(rhs._value, mask._value))
}
Expand Down
6 changes: 3 additions & 3 deletions stdlib/public/core/FloatingPoint.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -541,12 +541,12 @@ public enum FloatingPointRoundingRule {
}

@_transparent
public prefix func +<T : FloatingPoint>(x: T) -> T {
public prefix func + <T : FloatingPoint>(x: T) -> T {
return x
}

@_transparent
public prefix func -<T : FloatingPoint>(x: T) -> T {
public prefix func - <T : FloatingPoint>(x: T) -> T {
return x.negated()
}

Expand All @@ -573,7 +573,7 @@ public func ${op[0]}=<T : FloatingPoint>(lhs: inout T, rhs: T) {
%end

@_transparent
public func ==<T : FloatingPoint>(lhs: T, rhs: T) -> Bool {
public func == <T : FloatingPoint>(lhs: T, rhs: T) -> Bool {
return lhs.isEqual(to: rhs)
}

Expand Down
32 changes: 16 additions & 16 deletions stdlib/public/core/FloatingPointTypes.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -756,12 +756,12 @@ extension ${Self} : Arithmetic {
}

@_transparent
public prefix func +(x: ${Self}) -> ${Self} {
public prefix func + (x: ${Self}) -> ${Self} {
return x
}

@_transparent
public prefix func -(x: ${Self}) -> ${Self} {
public prefix func - (x: ${Self}) -> ${Self} {
return ${Self}(_bits: Builtin.fneg_FPIEEE${bits}(x._value))
}

Expand Down Expand Up @@ -838,42 +838,42 @@ extension ${Self} {
// definitions in the standard lib, or both.

@_transparent
public func +(lhs: ${Self}, rhs: ${Self}) -> ${Self} {
public func + (lhs: ${Self}, rhs: ${Self}) -> ${Self} {
return lhs.adding(rhs)
}

@_transparent
public func -(lhs: ${Self}, rhs: ${Self}) -> ${Self} {
public func - (lhs: ${Self}, rhs: ${Self}) -> ${Self} {
return lhs.subtracting(rhs)
}

@_transparent
public func *(lhs: ${Self}, rhs: ${Self}) -> ${Self} {
public func * (lhs: ${Self}, rhs: ${Self}) -> ${Self} {
return lhs.multiplied(by: rhs)
}

@_transparent
public func /(lhs: ${Self}, rhs: ${Self}) -> ${Self} {
public func / (lhs: ${Self}, rhs: ${Self}) -> ${Self} {
return lhs.divided(by: rhs)
}

@_transparent
public func +=(lhs: inout ${Self}, rhs: ${Self}) {
public func += (lhs: inout ${Self}, rhs: ${Self}) {
lhs.add(rhs)
}

@_transparent
public func -=(lhs: inout ${Self}, rhs: ${Self}) {
public func -= (lhs: inout ${Self}, rhs: ${Self}) {
lhs.subtract(rhs)
}

@_transparent
public func *=(lhs: inout ${Self}, rhs: ${Self}) {
public func *= (lhs: inout ${Self}, rhs: ${Self}) {
lhs.multiply(by: rhs)
}

@_transparent
public func /=(lhs: inout ${Self}, rhs: ${Self}) {
public func /= (lhs: inout ${Self}, rhs: ${Self}) {
lhs.divide(by: rhs)
}

Expand Down Expand Up @@ -908,38 +908,38 @@ extension ${Self} : Strideable {

@_transparent
@available(*, unavailable, message: "Use truncatingRemainder instead")
public func %(lhs: ${Self}, rhs: ${Self}) -> ${Self} {
public func % (lhs: ${Self}, rhs: ${Self}) -> ${Self} {
fatalError("% is not available.")
}

@_transparent
@available(*, unavailable, message: "Use formTruncatingRemainder instead")
public func %=(lhs: inout ${Self}, rhs: ${Self}) {
public func %= (lhs: inout ${Self}, rhs: ${Self}) {
fatalError("%= is not available.")
}

@_transparent
@available(*, unavailable, message: "use += 1")
@discardableResult
public prefix func ++(rhs: inout ${Self}) -> ${Self} {
public prefix func ++ (rhs: inout ${Self}) -> ${Self} {
fatalError("++ is not available")
}
@_transparent
@available(*, unavailable, message: "use -= 1")
@discardableResult
public prefix func --(rhs: inout ${Self}) -> ${Self} {
public prefix func -- (rhs: inout ${Self}) -> ${Self} {
fatalError("-- is not available")
}
@_transparent
@available(*, unavailable, message: "use += 1")
@discardableResult
public postfix func ++(lhs: inout ${Self}) -> ${Self} {
public postfix func ++ (lhs: inout ${Self}) -> ${Self} {
fatalError("++ is not available")
}
@_transparent
@available(*, unavailable, message: "use -= 1")
@discardableResult
public postfix func --(lhs: inout ${Self}) -> ${Self} {
public postfix func -- (lhs: inout ${Self}) -> ${Self} {
fatalError("-- is not available")
}

Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/core/Hashable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
/// return x.hashValue ^ y.hashValue
/// }
///
/// static func ==(lhs: GridPoint, rhs: GridPoint) -> Bool {
/// static func == (lhs: GridPoint, rhs: GridPoint) -> Bool {
/// return lhs.x == rhs.x && lhs.y == rhs.y
/// }
/// }
Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/core/HashedCollections.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -4548,7 +4548,7 @@ internal struct _Cocoa${Self}Index : Comparable {
}

extension _Cocoa${Self}Index {
internal static func ==(
internal static func == (
lhs: _Cocoa${Self}Index,
rhs: _Cocoa${Self}Index
) -> Bool {
Expand All @@ -4560,7 +4560,7 @@ extension _Cocoa${Self}Index {
return lhs.currentKeyIndex == rhs.currentKeyIndex
}

internal static func <(
internal static func < (
lhs: _Cocoa${Self}Index,
rhs: _Cocoa${Self}Index
) -> Bool {
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/core/HeapBuffer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ struct _HeapBuffer<Value, Element> : Equatable {

// HeapBuffers are equal when they reference the same buffer
public // @testable
func == <Value, Element> (
func == <Value, Element>(
lhs: _HeapBuffer<Value, Element>,
rhs: _HeapBuffer<Value, Element>) -> Bool {
return lhs._nativeObject == rhs._nativeObject
Expand Down
8 changes: 4 additions & 4 deletions stdlib/public/core/Index.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,25 @@ public protocol _Incrementable : Equatable {}

@available(*, unavailable, message: "Use \'-= 1\' or call collection.prior(Index)")
@discardableResult
public prefix func -- <T : _Incrementable> (i: inout T) -> T {
public prefix func -- <T : _Incrementable>(i: inout T) -> T {
Builtin.unreachable()
}

@available(*, unavailable, message: "Use \'-= 1\' or call collection.prior(Index)")
@discardableResult
public postfix func -- <T : _Incrementable> (i: inout T) -> T {
public postfix func -- <T : _Incrementable>(i: inout T) -> T {
Builtin.unreachable()
}

@available(*, unavailable, message: "Use \'+= 1\' or call 'collection.index(after: Index)")
@discardableResult
public prefix func ++ <T : _Incrementable> (i: inout T) -> T {
public prefix func ++ <T : _Incrementable>(i: inout T) -> T {
Builtin.unreachable()
}

@available(*, unavailable, message: "Use \'+= 1\' or call 'collection.index(after: Index)")
@discardableResult
public postfix func ++ <T : _Incrementable> (i: inout T) -> T {
public postfix func ++ <T : _Incrementable>(i: inout T) -> T {
Builtin.unreachable()
}

Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/core/Integers.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public func ${x.operator}= <T: ${Protocol}>(lhs: inout T, rhs: T) {
% end

@_transparent
public prefix func -<T: SignedArithmetic>(x: T) -> T {
public prefix func - <T: SignedArithmetic>(x: T) -> T {
return x.negated()
}

Expand Down
Loading