Skip to content
Merged
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 Sources/OpenSwiftUI/App/App/AppGraph.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ package final class AppGraph: GraphHost {
// MARK: - Override Methods

override package func instantiateOutputs() {
data.updateSeed &+= 1
data.updateSeed.unsafeIncrement()
let outputs = rootSubgraph.apply {
var inputs = _SceneInputs(
base: graphInputs,
Expand Down Expand Up @@ -187,7 +187,7 @@ extension AppGraph: GraphDelegate {
}

package func graphDidChange() {
data.updateSeed &+= 1
data.updateSeed.unsafeIncrement()
runTransaction()
let phaseChanged = $rootScenePhase.changedValue().changed
let commandsChanged = $rootCommandsList?.changedValue().changed ?? false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ struct ScrollEventConverter {
in: view
)
if rawPhase == 4 || rawPhase == 5 {
scrollSeed &+= 1
scrollSeed.unsafeIncrement()
accumulatedScrollDelta = .zero
}
return [eventID: panEvent]
}

mutating func reset() {
scrollSeed &+= 1
scrollSeed.unsafeIncrement()
accumulatedScrollDelta = .zero
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -594,8 +594,8 @@ open class NSHostingView<Content>: NSView, XcodeViewDebugDataProvider where Cont
contentMaxHeight = size.height.rounded(.up, toMultipleOf: pixelLength.height)
}

contentMaxWidth = Swift.max(contentMaxWidth, contentMinWidth)
contentMaxHeight = Swift.max(contentMaxHeight, contentMinHeight)
contentMaxWidth.formMax(contentMinWidth)
contentMaxHeight.formMax(contentMinHeight)

let currentMin = window.contentMinSize
let currentMax = window.contentMaxSize
Expand All @@ -615,10 +615,10 @@ open class NSHostingView<Content>: NSView, XcodeViewDebugDataProvider where Cont
var width = contentRect.width
var height = contentRect.height

width = Swift.min(width, window.contentMaxSize.width)
width = Swift.max(width, window.contentMinSize.width)
height = Swift.min(height, window.contentMaxSize.height)
height = Swift.max(height, window.contentMinSize.height)
width.formMin(window.contentMaxSize.width)
width.formMax(window.contentMinSize.width)
height.formMin(window.contentMaxSize.height)
height.formMax(window.contentMinSize.height)

if width != contentRect.width || height != contentRect.height {
window.setContentSize(CGSize(width: width, height: height))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ struct PlatformViewChild<Content: PlatformViewRepresentable>: StatefulRule {
[
attribute.graph.graphIdentity(),
"\(Content.self)",
platformView.map { UInt(bitPattern: Unmanaged.passUnretained($0).toOpaque()) } ?? 0,
platformView.map { UInt(bitPattern: address(of: $0)) } ?? 0,
]
) {
var (view, viewChanged) = $view.changedValue()
Expand Down Expand Up @@ -804,7 +804,7 @@ private struct PlatformViewLayoutEngine<Content>: LayoutEngine where Content: Pl
if k == VerticalAlignment.firstTextBaseline.key {
let baseline = view.platformView._baselineOffsets(at: viewSize.value)
let firstTextBaseline = baseline.firstTextBaseline
return firstTextBaseline.isNaN ? .zero : firstTextBaseline
return firstTextBaseline.mappingNaN(to: .zero)
} else if k == VerticalAlignment.lastTextBaseline.key {
let baseline = view.platformView._baselineOffsets(at: viewSize.value)
let lastTextBaseline = baseline.lastTextBaseline
Expand Down
9 changes: 4 additions & 5 deletions Sources/OpenSwiftUI/Layout/JindoTripleVStack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ extension JindoTripleVStack {

mutating func updateWithSplit(at index: Int, before: CGFloat) {
if index == 0 {
reserved.before = max(reserved.before, before)
reserved.before.formMax(before)
let group = groups[0]
groups[0] = Group(
count: group.count,
Expand Down Expand Up @@ -1548,7 +1548,7 @@ extension JindoTripleVStack {
)
children[childIndex] = child
let height = child.geometry.dimensions.height
let consumedHeight = height.isNaN ? 0 : height
let consumedHeight = height.mappingNaN(to: 0)
for stack in Stack.allCases {
if let stateIndex = children[childIndex].majorAxisGroup[stack] {
states[stateIndex].consume(consumedHeight)
Expand All @@ -1571,8 +1571,7 @@ extension JindoTripleVStack {
let stackHeader = header.stacks[stack]
state.currentMajorAxisPosition = stackExtents[stack]
if state.range.lowerBound == stackHeader.topPrefix {
sharedTopPrefixPosition = max(
sharedTopPrefixPosition,
sharedTopPrefixPosition.formMax(
stackExtents[stack]
+ distanceToPrevious(state.range.lowerBound, stack: stack)
)
Expand Down Expand Up @@ -1642,7 +1641,7 @@ extension JindoTripleVStack {
states[stateIndex].currentMajorAxisPosition = bottom
}
}
resultHeight = max(resultHeight, bottom)
resultHeight.formMax(bottom)
}

header.stackSize = CGSize(width: proposal.width, height: resultHeight)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ private struct GeometryActionBinder<Provider>: StatefulRule, AsyncAttribute wher
if phase.resetSeed != lastResetSeed {
reset(seed: phase.resetSeed)
}
proxySeed &+= 1
proxySeed.unsafeIncrement()
let proxy = GeometryProxy(
owner: attribute.identifier,
size: $size,
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenSwiftUI/View/Image/AsyncImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ extension CGImageSource {
guard let properties = CGImageSourceCopyPropertiesAtIndex(self, index, nil),
let orientationResult = CFDictionaryGetValue(
properties,
Unmanaged.passUnretained(kCGImagePropertyOrientation).toOpaque()
address(of: kCGImagePropertyOrientation)
),
let orientation = unsafeBitCast(orientationResult, to: NSNumber.self) as? Int
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ public struct _DynamicPropertyBuffer {
let itemSize = Int(oldItemPointer.pointee.size)
newBuffer += itemSize
oldBuffer += itemSize
count &-= 1
count.unsafeDecrement()
}
oldBuffer = buf
if size > 0 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ package struct HostPreferencesKey: PreferenceKey {
private static var nodeId = UInt32.zero

package static func makeNodeId() -> UInt32 {
nodeId &+= 1
nodeId.unsafeIncrement()
return nodeId
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private struct HostPreferencesTransform<K>: StatefulRule, AsyncAttribute, Custom
if keyRequested {
let anyInputsChanged = Graph.anyInputsChanged(excluding: [_keys.identifier, _childValues.base.identifier])
if anyInputsChanged {
delta &+= 1
delta.unsafeIncrement()
requiresUpdate = true
}
if anyInputsChanged || requiresUpdate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ private struct HostPreferencesWriter<K>: StatefulRule, AsyncAttribute, CustomStr
if keyRequested {
let (keyValue, keyValueChanged) = $keyValue.changedValue()
if keyValueChanged {
delta &+= 1
delta.unsafeIncrement()
requiresUpdate = true
}
if keyValueChanged || requiresUpdate {
Expand Down
4 changes: 2 additions & 2 deletions Sources/OpenSwiftUICore/Data/Update.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ package enum Update {
"ViewHost: (%p) update began PlatformHost [ %p ]",
[
0,
UInt(bitPattern: Unmanaged.passUnretained(trackHost).toOpaque()),
UInt(bitPattern: address(of: trackHost)),
]
)
#endif
Expand All @@ -94,7 +94,7 @@ package enum Update {
"ViewHost: (%p) update ended PlatformHost [ %p ]",
[
0,
UInt(bitPattern: Unmanaged.passUnretained(trackHost).toOpaque()),
UInt(bitPattern: address(of: trackHost)),
]
)
#endif
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenSwiftUICore/Data/Util/ObjectCache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ final package class ObjectCache<Key, Value> where Key: Hashable {
let index = bucket + offset
if let itemData = data.table[index].data {
if itemData.hash == hash, itemData.key == key {
data.clock &+= 1
data.clock.unsafeIncrement()
data.table[index].used = data.clock
return itemData.value
} else {
Expand Down
6 changes: 3 additions & 3 deletions Sources/OpenSwiftUICore/Data/Util/PropertyList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ private func find1<Key>(
if let result { return result }
}
if currentElement.keyType == Key.self {
return .fromOpaque(Unmanaged.passUnretained(currentElement).toOpaque())
return .fromOpaque(address(of: currentElement))
}
guard let after = currentElement.after else {
return nil
Expand Down Expand Up @@ -467,10 +467,10 @@ private func findValueWithSecondaryLookup<Lookup>(
}
let keyType = currentElement.keyType
if keyType == Lookup.Primary.self {
let element: Unmanaged<TypedElement<Lookup.Primary>> = .fromOpaque(Unmanaged.passUnretained(currentElement).toOpaque())
let element: Unmanaged<TypedElement<Lookup.Primary>> = .fromOpaque(address(of: currentElement))
return element.takeUnretainedValue().value
} else if keyType == Lookup.Secondary.self {
let element: Unmanaged<TypedElement<Lookup.Secondary>> = .fromOpaque(Unmanaged.passUnretained(currentElement).toOpaque())
let element: Unmanaged<TypedElement<Lookup.Secondary>> = .fromOpaque(address(of: currentElement))
if let value = Lookup.lookup(in: element.takeUnretainedValue().value) {
return value
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private struct DelayedPhase<BodyValue>: ResettableGestureRule {
let deadline = startTime + delayedModifier.duration
if useGestureGraph {
let gestureGraph = GestureGraph.current
gestureGraph.nextUpdateTime = min(gestureGraph.nextUpdateTime, deadline)
gestureGraph.nextUpdateTime.formMin(deadline)
} else {
ViewGraph.current.nextUpdate.gestures.at(deadline)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ package struct DistanceGesture: Gesture {
let movement: CGFloat
if let start {
movement = distance(start, location)
maxDistance = max(maxDistance, movement)
maxDistance.formMax(movement)
} else {
start = location
movement = .zero
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ private struct DurationPhase<BodyValue>: ResettableGestureRule {
}
if useGestureGraph {
let gestureGraph = GestureGraph.current
gestureGraph.nextUpdateTime = min(gestureGraph.nextUpdateTime, deadline)
gestureGraph.nextUpdateTime.formMin(deadline)
} else {
ViewGraph.current.nextUpdate.gestures.at(deadline)
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenSwiftUICore/Event/Gesture/GestureGraph.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ final package class GestureGraph: GraphHost, EventGraphHost, CustomStringConvert
startTransactionUpdate()
if data.time != time {
data.time = time
data.updateSeed &+= 1 // not setTime due to this
data.updateSeed.unsafeIncrement() // not setTime due to this
timeDidChange()
}
gestureEvents = events
Expand Down
4 changes: 2 additions & 2 deletions Sources/OpenSwiftUICore/Event/Gesture/RepeatGesture.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private struct RepeatPhase<V>: ResettableGestureRule {
self.value = phase
}
case let .ended(wrapped):
index &+= 1
index.unsafeIncrement()
if modifier.count > Int(index) {
deadline = time + modifier.maximumDelay
value = .possible(wrapped)
Expand All @@ -115,7 +115,7 @@ private struct RepeatPhase<V>: ResettableGestureRule {
}
if useGestureGraph {
let gestureGraph = GestureGraph.current
gestureGraph.nextUpdateTime = min(gestureGraph.nextUpdateTime, deadline)
gestureGraph.nextUpdateTime.formMin(deadline)
} else {
ViewGraph.current.nextUpdate.gestures.at(deadline)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ open class MultiViewResponder: ViewResponder {
options: options
)
mask.formUnion(childResult.mask)
priority = max(priority, childResult.priority)
priority.formMax(childResult.priority)
}
return ContainsPointsResult(mask: mask, priority: priority, children: children)
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/OpenSwiftUICore/Graph/GraphHost.swift
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ open class GraphHost: CustomReflectable {
guard let self else { return }
graphInvalidation(from: attribute)
}
graph.context = UnsafeRawPointer(Unmanaged.passUnretained(self).toOpaque())
graph.context = address(of: self)
}

deinit {
Expand Down Expand Up @@ -311,7 +311,7 @@ extension GraphHost {

// TODO: _ArchivedViewHost.reset()
package final func incrementPhase() {
data.phase.resetSeed &+= 1
data.phase.resetSeed.unsafeIncrement()
graphDelegate?.graphDidChange()
}

Expand Down Expand Up @@ -492,7 +492,7 @@ extension GraphHost {

package final func startTransactionUpdate() {
inTransaction = true
data.transactionSeed &+= 1
data.transactionSeed.unsafeIncrement()
}

package final func finishTransactionUpdate(in subgraph: Subgraph, postUpdate: (_ again: Bool) -> Void = { _ in }) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ struct DynamicContainerInfo<Adapter>: StatefulRule, AsyncAttribute, ObservedAttr
return
}
}
info.seed &+= 1
info.seed.unsafeIncrement()
value = info
}

Expand Down Expand Up @@ -576,7 +576,7 @@ struct DynamicContainerInfo<Adapter>: StatefulRule, AsyncAttribute, ObservedAttr
info.items.swapAt(target, reusedIndex)
}
} else {
lastUniqueId &+= 1
lastUniqueId.unsafeIncrement()
let createdItem = makeItem(
item,
uniqueId: lastUniqueId,
Expand Down Expand Up @@ -665,7 +665,7 @@ struct DynamicContainerInfo<Adapter>: StatefulRule, AsyncAttribute, ObservedAttr
let phase: TransitionPhase
switch info.items[index].phase {
case .willAppear, .identity:
info.items[index].resetSeed &-= 1
info.items[index].resetSeed.unsafeDecrement()
phase = .identity
case .didDisappear:
info.removedCount &-= 1
Expand Down Expand Up @@ -710,7 +710,7 @@ struct DynamicContainerInfo<Adapter>: StatefulRule, AsyncAttribute, ObservedAttr
if unusedCount < maxUnusedItems {
info.items.remove(at: index)
item.removalOrder = 0
item.resetSeed &+= 1
item.resetSeed.unsafeIncrement()
item.phase = nil
item.listener?.viewGraph = nil
item.listener = nil
Expand Down
16 changes: 8 additions & 8 deletions Sources/OpenSwiftUICore/Layout/Edge/EdgeInsets.swift
Original file line number Diff line number Diff line change
Expand Up @@ -266,17 +266,17 @@ extension EdgeInsets {
}

package mutating func formPointwiseMin(_ other: EdgeInsets) {
top = min(top, other.top)
leading = min(leading, other.leading)
bottom = min(bottom, other.bottom)
trailing = min(trailing, other.trailing)
top.formMin(other.top)
leading.formMin(other.leading)
bottom.formMin(other.bottom)
trailing.formMin(other.trailing)
}

package mutating func formPointwiseMax(_ other: EdgeInsets) {
top = max(top, other.top)
leading = max(leading, other.leading)
bottom = max(bottom, other.bottom)
trailing = max(trailing, other.trailing)
top.formMax(other.top)
leading.formMax(other.leading)
bottom.formMax(other.bottom)
trailing.formMax(other.trailing)
}

@inline(__always)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public struct GeometryReader<Content>: View, UnaryView, PrimitiveView where Cont
typealias Value = _VariadicView.Tree<_LayoutRoot<GeometryReaderLayout>, Content>

mutating func updateValue() {
seed &+= 1
seed.unsafeIncrement()
let proxy = GeometryProxy(
owner: attribute.identifier,
size: $size,
Expand Down
4 changes: 2 additions & 2 deletions Sources/OpenSwiftUICore/Layout/View/ViewSize.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ extension ViewSize {
return ViewSize(
value: CGSize(width: newWidth, height: newHeight),
proposal: CGSize(
width: newWidth.isNaN ? 0 : newWidth,
height: newHeight.isNaN ? 0 : newHeight
width: newWidth.mappingNaN(to: 0),
height: newHeight.mappingNaN(to: 0)
)
)
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenSwiftUICore/Log/CycleDetector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ package struct UpdateCycleDetector {
return true
}
if ttl != 0 {
ttl &-= 1
ttl.unsafeDecrement()
}
guard ttl == 0 else {
return true
Expand Down
Loading
Loading