Skip to content

Commit

Permalink
Fix compile issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle-Ye committed Sep 1, 2024
1 parent 00756e6 commit b36e6a5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Sources/OpenSwiftUI/Core/Data/Boxes/MutableBox.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final package class MutableBox<T> {

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

@inlinable
Expand Down
4 changes: 4 additions & 0 deletions Sources/OpenSwiftUI/Core/View/View/ViewList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,9 @@ package struct _ViewList_ID {

private struct Explicit: Equatable {
let id: AnyHashable
#if canImport(Darwin)
let owner: OGAttribute
#endif
let isUnary: Bool
}

Expand All @@ -200,9 +202,11 @@ package struct _ViewList_ID {
var explicitID: AnyHashable?
}

#if canImport(Darwin)
mutating func bind(explicitID: AnyHashable, owner: OGAttribute, isUnary: Bool) {
explicitIDs.append(.init(id: explicitID, owner: owner, isUnary: isUnary))
}
#endif
}

// MARK: - IndirectMap
Expand Down
16 changes: 16 additions & 0 deletions Sources/OpenSwiftUI/View/View/AnyView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -266,12 +266,15 @@ private struct AnyViewList: StatefulRule, AsyncAttribute {

final class Item: _ViewList_Subgraph {
let type: Any.Type
#if canImport(Darwin)
let owner: OGAttribute
#endif
@Attribute var list: ViewList
let id: UniqueID
let isUnary: Bool
let allItems: MutableBox<[Unmanaged<Item>]>

#if canImport(Darwin)
init(type: Any.Type, owner: OGAttribute, list: Attribute<ViewList>, id: UniqueID, isUnary: Bool, subgraph: OGSubgraph, allItems: MutableBox<[Unmanaged<Item>]>) {
self.type = type
self.owner = owner
Expand All @@ -282,6 +285,17 @@ private struct AnyViewList: StatefulRule, AsyncAttribute {
super.init(subgraph: subgraph)
allItems.wrappedValue.append(.passUnretained(self))
}
#else
init(type: Any.Type, list: Attribute<ViewList>, id: UniqueID, isUnary: Bool, subgraph: OGSubgraph, allItems: MutableBox<[Unmanaged<Item>]>) {
self.type = type
_list = list
self.id = id
self.isUnary = isUnary
self.allItems = allItems
super.init(subgraph: subgraph)
allItems.wrappedValue.append(.passUnretained(self))
}
#endif

override func invalidate() {
for (index, item) in allItems.wrappedValue.enumerated() {
Expand All @@ -294,7 +308,9 @@ private struct AnyViewList: StatefulRule, AsyncAttribute {
}

func bindID(_ id: inout _ViewList_ID) {
#if canImport(Darwin)
id.bind(explicitID: AnyHashable(self.id), owner: owner, isUnary: isUnary)
#endif
}
}

Expand Down

0 comments on commit b36e6a5

Please sign in to comment.