Skip to content

Commit 3337a0b

Browse files
authored
Update ViewList (#103)
* Add makeViewList implementation * Complete missing EmptyView implementation * Update ViewTraitKeys * Fix AnyViewChildList implementation * Add some doc for Model * Update MutableBox implementation * Update AnyViewList * Update ViewList * Fix compile issue * Fix werror issue
1 parent 36c266c commit 3337a0b

25 files changed

+732
-258
lines changed

Package.resolved

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
2-
"originHash" : "7c61cf2fa8336371c9cc17d001d4e08e34b0f8b92c637a0c44f1b2cd08cd55b2",
2+
"originHash" : "9749b5257cf4f28f086bdeac0424718c7ae499aeea22fdc45686fac00d8d561d",
33
"pins" : [
44
{
55
"identity" : "opengraph",
66
"kind" : "remoteSourceControl",
77
"location" : "https://github.com/OpenSwiftUIProject/OpenGraph",
88
"state" : {
99
"branch" : "main",
10-
"revision" : "48ad5323175fbfdfde2287bbf26c3e5a861ae2bb"
10+
"revision" : "58961e8c7fb7528a89dcd77a3a28a950f1791f1f"
1111
}
1212
},
1313
{

Sources/OpenSwiftUI/Core/Data/Boxes/MutableBox.swift

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,38 @@
22
// MutableBox.swift
33
// OpenSwiftUI
44
//
5-
// Audited for RELEASE_2021
5+
// Audited for RELEASE_2024
66
// Status: Complete
77

88
@propertyWrapper
9-
final class MutableBox<A> {
10-
private var value: A
11-
12-
var wrappedValue: A {
13-
get { value }
14-
set { value = newValue }
15-
}
9+
final package class MutableBox<T> {
10+
final package var value: T
1611

17-
init(_ value: A) {
12+
@inlinable
13+
package init(_ value: T) {
1814
self.value = value
1915
}
2016

21-
init(wrappedValue value: A) {
22-
self.value = value
17+
@inlinable
18+
convenience package init(wrappedValue value: T) {
19+
self.init(value)
2320
}
24-
25-
var projectedValue: MutableBox<A> {
21+
22+
@inlinable
23+
final package var wrappedValue: T {
24+
get { value }
25+
set { value = newValue }
26+
}
27+
28+
@inlinable
29+
final package var projectedValue: MutableBox<T> {
2630
self
2731
}
2832
}
2933

30-
extension MutableBox: Equatable where A: Equatable {
31-
static func == (lhs: MutableBox<A>, rhs: MutableBox<A>) -> Bool {
34+
extension MutableBox: Equatable where T: Equatable {
35+
@inlinable
36+
package static func == (lhs: MutableBox<T>, rhs: MutableBox<T>) -> Bool {
3237
lhs.value == rhs.value
3338
}
3439
}

Sources/OpenSwiftUI/Core/Data/Location/AnyLocation.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,18 @@
55
// Audited for RELEASE_2021
66
// Status: Complete
77

8+
/// The base type of all type-erased locations.
89
@usableFromInline
910
class AnyLocationBase {}
1011

12+
/// The base type of all type-erased locations with value-type Value.
13+
/// It is annotated as `@unchecked Sendable` so that user types such as
14+
/// `State`, and `SceneStorage` can be cleanly `Sendable`. However, it is
15+
/// also the user types' responsibility to ensure that `get`, and `set` does
16+
/// not access the graph concurrently (`get` should not be called while graph
17+
/// is updating, for example).
1118
@usableFromInline
12-
class AnyLocation<Value>: AnyLocationBase {
19+
class AnyLocation<Value>: AnyLocationBase, @unchecked Sendable {
1320
var wasRead: Bool {
1421
get { fatalError() }
1522
set { fatalError() }

Sources/OpenSwiftUI/Core/Data/Property/PropertyList.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ internal import OpenGraphShims
1111

1212
// MARK: - PropertyList
1313

14+
/// A mutable container of key-value pairs
1415
@usableFromInline
1516
@frozen
1617
struct PropertyList: CustomStringConvertible {

Sources/OpenSwiftUI/Core/View/CustomView.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ extension View {
1515
let (body, buffer) = inputs.withMutateGraphInputs { inputs in
1616
makeBody(view: view, inputs: &inputs, fields: fields)
1717
}
18+
// FIXME
1819
let outputs = _ViewDebug.makeView(
1920
view: body,
2021
inputs: inputs
@@ -27,6 +28,19 @@ extension View {
2728
return outputs
2829
}
2930

31+
static func makeViewList(view: _GraphValue<Self>, inputs: _ViewListInputs) -> _ViewListOutputs {
32+
let fields = DynamicPropertyCache.fields(of: Self.self)
33+
var inputs = inputs
34+
let (body, buffer) = inputs.withMutateGraphInputs { inputs in
35+
makeBody(view: view, inputs: &inputs, fields: fields)
36+
}
37+
let outputs = Body.makeDebuggableViewList(view: body, inputs: inputs)
38+
if let buffer {
39+
buffer.traceMountedProperties(to: body, fields: fields)
40+
}
41+
return outputs
42+
}
43+
3044
private static func makeBody(
3145
view: _GraphValue<Self>,
3246
inputs: inout _GraphInputs,

Sources/OpenSwiftUI/Core/View/VariadicView/VariadicView_ImplicitRoot.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ package protocol _VariadicView_ImplicitRoot: _VariadicView_AnyImplicitRoot, _Var
1818
}
1919

2020
extension _VariadicView_ImplicitRoot {
21-
package func visitType<Visitor: _VariadicView_ImplicitRootVisitor>(visitor: inout Visitor) {
21+
package static func visitType<V>(visitor: inout V) where V: _VariadicView_ImplicitRootVisitor {
2222
visitor.visit(type: Self.self)
2323
}
2424
}

Sources/OpenSwiftUI/Core/View/View.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ extension View {
8585
}
8686

8787
public static func _makeViewList(view: _GraphValue<Self>, inputs: _ViewListInputs) -> _ViewListOutputs {
88-
fatalError("TODO")
88+
makeViewList(view: view, inputs: inputs)
8989
}
9090

9191
public static func _viewListCount(inputs: _ViewListCountInputs) -> Int? {

0 commit comments

Comments
 (0)