Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ViewList #103

Merged
merged 10 commits into from
Sep 2, 2024
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 Package.resolved
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"originHash" : "7c61cf2fa8336371c9cc17d001d4e08e34b0f8b92c637a0c44f1b2cd08cd55b2",
"originHash" : "9749b5257cf4f28f086bdeac0424718c7ae499aeea22fdc45686fac00d8d561d",
"pins" : [
{
"identity" : "opengraph",
"kind" : "remoteSourceControl",
"location" : "https://github.com/OpenSwiftUIProject/OpenGraph",
"state" : {
"branch" : "main",
"revision" : "48ad5323175fbfdfde2287bbf26c3e5a861ae2bb"
"revision" : "58961e8c7fb7528a89dcd77a3a28a950f1791f1f"
}
},
{
Expand Down
35 changes: 20 additions & 15 deletions Sources/OpenSwiftUI/Core/Data/Boxes/MutableBox.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,38 @@
// MutableBox.swift
// OpenSwiftUI
//
// Audited for RELEASE_2021
// Audited for RELEASE_2024
// Status: Complete

@propertyWrapper
final class MutableBox<A> {
private var value: A

var wrappedValue: A {
get { value }
set { value = newValue }
}
final package class MutableBox<T> {
final package var value: T

init(_ value: A) {
@inlinable
package init(_ value: T) {
self.value = value
}

init(wrappedValue value: A) {
self.value = value
@inlinable
convenience package init(wrappedValue value: T) {
self.init(value)
}

var projectedValue: MutableBox<A> {

@inlinable
final package var wrappedValue: T {
get { value }
set { value = newValue }
}

@inlinable
final package var projectedValue: MutableBox<T> {
self
}
}

extension MutableBox: Equatable where A: Equatable {
static func == (lhs: MutableBox<A>, rhs: MutableBox<A>) -> Bool {
extension MutableBox: Equatable where T: Equatable {
@inlinable
package static func == (lhs: MutableBox<T>, rhs: MutableBox<T>) -> Bool {

Check warning on line 36 in Sources/OpenSwiftUI/Core/Data/Boxes/MutableBox.swift

View check run for this annotation

Codecov / codecov/patch

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

Added line #L36 was not covered by tests
lhs.value == rhs.value
}
}
9 changes: 8 additions & 1 deletion Sources/OpenSwiftUI/Core/Data/Location/AnyLocation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@
// Audited for RELEASE_2021
// Status: Complete

/// The base type of all type-erased locations.
@usableFromInline
class AnyLocationBase {}

/// The base type of all type-erased locations with value-type Value.
/// It is annotated as `@unchecked Sendable` so that user types such as
/// `State`, and `SceneStorage` can be cleanly `Sendable`. However, it is
/// also the user types' responsibility to ensure that `get`, and `set` does
/// not access the graph concurrently (`get` should not be called while graph
/// is updating, for example).
@usableFromInline
class AnyLocation<Value>: AnyLocationBase {
class AnyLocation<Value>: AnyLocationBase, @unchecked Sendable {
var wasRead: Bool {
get { fatalError() }
set { fatalError() }
Expand Down
1 change: 1 addition & 0 deletions Sources/OpenSwiftUI/Core/Data/Property/PropertyList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ internal import OpenGraphShims

// MARK: - PropertyList

/// A mutable container of key-value pairs
@usableFromInline
@frozen
struct PropertyList: CustomStringConvertible {
Expand Down
14 changes: 14 additions & 0 deletions Sources/OpenSwiftUI/Core/View/CustomView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
let (body, buffer) = inputs.withMutateGraphInputs { inputs in
makeBody(view: view, inputs: &inputs, fields: fields)
}
// FIXME

Check warning on line 18 in Sources/OpenSwiftUI/Core/View/CustomView.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUI/Core/View/CustomView.swift#L18

Added line #L18 was not covered by tests
let outputs = _ViewDebug.makeView(
view: body,
inputs: inputs
Expand All @@ -27,6 +28,19 @@
return outputs
}

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)

Check warning on line 35 in Sources/OpenSwiftUI/Core/View/CustomView.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUI/Core/View/CustomView.swift#L31-L35

Added lines #L31 - L35 were not covered by tests
}
let outputs = Body.makeDebuggableViewList(view: body, inputs: inputs)
if let buffer {
buffer.traceMountedProperties(to: body, fields: fields)

Check warning on line 39 in Sources/OpenSwiftUI/Core/View/CustomView.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUI/Core/View/CustomView.swift#L37-L39

Added lines #L37 - L39 were not covered by tests
}
return outputs

Check warning on line 41 in Sources/OpenSwiftUI/Core/View/CustomView.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUI/Core/View/CustomView.swift#L41

Added line #L41 was not covered by tests
}

private static func makeBody(
view: _GraphValue<Self>,
inputs: inout _GraphInputs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
}

extension _VariadicView_ImplicitRoot {
package func visitType<Visitor: _VariadicView_ImplicitRootVisitor>(visitor: inout Visitor) {
package static func visitType<V>(visitor: inout V) where V: _VariadicView_ImplicitRootVisitor {

Check warning on line 21 in Sources/OpenSwiftUI/Core/View/VariadicView/VariadicView_ImplicitRoot.swift

View check run for this annotation

Codecov / codecov/patch

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

Added line #L21 was not covered by tests
visitor.visit(type: Self.self)
}
}
2 changes: 1 addition & 1 deletion Sources/OpenSwiftUI/Core/View/View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
}

public static func _makeViewList(view: _GraphValue<Self>, inputs: _ViewListInputs) -> _ViewListOutputs {
fatalError("TODO")
makeViewList(view: view, inputs: inputs)

Check warning on line 88 in Sources/OpenSwiftUI/Core/View/View.swift

View check run for this annotation

Codecov / codecov/patch

Sources/OpenSwiftUI/Core/View/View.swift#L88

Added line #L88 was not covered by tests
}

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