Skip to content
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
4 changes: 2 additions & 2 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Sources/OpenAttributeGraphCxx/Graph/OAGGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
25 changes: 25 additions & 0 deletions Sources/OpenAttributeGraphCxx/Graph/OAGSubgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}