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
30 changes: 20 additions & 10 deletions .swiftformat
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@
--asynccapturing
--beforemarks
--binarygrouping 4,8
--callsiteparen default
--categorymark "MARK: %c"
--classthreshold 0
--closingparen balanced
--closurevoid remove
--commas always
--complexattrs preserve
--computedvarattrs preserve
--condassignment after-property
--conflictmarkers reject
--dateformat system
--decimalgrouping 3,6
--doccomments before-declarations
--elseposition same-line
--emptybraces no-space
--enumnamespaces always
Expand All @@ -30,46 +36,51 @@
--header ignore
--hexgrouping 4,8
--hexliteralcase uppercase
--ifdef no-indent
--ifdef indent
--importgrouping alpha
--indent 4
--indentcase false
--indentstrings false
--initcodernil false
--lifecycle
--lineaftermarks true
--linebreaks lf
--markcategories true
--markextensions always
--marktypes always
--maxwidth none
--modifierorder
--modifierorder nonisolated,public
--nevertrailing
--nilinit remove
--noncomplexattrs
--nospaceoperators
--nowrapoperators
--octalgrouping 4,8
--onelineforeach ignore
--operatorfunc spaced
--organizationmode visibility
--organizetypes actor,class,enum,struct
--patternlet hoist
--ranges spaced
--redundanttype inferred
--redundanttype infer-locals-only
--self remove
--selfrequired
--semicolons inline
--shortoptionals always
--shortoptionals except-properties
--smarttabs enabled
--someany false
--someany true
--storedvarattrs preserve
--stripunusedargs always
--structthreshold 0
--swiftversion 5.10
--tabwidth unspecified
--throwcapturing
--timezone system
--trailingclosures
--trimwhitespace nonblank-lines
--trimwhitespace always
--typeattributes preserve
--typeblanklines remove
--typedelimiter space-after
--typemark "MARK: - %t"
--varattributes preserve
--voidtype void
--wraparguments preserve
--wrapcollections preserve
Expand All @@ -82,5 +93,4 @@
--wraptypealiases preserve
--xcodeindentation disabled
--yodaswap always
--disable blankLineAfterImports,wrapMultilineStatementBraces
--enable acronyms,blankLinesBetweenImports
--disable unusedArguments
22 changes: 22 additions & 0 deletions Sources/OpenSwiftUICore/Data/Transaction/TransitionTraitKey.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// TransitionTraitKey.swift
// OpenSwiftUICore
//
// Audited for iOS 18.0
// Status: WIP

@usableFromInline
struct CanTransitionTraitKey: _ViewTraitKey {
@inlinable
static var defaultValue: Bool { false }
}

@available(*, unavailable)
extension CanTransitionTraitKey: Sendable {}

