Skip to content

Commit ba43752

Browse files
committed
change to UInt64 where needed
1 parent 1e11462 commit ba43752

File tree

6 files changed

+44
-44
lines changed

6 files changed

+44
-44
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,15 @@ extension ProgressManager {
7171
///
7272
/// - Parameter property: The `TotalByteCount` property type.
7373
/// - Returns: The sum of all total byte counts across the entire progress subtree, in bytes.
74-
public func summary(of property: ProgressManager.Properties.TotalByteCount.Type) -> Int64 {
74+
public func summary(of property: ProgressManager.Properties.TotalByteCount.Type) -> UInt64 {
7575
return getUpdatedByteCount(type: .total)
7676
}
7777

7878
/// Returns the completed byte count across the progress subtree.
7979
///
8080
/// - Parameter property: The `CompletedByteCount` property type.
8181
/// - Returns: The sum of all completed byte counts across the entire progress subtree, in bytes.
82-
public func summary(of property: ProgressManager.Properties.CompletedByteCount.Type) -> Int64 {
82+
public func summary(of property: ProgressManager.Properties.CompletedByteCount.Type) -> UInt64 {
8383
return getUpdatedByteCount(type: .completed)
8484
}
8585

@@ -90,9 +90,9 @@ extension ProgressManager {
9090
///
9191
/// - Note: The throughput is calculated as the sum of all throughput values divided by the count
9292
/// of progress managers that have throughput data.
93-
public func summary(of property: ProgressManager.Properties.Throughput.Type) -> Int64 {
93+
public func summary(of property: ProgressManager.Properties.Throughput.Type) -> UInt64 {
9494
let throughput = getUpdatedThroughput()
95-
return throughput.values / Int64(throughput.count)
95+
return throughput.values / UInt64(throughput.count)
9696
}
9797

9898
/// Returns the maximum estimated time remaining for completion across the progress subtree.
@@ -306,7 +306,7 @@ extension ProgressManager {
306306

307307
/// Gets or sets the total byte count property.
308308
/// - Parameter key: A key path to the `TotalByteCount` property type.
309-
public subscript(dynamicMember key: KeyPath<ProgressManager.Properties, ProgressManager.Properties.TotalByteCount.Type>) -> Int64 {
309+
public subscript(dynamicMember key: KeyPath<ProgressManager.Properties, ProgressManager.Properties.TotalByteCount.Type>) -> UInt64 {
310310
get {
311311
return state.totalByteCount
312312
}
@@ -324,7 +324,7 @@ extension ProgressManager {
324324

325325
/// Gets or sets the completed byte count property.
326326
/// - Parameter key: A key path to the `CompletedByteCount` property type.
327-
public subscript(dynamicMember key: KeyPath<ProgressManager.Properties, ProgressManager.Properties.CompletedByteCount.Type>) -> Int64 {
327+
public subscript(dynamicMember key: KeyPath<ProgressManager.Properties, ProgressManager.Properties.CompletedByteCount.Type>) -> UInt64 {
328328
get {
329329
return state.completedByteCount
330330
}
@@ -342,7 +342,7 @@ extension ProgressManager {
342342

343343
/// Gets or sets the throughput property.
344344
/// - Parameter key: A key path to the `Throughput` property type.
345-
public subscript(dynamicMember key: KeyPath<ProgressManager.Properties, ProgressManager.Properties.Throughput.Type>) -> Int64 {
345+
public subscript(dynamicMember key: KeyPath<ProgressManager.Properties, ProgressManager.Properties.Throughput.Type>) -> UInt64 {
346346
get {
347347
return state.throughput
348348
}

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

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -134,21 +134,21 @@ extension ProgressManager {
134134
public var totalByteCount: TotalByteCount.Type { TotalByteCount.self }
135135
public struct TotalByteCount: Sendable, Property {
136136

137-
public typealias Value = Int64
137+
public typealias Value = UInt64
138138

139-
public typealias Summary = Int64
139+
public typealias Summary = UInt64
140140

141141
public static var key: String { return "Foundation.ProgressManager.Properties.TotalByteCount" }
142142

143-
public static var defaultValue: Int64 { return 0 }
143+
public static var defaultValue: UInt64 { return 0 }
144144

145-
public static var defaultSummary: Int64 { return 0 }
145+
public static var defaultSummary: UInt64 { return 0 }
146146

147-
public static func reduce(into summary: inout Int64, value: Int64) {
147+
public static func reduce(into summary: inout UInt64, value: UInt64) {
148148
summary += value
149149
}
150150

151-
public static func merge(_ summary1: Int64, _ summary2: Int64) -> Int64 {
151+
public static func merge(_ summary1: UInt64, _ summary2: UInt64) -> UInt64 {
152152
return summary1 + summary2
153153
}
154154
}
@@ -157,44 +157,44 @@ extension ProgressManager {
157157
public var completedByteCount: CompletedByteCount.Type { CompletedByteCount.self }
158158
public struct CompletedByteCount: Sendable, Property {
159159

160-
public typealias Value = Int64
160+
public typealias Value = UInt64
161161

162-
public typealias Summary = Int64
162+
public typealias Summary = UInt64
163163

164164
public static var key: String { return "Foundation.ProgressManager.Properties.CompletedByteCount" }
165165

166-
public static var defaultValue: Int64 { return 0 }
166+
public static var defaultValue: UInt64 { return 0 }
167167

168-
public static var defaultSummary: Int64 { return 0 }
168+
public static var defaultSummary: UInt64 { return 0 }
169169

170-
public static func reduce(into summary: inout Int64, value: Int64) {
170+
public static func reduce(into summary: inout UInt64, value: UInt64) {
171171
summary += value
172172
}
173173

174-
public static func merge(_ summary1: Int64, _ summary2: Int64) -> Int64 {
174+
public static func merge(_ summary1: UInt64, _ summary2: UInt64) -> UInt64 {
175175
return summary1 + summary2
176176
}
177177
}
178178

179179
/// The throughput, in bytes per second.
180180
public var throughput: Throughput.Type { Throughput.self }
181181
public struct Throughput: Sendable, Property {
182-
public typealias Value = Int64
182+
public typealias Value = UInt64
183183

184184
public struct AggregateThroughput: Sendable, Equatable {
185-
var values: Int64
185+
var values: UInt64
186186
var count: Int
187187
}
188188

189189
public typealias Summary = AggregateThroughput
190190

191191
public static var key: String { return "Foundation.ProgressManager.Properties.Throughput" }
192192

193-
public static var defaultValue: Int64 { return 0 }
193+
public static var defaultValue: UInt64 { return 0 }
194194

195195
public static var defaultSummary: AggregateThroughput { return AggregateThroughput(values: 0, count: 0) }
196196

197-
public static func reduce(into summary: inout AggregateThroughput, value: Int64) {
197+
public static func reduce(into summary: inout AggregateThroughput, value: UInt64) {
198198
summary = Summary(values: summary.values + value, count: summary.count + 1)
199199
}
200200

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,12 @@ extension ProgressManager {
229229
}
230230
}
231231

232-
internal func getUpdatedByteCount(type: CountType) -> Int64 {
232+
internal func getUpdatedByteCount(type: CountType) -> UInt64 {
233233
switch type {
234234
case .total:
235235
return state.withLock { state in
236236
// Get self's totalByteCount as part of summary
237-
var value: Int64 = 0
237+
var value: UInt64 = 0
238238
ProgressManager.Properties.TotalByteCount.reduce(into: &value, value: state.totalByteCount)
239239

240240
guard !state.children.isEmpty else {
@@ -246,7 +246,7 @@ extension ProgressManager {
246246
// Update dirty path
247247
if let child = childState.child {
248248
let updatedSummary = child.getUpdatedByteCount(type: type)
249-
let newTotalByteCountState = PropertyStateInt64(value: updatedSummary, isDirty: false)
249+
let newTotalByteCountState = PropertyStateUInt64(value: updatedSummary, isDirty: false)
250250
state.children[idx].totalByteCount = newTotalByteCountState
251251
value = ProgressManager.Properties.TotalByteCount.merge(value, updatedSummary)
252252
}
@@ -260,7 +260,7 @@ extension ProgressManager {
260260
case .completed:
261261
return state.withLock { state in
262262
// Get self's completedByteCount as part of summary
263-
var value: Int64 = 0
263+
var value: UInt64 = 0
264264
ProgressManager.Properties.CompletedByteCount.reduce(into: &value, value: state.completedByteCount)
265265

266266
guard !state.children.isEmpty else {
@@ -272,7 +272,7 @@ extension ProgressManager {
272272
// Update dirty path
273273
if let child = childState.child {
274274
let updatedSummary = child.getUpdatedByteCount(type: type)
275-
let newCompletedByteCountState = PropertyStateInt64(value: updatedSummary, isDirty: false)
275+
let newCompletedByteCountState = PropertyStateUInt64(value: updatedSummary, isDirty: false)
276276
state.children[idx].completedByteCount = newCompletedByteCountState
277277
value = ProgressManager.Properties.CompletedByteCount.merge(value, updatedSummary)
278278
}
@@ -542,15 +542,15 @@ extension ProgressManager {
542542
}
543543
}
544544

545-
internal func setChildTotalByteCount(value: Int64, at position: Int) {
545+
internal func setChildTotalByteCount(value: UInt64, at position: Int) {
546546
state.withLock { state in
547-
state.children[position].totalByteCount = PropertyStateInt64(value: value, isDirty: false)
547+
state.children[position].totalByteCount = PropertyStateUInt64(value: value, isDirty: false)
548548
}
549549
}
550550

551-
internal func setChildCompletedByteCount(value: Int64, at position: Int) {
551+
internal func setChildCompletedByteCount(value: UInt64, at position: Int) {
552552
state.withLock { state in
553-
state.children[position].completedByteCount = PropertyStateInt64(value: value, isDirty: false)
553+
state.children[position].completedByteCount = PropertyStateUInt64(value: value, isDirty: false)
554554
}
555555
}
556556

Sources/FoundationEssentials/ProgressManager/ProgressManager+State.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ extension ProgressManager {
4646
var isDirty: Bool
4747
}
4848

49-
internal struct PropertyStateInt64 {
50-
var value: Int64
49+
internal struct PropertyStateUInt64 {
50+
var value: UInt64
5151
var isDirty: Bool
5252
}
5353

@@ -86,8 +86,8 @@ extension ProgressManager {
8686
var isDirty: Bool
8787
var totalFileCount: PropertyStateInt
8888
var completedFileCount: PropertyStateInt
89-
var totalByteCount: PropertyStateInt64
90-
var completedByteCount: PropertyStateInt64
89+
var totalByteCount: PropertyStateUInt64
90+
var completedByteCount: PropertyStateUInt64
9191
var throughput: PropertyStateThroughput
9292
var estimatedTimeRemaining: PropertyStateDuration
9393
var fileURL: PropertyStateURL
@@ -119,9 +119,9 @@ extension ProgressManager {
119119
var parents: [ParentState]
120120
var totalFileCount: Int
121121
var completedFileCount: Int
122-
var totalByteCount: Int64
123-
var completedByteCount: Int64
124-
var throughput: Int64
122+
var totalByteCount: UInt64
123+
var completedByteCount: UInt64
124+
var throughput: UInt64
125125
var estimatedTimeRemaining: Duration
126126
var fileURL: URL?
127127
var propertiesInt: [MetatypeWrapper<Int>: Int]

Sources/FoundationEssentials/ProgressManager/ProgressManager.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ internal import _FoundationCollections
244244
isDirty: true,
245245
totalFileCount: PropertyStateInt(value: ProgressManager.Properties.TotalFileCount.defaultSummary, isDirty: false),
246246
completedFileCount: PropertyStateInt(value: ProgressManager.Properties.CompletedFileCount.defaultSummary, isDirty: false),
247-
totalByteCount: PropertyStateInt64(value: ProgressManager.Properties.TotalByteCount.defaultSummary, isDirty: false),
248-
completedByteCount: PropertyStateInt64(value: ProgressManager.Properties.CompletedByteCount.defaultSummary, isDirty: false),
247+
totalByteCount: PropertyStateUInt64(value: ProgressManager.Properties.TotalByteCount.defaultSummary, isDirty: false),
248+
completedByteCount: PropertyStateUInt64(value: ProgressManager.Properties.CompletedByteCount.defaultSummary, isDirty: false),
249249
throughput: PropertyStateThroughput(value: ProgressManager.Properties.Throughput.defaultSummary, isDirty: false),
250250
estimatedTimeRemaining: PropertyStateDuration(value: ProgressManager.Properties.EstimatedTimeRemaining.defaultSummary, isDirty: false),
251251
fileURL: PropertyStateURL(value: ProgressManager.Properties.FileURL.defaultSummary, isDirty: false),

Sources/FoundationEssentials/ProgressManager/ProgressReporter.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,23 +134,23 @@ import Observation
134134
///
135135
/// - Parameter property: The `TotalByteCount` property type.
136136
/// - Returns: The sum of all total byte counts across the entire progress subtree, in bytes.
137-
public func summary(of property: ProgressManager.Properties.TotalByteCount.Type) -> Int64 {
137+
public func summary(of property: ProgressManager.Properties.TotalByteCount.Type) -> UInt64 {
138138
manager.summary(of: property)
139139
}
140140

141141
/// Returns the completed byte count across the progress subtree.
142142
///
143143
/// - Parameter property: The `CompletedByteCount` property type.
144144
/// - Returns: The sum of all completed byte counts across the entire progress subtree, in bytes.
145-
public func summary(of property: ProgressManager.Properties.CompletedByteCount.Type) -> Int64 {
145+
public func summary(of property: ProgressManager.Properties.CompletedByteCount.Type) -> UInt64 {
146146
manager.summary(of: property)
147147
}
148148

149149
/// Returns the average throughput across the progress subtree.
150150
///
151151
/// - Parameter property: The `Throughput` property type.
152152
/// - Returns: The average throughput across the entire progress subtree, in bytes per second.
153-
public func summary(of property: ProgressManager.Properties.Throughput.Type) -> Int64 {
153+
public func summary(of property: ProgressManager.Properties.Throughput.Type) -> UInt64 {
154154
manager.summary(of: property)
155155
}
156156

0 commit comments

Comments
 (0)