Skip to content

Commit e695360

Browse files
committed
move interopChild checks into State
change interop variables into an enum reorder interopType switch statements move interop switch-case into enum change Throughput and fileURL Summary types remove old unused calls introduce terminate method requirement + rewrite implementation for additional property change additional property string summary to [String] change string type to use String? and [String?] add propertiesURL as available additional property type formatting for readability add propertiesUInt64 as available additional property type deinit test for additional properties + fix for deinit fractionCompleted calculation edit test to test deinit behavior for EstimatedTimeRemaining replace redundant deinit complete(count:) call with mark dirty + add tests for deinit bahavior more deinit tests additional unit tests for deinit behavior separate string additional properties into retaining vs non-retaining version add custom URL property unit tests add custom UInt64 property unit tests update documentation for additional properties methods updated initializer draft additional property observation fix establish keypaths for fileCount + rename terminate to finalSummary add observationRegistrar access calls add observationRegistrar withMutation calls add accessObservation to withProperties remove fileURL Enhancements for Additional Properties
1 parent e0d4db7 commit e695360

10 files changed

+1335
-653
lines changed

Sources/FoundationEssentials/ProgressManager/ProgressManager+Interop.swift

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,56 @@ extension ProgressManager {
220220
var reporterBridge: ProgressReporterBridge?
221221
var nsProgressBridge: Foundation.Progress?
222222
}
223+
224+
internal enum InteropType {
225+
case interopMirror(ProgressManager)
226+
case interopObservation(InteropObservation)
227+
228+
internal var totalCount: Int? {
229+
switch self {
230+
case .interopMirror(let mirror):
231+
mirror.totalCount
232+
case .interopObservation:
233+
nil
234+
}
235+
}
236+
237+
internal var completedCount: Int? {
238+
switch self {
239+
case .interopMirror(let mirror):
240+
mirror.completedCount
241+
case .interopObservation:
242+
nil
243+
}
244+
}
245+
246+
internal var fractionCompleted: Double? {
247+
switch self {
248+
case .interopMirror(let mirror):
249+
mirror.fractionCompleted
250+
case .interopObservation:
251+
nil
252+
}
253+
}
254+
255+
internal var isIndeterminate: Bool? {
256+
switch self {
257+
case .interopMirror(let mirror):
258+
mirror.isIndeterminate
259+
case .interopObservation:
260+
nil
261+
}
262+
}
263+
264+
internal var isFinished: Bool? {
265+
switch self {
266+
case .interopMirror(let mirror):
267+
mirror.isFinished
268+
case .interopObservation:
269+
nil
270+
}
271+
}
272+
}
223273
}
224274

225275
extension ProgressManager.State {
@@ -251,19 +301,23 @@ extension ProgressManager {
251301

252302
internal func addBridge(reporterBridge: ProgressReporterBridge? = nil, nsProgressBridge: Foundation.Progress? = nil) {
253303
state.withLock { state in
304+
var interopObservation = InteropObservation(subprogressBridge: nil)
305+
254306
if let reporterBridge {
255-
state.interopObservation.reporterBridge = reporterBridge
307+
interopObservation.reporterBridge = reporterBridge
256308
}
257309

258310
if let nsProgressBridge {
259-
state.interopObservation.nsProgressBridge = nsProgressBridge
311+
interopObservation.nsProgressBridge = nsProgressBridge
260312
}
313+
314+
state.interopType = .interopObservation(interopObservation)
261315
}
262316
}
263317

264-
internal func setInteropChild(interopChild: ProgressManager) {
318+
internal func setInteropChild(interopMirror: ProgressManager) {
265319
state.withLock { state in
266-
state.interopChild = interopChild
320+
state.interopType = .interopMirror(interopMirror)
267321
}
268322
}
269323
}

0 commit comments

Comments
 (0)