Skip to content

Commit

Permalink
stdlib: fix coding style
Browse files Browse the repository at this point in the history
Swift SVN r32425
  • Loading branch information
gribozavr committed Oct 3, 2015
1 parent f7005d5 commit 6536edd
Show file tree
Hide file tree
Showing 37 changed files with 181 additions and 141 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public let partitionExhaustiveTests = [
PartitionExhaustiveTest([ 10, 20, 30, 40, 50, 60, 70 ]),
]

public func withInvalidOrderings(body: ((Int,Int) -> Bool) -> ()) {
public func withInvalidOrderings(body: ((Int,Int) -> Bool) -> Void) {
// Test some ordering predicates that don't create strict weak orderings
body { (_,_) in true }
body { (_,_) in false }
Expand Down
2 changes: 1 addition & 1 deletion stdlib/private/StdlibUnittest/LoggingWrappers.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ public struct Logging${Kind}<Base: ${Kind}Type> : ${Kind}Type, LoggingType {
}

public func forEach(
@noescape body: (Base.Generator.Element) throws -> ()
@noescape body: (Base.Generator.Element) throws -> Void
) rethrows {
++Log.forEach[selfType]
try base.forEach(body)
Expand Down
7 changes: 4 additions & 3 deletions stdlib/private/StdlibUnittest/RaceTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import Glibc
#if _runtime(_ObjC)
import ObjectiveC
#else
func autoreleasepool(@noescape code: () -> ()) {
func autoreleasepool(@noescape code: () -> Void) {
// Native runtime does not have autorelease pools. Execute the code
// directly.
code()
Expand Down Expand Up @@ -92,8 +92,9 @@ public protocol RaceTestWithPerTrialDataType {

/// Evaluates the observations made by all threads for a particular instance
/// of `RaceData`.
func evaluateObservations(observations: [Observation],
_ sink: (RaceTestObservationEvaluation) -> ())
func evaluateObservations(
observations: [Observation],
_ sink: (RaceTestObservationEvaluation) -> Void)
}

/// The result of evaluating observations.
Expand Down
6 changes: 3 additions & 3 deletions stdlib/private/StdlibUnittest/StdlibCoreExtras.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ extension TypeIdentifier
func _forAllPermutationsImpl(
index: Int, _ size: Int,
inout _ perm: [Int], inout _ visited: [Bool],
_ body: ([Int]) -> ()
_ body: ([Int]) -> Void
) {
if index == size {
body(perm)
Expand All @@ -156,7 +156,7 @@ func _forAllPermutationsImpl(
}

/// Generate all permutations.
public func forAllPermutations(size: Int, body: ([Int]) -> ()) {
public func forAllPermutations(size: Int, body: ([Int]) -> Void) {
if size == 0 {
return
}
Expand All @@ -168,7 +168,7 @@ public func forAllPermutations(size: Int, body: ([Int]) -> ()) {

/// Generate all permutations.
public func forAllPermutations<S : SequenceType>(
sequence: S, body: ([S.Generator.Element]) -> ()
sequence: S, body: ([S.Generator.Element]) -> Void
) {
let data = Array(sequence)
forAllPermutations(data.count) {
Expand Down
22 changes: 11 additions & 11 deletions stdlib/private/StdlibUnittest/StdlibUnittest.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ var _seenExpectCrash = false
/// Run `body` and expect a failure to happen.
///
/// The check passes iff `body` triggers one or more failures.
public func expectFailure(${TRACE1}, body: () -> ()) {
public func expectFailure(${TRACE1}, body: () -> Void) {
let startAnyExpectFailed = _anyExpectFailed
_anyExpectFailed = false
body()
Expand Down Expand Up @@ -399,9 +399,9 @@ func _defaultTestSuiteFailedCallback() {
abort()
}

var _testSuiteFailedCallback: () -> () = _defaultTestSuiteFailedCallback
var _testSuiteFailedCallback: () -> Void = _defaultTestSuiteFailedCallback

public func _setTestSuiteFailedCallback(callback: () -> ()) {
public func _setTestSuiteFailedCallback(callback: () -> Void) {
_testSuiteFailedCallback = callback
}

Expand Down Expand Up @@ -828,8 +828,8 @@ public class TestSuite {
public func test(
name: String,
file: String = __FILE__, line: UInt = __LINE__,
_ testFunction: () -> ()) {
_ testFunction: () -> Void
) {
_TestBuilder(testSuite: self, name: name, loc: SourceLoc(file, line))
.code(testFunction)
}
Expand All @@ -840,12 +840,12 @@ public class TestSuite {
return _TestBuilder(testSuite: self, name: name, loc: SourceLoc(file, line))
}

public func setUp(code: () -> ()) {
public func setUp(code: () -> Void) {
_precondition(_testSetUpCode == nil, "set-up code already set")
_testSetUpCode = code
}

public func tearDown(code: () -> ()) {
public func tearDown(code: () -> Void) {
_precondition(_testTearDownCode == nil, "tear-down code already set")
_testTearDownCode = code
}
Expand Down Expand Up @@ -880,7 +880,7 @@ public class TestSuite {
let stdinText: String?
let stdinEndsWithEOF: Bool
let crashOutputMatches: [String]
let code: () -> ()
let code: () -> Void

/// Whether the test harness should stop reusing the child process after
/// running this test.
Expand Down Expand Up @@ -938,7 +938,7 @@ public class TestSuite {
return self
}

public func code(testFunction: () -> ()) {
public func code(testFunction: () -> Void) {
_testSuite._tests.append(
_Test(
name: _name, testLoc: _data._testLoc!, xfail: _data._xfail,
Expand All @@ -954,10 +954,10 @@ public class TestSuite {
var _tests: [_Test] = []

/// Code that is run before every test.
var _testSetUpCode: (() -> ())?
var _testSetUpCode: (() -> Void)?

/// Code that is run after every test.
var _testTearDownCode: (() -> ())?
var _testTearDownCode: (() -> Void)?

/// Maps test name to index in `_tests`.
var _testNameToIndex: [String : Int] = [:]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public func withOverriddenNSLocaleCurrentLocale<Result>(
/// return-autoreleased optimization.)
@inline(never)
public func autoreleasepoolIfUnoptimizedReturnAutoreleased(
@noescape body: () -> ()
@noescape body: () -> Void
) {
#if arch(i386) && (os(iOS) || os(watchOS))
autoreleasepool(body)
Expand Down
2 changes: 1 addition & 1 deletion stdlib/private/SwiftPrivate/IO.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public struct _FDOutputStream : OutputStreamType {
public mutating func write(string: String) {
let utf8 = string.nulTerminatedUTF8
utf8.withUnsafeBufferPointer {
(utf8) -> () in
(utf8) -> Void in
var writtenBytes = 0
let bufferSize = utf8.count - 1
while writtenBytes != bufferSize {
Expand Down
6 changes: 3 additions & 3 deletions stdlib/public/SDK/Foundation/Foundation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1227,16 +1227,16 @@ extension NSDictionary {
internal func NS_Swift_NSUndoManager_registerUndoWithTargetHandler(
self_: AnyObject,
_ target: AnyObject,
_ handler: @convention(block) AnyObject -> ())
_ handler: @convention(block) (AnyObject) -> Void)

extension NSUndoManager {
@available(OSX 10.11, iOS 9.0, *)
public func registerUndoWithTarget<TargetType : AnyObject>(
target: TargetType, handler: TargetType -> ()
target: TargetType, handler: (TargetType) -> Void
) {
// The generic blocks use a different ABI, so we need to wrap the provided
// handler in something ObjC compatible.
let objcCompatibleHandler: AnyObject -> () = { internalTarget in
let objcCompatibleHandler: (AnyObject) -> Void = { internalTarget in
handler(internalTarget as! TargetType)
}
NS_Swift_NSUndoManager_registerUndoWithTargetHandler(
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/SDK/ObjectiveC/ObjectiveC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func __pushAutoreleasePool() -> COpaquePointer
@asmname("objc_autoreleasePoolPop")
func __popAutoreleasePool(pool: COpaquePointer)

public func autoreleasepool(@noescape code: () -> ()) {
public func autoreleasepool(@noescape code: () -> Void) {
let pool = __pushAutoreleasePool()
code()
__popAutoreleasePool(pool)
Expand Down
12 changes: 6 additions & 6 deletions stdlib/public/core/AssertCommon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ func _assertionFailed(
_ file: StaticString, _ line: UInt
) {
prefix.withUTF8Buffer {
(prefix) -> () in
(prefix) -> Void in
message.withUTF8Buffer {
(message) -> () in
(message) -> Void in
file.withUTF8Buffer {
(file) -> () in
(file) -> Void in
_reportFatalErrorInFile(
prefix.baseAddress, UInt(prefix.count),
message.baseAddress, UInt(message.count),
Expand All @@ -124,12 +124,12 @@ func _assertionFailed(
_ file: StaticString, _ line: UInt
) {
prefix.withUTF8Buffer {
(prefix) -> () in
(prefix) -> Void in
let messageUTF8 = message.nulTerminatedUTF8
messageUTF8.withUnsafeBufferPointer {
(messageUTF8) -> () in
(messageUTF8) -> Void in
file.withUTF8Buffer {
(file) -> () in
(file) -> Void in
_reportFatalErrorInFile(
prefix.baseAddress, UInt(prefix.count),
messageUTF8.baseAddress, UInt(messageUTF8.count),
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 @@ -37,7 +37,7 @@ public struct Character :
var asInt: UInt64 = 0
var shift: UInt64 = 0

let output: (UTF8.CodeUnit) -> () = {
let output: (UTF8.CodeUnit) -> Void = {
asInt |= UInt64($0) << shift
shift += 8
}
Expand Down Expand Up @@ -204,7 +204,7 @@ public struct Character :
_sanityCheck(count <= 4, "Character with more than 4 UTF-16 code units")
self.count = UInt16(count)
var u16: UInt64 = 0
let output: (UTF16.CodeUnit) -> () = {
let output: (UTF16.CodeUnit) -> Void = {
u16 = u16 << 16
u16 = u16 | UInt64($0)
}
Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/core/CollectionAlgorithms.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ ${orderingRequirementForComparable}
public mutating func sortInPlace() {
let didSortUnsafeBuffer: Void? =
_withUnsafeMutableBufferPointerIfSupported {
(baseAddress, count) -> () in
(baseAddress, count) -> Void in
var bufferPointer =
UnsafeMutableBufferPointer(start: baseAddress, count: count)
bufferPointer.sortInPlace()
Expand Down Expand Up @@ -288,7 +288,7 @@ ${orderingRequirementForPredicate}

let didSortUnsafeBuffer: Void? =
_withUnsafeMutableBufferPointerIfSupported {
(baseAddress, count) -> () in
(baseAddress, count) -> Void in
var bufferPointer =
UnsafeMutableBufferPointer(start: baseAddress, count: count)
bufferPointer.sortInPlace(escapableIsOrderedBefore)
Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/core/Sequence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public protocol SequenceType {
/// skip subsequent calls.
///
/// - Complexity: O(`self.count`)
func forEach(@noescape body: (Generator.Element) throws -> ()) rethrows
func forEach(@noescape body: (Generator.Element) throws -> Void) rethrows

/// Returns a subsequence containing all but the first `n` elements.
///
Expand Down Expand Up @@ -575,7 +575,7 @@ extension SequenceType {
///
/// - Complexity: O(`self.count`)
public func forEach(
@noescape body: (Generator.Element) throws -> ()
@noescape body: (Generator.Element) throws -> Void
) rethrows {
for element in self {
try body(element)
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/core/StaticString.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public struct StaticString
} else {
var buffer: UInt64 = 0
var i = 0
let sink: (UInt8) -> () = {
let sink: (UInt8) -> Void = {
buffer = buffer | (UInt64($0) << (UInt64(i) * 8))
++i
}
Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/core/String.swift
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ extension String {
Encoding: UnicodeCodecType
>(encoding: Encoding.Type) -> Int {
var codeUnitCount = 0
let output: (Encoding.CodeUnit) -> () = { _ in ++codeUnitCount }
let output: (Encoding.CodeUnit) -> Void = { _ in ++codeUnitCount }
self._encode(encoding, output: output)
return codeUnitCount
}
Expand All @@ -286,7 +286,7 @@ extension String {
// with unpaired surrogates
func _encode<
Encoding: UnicodeCodecType
>(encoding: Encoding.Type, output: (Encoding.CodeUnit) -> ())
>(encoding: Encoding.Type, output: (Encoding.CodeUnit) -> Void)
{
return _core.encode(encoding, output: output)
}
Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/core/StringBuffer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public struct _StringBuffer {

if isAscii {
var p = UnsafeMutablePointer<UTF8.CodeUnit>(result.start)
let sink: (UTF32.CodeUnit) -> () = {
let sink: (UTF32.CodeUnit) -> Void = {
(p++).memory = UTF8.CodeUnit($0)
}
let hadError = transcode(
Expand All @@ -116,7 +116,7 @@ public struct _StringBuffer {
}
else {
var p = result._storage.baseAddress
let sink: (UTF16.CodeUnit) -> () = {
let sink: (UTF16.CodeUnit) -> Void = {
(p++).memory = $0
}
let hadError = transcode(
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/core/StringCore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ public struct _StringCore {
/// Write the string, in the given encoding, to output.
func encode<
Encoding: UnicodeCodecType
>(encoding: Encoding.Type, output: (Encoding.CodeUnit) -> ())
>(encoding: Encoding.Type, output: (Encoding.CodeUnit) -> Void)
{
if _fastPath(_baseAddress != nil) {
if _fastPath(elementWidth == 1) {
Expand Down
20 changes: 14 additions & 6 deletions stdlib/public/core/Unicode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public protocol UnicodeCodecType {

/// Encode a `UnicodeScalar` as a series of `CodeUnit`s by
/// calling `output` on each `CodeUnit`.
static func encode(input: UnicodeScalar, output: (CodeUnit) -> ())
static func encode(input: UnicodeScalar, output: (CodeUnit) -> Void)
}

/// A codec for [UTF-8](http://www.unicode.org/glossary/#UTF_8).
Expand Down Expand Up @@ -444,7 +444,10 @@ public struct UTF8 : UnicodeCodecType {

/// Encode a `UnicodeScalar` as a series of `CodeUnit`s by
/// calling `output` on each `CodeUnit`.
public static func encode(input: UnicodeScalar, output put: (CodeUnit) -> ()) {
public static func encode(
input: UnicodeScalar,
output put: (CodeUnit) -> Void
) {
var c = UInt32(input)
var buf3 = UInt8(c & 0xFF)

Expand Down Expand Up @@ -610,7 +613,10 @@ public struct UTF16 : UnicodeCodecType {

/// Encode a `UnicodeScalar` as a series of `CodeUnit`s by
/// calling `output` on each `CodeUnit`.
public static func encode(input: UnicodeScalar, output put: (CodeUnit) -> ()) {
public static func encode(
input: UnicodeScalar,
output put: (CodeUnit) -> Void
) {
let scalarValue: UInt32 = UInt32(input)

if scalarValue <= UInt32(UInt16.max) {
Expand Down Expand Up @@ -665,8 +671,10 @@ public struct UTF32 : UnicodeCodecType {

/// Encode a `UnicodeScalar` as a series of `CodeUnit`s by
/// calling `output` on each `CodeUnit`.
public static func encode(input: UnicodeScalar,
output put: (CodeUnit) -> ()) {
public static func encode(
input: UnicodeScalar,
output put: (CodeUnit) -> Void
) {
put(UInt32(input))
}
}
Expand All @@ -683,7 +691,7 @@ public func transcode<
OutputEncoding : UnicodeCodecType
where InputEncoding.CodeUnit == Input.Element>(
inputEncoding: InputEncoding.Type, _ outputEncoding: OutputEncoding.Type,
var _ input: Input, _ output: (OutputEncoding.CodeUnit) -> (),
var _ input: Input, _ output: (OutputEncoding.CodeUnit) -> Void,
stopOnError: Bool
) -> Bool {

Expand Down
Loading

0 comments on commit 6536edd

Please sign in to comment.