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

feature/graphhost #44

Merged
merged 10 commits into from
Mar 9, 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
2 changes: 1 addition & 1 deletion Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"location" : "https://github.com/OpenSwiftUIProject/OpenGraph",
"state" : {
"branch" : "main",
"revision" : "10eb096bfdefd73bb50df410b87602208bcc06c1"
"revision" : "2435a0a02b3ab3b97799a8f387284686fe9e6a7a"
}
},
{
Expand Down
14 changes: 14 additions & 0 deletions Scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/zsh

# A `realpath` alternative using the default C implementation.
filepath() {
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
}

OPENSWIFTUI_ROOT="$(dirname $(dirname $(filepath $0)))"

cd $OPENSWIFTUI_ROOT

export OPENSWIFTUI_SWIFT_TESTING=0
export OPENGRAPH_SWIFT_TESTING=0
swift build
14 changes: 14 additions & 0 deletions Sources/OpenSwiftUI/Core/Attribute/InvalidatableAttribute.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// InvalidatableAttribute.swift
// OpenSwiftUI
//
// Audited for RELEASE_2021
// Status: WIP

internal import OpenGraphShims

// TODO: PlatformViewChild in _A513612C07DFA438E70B9FA90719B40D

protocol InvalidatableAttribute: _AttributeBody {
static func willInvalidate(attribute: OGAttribute)
}
13 changes: 13 additions & 0 deletions Sources/OpenSwiftUI/Core/Attribute/RemovableAttribute.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// RemovableAttribute.swift
// OpenSwiftUI
//
// Audited for RELEASE_2021
// Status: WIP

internal import OpenGraphShims

protocol RemovableAttribute: _AttributeBody {
static func willRemove(attribute: OGAttribute)
static func didReinsert(attribute: OGAttribute)
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,8 @@ struct ObservableObjectLocation<Root, Value>: Location where Root: ObservableObj
base[keyPath: keyPath] = value
}
}

extension ObservableObjectLocation: TransactionHostProvider {
// TODO
var mutationHost: GraphHost? { nil }
}
5 changes: 5 additions & 0 deletions Sources/OpenSwiftUI/Core/Graph/Extensions/OGGraph.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
internal import OpenGraphShims

extension OGGraph {

}
38 changes: 38 additions & 0 deletions Sources/OpenSwiftUI/Core/Graph/Extensions/OGSubgraph.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
internal import OpenGraphShims

extension OGSubgraph {
func willRemove() {
#if canImport(Darwin)
OGSubgraph.apply(self, flags: .removable) { attribute in
let type = attribute._bodyType
if let removableType = type as? RemovableAttribute.Type {
removableType.willRemove(attribute: attribute)
}
}
#endif
}

func didReinsert() {
#if canImport(Darwin)
OGSubgraph.apply(self, flags: .removable) { attribute in
let type = attribute._bodyType
if let removableType = type as? RemovableAttribute.Type {
removableType.didReinsert(attribute: attribute)
}
}
#endif
}

func willInvalidate(isInserted: Bool) {
#if canImport(Darwin)
OGSubgraph.apply(self, flags: isInserted ? [.removable, .invalidatable] : [.invalidatable]) { attribute in
let type = attribute._bodyType
if let invalidatableType = type as? InvalidatableAttribute.Type {
invalidatableType.willInvalidate(attribute: attribute)
} else if isInserted, let removableType = type as? RemovableAttribute.Type {
removableType.willRemove(attribute: attribute)
}
}
#endif
}
}
Loading
Loading