Skip to content

Commit 2819341

Browse files
committed
Add _GraphInputs.recordReusableInput
1 parent b7e86ad commit 2819341

File tree

4 files changed

+348
-151
lines changed

4 files changed

+348
-151
lines changed
Lines changed: 123 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -1,141 +1,125 @@
1+
//@_spi(ForOpenSwiftUIOnly) import OpenSwiftUICore
12
//
2-
// GraphInputs.swift
3-
// OpenSwiftUICore
3+
//internal import OpenGraphShims
44
//
5-
// Audited for RELEASE_2021
6-
// Status: Complete
7-
8-
package protocol GraphInput: PropertyKey {
9-
static var isTriviallyReusable: Swift.Bool { get }
10-
static func makeReusable(indirectMap: IndirectAttributeMap, value: inout Value)
11-
static func tryToReuse(_ value: Value, by other: Value, indirectMap: IndirectAttributeMap, testOnly: Bool) -> Bool
12-
}
13-
14-
internal import OpenGraphShims
15-
16-
public struct _GraphInputs {
17-
var customInputs: PropertyList
18-
var time: Attribute<Time>
19-
var cachedEnvironment: MutableBox<CachedEnvironment>
20-
var phase: Attribute<_GraphInputs.Phase>
21-
var transaction: Attribute<Transaction>
22-
private var changedDebugProperties: _ViewDebug.Properties
23-
private var options: _GraphInputs.Options
24-
#if canImport(Darwin) // FIXME: See #39
25-
var mergedInputs: Set<AnyAttribute>
26-
#endif
27-
28-
#if canImport(Darwin)
29-
init(customInputs: PropertyList = PropertyList(),
30-
time: Attribute<Time>,
31-
cachedEnvironment: MutableBox<CachedEnvironment>,
32-
phase: Attribute<Phase>,
33-
transaction: Attribute<Transaction>,
34-
changedDebugProperties: _ViewDebug.Properties = [],
35-
options: _GraphInputs.Options = [],
36-
mergedInputs: Set<AnyAttribute> = []) {
37-
self.customInputs = customInputs
38-
self.time = time
39-
self.cachedEnvironment = cachedEnvironment
40-
self.phase = phase
41-
self.transaction = transaction
42-
self.changedDebugProperties = changedDebugProperties
43-
self.options = options
44-
self.mergedInputs = mergedInputs
45-
}
46-
#else // FIXME: See #39
47-
init(customInputs: PropertyList = PropertyList(),
48-
time: Attribute<Time>,
49-
cachedEnvironment: MutableBox<CachedEnvironment>,
50-
phase: Attribute<Phase>,
51-
transaction: Attribute<Transaction>,
52-
changedDebugProperties: _ViewDebug.Properties = [],
53-
options: _GraphInputs.Options = []/*,
54-
mergedInputs: Set<AnyAttribute> = []*/) {
55-
self.customInputs = customInputs
56-
self.time = time
57-
self.cachedEnvironment = cachedEnvironment
58-
self.phase = phase
59-
self.transaction = transaction
60-
self.changedDebugProperties = changedDebugProperties
61-
self.options = options
62-
/* self.mergedInputs = mergedInputs */
63-
}
64-
#endif
65-
66-
subscript<Input: GraphInput>(_ type: Input.Type) -> Input.Value {
67-
get { customInputs[type] }
68-
set { customInputs[type] = newValue }
69-
}
70-
71-
// MARK: - cachedEnvironment
72-
73-
@inline(__always)
74-
func detechedEnvironmentInputs() -> Self {
75-
var newInputs = self
76-
newInputs.cachedEnvironment = MutableBox(cachedEnvironment.wrappedValue)
77-
return newInputs
78-
}
79-
80-
@inline(__always)
81-
mutating func updateCachedEnvironment(_ box: MutableBox<CachedEnvironment>) {
82-
cachedEnvironment = box
83-
changedDebugProperties.insert(.environment)
84-
}
85-
86-
// MARK: - changedDebugProperties
87-
88-
@inline(__always)
89-
func withEmptyChangedDebugPropertiesInputs<R>(_ body: (_GraphInputs) -> R) -> R {
90-
var inputs = self
91-
inputs.changedDebugProperties = []
92-
return body(inputs)
93-
}
94-
95-
// MARK: - options
96-
97-
@inline(__always)
98-
var enableLayout: Bool {
99-
get { options.contains(.enableLayout) }
100-
// TODO: setter
101-
}
102-
}
103-
104-
extension _GraphInputs {
105-
struct Phase: Equatable {
106-
var value: UInt32
107-
108-
@inline(__always)
109-
var seed: UInt32 {
110-
get { value >> 1 }
111-
// TODO
112-
// set
113-
}
114-
}
115-
}
116-
117-
extension _GraphInputs {
118-
struct Options: OptionSet {
119-
let rawValue: UInt32
120-
121-
static var enableLayout: Options { Options(rawValue: 1 << 1) }
122-
}
123-
}
124-
125-
extension _GraphInputs {
126-
typealias ConstantID = Int
127-
128-
func intern<Value>(_ value: Value, id: ConstantID) -> Attribute<Value> {
129-
cachedEnvironment.wrappedValue.intern(value, id: id.internID)
130-
}
131-
}
132-
133-
extension _GraphInputs.ConstantID {
134-
@inline(__always)
135-
var internID: Self { self & 0x1 }
136-
}
137-
138-
/// Protocol for modifiers that only modify their children's inputs.
139-
public protocol _GraphInputsModifier {
140-
static func _makeInputs(modifier: _GraphValue<Self>, inputs: inout _GraphInputs)
141-
}
5+
//public struct _GraphInputs {
6+
// var customInputs: PropertyList
7+
// var time: Attribute<Time>
8+
// var cachedEnvironment: MutableBox<CachedEnvironment>
9+
// var phase: Attribute<_GraphInputs.Phase>
10+
// var transaction: Attribute<Transaction>
11+
// private var changedDebugProperties: _ViewDebug.Properties
12+
// private var options: _GraphInputs.Options
13+
// #if canImport(Darwin) // FIXME: See #39
14+
// var mergedInputs: Set<OGAttribute>
15+
// #endif
16+
//
17+
// #if canImport(Darwin)
18+
// init(customInputs: PropertyList = PropertyList(),
19+
// time: Attribute<Time>,
20+
// cachedEnvironment: MutableBox<CachedEnvironment>,
21+
// phase: Attribute<Phase>,
22+
// transaction: Attribute<Transaction>,
23+
// changedDebugProperties: _ViewDebug.Properties = [],
24+
// options: _GraphInputs.Options = [],
25+
// mergedInputs: Set<OGAttribute> = []) {
26+
// self.customInputs = customInputs
27+
// self.time = time
28+
// self.cachedEnvironment = cachedEnvironment
29+
// self.phase = phase
30+
// self.transaction = transaction
31+
// self.changedDebugProperties = changedDebugProperties
32+
// self.options = options
33+
// self.mergedInputs = mergedInputs
34+
// }
35+
// #else // FIXME: See #39
36+
// init(customInputs: PropertyList = PropertyList(),
37+
// time: Attribute<Time>,
38+
// cachedEnvironment: MutableBox<CachedEnvironment>,
39+
// phase: Attribute<Phase>,
40+
// transaction: Attribute<Transaction>,
41+
// changedDebugProperties: _ViewDebug.Properties = [],
42+
// options: _GraphInputs.Options = []/*,
43+
// mergedInputs: Set<OGAttribute> = []*/) {
44+
// self.customInputs = customInputs
45+
// self.time = time
46+
// self.cachedEnvironment = cachedEnvironment
47+
// self.phase = phase
48+
// self.transaction = transaction
49+
// self.changedDebugProperties = changedDebugProperties
50+
// self.options = options
51+
// /* self.mergedInputs = mergedInputs */
52+
// }
53+
// #endif
54+
//
55+
// subscript<Input: GraphInput>(_ type: Input.Type) -> Input.Value {
56+
// get { customInputs[type] }
57+
// set { customInputs[type] = newValue }
58+
// }
59+
//
60+
// // MARK: - cachedEnvironment
61+
//
62+
// @inline(__always)
63+
// func detechedEnvironmentInputs() -> Self {
64+
// var newInputs = self
65+
// newInputs.cachedEnvironment = MutableBox(cachedEnvironment.wrappedValue)
66+
// return newInputs
67+
// }
68+
//
69+
// @inline(__always)
70+
// mutating func updateCachedEnvironment(_ box: MutableBox<CachedEnvironment>) {
71+
// cachedEnvironment = box
72+
// changedDebugProperties.insert(.environment)
73+
// }
74+
//
75+
// // MARK: - changedDebugProperties
76+
//
77+
// @inline(__always)
78+
// func withEmptyChangedDebugPropertiesInputs<R>(_ body: (_GraphInputs) -> R) -> R {
79+
// var inputs = self
80+
// inputs.changedDebugProperties = []
81+
// return body(inputs)
82+
// }
83+
//
84+
// // MARK: - options
85+
//
86+
// @inline(__always)
87+
// var enableLayout: Bool {
88+
// get { options.contains(.enableLayout) }
89+
// // TODO: setter
90+
// }
91+
//}
92+
//
93+
//extension _GraphInputs {
94+
// struct Phase: Equatable {
95+
// var value: UInt32
96+
//
97+
// @inline(__always)
98+
// var seed: UInt32 {
99+
// get { value >> 1 }
100+
// // TODO
101+
// // set
102+
// }
103+
// }
104+
//}
105+
//
106+
//extension _GraphInputs {
107+
// struct Options: OptionSet {
108+
// let rawValue: UInt32
109+
//
110+
// static var enableLayout: Options { Options(rawValue: 1 << 1) }
111+
// }
112+
//}
113+
//
114+
//extension _GraphInputs {
115+
// typealias ConstantID = Int
116+
//
117+
// func intern<Value>(_ value: Value, id: ConstantID) -> Attribute<Value> {
118+
// cachedEnvironment.wrappedValue.intern(value, id: id.internID)
119+
// }
120+
//}
121+
//
122+
//extension _GraphInputs.ConstantID {
123+
// @inline(__always)
124+
// var internID: Self { self & 0x1 }
125+
//}

