diff --git a/Package.resolved b/Package.resolved index a792ce23..25a2bd3e 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "388a5c22c69d82c7f6b3b006c51d450c398ee78df767269226a0294ec043c444", + "originHash" : "9a0c6977a60be4c351b05b7d8aab7de908342d5638eaaadf034c914fbe903558", "pins" : [ { "identity" : "darwinprivateframeworks", @@ -7,7 +7,7 @@ "location" : "https://github.com/OpenSwiftUIProject/DarwinPrivateFrameworks.git", "state" : { "branch" : "main", - "revision" : "082d0abd12876636df553723e22a395a881f5491" + "revision" : "27cecdd28a2ec028d7cb80de45ebc641a4eac1f7" } }, { diff --git a/Sources/OpenAttributeGraphCxx/Graph/OAGGraph.cpp b/Sources/OpenAttributeGraphCxx/Graph/OAGGraph.cpp index 2bab8c2c..b7c4f661 100644 --- a/Sources/OpenAttributeGraphCxx/Graph/OAGGraph.cpp +++ b/Sources/OpenAttributeGraphCxx/Graph/OAGGraph.cpp @@ -209,3 +209,12 @@ bool OAGGraphAnyInputsChanged(const OAGAttribute *excluded_inputs, size_t count) // TODO return false; } + +bool OAGGraphBeginDeferringSubgraphInvalidation(OAGGraphRef graph) { + // TODO + return false; +} + +void OAGGraphEndDeferringSubgraphInvalidation(OAGGraphRef graph, bool was_deferring) { + // TODO +} diff --git a/Sources/OpenAttributeGraphCxx/Graph/OAGSubgraph.cpp b/Sources/OpenAttributeGraphCxx/Graph/OAGSubgraph.cpp index 45896a47..4b24503e 100644 --- a/Sources/OpenAttributeGraphCxx/Graph/OAGSubgraph.cpp +++ b/Sources/OpenAttributeGraphCxx/Graph/OAGSubgraph.cpp @@ -136,6 +136,31 @@ void OAGSubgraphRemoveChild(OAGSubgraphRef parent, OAGSubgraphRef child) { // TODO } +OAGSubgraphRef OAGSubgraphGetChild(OAGSubgraphRef cf_subgraph, uint32_t index, uint8_t *_Nullable tag_out) { + // TODO + return nullptr; +} + +uint32_t OAGSubgraphGetChildCount(OAGSubgraphRef cf_subgraph) { + // TODO + return 0; +} + +OAGSubgraphRef OAGSubgraphGetParent(OAGSubgraphRef cf_subgraph, int64_t index) { + // TODO + return nullptr; +} + +uint64_t OAGSubgraphGetParentCount(OAGSubgraphRef cf_subgraph) { + // TODO + return 0; +} + +bool OAGSubgraphIsAncestor(OAGSubgraphRef cf_subgraph, OAGSubgraphRef other) { + // TODO + return false; +} + void OAGSubgraphApply(OAGSubgraphRef cf_subgraph, OAGAttributeFlags flags, const void (*function)(const void * _Nullable context OAG_SWIFT_CONTEXT, OAGAttribute attribute) OAG_SWIFT_CC(swift), diff --git a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGGraph.h b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGGraph.h index bda9886e..1c47b566 100644 --- a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGGraph.h +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGGraph.h @@ -114,6 +114,14 @@ OAG_REFINED_FOR_SWIFT bool OAGGraphAnyInputsChanged(const OAGAttribute *excluded_inputs, size_t count); #endif +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +bool OAGGraphBeginDeferringSubgraphInvalidation(OAGGraphRef graph) OAG_SWIFT_NAME(OAGGraphRef.beginDeferringSubgraphInvalidation(self:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +void OAGGraphEndDeferringSubgraphInvalidation(OAGGraphRef graph, bool was_deferring) OAG_SWIFT_NAME(OAGGraphRef.endDeferringSubgraphInvalidation(self:wasDeferring:)); + OAG_EXTERN_C_END OAG_IMPLICIT_BRIDGING_DISABLED diff --git a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGSubgraph.h b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGSubgraph.h index a6558360..e49efa4c 100644 --- a/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGSubgraph.h +++ b/Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGSubgraph.h @@ -22,7 +22,7 @@ OAG_EXTERN_C_BEGIN OAG_EXPORT OAG_REFINED_FOR_SWIFT -CFTypeID OAGSubgraphGetTypeID(); +CFTypeID OAGSubgraphGetTypeID(void) OAG_SWIFT_NAME(getter:OAGSubgraphRef.typeID()); OAG_EXPORT OAG_REFINED_FOR_SWIFT @@ -68,6 +68,26 @@ OAG_EXPORT OAG_REFINED_FOR_SWIFT void OAGSubgraphRemoveChild(OAGSubgraphRef parent, OAGSubgraphRef child) OAG_SWIFT_NAME(OAGSubgraphRef.removeChild(self:_:)); +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +OAGSubgraphRef OAGSubgraphGetChild(OAGSubgraphRef cf_subgraph, uint32_t index, uint8_t *_Nullable tag_out) OAG_SWIFT_NAME(OAGSubgraphRef.child(self:at:tag:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +uint32_t OAGSubgraphGetChildCount(OAGSubgraphRef cf_subgraph) OAG_SWIFT_NAME(getter:OAGSubgraphRef.childCount(self:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +OAGSubgraphRef OAGSubgraphGetParent(OAGSubgraphRef cf_subgraph, int64_t index) OAG_SWIFT_NAME(OAGSubgraphRef.parent(self:at:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +uint64_t OAGSubgraphGetParentCount(OAGSubgraphRef cf_subgraph) OAG_SWIFT_NAME(getter:OAGSubgraphRef.parentCount(self:)); + +OAG_EXPORT +OAG_REFINED_FOR_SWIFT +bool OAGSubgraphIsAncestor(OAGSubgraphRef cf_subgraph, OAGSubgraphRef other) OAG_SWIFT_NAME(OAGSubgraphRef.isAncestor(self:of:)); + OAG_EXPORT OAG_REFINED_FOR_SWIFT bool OAGSubgraphIntersects(OAGSubgraphRef subgraph, OAGAttributeFlags flags) OAG_SWIFT_NAME(OAGSubgraphRef.intersects(self:flags:)); diff --git a/Tests/OpenAttributeGraphCompatibilityTests/Graph/GraphCompatibilityTests.swift b/Tests/OpenAttributeGraphCompatibilityTests/Graph/GraphCompatibilityTests.swift index ad3b0613..e77e641a 100644 --- a/Tests/OpenAttributeGraphCompatibilityTests/Graph/GraphCompatibilityTests.swift +++ b/Tests/OpenAttributeGraphCompatibilityTests/Graph/GraphCompatibilityTests.swift @@ -85,4 +85,18 @@ struct GraphCompatibilityTests { #expect(graph.mainUpdates == 0) } #endif + + @Test(.disabled(if: !compatibilityTestEnabled, "Not implemented on OAG")) + func beginDeferringSubgraphInvalidation() { + let graph = Graph() + + let wasDeferring1 = graph.beginDeferringSubgraphInvalidation() + #expect(wasDeferring1 == false) + + let wasDeferring2 = graph.beginDeferringSubgraphInvalidation() + #expect(wasDeferring2 == true) + + graph.endDeferringSubgraphInvalidation(wasDeferring: wasDeferring2) + graph.endDeferringSubgraphInvalidation(wasDeferring: wasDeferring1) + } } diff --git a/Tests/OpenAttributeGraphCompatibilityTests/Graph/SubgraphCompatibilityTests.swift b/Tests/OpenAttributeGraphCompatibilityTests/Graph/SubgraphCompatibilityTests.swift index b08dd697..ed0bc3c8 100644 --- a/Tests/OpenAttributeGraphCompatibilityTests/Graph/SubgraphCompatibilityTests.swift +++ b/Tests/OpenAttributeGraphCompatibilityTests/Graph/SubgraphCompatibilityTests.swift @@ -76,4 +76,56 @@ struct SubgraphCompatibilityTests { #expect(notifiedCount == 0) } } + + @MainActor + @Suite // Both ConditionTrait and GraphEnvironmentTrait's isRecursive are true + struct ChildrenTests { + @Test + func addChild() { + let graph = Graph() + let subgraph = Subgraph(graph: graph) + let child = Subgraph(graph: graph) + + subgraph.addChild(child) + #expect(subgraph.childCount == 1) + #expect(subgraph.isAncestor(of: child) == true) + + #expect(subgraph.child(at: 0, tag: nil) === child) + + #expect(child.parentCount == 1) + #expect(child.parent(at: 0) === subgraph) + } + + @Test + func addChildWithTag() { + let graph = Graph() + let subgraph = Subgraph(graph: graph) + let child = Subgraph(graph: graph) + + subgraph.addChild(child, tag: 1) + #expect(subgraph.childCount == 1) + #expect(subgraph.isAncestor(of: child) == true) + + var tag = 0 + #expect(subgraph.child(at: 0, tag: &tag) === child) + #expect(tag == 1) + + #expect(child.parentCount == 1) + #expect(child.parent(at: 0) === subgraph) + } + + @Test + func removeChild() { + let graph = Graph() + let subgraph = Subgraph(graph: graph) + let child = Subgraph(graph: graph) + + subgraph.addChild(child) + subgraph.removeChild(child) + #expect(subgraph.childCount == 0) + #expect(subgraph.isAncestor(of: child) == false) + + #expect(child.parentCount == 0) + } + } }