diff --git a/Sources/OpenSwiftUICore/Data/DynamicProperty/DynamicProperty.swift b/Sources/OpenSwiftUICore/Data/DynamicProperty/DynamicProperty.swift index fa83e23f..7ad4fa6c 100644 --- a/Sources/OpenSwiftUICore/Data/DynamicProperty/DynamicProperty.swift +++ b/Sources/OpenSwiftUICore/Data/DynamicProperty/DynamicProperty.swift @@ -218,7 +218,6 @@ extension BodyAccessor { inputs: inout _GraphInputs, fields: DynamicPropertyCache.Fields ) -> (_GraphValue, _DynamicPropertyBuffer?) { - #if canImport(Darwin) guard Body.self != Never.self else { preconditionFailure("\(Body.self) may not have Body == Never") } @@ -253,9 +252,6 @@ extension BodyAccessor { return project(flags: MainThreadFlags.self) } } - #else - preconditionFailure("See #39") - #endif } } @@ -273,8 +269,6 @@ private struct MainThreadFlags: RuleThreadFlags { static var value: OGAttributeTypeFlags { .mainThread } } -#if canImport(Darwin) - // MARK: - StaticBody private struct StaticBody { @@ -404,5 +398,3 @@ extension DynamicBody: BodyAccessorRule { extension DynamicBody: CustomStringConvertible { var description: String { "\(Accessor.Body.self)" } } - -#endif diff --git a/Sources/OpenSwiftUICore/Data/Environment/CachedEnvironment.swift b/Sources/OpenSwiftUICore/Data/Environment/CachedEnvironment.swift index 99048006..6dd419e8 100644 --- a/Sources/OpenSwiftUICore/Data/Environment/CachedEnvironment.swift +++ b/Sources/OpenSwiftUICore/Data/Environment/CachedEnvironment.swift @@ -12,24 +12,19 @@ package import OpenGraphShims package struct CachedEnvironment { package var environment: Attribute private var items: [Item] - #if canImport(Darwin) private var constants: [HashableConstant: AnyAttribute] - #endif // private var animatedFrame: AnimatedFrame? // private var resolvedFgStyles: [ResolvedFgStyle : Swift<_ShapeStyle_Resolved.ResolvedFg>] package init(_ environment: Attribute) { self.environment = environment items = [] - #if canImport(Darwin) constants = [:] - #endif // animatedFrame = nil // resolvedFgStyles = [:] FIXME: 0x100: ? } package mutating func attribute(keyPath: KeyPath) -> Attribute { - #if canImport(Darwin) if let item = items.first(where: { $0.key == keyPath }) { return Attribute(identifier: item.value) } else { @@ -37,13 +32,9 @@ package struct CachedEnvironment { items.append(Item(key: keyPath, value: value.identifier)) return value } - #else - preconditionFailure("See #39") - #endif } package mutating func intern(_ value: Value, id: Int) -> Attribute { - #if canImport(Darwin) let constant = HashableConstant(value, id: id) if let identifier = constants[constant] { return Attribute(identifier: identifier) @@ -52,9 +43,6 @@ package struct CachedEnvironment { constants[constant] = attribute.identifier return attribute } - #else - preconditionFailure("See #39") - #endif } func animatedPosition(for inputs: _ViewInputs) -> Attribute { @@ -75,9 +63,7 @@ package struct CachedEnvironment { extension CachedEnvironment { private struct Item { var key: PartialKeyPath - #if canImport(Darwin) // See #39 var value: AnyAttribute - #endif } } diff --git a/Sources/OpenSwiftUICore/Data/Preference/PreferenceBridge.swift b/Sources/OpenSwiftUICore/Data/Preference/PreferenceBridge.swift index 90d3c5f4..388991aa 100644 --- a/Sources/OpenSwiftUICore/Data/Preference/PreferenceBridge.swift +++ b/Sources/OpenSwiftUICore/Data/Preference/PreferenceBridge.swift @@ -45,17 +45,14 @@ package final class PreferenceBridge { } package func wrapInputs(_ inputs: inout _ViewInputs) { - #if canImport(Darwin) inputs.customInputs = bridgedViewInputs for key in requestedPreferences { inputs.preferences.keys.add(key) } inputs.preferences.hostKeys = Attribute(MergePreferenceKeys(lhs: inputs.preferences.hostKeys, rhs: _hostPreferenceKeys)) - #endif } package func wrapOutputs(_ outputs: inout PreferencesOutputs, inputs: _ViewInputs) { - #if canImport(Darwin) bridgedViewInputs = inputs.customInputs for key in inputs.preferences.keys { if key == _AnyPreferenceKey.self { @@ -90,8 +87,6 @@ package final class PreferenceBridge { outputs[anyKey: key] = result } } - #endif - } package func addChild(_ child: ViewGraph) { @@ -116,7 +111,6 @@ package final class PreferenceBridge { } } - #if canImport(Darwin) package func addValue(_ src: AnyAttribute, for key: any AnyPreferenceKey.Type) { struct AddValue: PreferenceKeyVisitor { var combiner: AnyAttribute @@ -167,17 +161,13 @@ package final class PreferenceBridge { viewGraph.graphInvalidation(from: isInvalidating ? nil : src) } } - #endif - + package func updateHostValues(_ keys: Attribute) { - #if canImport(Darwin) guard let viewGraph else { return } viewGraph.graphInvalidation(from: keys.identifier) - #endif } package func addHostValues(_ values: WeakAttribute, for keys: Attribute) { - #if canImport(Darwin) guard let viewGraph, let combiner = $hostPreferencesCombiner else { return } @@ -188,20 +178,16 @@ package final class PreferenceBridge { combiner.addChild(keys: keys, values: values) } viewGraph.graphInvalidation(from: keys.identifier) - #endif } package func addHostValues(_ values: OptionalAttribute, for keys: Attribute) { - #if canImport(Darwin) guard let attribute = values.attribute else { return } addHostValues(WeakAttribute(attribute), for: keys) - #endif } package func removeHostValues(for keys: Attribute, isInvalidating: Bool = false) { - #if canImport(Darwin) guard let viewGraph, let combiner = $hostPreferencesCombiner else { return } @@ -220,7 +206,6 @@ package final class PreferenceBridge { if hasRemoved { viewGraph.graphInvalidation(from: isInvalidating ? nil : keys.identifier) } - #endif } } diff --git a/Sources/OpenSwiftUICore/Data/Preference/PreferencesOutputs.swift b/Sources/OpenSwiftUICore/Data/Preference/PreferencesOutputs.swift index ecb80523..ed759058 100644 --- a/Sources/OpenSwiftUICore/Data/Preference/PreferencesOutputs.swift +++ b/Sources/OpenSwiftUICore/Data/Preference/PreferencesOutputs.swift @@ -17,7 +17,6 @@ package struct PreferencesOutputs { debugProperties = [] } - #if canImport(Darwin) subscript(anyKey key: AnyPreferenceKey.Type) -> AnyAttribute? { get { preferences.first { $0.key == key }?.value } set { @@ -39,60 +38,40 @@ package struct PreferencesOutputs { } } } - #endif - + subscript(key: K.Type) -> Attribute? where K: PreferenceKey { get { - #if canImport(Darwin) let value = self[anyKey: _AnyPreferenceKey.self] return value.map { Attribute(identifier: $0) } - #else - preconditionFailure("See #39") - #endif } set { - #if canImport(Darwin) self[anyKey: _AnyPreferenceKey.self] = newValue.map { $0.identifier } - #else - preconditionFailure("See #39") - #endif } } package mutating func appendPreference(key: K.Type, value: Attribute) where K: PreferenceKey{ - #if canImport(Darwin) preferences.append(KeyValue(key: _AnyPreferenceKey.self, value: value.identifier)) - #else - preconditionFailure("See #39") - #endif } - - #if canImport(Darwin) + package func forEachPreference(_ body: (any AnyPreferenceKey.Type, AnyAttribute) -> Void) { preferences.forEach { body($0.key, $0.value) } } - #endif - - #if canImport(Darwin) + package func setIndirectDependency(_ dependency: AnyAttribute?) { preferences.forEach { $0.value.indirectDependency = dependency } } - #endif - + package func attachIndirectOutputs(to childOutputs: PreferencesOutputs) { - #if canImport(Darwin) for preference in preferences { for childPreference in childOutputs.preferences where childPreference.key == preference.key { preference.value.source = childPreference.value } } - #endif } package func detachIndirectOutputs() { - #if canImport(Darwin) struct ResetPreference: PreferenceKeyVisitor { var destination: AnyAttribute func visit(key: K.Type) where K: PreferenceKey { @@ -103,15 +82,12 @@ package struct PreferencesOutputs { var visitor = ResetPreference(destination: keyValue.value) keyValue.key.visitKey(&visitor) } - #endif } } extension PreferencesOutputs { private struct KeyValue { var key: any AnyPreferenceKey.Type - #if canImport(Darwin) var value: AnyAttribute - #endif } } diff --git a/Sources/OpenSwiftUICore/Data/Preference/View_Indirect.swift b/Sources/OpenSwiftUICore/Data/Preference/View_Indirect.swift index c3e25d1f..9be33a72 100644 --- a/Sources/OpenSwiftUICore/Data/Preference/View_Indirect.swift +++ b/Sources/OpenSwiftUICore/Data/Preference/View_Indirect.swift @@ -24,38 +24,33 @@ extension _ViewInputs { @IndirectAttribute(source: defaultLayoutComputer) var indirect: LayoutComputer outputs.layoutComputer = $indirect + #else + preconditionFailure("#39") #endif return outputs } } extension _ViewOutputs { - #if canImport(Darwin) package func setIndirectDependency(_ dependency: AnyAttribute?) { preferences.setIndirectDependency(dependency) if let target = layoutComputer?.identifier { target.indirectDependency = dependency } } - #endif - package func attachIndirectOutputs(to childOutputs: _ViewOutputs) { - #if canImport(Darwin) preferences.attachIndirectOutputs(to: childOutputs.preferences) if let target = layoutComputer?.identifier, let source = childOutputs.layoutComputer?.identifier { target.source = source } - #endif } package func detachIndirectOutputs() { - #if canImport(Darwin) preferences.detachIndirectOutputs() if let target = layoutComputer?.identifier { target.source = .nil } - #endif } } diff --git a/Sources/OpenSwiftUICore/Data/Transaction/Transaction.swift b/Sources/OpenSwiftUICore/Data/Transaction/Transaction.swift index f88fa59b..ac1babe8 100644 --- a/Sources/OpenSwiftUICore/Data/Transaction/Transaction.swift +++ b/Sources/OpenSwiftUICore/Data/Transaction/Transaction.swift @@ -262,20 +262,12 @@ package struct TransactionID: Comparable, Hashable { @inlinable package init(context: AnyRuleContext) { - #if canImport(Darwin) self.init(graph: context.attribute.graph) - #else - preconditionFailure("See #39") - #endif } @inlinable package init(context: RuleContext) { - #if canImport(Darwin) self.init(graph: context.attribute.graph) - #else - preconditionFailure("See #39") - #endif } @inlinable diff --git a/Sources/OpenSwiftUICore/Data/Update.swift b/Sources/OpenSwiftUICore/Data/Update.swift index f7ec9f60..a4dbfda5 100644 --- a/Sources/OpenSwiftUICore/Data/Update.swift +++ b/Sources/OpenSwiftUICore/Data/Update.swift @@ -123,16 +123,12 @@ package enum Update { if Thread.isMainThread { body() } else { - #if canImport(Darwin) withoutActuallyEscaping(body) { escapableBody in let context = AnyRuleContext(attribute: AnyOptionalAttribute.current.identifier) MovableLock.syncMain(lock: _lock) { context.update(body: escapableBody) } } - #else - preconditionFailure("See #39") - #endif } #endif } diff --git a/Sources/OpenSwiftUICore/Graph/GraphHost.swift b/Sources/OpenSwiftUICore/Graph/GraphHost.swift index 6cdcb78c..f76f0661 100644 --- a/Sources/OpenSwiftUICore/Graph/GraphHost.swift +++ b/Sources/OpenSwiftUICore/Graph/GraphHost.swift @@ -112,9 +112,7 @@ open class GraphHost: CustomReflectable { package final var graphInputs: _GraphInputs { data.inputs } package final var globalSubgraph: Subgraph { data.globalSubgraph } package final var rootSubgraph: Subgraph { data.rootSubgraph } - #if canImport(Darwin) private var constants: [ConstantKey: AnyAttribute] = [:] - #endif private(set) package final var isInstantiated: Bool = false package final var hostPreferenceValues: WeakAttribute = WeakAttribute() package final var lastHostPreferencesSeed: VersionSeed = .invalid @@ -143,7 +141,6 @@ open class GraphHost: CustomReflectable { } package static var currentHost: GraphHost { - #if canImport(Darwin) if let currentAttribute = AnyAttribute.current { currentAttribute.graph.graphHost() } else if let currentSubgraph = Subgraph.current { @@ -151,9 +148,6 @@ open class GraphHost: CustomReflectable { } else { preconditionFailure("no current graph host") } - #else - preconditionFailure("Compiler issue on Linux. See #39") - #endif } package init(data: Data) { @@ -166,12 +160,10 @@ open class GraphHost: CustomReflectable { else { return } graphDelegate.updateGraph { _ in } } - #if canImport(Darwin) Graph.setInvalidationCallback(graph) { [weak self] attribute in guard let self else { return } graphInvalidation(from: attribute) } - #endif graph.context = UnsafeRawPointer(Unmanaged.passUnretained(self).toOpaque()) } @@ -222,7 +214,6 @@ open class GraphHost: CustomReflectable { } package final func intern(_ value: T, for type: Any.Type = T.self, id: ConstantID) -> Attribute { - #if canImport(Darwin) if let attribute = constants[ConstantKey(type: type , id: id)] { return Attribute(identifier: attribute) } else { @@ -230,9 +221,6 @@ open class GraphHost: CustomReflectable { constants[ConstantKey(type: type, id: id)] = result.identifier return result } - #else - preconditionFailure("See #39") - #endif } public final var customMirror: Mirror { Mirror(self, children: []) } @@ -252,7 +240,6 @@ extension GraphHost: Sendable {} @_spi(ForOpenSwiftUIOnly) extension GraphHost { package final func graphInvalidation(from src: AnyAttribute?) { - #if canImport(Darwin) guard let src else { graphDelegate?.graphDidChange() return @@ -265,7 +252,6 @@ extension GraphHost { return } emptyTransaction(transaction) - #endif } package final func instantiate() { @@ -389,10 +375,8 @@ extension GraphHost { style: _GraphMutation_Style = .deferred, mayDeferUpdate: Bool = true ) { - #if canImport(Darwin) // Blocked by WeakAttribute.base API in OpenGraph // asyncTransaction(transaction, id: transactionID, mutation: InvalidatingGraphMutation(attribute: attribute.base), style: style, mayDeferUpdate: mayDeferUpdate) - #endif } package final func emptyTransaction(_ transaction: Transaction = .init()) { @@ -543,7 +527,6 @@ package struct CustomGraphMutation: GraphMutation { package func combine(with other: T) -> Bool where T : GraphMutation { false } } -#if canImport(Darwin) struct InvalidatingGraphMutation: GraphMutation { let attribute: AnyWeakAttribute @@ -558,7 +541,6 @@ struct InvalidatingGraphMutation: GraphMutation { return mutation.attribute == attribute } } -#endif private struct EmptyGraphMutation: GraphMutation { package init() {} diff --git a/Sources/OpenSwiftUICore/Graph/GraphInputs.swift b/Sources/OpenSwiftUICore/Graph/GraphInputs.swift index 88572e09..ff887bbc 100644 --- a/Sources/OpenSwiftUICore/Graph/GraphInputs.swift +++ b/Sources/OpenSwiftUICore/Graph/GraphInputs.swift @@ -72,9 +72,7 @@ public struct _GraphInputs { package var transaction: Attribute package var changedDebugProperties: _ViewDebug.Properties package var options: _GraphInputs.Options - #if canImport(Darwin) package var mergedInputs: Set - #endif package init( time: Attribute