Skip to content

Commit 119f0b4

Browse files
committed
eliminate typealias and name Swift classes to match types from C API
1 parent 7bf307c commit 119f0b4

File tree

1 file changed

+21
-33
lines changed

1 file changed

+21
-33
lines changed

src/swift/Dispatch.swift

Lines changed: 21 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ import CDispatch
3030
// returned from API methods with DISPATCH_RETURNS_RETAINED
3131
//////////
3232

33-
public typealias dispatch_object_t = DispatchObject
34-
public class DispatchObject {
33+
public class dispatch_object_t {
3534
let cobj:OpaquePointer;
3635

3736
deinit {
@@ -43,33 +42,22 @@ public class DispatchObject {
4342
}
4443
}
4544

46-
public typealias dispatch_data_t = DispatchData
47-
public class DispatchData : DispatchObject {
45+
public class dispatch_data_t : dispatch_object_t {
4846
}
4947

50-
51-
public typealias dispatch_group_t = DispatchGroup
52-
public class DispatchGroup : DispatchObject {
48+
public class dispatch_group_t : dispatch_object_t {
5349
}
5450

55-
56-
public typealias dispatch_io_t = DispatchIO
57-
public class DispatchIO : DispatchObject {
51+
public class dispatch_io_t : dispatch_object_t {
5852
}
5953

60-
61-
public typealias dispatch_queue_t = DispatchQueue
62-
public class DispatchQueue : DispatchObject {
54+
public class dispatch_queue_t : dispatch_object_t {
6355
}
6456

65-
66-
public typealias dispatch_semaphore_t = DispatchSemaphore
67-
public class DispatchSemaphore : DispatchObject {
57+
public class dispatch_semaphore_t : dispatch_object_t {
6858
}
6959

70-
71-
public typealias dispatch_source_t = DispatchSource
72-
public class DispatchSource : DispatchObject {
60+
public class dispatch_source_t : dispatch_object_t {
7361
}
7462

7563
//////////
@@ -175,7 +163,7 @@ public var DISPATCH_QUEUE_PRIORITY_BACKGROUND: dispatch_queue_priority_t {
175163
}
176164

177165
public func dispatch_get_global_queue(identifier:Int, _ flags:UInt) -> dispatch_queue_t {
178-
return DispatchQueue(CDispatch.dispatch_get_global_queue(identifier, flags))
166+
return dispatch_queue_t(CDispatch.dispatch_get_global_queue(identifier, flags))
179167
}
180168

181169
// skip dispatch_queue_attr_make_with_qos_class; no QoS on Linux
@@ -191,7 +179,7 @@ public var DISPATCH_QUEUE_CONCURRENT: dispatch_queue_attr_t {
191179

192180
public func dispatch_queue_create(label:UnsafePointer<Int8>,
193181
_ attr:dispatch_queue_attr_t) -> dispatch_queue_t {
194-
return DispatchQueue(CDispatch.dispatch_queue_create(label, attr))
182+
return dispatch_queue_t(CDispatch.dispatch_queue_create(label, attr))
195183
}
196184

197185
public var DISPATCH_CURRENT_QUEUE_LABEL: dispatch_queue_t? {
@@ -362,7 +350,7 @@ public func dispatch_source_create(type:dispatch_source_type_t,
362350
_ mask:UInt,
363351
_ queue:dispatch_queue_t?) -> dispatch_source_t {
364352
let cqueue = queue != nil ? queue!.cobj : nil
365-
return DispatchSource(CDispatch.dispatch_source_create(type, handle, mask, cqueue))
353+
return dispatch_source_t(CDispatch.dispatch_source_create(type, handle, mask, cqueue))
366354
}
367355

368356
public func dispatch_source_set_event_handler(source:dispatch_source_t,
@@ -416,7 +404,7 @@ public func dispatch_source_set_registration_handler(source:dispatch_source_t,
416404
//////////
417405

418406
public func dispatch_group_create() -> dispatch_group_t {
419-
return DispatchGroup(CDispatch.dispatch_group_create())
407+
return dispatch_group_t(CDispatch.dispatch_group_create())
420408
}
421409

422410
public func dispatch_group_async(group:dispatch_group_t, _ queue:dispatch_queue_t,
@@ -447,7 +435,7 @@ public func dispatch_group_leave(group:dispatch_group_t) -> Void {
447435

448436
public func dispatch_semaphore_create(value:Int) -> dispatch_semaphore_t? {
449437
let csem = CDispatch.dispatch_semaphore_create(value)
450-
return csem != nil ? DispatchSemaphore(csem) : nil
438+
return csem != nil ? dispatch_semaphore_t(csem) : nil
451439
}
452440

453441
public func dispatch_semaphore_wait(dsema:dispatch_semaphore_t, _ timeout:dispatch_time_t) -> Int {
@@ -476,7 +464,7 @@ public var dispatch_data_empty: dispatch_data_t {
476464

477465
public func dispatch_data_create(buffer:UnsafePointer<Void>, _ size:size_t,
478466
_ queue:dispatch_queue_t, _ destructor:dispatch_block_t?) -> dispatch_data_t {
479-
return DispatchData(CDispatch.dispatch_data_create(buffer, size, queue.cobj, destructor))
467+
return dispatch_data_t(CDispatch.dispatch_data_create(buffer, size, queue.cobj, destructor))
480468
}
481469

482470
public func dispatch_data_get_size(data:dispatch_data_t)-> size_t {
@@ -486,24 +474,24 @@ public func dispatch_data_get_size(data:dispatch_data_t)-> size_t {
486474
public func dispatch_data_create_map(data:dispatch_data_t,
487475
_ buffer_ptr:UnsafeMutablePointer<UnsafePointer<Void>>,
488476
_ size_ptr:UnsafeMutablePointer<size_t>) -> dispatch_data_t {
489-
return DispatchData(CDispatch.dispatch_data_create_map(data.cobj, buffer_ptr, size_ptr))
477+
return dispatch_data_t(CDispatch.dispatch_data_create_map(data.cobj, buffer_ptr, size_ptr))
490478
}
491479

492480
public func dispatch_data_create_concat(data1:dispatch_data_t, _ data2:dispatch_data_t)->dispatch_data_t {
493-
return DispatchData(CDispatch.dispatch_data_create_concat(data1.cobj, data2.cobj))
481+
return dispatch_data_t(CDispatch.dispatch_data_create_concat(data1.cobj, data2.cobj))
494482
}
495483

496484
public func dispatch_data_create_subrange(data:dispatch_data_t,
497485
_ offset:size_t, _ length:size_t) -> dispatch_data_t {
498-
return DispatchData(CDispatch.dispatch_data_create_subrange(data.cobj, offset, length))
486+
return dispatch_data_t(CDispatch.dispatch_data_create_subrange(data.cobj, offset, length))
499487
}
500488

501489
// TODO: defer dispatch_data_applier_t/dispatch_data_apply
502490
// a little unclear how best to unwrap/wrap within the block.
503491

504492
public func dispatch_data_copy_region(data:dispatch_data_t, _ location:size_t,
505493
_ offset_ptr:UnsafeMutablePointer<size_t>) -> dispatch_data_t {
506-
return DispatchData(CDispatch.dispatch_data_copy_region(data.cobj, location, offset_ptr))
494+
return dispatch_data_t(CDispatch.dispatch_data_copy_region(data.cobj, location, offset_ptr))
507495
}
508496

509497
//////////
@@ -531,22 +519,22 @@ public func dispatch_io_create(type:dispatch_io_type_t,
531519
_ fd:dispatch_fd_t,
532520
_ queue:dispatch_queue_t,
533521
_ cleanup_handler:dispatch_io_handler_block_t) -> dispatch_io_t {
534-
return DispatchIO(CDispatch.dispatch_io_create(type, fd, queue.cobj, cleanup_handler))
522+
return dispatch_io_t(CDispatch.dispatch_io_create(type, fd, queue.cobj, cleanup_handler))
535523
}
536524

537525
public func dispatch_io_create_with_path(type:dispatch_io_type_t,
538526
_ path:UnsafePointer<Int8>,
539527
_ oflag:Int32, _ mode:mode_t,
540528
_ queue:dispatch_queue_t,
541529
_ cleanup_handler:dispatch_io_handler_block_t) -> dispatch_io_t {
542-
return DispatchIO(CDispatch.dispatch_io_create_with_path(type, path, oflag, mode, queue.cobj, cleanup_handler))
530+
return dispatch_io_t(CDispatch.dispatch_io_create_with_path(type, path, oflag, mode, queue.cobj, cleanup_handler))
543531
}
544532

545533
public func dispatch_io_create_with_io(type:dispatch_io_type_t,
546534
_ io:dispatch_io_t,
547535
_ queue:dispatch_queue_t,
548536
_ cleanup_handler:dispatch_io_handler_block_t) -> dispatch_io_t {
549-
return DispatchIO(CDispatch.dispatch_io_create_with_io(type, io.cobj, queue.cobj, cleanup_handler))
537+
return dispatch_io_t(CDispatch.dispatch_io_create_with_io(type, io.cobj, queue.cobj, cleanup_handler))
550538
}
551539

552540
// TODO: dispatch_io_handler_t (dispatch_data_t in block...)
@@ -598,7 +586,7 @@ public func dispatch_io_set_interval(channel:dispatch_io_t,
598586
// Internal macros and helper functions. Not part of the exported API
599587
//===----------------------------------------------------------------------===//
600588

601-
internal let mainQueue:dispatch_queue_t = DispatchQueue(CDispatch.dispatch_get_main_queue())
589+
internal let mainQueue:dispatch_queue_t = dispatch_queue_t(CDispatch.dispatch_get_main_queue())
602590

603591
@_silgen_name("_swift_dispatch_object_type_punner")
604592
internal func _to_dot(x:OpaquePointer) -> CDispatch.dispatch_object_t

0 commit comments

Comments
 (0)