Skip to content

Fixed the tuple label error #131

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

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 2 additions & 2 deletions src/swift/Data.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ public struct DispatchData : RandomAccessCollection {
}

public func enumerateBytes(
block: @noescape (_ buffer: UnsafeBufferPointer<UInt8>, _ byteIndex: Int, _ stop: inout Bool) -> Void)
block: @noescape ( buffer: UnsafeBufferPointer<UInt8>, byteIndex: Int, stop: inout Bool) -> Void)
{
_swift_dispatch_data_apply(__wrapped.__wrapped) { (data: dispatch_data_t, offset: Int, ptr: UnsafeRawPointer, size: Int) in
let bytePtr = ptr.bindMemory(to: UInt8.self, capacity: size)
let bp = UnsafeBufferPointer(start: bytePtr, count: size)
var stop = false
block(bp, offset, &stop)
block(buffer: bp, byteIndex: offset, stop: &stop)
return !stop
}
}
Expand Down
22 changes: 11 additions & 11 deletions src/swift/IO.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,23 @@ public extension DispatchIO {
public static let strictInterval = IntervalFlags(rawValue: 1)
}

public class func read(fromFileDescriptor: Int32, maxLength: Int, runningHandlerOn queue: DispatchQueue, handler: (_ data: DispatchData, _ error: Int32) -> Void) {
public class func read(fromFileDescriptor: Int32, maxLength: Int, runningHandlerOn queue: DispatchQueue, handler: ( data: DispatchData, error: Int32) -> Void) {
dispatch_read(fromFileDescriptor, maxLength, queue.__wrapped) { (data: dispatch_data_t, error: Int32) in
handler(DispatchData(data: data), error)
handler(data: DispatchData(data: data), error: error)
}
}

public class func write(toFileDescriptor: Int32, data: DispatchData, runningHandlerOn queue: DispatchQueue, handler: (_ data: DispatchData?, _ error: Int32) -> Void) {
public class func write(toFileDescriptor: Int32, data: DispatchData, runningHandlerOn queue: DispatchQueue, handler: ( data: DispatchData?, error: Int32) -> Void) {
dispatch_write(toFileDescriptor, data.__wrapped.__wrapped, queue.__wrapped) { (data: dispatch_data_t?, error: Int32) in
handler(data.flatMap { DispatchData(data: $0) }, error)
handler(data: data.flatMap { DispatchData(data: $0) }, error: error)
}
}

public convenience init(
type: StreamType,
fileDescriptor: Int32,
queue: DispatchQueue,
cleanupHandler: (_ error: Int32) -> Void)
cleanupHandler: ( error: Int32) -> Void)
{
self.init(__type: type.rawValue, fd: fileDescriptor, queue: queue, handler: cleanupHandler)
}
Expand All @@ -61,7 +61,7 @@ public extension DispatchIO {
oflag: Int32,
mode: mode_t,
queue: DispatchQueue,
cleanupHandler: (_ error: Int32) -> Void)
cleanupHandler: ( error: Int32) -> Void)
{
self.init(__type: type.rawValue, path: path, oflag: oflag, mode: mode, queue: queue, handler: cleanupHandler)
}
Expand All @@ -70,20 +70,20 @@ public extension DispatchIO {
type: StreamType,
io: DispatchIO,
queue: DispatchQueue,
cleanupHandler: (_ error: Int32) -> Void)
cleanupHandler: ( error: Int32) -> Void)
{
self.init(__type: type.rawValue, io: io, queue: queue, handler: cleanupHandler)
}

public func read(offset: off_t, length: Int, queue: DispatchQueue, ioHandler: (_ done: Bool, _ data: DispatchData?, _ error: Int32) -> Void) {
public func read(offset: off_t, length: Int, queue: DispatchQueue, ioHandler: ( done: Bool, data: DispatchData?, error: Int32) -> Void) {
dispatch_io_read(self.__wrapped, offset, length, queue.__wrapped) { (done: Bool, data: dispatch_data_t?, error: Int32) in
ioHandler(done, data.flatMap { DispatchData(data: $0) }, error)
ioHandler(done: done, data: data.flatMap { DispatchData(data: $0) }, error: error)
}
}

public func write(offset: off_t, data: DispatchData, queue: DispatchQueue, ioHandler: (_ done: Bool, _ data: DispatchData?, _ error: Int32) -> Void) {
public func write(offset: off_t, data: DispatchData, queue: DispatchQueue, ioHandler: ( done: Bool, data: DispatchData?, error: Int32) -> Void) {
dispatch_io_write(self.__wrapped, offset, data.__wrapped.__wrapped, queue.__wrapped) { (done: Bool, data: dispatch_data_t?, error: Int32) in
ioHandler(done, data.flatMap { DispatchData(data: $0) }, error)
ioHandler(done: done, data: data.flatMap { DispatchData(data: $0) }, error: error)
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/swift/Wrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,17 @@ public class DispatchIO : DispatchObject {
}

internal init(__type: UInt, fd: Int32, queue: DispatchQueue,
handler: (_ error: Int32) -> Void) {
handler: (error: Int32) -> Void) {
__wrapped = dispatch_io_create(__type, fd, queue.__wrapped, handler)
}

internal init(__type: UInt, path: UnsafePointer<Int8>, oflag: Int32,
mode: mode_t, queue: DispatchQueue, handler: (_ error: Int32) -> Void) {
mode: mode_t, queue: DispatchQueue, handler: (error: Int32) -> Void) {
__wrapped = dispatch_io_create_with_path(__type, path, oflag, mode, queue.__wrapped, handler)
}

internal init(__type: UInt, io: DispatchIO,
queue: DispatchQueue, handler: (_ error: Int32) -> Void) {
queue: DispatchQueue, handler: (error: Int32) -> Void) {
__wrapped = dispatch_io_create_with_io(__type, io.__wrapped, queue.__wrapped, handler)
}

Expand Down