diff --git a/Sources/OpenSwiftUICore/Layout/Stack/HStack.swift b/Sources/OpenSwiftUICore/Layout/Stack/HStack.swift new file mode 100644 index 00000000..6adfe941 --- /dev/null +++ b/Sources/OpenSwiftUICore/Layout/Stack/HStack.swift @@ -0,0 +1,188 @@ +// +// HStack.swift +// OpenSwiftUICore +// +// Audited for 6.4.41 +// Status: Complete + +public import Foundation + +/// A view that arranges its subviews in a horizontal line. +/// +/// Unlike ``LazyHStack``, which only renders the views when your app needs to +/// display them onscreen, an `HStack` renders the views all at once, regardless +/// of whether they are on- or offscreen. Use the regular `HStack` when you have +/// a small number of subviews or don't want the delayed rendering behavior +/// of the "lazy" version. +/// +/// The following example shows a simple horizontal stack of five text views: +/// +/// var body: some View { +/// HStack( +/// alignment: .top, +/// spacing: 10 +/// ) { +/// ForEach( +/// 1...5, +/// id: \.self +/// ) { +/// Text("Item \($0)") +/// } +/// } +/// } +/// +/// ![Five text views, named Item 1 through Item 5, arranged in a +/// horizontal row.](OpenSwiftUI-HStack-simple.png) +/// +/// > Note: If you need a horizontal stack that conforms to the ``Layout`` +/// protocol, like when you want to create a conditional layout using +/// ``AnyLayout``, use ``HStackLayout`` instead. +@available(OpenSwiftUI_v1_0, *) +@frozen +public struct HStack: View, UnaryView, PrimitiveView where Content: View { + @usableFromInline + var _tree: _VariadicView.Tree<_HStackLayout, Content> + + /// Creates a horizontal stack with the given spacing and vertical alignment. + /// + /// - Parameters: + /// - alignment: The guide for aligning the subviews in this stack. This + /// guide has the same vertical screen coordinate for every subview. + /// - spacing: The distance between adjacent subviews, or `nil` if you + /// want the stack to choose a default distance for each pair of + /// subviews. + /// - content: A view builder that creates the content of this stack. + @inlinable + public init( + alignment: VerticalAlignment = .center, + spacing: CGFloat? = nil, + @ViewBuilder content: () -> Content + ) { + _tree = .init( + _HStackLayout(alignment: alignment, spacing: spacing) + ) { + content() + } + } + + nonisolated public static func _makeView( + view: _GraphValue, + inputs: _ViewInputs + ) -> _ViewOutputs { + _VariadicView.Tree.makeDebuggableView( + view: view[offset: { .of(&$0._tree) }], + inputs: inputs + ) + } +} + +@available(*, unavailable) +extension HStack: Sendable {} + +@_spi(ReallyDoNotImport) +@available(OpenSwiftUI_v4_0, *) +@available(*, deprecated, renamed: "HStackLayout") +extension HStack: Animatable where Content == EmptyView { + public typealias AnimatableData = EmptyAnimatableData +} + +@_spi(ReallyDoNotImport) +@available(OpenSwiftUI_v4_0, *) +@available(*, deprecated, renamed: "HStackLayout") +extension HStack: Layout where Content == EmptyView { + public typealias Cache = _HStackLayout.Cache +} + +@available(*, deprecated, renamed: "HStackLayout") +extension HStack: DerivedLayout where Content == EmptyView { + package typealias Base = _HStackLayout + + package var base: _HStackLayout { + _HStackLayout( + alignment: _tree.root.alignment, + spacing: _tree.root.spacing + ) + } +} + +@frozen +public struct _HStackLayout { + public var alignment: VerticalAlignment + + public var spacing: CGFloat? + + @inlinable + public init(alignment: VerticalAlignment = .center, spacing: CGFloat? = nil) { + self.alignment = alignment + self.spacing = spacing + } + + package static let majorAxis: Axis = .horizontal +} + +extension _HStackLayout: HVStack { + @available(OpenSwiftUI_v1_0, *) + public typealias Body = Never + + @available(OpenSwiftUI_v1_0, *) + package typealias MinorAxisAlignment = VerticalAlignment +} + +@available(OpenSwiftUI_v4_0, *) +extension _HStackLayout: Layout { + public typealias Cache = _StackLayoutCache + + @available(OpenSwiftUI_v4_0, *) + public typealias AnimatableData = EmptyAnimatableData +} + +extension _HStackLayout: _VariadicView.ImplicitRoot { + package static var implicitRoot: _HStackLayout { .init() } +} + +/// A horizontal container that you can use in conditional layouts. +/// +/// This layout container behaves like an ``HStack``, but conforms to the +/// ``Layout`` protocol so you can use it in the conditional layouts that you +/// construct with ``AnyLayout``. If you don't need a conditional layout, use +/// ``HStack`` instead. +@available(OpenSwiftUI_v4_0, *) +@frozen +public struct HStackLayout: Layout { + /// The vertical alignment of subviews. + public var alignment: VerticalAlignment + + /// The distance between adjacent subviews. + /// + /// Set this value to `nil` to use default distances between subviews. + public var spacing: CGFloat? + + /// Creates a horizontal stack with the specified spacing and vertical + /// alignment. + /// + /// - Parameters: + /// - alignment: The guide for aligning the subviews in this stack. It + /// has the same vertical screen coordinate for all subviews. + /// - spacing: The distance between adjacent subviews. Set this value + /// to `nil` to use default distances between subviews. + @inlinable + public init(alignment: VerticalAlignment = .center, spacing: CGFloat? = nil) { + self.alignment = alignment + self.spacing = spacing + } + + @available(OpenSwiftUI_v4_0, *) + public typealias AnimatableData = EmptyAnimatableData + + @available(OpenSwiftUI_v4_0, *) + public typealias Cache = _HStackLayout.Cache +} + +extension HStackLayout: DerivedLayout { + package var base: _HStackLayout { + .init(alignment: alignment, spacing: spacing) + } + + @available(OpenSwiftUI_v4_0, *) + package typealias Base = _HStackLayout +} diff --git a/Sources/OpenSwiftUICore/Layout/Stack/HVStack.swift b/Sources/OpenSwiftUICore/Layout/Stack/HVStack.swift index 4c44f1ed..7a1aa2d8 100644 --- a/Sources/OpenSwiftUICore/Layout/Stack/HVStack.swift +++ b/Sources/OpenSwiftUICore/Layout/Stack/HVStack.swift @@ -1,23 +1,100 @@ -public import Foundation - -@frozen -public struct HStack: PrimitiveView { - @inlinable - public init( - alignment: VerticalAlignment = .center, - spacing: CGFloat? = nil, - @ViewBuilder content: () -> Content +// +// HVStack.swift +// OpenSwiftUICore +// +// Audited for 6.4.41 +// Status: WIP + +package import Foundation + +package protocol HVStack: Layout, _VariadicView_UnaryViewRoot where Cache == _StackLayoutCache { + associatedtype MinorAxisAlignment: AlignmentGuide + + var spacing: CGFloat? { get } + + var alignment: MinorAxisAlignment { get } + + static var majorAxis: Axis { get } + + static var resizeChildrenWithTrailingOverflow: Bool { get } +} + +public struct _StackLayoutCache { + var stack: StackLayout +} + +@available(*, unavailable) +extension _StackLayoutCache: Sendable {} + +extension HVStack { + package static var resizeChildrenWithTrailingOverflow: Bool { + false + } + + nonisolated public static func _makeView( + root: _GraphValue, + inputs: _ViewInputs, + body: (_Graph, _ViewInputs) -> _ViewListOutputs + ) -> _ViewOutputs { + _makeLayoutView(root: root, inputs: inputs, body: body) + } +} + +extension HVStack { + public static var layoutProperties: LayoutProperties { + var properties = LayoutProperties() + properties.stackOrientation = Self.majorAxis + properties.isDefaultEmptyLayout = false + properties.isIdentityUnaryLayout = true + return properties + } + + public func makeCache(subviews: Subviews) -> Cache { + preconditionFailure("TODO") + } + + public func updateCache(_ cache: inout Cache, subviews: Self.Subviews) { + preconditionFailure("TODO") + } + + public func spacing(subviews: Subviews, cache: inout Cache) -> ViewSpacing { + preconditionFailure("TODO") + } + + public func sizeThatFits( + proposal: ProposedViewSize, + subviews: Self.Subviews, + cache: inout Self.Cache + ) -> CGSize { + preconditionFailure("TODO") + } + + public func placeSubviews( + in bounds: CGRect, + proposal: ProposedViewSize, + subviews: Self.Subviews, + cache: inout Self.Cache ) { - _tree = .init( - root: _HStackLayout(alignment: alignment, spacing: spacing), - content: content() - ) + preconditionFailure("TODO") } - @usableFromInline - var _tree: _VariadicView.Tree<_HStackLayout, Content> + public func explicitAlignment( + of guide: HorizontalAlignment, + in bounds: CGRect, + proposal: ProposedViewSize, + subviews: Self.Subviews, + cache: inout Self.Cache + ) -> CGFloat? { + preconditionFailure("TODO") + } - public static func _makeView(view _: _GraphValue>, inputs _: _ViewInputs) -> _ViewOutputs { + public func explicitAlignment( + of guide: VerticalAlignment, + in bounds: CGRect, + proposal: ProposedViewSize, + subviews: Self.Subviews, + cache: inout Self.Cache + ) -> CGFloat? { preconditionFailure("TODO") } } diff --git a/Sources/OpenSwiftUICore/Layout/Stack/HVStackLayout.swift b/Sources/OpenSwiftUICore/Layout/Stack/HVStackLayout.swift deleted file mode 100644 index 3ca7214e..00000000 --- a/Sources/OpenSwiftUICore/Layout/Stack/HVStackLayout.swift +++ /dev/null @@ -1,64 +0,0 @@ -public import Foundation - -/// A layout that arranges its children in a horizontal line. -@frozen -public struct _HStackLayout { - /// The vertical alignment of children. - public var alignment: VerticalAlignment - - /// The distance between adjacent children, or `nil` if the stack should - /// choose a default distance for each pair of children. - public var spacing: CGFloat? - - /// Creates an instance with the given spacing and vertical alignment. - /// - /// - Parameters: - /// - alignment: The guide for aligning the subviews in this stack. It - /// has the same vertical screen coordinate for all children. - /// - spacing: The distance between adjacent subviews, or `nil` if you - /// want the stack to choose a default distance for each pair of - /// subviews. - @inlinable - public init(alignment: VerticalAlignment = .center, spacing: CGFloat? = nil) { - self.alignment = alignment - self.spacing = spacing - } - - public typealias AnimatableData = EmptyAnimatableData - public typealias Body = Never -} - -/// A layout that arranges its children in a vertical line. -@frozen -public struct _VStackLayout { - /// The horizontal alignment of children. - public var alignment: HorizontalAlignment - - /// The distance between adjacent children, or `nil` if the stack should - /// choose a default distance for each pair of children. - public var spacing: CGFloat? - - /// Creates an instance with the given spacing and horizontal alignment. - /// - /// - Parameters: - /// - alignment: The guide for aligning the subviews in this stack. It - /// has the same horizontal screen coordinate for all children. - /// - spacing: The distance between adjacent subviews, or `nil` if you - /// want the stack to choose a default distance for each pair of - /// subviews. - @inlinable - public init(alignment: HorizontalAlignment = .center, spacing: CGFloat? = nil) { - self.alignment = alignment - self.spacing = spacing - } - - public typealias AnimatableData = EmptyAnimatableData - public typealias Body = Never -} - -extension _HStackLayout: _VariadicView_ImplicitRoot { - package static var implicitRoot: _HStackLayout { _HStackLayout() } -} -extension _VStackLayout: _VariadicView_ImplicitRoot { - package static var implicitRoot: _VStackLayout { _VStackLayout() } -} diff --git a/Sources/OpenSwiftUICore/Layout/Stack/StackLayout.swift b/Sources/OpenSwiftUICore/Layout/Stack/StackLayout.swift new file mode 100644 index 00000000..81c8a6cf --- /dev/null +++ b/Sources/OpenSwiftUICore/Layout/Stack/StackLayout.swift @@ -0,0 +1,44 @@ +// +// StackLayout.swift +// OpenSwiftUICore +// +// Audited for 6.4.41 +// Status: WIP +// ID: 00690F480F8D293143B214DBE6D72CD0 (SwiftUICore?) + +import Foundation + +struct StackLayout { + private struct MajorAxisRangeCache { + var min: CGFloat? + var max: CGFloat? + } + + private struct Header { + let minorAxisAlignment: AlignmentKey + let uniformSpacing: CGFloat? + let majorAxis: Axis + var internalSpacing: CGFloat + var lastProposedSize: ProposedViewSize + var stackSize: CGSize + let proxies: LayoutSubviews + let resizeChildrenWithTrailingOverflow: Bool + } + + private var header: Header + + private struct Child { + var layoutPriority: Double + var majorAxisRangeCache: StackLayout.MajorAxisRangeCache + let distanceToPrevious: CGFloat + var fittingOrder: Int + var geometry: ViewGeometry + } + + private var children: [Child] + + private func makeChildren() { + // TODO + } +} + diff --git a/Sources/OpenSwiftUICore/Layout/Stack/VStack.swift b/Sources/OpenSwiftUICore/Layout/Stack/VStack.swift new file mode 100644 index 00000000..e7220465 --- /dev/null +++ b/Sources/OpenSwiftUICore/Layout/Stack/VStack.swift @@ -0,0 +1,188 @@ +// +// VStack.swift +// OpenSwiftUICore +// +// Audited for 6.4.41 +// Status: Complete + +public import Foundation + +/// A view that arranges its subviews in a vertical line. +/// +/// Unlike ``LazyVStack``, which only renders the views when your app needs to +/// display them, a `VStack` renders the views all at once, regardless +/// of whether they are on- or offscreen. Use the regular `VStack` when you have +/// a small number of subviews or don't want the delayed rendering behavior +/// of the "lazy" version. +/// +/// The following example shows a simple vertical stack of 10 text views: +/// +/// var body: some View { +/// VStack( +/// alignment: .leading, +/// spacing: 10 +/// ) { +/// ForEach( +/// 1...10, +/// id: \.self +/// ) { +/// Text("Item \($0)") +/// } +/// } +/// } +/// +/// ![Ten text views, named Item 1 through Item 10, arranged in a +/// vertical line.](OpenSwiftUI-VStack-simple.png) +/// +/// > Note: If you need a vertical stack that conforms to the ``Layout`` +/// protocol, like when you want to create a conditional layout using +/// ``AnyLayout``, use ``VStackLayout`` instead. +@available(OpenSwiftUI_v1_0, *) +@frozen +public struct VStack: View, UnaryView, PrimitiveView where Content: View { + @usableFromInline + var _tree: _VariadicView.Tree<_VStackLayout, Content> + + /// Creates an instance with the given spacing and horizontal alignment. + /// + /// - Parameters: + /// - alignment: The guide for aligning the subviews in this stack. This + /// guide has the same vertical screen coordinate for every subview. + /// - spacing: The distance between adjacent subviews, or `nil` if you + /// want the stack to choose a default distance for each pair of + /// subviews. + /// - content: A view builder that creates the content of this stack. + @inlinable + public init( + alignment: HorizontalAlignment = .center, + spacing: CGFloat? = nil, + @ViewBuilder content: () -> Content + ) { + _tree = .init( + _VStackLayout(alignment: alignment, spacing: spacing) + ) { + content() + } + } + + nonisolated public static func _makeView( + view: _GraphValue, + inputs: _ViewInputs + ) -> _ViewOutputs { + _VariadicView.Tree.makeDebuggableView( + view: view[offset: { .of(&$0._tree) }], + inputs: inputs + ) + } +} + +@available(*, unavailable) +extension VStack: Sendable {} + +@_spi(ReallyDoNotImport) +@available(OpenSwiftUI_v4_0, *) +@available(*, deprecated, renamed: "VStackLayout") +extension VStack: Animatable where Content == EmptyView { + public typealias AnimatableData = EmptyAnimatableData +} + +@_spi(ReallyDoNotImport) +@available(OpenSwiftUI_v4_0, *) +@available(*, deprecated, renamed: "VStackLayout") +extension VStack: Layout where Content == EmptyView { + public typealias Cache = _VStackLayout.Cache +} + +@available(*, deprecated, renamed: "VStackLayout") +extension VStack: DerivedLayout where Content == EmptyView { + package typealias Base = _VStackLayout + + package var base: _VStackLayout { + _VStackLayout( + alignment: _tree.root.alignment, + spacing: _tree.root.spacing + ) + } +} + +@frozen +public struct _VStackLayout { + public var alignment: HorizontalAlignment + + public var spacing: CGFloat? + + @inlinable + public init(alignment: HorizontalAlignment = .center, spacing: CGFloat? = nil) { + self.alignment = alignment + self.spacing = spacing + } + + package static let majorAxis: Axis = .vertical +} + +extension _VStackLayout: HVStack { + @available(OpenSwiftUI_v1_0, *) + public typealias Body = Never + + @available(OpenSwiftUI_v1_0, *) + package typealias MinorAxisAlignment = HorizontalAlignment +} + +@available(OpenSwiftUI_v4_0, *) +extension _VStackLayout: Layout { + public typealias Cache = _StackLayoutCache + + @available(OpenSwiftUI_v4_0, *) + public typealias AnimatableData = EmptyAnimatableData +} + +extension _VStackLayout: _VariadicView.ImplicitRoot { + package static var implicitRoot: _VStackLayout { .init() } +} + +/// A vertical container that you can use in conditional layouts. +/// +/// This layout container behaves like a ``VStack``, but conforms to the +/// ``Layout`` protocol so you can use it in the conditional layouts that you +/// construct with ``AnyLayout``. If you don't need a conditional layout, use +/// ``VStack`` instead. +@available(OpenSwiftUI_v4_0, *) +@frozen +public struct VStackLayout: Layout { + /// The horizontal alignment of subviews. + public var alignment: HorizontalAlignment + + /// The distance between adjacent subviews. + /// + /// Set this value to `nil` to use default distances between subviews. + public var spacing: CGFloat? + + /// Creates a vertical stack with the specified spacing and horizontal + /// alignment. + /// + /// - Parameters: + /// - alignment: The guide for aligning the subviews in this stack. It + /// has the same horizontal screen coordinate for all subviews. + /// - spacing: The distance between adjacent subviews. Set this value + /// to `nil` to use default distances between subviews. + @inlinable + public init(alignment: HorizontalAlignment = .center, spacing: CGFloat? = nil) { + self.alignment = alignment + self.spacing = spacing + } + + @available(OpenSwiftUI_v4_0, *) + public typealias AnimatableData = EmptyAnimatableData + + @available(OpenSwiftUI_v4_0, *) + public typealias Cache = _VStackLayout.Cache +} + +extension VStackLayout: DerivedLayout { + package var base: _VStackLayout { + .init(alignment: alignment, spacing: spacing) + } + + @available(OpenSwiftUI_v4_0, *) + package typealias Base = _VStackLayout +} diff --git a/Sources/OpenSwiftUICore/Layout/Stack/ZStack.swift b/Sources/OpenSwiftUICore/Layout/Stack/ZStack.swift new file mode 100644 index 00000000..3d09d0cc --- /dev/null +++ b/Sources/OpenSwiftUICore/Layout/Stack/ZStack.swift @@ -0,0 +1,197 @@ +// +// ZStack.swift +// OpenSwiftUICore +// +// Audited for 6.4.41 +// Status: WIP + +public import Foundation + +/// A view that overlays its subviews, aligning them in both axes. +/// +/// The `ZStack` assigns each successive subview a higher z-axis value than +/// the one before it, meaning later subviews appear "on top" of earlier ones. +/// +/// The following example creates a `ZStack` of 100 x 100 point ``Rectangle`` +/// views filled with one of six colors, offsetting each successive subview +/// by 10 points so they don't completely overlap: +/// +/// let colors: [Color] = +/// [.red, .orange, .yellow, .green, .blue, .purple] +/// +/// var body: some View { +/// ZStack { +/// ForEach(0.. Note: If you need a version of this stack that conforms to the ``Layout`` +/// protocol, like when you want to create a conditional layout using +/// ``AnyLayout``, use ``ZStackLayout`` instead. +@available(OpenSwiftUI_v1_0, *) +@frozen +public struct ZStack: View, UnaryView, PrimitiveView where Content: View { + @usableFromInline + package var _tree: _VariadicView.Tree<_ZStackLayout, Content> + + @inlinable + public init(alignment: Alignment = .center, @ViewBuilder content: () -> Content) { + _tree = .init(_ZStackLayout(alignment: alignment)) { content() } + } + + nonisolated public static func _makeView( + view: _GraphValue>, + inputs: _ViewInputs + ) -> _ViewOutputs { + _VariadicView.Tree.makePlatformSubstitutableView( + view: view[offset: { .of(&$0._tree) }], + inputs: inputs + ) + } + + @available(OpenSwiftUI_v1_0, *) + public typealias Body = Never +} + +@available(*, unavailable) +extension ZStack: Sendable {} + +@available(OpenSwiftUI_v1_0, *) +@frozen +public struct _ZStackLayout: _VariadicView.UnaryViewRoot, Animatable { + public var alignment: Alignment + + @inlinable + public init(alignment: Alignment = .center) { + self.alignment = alignment + } + + nonisolated public static func _makeView( + root: _GraphValue<_ZStackLayout>, + inputs: _ViewInputs, + body: (_Graph, _ViewInputs) -> _ViewListOutputs + ) -> _ViewOutputs { + CoreGlue.shared.makeLayoutView( + root: root, + inputs: inputs, + body: body + ) + } + + @available(OpenSwiftUI_v1_0, *) + public typealias AnimatableData = EmptyAnimatableData + + @available(OpenSwiftUI_v1_0, *) + public typealias Body = Never +} + +@available(OpenSwiftUI_v4_0, *) +extension _ZStackLayout: Layout { + public static var layoutProperties: LayoutProperties { + var properties = LayoutProperties() + properties.stackOrientation = nil + properties.isIdentityUnaryLayout = true + return properties + } + + public func placeSubviews( + in bounds: CGRect, + proposal: ProposedViewSize, + subviews: _ZStackLayout.Subviews, + cache: inout Void + ) { + preconditionFailure("TODO") + } + + public func spacing(subviews: _ZStackLayout.Subviews, cache: inout Void) -> ViewSpacing { + preconditionFailure("TODO") + } + + public func sizeThatFits( + proposal: ProposedViewSize, + subviews: _ZStackLayout.Subviews, + cache: inout Void + ) -> CGSize { + preconditionFailure("TODO") + } + + @available(OpenSwiftUI_v4_0, *) + public typealias Cache = Void +} + +extension _ZStackLayout: _VariadicView.ImplicitRoot { + package static var implicitRoot: _ZStackLayout { .init() } +} + +/// An overlaying container that you can use in conditional layouts. +/// +/// This layout container behaves like a ``ZStack``, but conforms to the +/// ``Layout`` protocol so you can use it in the conditional layouts that you +/// construct with ``AnyLayout``. If you don't need a conditional layout, use +/// ``ZStack`` instead. +@available(OpenSwiftUI_v4_0, *) +@frozen +public struct ZStackLayout: Layout { + /// The alignment of subviews. + public var alignment: Alignment + + /// Creates a stack with the specified alignment. + /// + /// - Parameters: + /// - alignment: The guide for aligning the subviews in this stack + /// on both the x- and y-axes. + @inlinable + public init(alignment: Alignment = .center) { + self.alignment = alignment + } + + @available(OpenSwiftUI_v4_0, *) + public typealias AnimatableData = EmptyAnimatableData + + @available(OpenSwiftUI_v4_0, *) + public typealias Cache = Void +} + +extension ZStackLayout: DerivedLayout { + package var base: _ZStackLayout { + .init(alignment: alignment) + } + + @available(OpenSwiftUI_v4_0, *) + package typealias Base = _ZStackLayout +} diff --git a/Sources/OpenSwiftUICore/Tracing/ReuseTrace.swift b/Sources/OpenSwiftUICore/Tracing/ReuseTrace.swift index 5c9708a4..c57a9c9f 100644 --- a/Sources/OpenSwiftUICore/Tracing/ReuseTrace.swift +++ b/Sources/OpenSwiftUICore/Tracing/ReuseTrace.swift @@ -24,31 +24,80 @@ package struct ReuseTrace { // OGGraphAddTraceEvent // recorder.graph.addTraceEvent(name) } - + @inline(__always) package static func traceReuseInternalFailure() { traceReuseFailure("resuse_internal") } - + @inline(__always) package static func traceReuseViewInputsDifferentFailure() { traceReuseFailure("reuse_inputsDifferent") } + @inline(__always) + package static func traceReuseSkippedNotIdle(_ subgraph: Subgraph) { + // TODO + } + + @inline(__always) + package static func traceReuseItemUnplaced(_ subgraph: Subgraph) { + // TODO + } + + @inline(__always) + package static func traceCacheItemRecycled(_ subgraph: Subgraph) { + // TODO + } + + @inline(__always) + package static func traceReuseCacheItemPlaced(_ subgraph: Subgraph) { + // TODO + } + + @inline(__always) + package static func traceReuseCacheItemFailure(_ subgraph: Subgraph) { + // TODO + } + + @inline(__always) + package static func traceReuseCacheItemAdded(_ itemReuseIdentifier: Int, _ subgraph: Subgraph) { + // TODO + } + + @inline(__always) + package static func traceMismatchedReuseIDFailure(_ itemReuseIdentifier: Int, _ subgraph: Subgraph) { + // TODO + } + + @inline(__always) + package static func traceReuseIdentifier(_ itemReuseIdentifier: Int) { + // TODO + } + + @inline(__always) + package static func traceReuseTypeComparisonFailure(_ baseType: (any Any.Type)?, _ candidateType: (any Any.Type)?) { + // TODO + } + @inline(__always) package static func traceReuseUnaryElementExpectedFailure(_ elementType: any Any.Type) { - traceReuseFailure("reuse_unaryElement") + // TODO } @inline(__always) package static func traceReuseInvalidSubgraphFailure(_ typeFoundInvalid: any Any.Type) { - // FIXME: ReuseTraceInternal.InvalidSubgraphFailure - traceReuseFailure("reuse_invalidSubgraph") + // TODO + } + + @inline(__always) + package static func traceReuseIncompatibleListsFailure(_ baseList: any Any.Type, _ candidateList: any Any.Type) { + // TODO } @inline(__always) package static func traceReuseBodyMismatchedFailure() { - traceReuseFailure("reuse_bodyMismatched") + // TODO } @inline(__always) @@ -56,7 +105,10 @@ package struct ReuseTrace { // TODO } - // TODO + @inline(__always) + package static func traceReusePreventedFailure(_ preventingType: any Any.Type) { + // TODO + } final package class Recorder { var graph: Graph diff --git a/Sources/OpenSwiftUICore/View/Input/ViewPlatformOutputs.swift b/Sources/OpenSwiftUICore/View/Input/ViewPlatformOutputs.swift new file mode 100644 index 00000000..77bad323 --- /dev/null +++ b/Sources/OpenSwiftUICore/View/Input/ViewPlatformOutputs.swift @@ -0,0 +1,58 @@ +// +// ViewPlatformOutputs.swift +// OpenSwiftUICore +// +// Audited for 6.4.41 +// Status: Complete + +extension _ViewOutputs { + package static func makePlatformRootGeometryTransform( + inputs: _ViewInputs, + body: (_ViewInputs) -> _ViewOutputs + ) -> _ViewOutputs { + body(inputs) + } +} + +extension _VariadicView.Tree where Root: _VariadicView_ViewRoot, Content: View { + @inline(__always) + package static func makePlatformSubstitutableView( + view: _GraphValue, + inputs: _ViewInputs + ) -> _ViewOutputs { + makeDebuggableView(view: view, inputs: inputs) + } +} + +protocol ZStackParameterSmuggle { + static func makeParameterSmuggledZStackView( + view: _GraphValue<_VariadicView.Tree<_ZStackLayout, Content>>, + inputs: _ViewInputs + ) -> _ViewOutputs where Content: View +} + +extension _VariadicView.Tree where Root == _ZStackLayout, Content: View { + @inline(__always) + package static func makePlatformSubstitutableView( + view: _GraphValue, + inputs: _ViewInputs + ) -> _ViewOutputs { + if let conformance = Content.self as? any ZStackParameterSmuggle.Type { + conformance.makeParameterSmuggledZStackView( + view: view, + inputs: inputs) + } else { + makeDebuggableView(view: view, inputs: inputs) + } + } +} + +package func makePlatformSecondaryView( + primaryInputs: _ViewInputs, + primaryOutputs: _ViewOutputs, + secondaryInputs: _ViewInputs, + flipOrder: Bool, + body: @escaping (_Graph, _ViewInputs) -> _ViewOutputs +) -> _ViewOutputs { + body(_Graph(), secondaryInputs) +}