Skip to content

Commit 12988a5

Browse files
committed
rename properties inside State
1 parent 24efaaf commit 12988a5

File tree

6 files changed

+311
-304
lines changed

6 files changed

+311
-304
lines changed

Sources/FoundationEssentials/ProgressManager/ProgressManager+Interop.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ extension ProgressManager {
108108
let progressBridge = NSProgressBridge(
109109
manager: self,
110110
progress: progress,
111-
portion: count
111+
assignedCount: count
112112
)
113113

114114
// Add bridge as a parent
@@ -177,7 +177,7 @@ internal final class NSProgressBridge: Progress, @unchecked Sendable {
177177
internal let managerBridge: ProgressManager
178178
internal let progress: Progress
179179

180-
init(manager: ProgressManager, progress: Progress, portion: Int) {
180+
init(manager: ProgressManager, progress: Progress, assignedCount: Int) {
181181
self.manager = manager
182182
self.managerBridge = ProgressManager(totalCount: Int(clamping: progress.totalUnitCount))
183183
self.progress = progress
@@ -188,11 +188,11 @@ internal final class NSProgressBridge: Progress, @unchecked Sendable {
188188
}
189189

190190
let position = manager.addChild(
191-
child: managerBridge,
192-
portion: portion,
191+
childManager: managerBridge,
192+
assignedCount: assignedCount,
193193
childFraction: ProgressFraction(completed: Int(clamping: completedUnitCount), total: Int(clamping: totalUnitCount))
194194
)
195-
managerBridge.addParent(parent: manager, positionInParent: position)
195+
managerBridge.addParent(parentManager: manager, positionInParent: position)
196196
}
197197

198198
// Overrides the _updateChild func that Foundation.Progress calls to update parent

Sources/FoundationEssentials/ProgressManager/ProgressManager+Properties+Accessors.swift

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ extension ProgressManager {
7676
} else if P.self == ProgressManager.Properties.CompletedFileCount.self {
7777
return state.completedFileCount
7878
} else {
79-
return state.propertiesInt[MetatypeWrapper(P.self)] ?? P.defaultValue
79+
return state.customPropertiesInt[MetatypeWrapper(P.self)] ?? P.defaultValue
8080
}
8181
}
8282
}
8383

8484
set {
85-
var parents: [ParentState]?
85+
var parents: [Parent]?
8686
if P.self == ProgressManager.Properties.TotalFileCount.self {
8787
self.withMutation(keyPath: \.totalFileCount) {
8888
parents = state.withLock { state in
@@ -106,10 +106,10 @@ extension ProgressManager {
106106
} else {
107107
self.withMutation(keyPath: \.additionalPropertiesSink) {
108108
parents = state.withLock { state in
109-
guard newValue != state.propertiesInt[MetatypeWrapper(P.self)] else {
109+
guard newValue != state.customPropertiesInt[MetatypeWrapper(P.self)] else {
110110
return nil
111111
}
112-
state.propertiesInt[MetatypeWrapper(P.self)] = newValue
112+
state.customPropertiesInt[MetatypeWrapper(P.self)] = newValue
113113
return state.parents
114114
}
115115
}
@@ -149,13 +149,13 @@ extension ProgressManager {
149149
} else if P.self == ProgressManager.Properties.CompletedByteCount.self {
150150
return state.completedByteCount
151151
} else {
152-
return state.propertiesUInt64[MetatypeWrapper(P.self)] ?? P.defaultValue
152+
return state.customPropertiesUInt64[MetatypeWrapper(P.self)] ?? P.defaultValue
153153
}
154154
}
155155
}
156156

157157
set {
158-
var parents: [ParentState]?
158+
var parents: [Parent]?
159159
if P.self == ProgressManager.Properties.TotalByteCount.self {
160160
self.withMutation(keyPath: \.totalByteCount) {
161161
parents = state.withLock { state in
@@ -179,10 +179,10 @@ extension ProgressManager {
179179
} else {
180180
self.withMutation(keyPath: \.additionalPropertiesSink) {
181181
parents = state.withLock { state in
182-
guard newValue != state.propertiesUInt64[MetatypeWrapper(P.self)] else {
182+
guard newValue != state.customPropertiesUInt64[MetatypeWrapper(P.self)] else {
183183
return nil
184184
}
185-
state.propertiesUInt64[MetatypeWrapper(P.self)] = newValue
185+
state.customPropertiesUInt64[MetatypeWrapper(P.self)] = newValue
186186
return state.parents
187187
}
188188
}
@@ -211,18 +211,18 @@ extension ProgressManager {
211211
get {
212212
self.access(keyPath: \.additionalPropertiesSink)
213213
return state.withLock { state in
214-
return state.propertiesDouble[MetatypeWrapper(P.self)] ?? P.defaultValue
214+
return state.customPropertiesDouble[MetatypeWrapper(P.self)] ?? P.defaultValue
215215
}
216216
}
217217

218218
set {
219-
var parents: [ParentState]?
219+
var parents: [Parent]?
220220
self.withMutation(keyPath: \.additionalPropertiesSink) {
221221
parents = state.withLock { state in
222-
guard newValue != state.propertiesDouble[MetatypeWrapper(P.self)] else {
222+
guard newValue != state.customPropertiesDouble[MetatypeWrapper(P.self)] else {
223223
return nil
224224
}
225-
state.propertiesDouble[MetatypeWrapper(P.self)] = newValue
225+
state.customPropertiesDouble[MetatypeWrapper(P.self)] = newValue
226226
return state.parents
227227
}
228228
}
@@ -244,18 +244,18 @@ extension ProgressManager {
244244
get {
245245
self.access(keyPath: \.additionalPropertiesSink)
246246
return state.withLock { state in
247-
return state.propertiesString[MetatypeWrapper(P.self)] ?? P.defaultValue
247+
return state.customPropertiesString[MetatypeWrapper(P.self)] ?? P.defaultValue
248248
}
249249
}
250250

251251
set {
252-
var parents: [ParentState]?
252+
var parents: [Parent]?
253253
self.withMutation(keyPath: \.additionalPropertiesSink) {
254254
parents = state.withLock { state in
255-
guard newValue != state.propertiesString[MetatypeWrapper(P.self)] else {
255+
guard newValue != state.customPropertiesString[MetatypeWrapper(P.self)] else {
256256
return nil
257257
}
258-
state.propertiesString[MetatypeWrapper(P.self)] = newValue
258+
state.customPropertiesString[MetatypeWrapper(P.self)] = newValue
259259
return state.parents
260260
}
261261
}
@@ -277,18 +277,18 @@ extension ProgressManager {
277277
get {
278278
self.access(keyPath: \.additionalPropertiesSink)
279279
return state.withLock { state in
280-
return state.propertiesURL[MetatypeWrapper(P.self)] ?? P.defaultValue
280+
return state.customPropertiesURL[MetatypeWrapper(P.self)] ?? P.defaultValue
281281
}
282282
}
283283

284284
set {
285-
var parents: [ParentState]?
285+
var parents: [Parent]?
286286
self.withMutation(keyPath: \.additionalPropertiesSink) {
287287
parents = state.withLock { state in
288-
guard newValue != state.propertiesURL[MetatypeWrapper(P.self)] else {
288+
guard newValue != state.customPropertiesURL[MetatypeWrapper(P.self)] else {
289289
return nil
290290
}
291-
state.propertiesURL[MetatypeWrapper(P.self)] = newValue
291+
state.customPropertiesURL[MetatypeWrapper(P.self)] = newValue
292292
return state.parents
293293
}
294294
}
@@ -317,13 +317,13 @@ extension ProgressManager {
317317
if P.self == ProgressManager.Properties.Throughput.self {
318318
return state.throughput
319319
} else {
320-
return state.propertiesUInt64Array[MetatypeWrapper(P.self)] ?? P.defaultValue
320+
return state.customPropertiesUInt64Array[MetatypeWrapper(P.self)] ?? P.defaultValue
321321
}
322322
}
323323
}
324324

325325
set {
326-
var parents: [ParentState]?
326+
var parents: [Parent]?
327327
if P.self == ProgressManager.Properties.Throughput.self {
328328
self.withMutation(keyPath: \.throughput) {
329329
parents = state.withLock { state in
@@ -337,10 +337,10 @@ extension ProgressManager {
337337
} else {
338338
self.withMutation(keyPath: \.additionalPropertiesSink) {
339339
parents = state.withLock { state in
340-
guard newValue != state.propertiesUInt64Array[MetatypeWrapper(P.self)] else {
340+
guard newValue != state.customPropertiesUInt64Array[MetatypeWrapper(P.self)] else {
341341
return nil
342342
}
343-
state.propertiesUInt64Array[MetatypeWrapper(P.self)] = newValue
343+
state.customPropertiesUInt64Array[MetatypeWrapper(P.self)] = newValue
344344
return state.parents
345345
}
346346
}
@@ -374,13 +374,13 @@ extension ProgressManager {
374374
if P.self == ProgressManager.Properties.EstimatedTimeRemaining.self {
375375
return state.estimatedTimeRemaining
376376
} else {
377-
return state.propertiesDuration[MetatypeWrapper(P.self)] ?? P.defaultValue
377+
return state.customPropertiesDuration[MetatypeWrapper(P.self)] ?? P.defaultValue
378378
}
379379
}
380380
}
381381

382382
set {
383-
var parents: [ParentState]?
383+
var parents: [Parent]?
384384
if P.self == ProgressManager.Properties.EstimatedTimeRemaining.self {
385385
self.withMutation(keyPath: \.estimatedTimeRemaining) {
386386
parents = state.withLock { state in
@@ -394,10 +394,10 @@ extension ProgressManager {
394394
} else {
395395
self.withMutation(keyPath: \.additionalPropertiesSink) {
396396
parents = state.withLock { state in
397-
guard newValue != state.propertiesDuration[MetatypeWrapper(P.self)] else {
397+
guard newValue != state.customPropertiesDuration[MetatypeWrapper(P.self)] else {
398398
return nil
399399
}
400-
state.propertiesDuration[MetatypeWrapper(P.self)] = newValue
400+
state.customPropertiesDuration[MetatypeWrapper(P.self)] = newValue
401401
return state.parents
402402
}
403403
}

0 commit comments

Comments
 (0)