Sources/OpenSwiftUI/View/Control/Button/ButtonStyle/ButtonDefaultRenderingModeModifier.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ internal import COpenSwiftUI
1111
extension View {
1212
func buttonDefaultRenderingMode() -> some View {
1313
EmptyView()
14-
.modifier(StaticIf(ShouldRenderAsTemplate.self, then: ButtonDefaultRenderingModeModifier()))
14+
// .modifier(StaticIf(ShouldRenderAsTemplate.self, then: ButtonDefaultRenderingModeModifier()))
1515
}
1616
}
1717

@@ -22,13 +22,13 @@ private struct ButtonDefaultRenderingModeModifier: ViewModifier {
2222
}
2323
}
2424

25-
private struct ShouldRenderAsTemplate: Feature {
26-
static var isEnable: Bool {
27-
let semantics = Semantics.v2
28-
if let forced = Semantics.forced {
29-
return forced >= semantics
30-
} else {
31-
return dyld_program_sdk_at_least(.init(semantics: semantics))
32-
}
33-
}
34-
}
25+
//private struct ShouldRenderAsTemplate: Feature {
26+
// static var isEnable: Bool {
27+
// let semantics = Semantics.v2
28+
// if let forced = Semantics.forced {
29+
// return forced >= semantics
30+
// } else {
31+
// return dyld_program_sdk_at_least(.init(semantics: semantics))
32+
// }
33+
// }
34+
//}

Sources/OpenSwiftUICore/Data/Property/PropertyList.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ package struct PropertyList: CustomStringConvertible {
8282

8383
package subscript<K>(key: K.Type) -> K.Value where K: DerivedPropertyKey {
8484
get { fatalError("TODO") }
85-
set { fatalError("TODO") }
8685
}
8786

8887
@usableFromInline

0 commit comments

Comments
 (0)