extension ViewTraitCollection {
package var canTransition: Bool {
get { self[CanTransitionTraitKey.self] }
set { self[CanTransitionTraitKey.self] = newValue }
}
}
19 changes: 12 additions & 7 deletions Sources/OpenSwiftUICore/Graph/GraphInputs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@ public struct _GraphInputs {
package struct Phase: Equatable {
var value: UInt32

@inline(__always)
static var isBeingRemovedBitCount: Int { 1 }
@inline(__always)
static var isBeingRemovedMask: UInt32 { (1 << isBeingRemovedBitCount) - 1}
@inline(__always)
static var resetSeedMask: UInt32 { ~isBeingRemovedMask }

@inlinable
package init(value: UInt32) {
self.value = value
Expand All @@ -211,19 +218,17 @@ public struct _GraphInputs {

@inlinable
package var resetSeed: UInt32 {
get { value >> 1 }
set { value = (newValue << 1) | (value & 1) }
get { value >> Self.isBeingRemovedBitCount }
set { value = (newValue << Self.isBeingRemovedBitCount) | (value & Self.isBeingRemovedMask) }
}

package var isBeingRemoved: Bool {
get { value & 1 != 0 }
set { value = (newValue ? 1 : 0) | (value & 0xFFFF_FFFE) }
get { (value & Self.isBeingRemovedMask) != 0 }
set { value = (newValue ? 1 : 0) | (value & Self.resetSeedMask) }
}

@inlinable
package var isInserted: Bool {
value & 1 == 0
}
package var isInserted: Bool { !isBeingRemoved }

@inlinable
package mutating func merge(_ other: _GraphInputs.Phase) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenSwiftUICore/Graph/GraphReuse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ package import OpenGraphShims
package typealias Subgraph = OGSubgraph
package typealias Graph = OGGraph

package final class IndirectAttributeMap {
public final class IndirectAttributeMap {
#if canImport(Darwin)
package final let subgraph: Subgraph
package final var map: [AnyAttribute: AnyAttribute]
Expand Down
18 changes: 17 additions & 1 deletion Sources/OpenSwiftUICore/Graph/ReuseTrace.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,23 @@ package struct ReuseTrace {
package static func traceReuseViewInputsDifferentFailure() {
traceReuseFailure("reuse_inputsDifferent")
}


@inline(__always)
package static func traceReuseUnaryElementExpectedFailure(_ elementType: any Any.Type) {
traceReuseFailure("reuse_unaryElement")
}

@inline(__always)
package static func traceReuseInvalidSubgraphFailure(_ typeFoundInvalid: any Any.Type) {
// FIXME: ReuseTraceInternal.InvalidSubgraphFailure
traceReuseFailure("reuse_invalidSubgraph")
}

@inline(__always)
package static func traceReuseBodyMismatchedFailure() {
traceReuseFailure("reuse_bodyMismatched")
}

// TODO

final package class Recorder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,56 @@ extension _ViewModifier_Content {
}
}
}

// MARK: - BodyInput

// FIXME
private struct BodyInput<Input> {}

private enum BodyInputElement: GraphReusable, Equatable {
typealias MakeViewBody = (_Graph, _ViewInputs) -> _ViewOutputs
typealias MakeViewListBody = (_Graph, _ViewListInputs) -> _ViewListOutputs

case view(MakeViewBody)
case list(MakeViewListBody)

static func == (lhs: BodyInputElement, rhs: BodyInputElement) -> Bool {
if case let .view(lhsBody) = lhs, case let .view(rhsBody) = rhs {
compareValues(lhsBody, rhsBody, options: .init(rawValue: 0x103))
} else if case let .list(lhsBody) = lhs, case let .list(rhsBody) = rhs{
compareValues(lhsBody, rhsBody, options: .init(rawValue: 0x103))
} else {
false
}
}

static var isTriviallyReusable: Bool {
_SemanticFeature_v5.isEnabled
}

func makeReusable(indirectMap: IndirectAttributeMap) {
return
}

func tryToReuse(by other: BodyInputElement, indirectMap: IndirectAttributeMap, testOnly: Bool) -> Bool {
switch self {
case let .view(makeViewBody):
guard case let .view(otherMakeViewBody) = other else {
ReuseTrace.traceReuseInternalFailure()
return false
}
return Self.isTriviallyReusable || compareValues(makeViewBody, otherMakeViewBody, options: .init(rawValue: 0x103))
case let .list(makeViewListBody):
guard case let .list(otherMakeViewListBody) = other else {
ReuseTrace.traceReuseInternalFailure()
return false
}
return Self.isTriviallyReusable || compareValues(makeViewListBody, otherMakeViewListBody, options: .init(rawValue: 0x103))
}
}
}


private struct BodyCountInput<V>: ViewInput {
static var defaultValue: Stack<_ViewListCountInputs> { .init() }
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ extension ViewModifier where Self: _GraphInputsModifier, Body == Never {
body: @escaping (_Graph, _ViewListInputs) -> _ViewListOutputs
) -> _ViewListOutputs {
var inputs = inputs
inputs.withMutateGraphInputs { inputs in
_makeInputs(modifier: modifier, inputs: &inputs)
}
_makeInputs(modifier: modifier, inputs: &inputs.base)
let outputs = body(_Graph(), inputs)
return outputs
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ extension _GraphInputs {
pushScope(id: makeStableTypeData(type))
}

package var stableIDScope: WeakAttribute<_DisplayList_StableIdentityScope>? {
package var stableIDScope: WeakAttribute<DisplayList.StableIdentityScope>? {
guard !options.contains(.needsStableDisplayListIDs) else {
return nil
}
Expand Down
4 changes: 4 additions & 0 deletions Sources/OpenSwiftUICore/View/AnyView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,10 @@ private struct AnyViewList: StatefulRule, AsyncAttribute {
}

struct Transform: _ViewList_SublistTransform_Item {
func bindID(_ id: inout _ViewList_ID) {
// TODO
}

func apply(sublist: inout _ViewList_Sublist) {
item.bindID(&sublist.id)
sublist.elements = item.wrapping(sublist.elements)
Expand Down
4 changes: 1 addition & 3 deletions Sources/OpenSwiftUICore/View/CustomView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ extension View {
nonisolated package static func makeViewList(view: _GraphValue<Self>, inputs: _ViewListInputs) -> _ViewListOutputs {
let fields = DynamicPropertyCache.fields(of: Self.self)
var inputs = inputs
let (body, buffer) = inputs.withMutateGraphInputs { inputs in
makeBody(view: view, inputs: &inputs, fields: fields)
}
let (body, buffer) = makeBody(view: view, inputs: &inputs.base, fields: fields)
let outputs = Body.makeDebuggableViewList(view: body, inputs: inputs)
if let buffer {
buffer.traceMountedProperties(to: body, fields: fields)
Expand Down
5 changes: 1 addition & 4 deletions Sources/OpenSwiftUICore/View/EmptyView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ public struct EmptyView: PrimitiveView {
}

public static func _makeViewList(view: _GraphValue<EmptyView>, inputs: _ViewListInputs) -> _ViewListOutputs {
guard inputs.options.contains(.isNonEmptyParent) else {
return _ViewListOutputs.emptyParentViewList(inputs: inputs)
}
return _ViewListOutputs.nonEmptyParentViewList(inputs: inputs)
.emptyViewList(inputs: inputs)
}

public static func _viewListCount(inputs: _ViewListCountInputs) -> Int? {
Expand Down
Loading
Loading