From 4903b1fb250b2480f78e21628740bf967e22d2fa Mon Sep 17 00:00:00 2001 From: James Moschou Date: Wed, 17 Jun 2026 13:47:39 +0200 Subject: [PATCH] Rename AG namespace to IAG --- Sources/Compute/Attribute/AnyAttribute.swift | 24 +- Sources/Compute/Attribute/Attribute.swift | 22 +- Sources/Compute/Attribute/AttributeType.swift | 16 +- .../Indirect/IndirectAttribute.swift | 6 +- .../Optional/AnyOptionalAttribute.swift | 2 +- .../Optional/OptionalAttribute.swift | 2 +- Sources/Compute/Attribute/Rule/Rule.swift | 10 +- .../Compute/Attribute/Rule/StatefulRule.swift | 2 +- .../RuleContext/AnyRuleContext.swift | 18 +- .../Attribute/RuleContext/RuleContext.swift | 16 +- .../Attribute/Weak/AnyWeakAttribute.swift | 4 +- .../Attribute/Weak/WeakAttribute.swift | 4 +- Sources/Compute/Graph/Graph.swift | 26 +- Sources/Compute/Graph/Subgraph.swift | 18 +- Sources/Compute/Graph/TreeElement.swift | 4 +- Sources/Compute/Runtime/CompareValues.swift | 2 +- Sources/Compute/Runtime/Enum.swift | 12 +- Sources/Compute/Runtime/Metadata.swift | 16 +- Sources/Compute/Runtime/Tuple.swift | 10 +- Sources/ComputeCxx/Array/ArrayRef.h | 10 +- .../Attribute/AttributeData/Edge/InputEdge.h | 12 +- .../Attribute/AttributeData/Edge/OutputEdge.h | 4 +- .../AttributeData/Node/IndirectNode.cpp | 4 +- .../AttributeData/Node/IndirectNode.h | 10 +- .../Attribute/AttributeData/Node/Node.cpp | 4 +- .../Attribute/AttributeData/Node/Node.h | 32 +- .../Attribute/AttributeID/AGAttribute.cpp | 5 - .../Attribute/AttributeID/AGWeakAttribute.cpp | 21 - .../Attribute/AttributeID/AttributeID.cpp | 10 +- .../Attribute/AttributeID/AttributeID.h | 16 +- .../Attribute/AttributeID/IAGAttribute.cpp | 5 + .../AttributeID/IAGWeakAttribute.cpp | 21 + .../Attribute/AttributeID/OffsetAttributeID.h | 10 +- .../AttributeID/RelativeAttributeID.h | 4 +- .../Attribute/AttributeID/WeakAttributeID.cpp | 6 +- .../Attribute/AttributeID/WeakAttributeID.h | 16 +- .../Attribute/AttributeType/AttributeType.h | 54 +- .../Attribute/AttributeView/AttributeView.h | 4 +- Sources/ComputeCxx/Closure/ClosureFunction.h | 8 +- .../Closure/{AGClosure.cpp => IAGClosure.cpp} | 8 +- .../Comparison/AGComparison-Private.h | 15 - .../ComputeCxx/Comparison/AGComparison.cpp | 33 - Sources/ComputeCxx/Comparison/Builder.h | 18 +- Sources/ComputeCxx/Comparison/Compare.cpp | 20 +- Sources/ComputeCxx/Comparison/Compare.h | 16 +- .../Comparison/IAGComparison-Private.h | 15 + .../ComputeCxx/Comparison/IAGComparison.cpp | 33 + .../Comparison/LayoutDescriptor.cpp | 96 +- .../ComputeCxx/Comparison/LayoutDescriptor.h | 32 +- Sources/ComputeCxx/Comparison/ValueLayout.h | 4 +- Sources/ComputeCxx/Data/Constants.h | 10 +- Sources/ComputeCxx/Data/Page.h | 10 +- Sources/ComputeCxx/Data/Pointer.h | 14 +- Sources/ComputeCxx/Data/Table.cpp | 14 +- Sources/ComputeCxx/Data/Table.h | 10 +- Sources/ComputeCxx/Data/Vector.h | 10 +- Sources/ComputeCxx/Data/Zone.cpp | 4 +- Sources/ComputeCxx/Data/Zone.h | 10 +- Sources/ComputeCxx/Errors/Errors.cpp | 4 +- Sources/ComputeCxx/Errors/Errors.h | 10 +- Sources/ComputeCxx/Graph/AGDescription.mm | 8 - Sources/ComputeCxx/Graph/AGGraph.cpp | 1089 ----------------- Sources/ComputeCxx/Graph/AGGraph.mm | 24 - Sources/ComputeCxx/Graph/Context.cpp | 16 +- Sources/ComputeCxx/Graph/Context.h | 22 +- Sources/ComputeCxx/Graph/Graph.cpp | 192 +-- Sources/ComputeCxx/Graph/Graph.h | 46 +- Sources/ComputeCxx/Graph/Graph.mm | 86 +- Sources/ComputeCxx/Graph/IAGDescription.mm | 8 + .../{AGGraph-Private.h => IAGGraph-Private.h} | 12 +- Sources/ComputeCxx/Graph/IAGGraph.cpp | 1089 +++++++++++++++++ Sources/ComputeCxx/Graph/IAGGraph.mm | 24 + Sources/ComputeCxx/Graph/KeyTable.cpp | 4 +- Sources/ComputeCxx/Graph/KeyTable.h | 10 +- Sources/ComputeCxx/Graph/TraceRecorder.cpp | 16 +- Sources/ComputeCxx/Graph/TraceRecorder.h | 18 +- .../ComputeCxx/Graph/Tree/AGTreeElement.cpp | 94 -- Sources/ComputeCxx/Graph/Tree/AGTreeValue.cpp | 26 - .../ComputeCxx/Graph/Tree/IAGTreeElement.cpp | 94 ++ .../ComputeCxx/Graph/Tree/IAGTreeValue.cpp | 26 + .../ComputeCxx/Graph/Tree/TreeDataElement.cpp | 4 +- Sources/ComputeCxx/Graph/Tree/TreeElement.h | 14 +- Sources/ComputeCxx/Graph/Tree/TreeValue.h | 14 +- Sources/ComputeCxx/Graph/UpdateStack.cpp | 44 +- Sources/ComputeCxx/Graph/UpdateStack.h | 14 +- Sources/ComputeCxx/Log/Log.cpp | 4 +- Sources/ComputeCxx/Log/Log.h | 10 +- .../ComputeCxx/Subgraph/AGSubgraph-Private.h | 24 - Sources/ComputeCxx/Subgraph/AGSubgraph.cpp | 369 ------ .../ComputeCxx/Subgraph/IAGSubgraph-Private.h | 24 + Sources/ComputeCxx/Subgraph/IAGSubgraph.cpp | 369 ++++++ Sources/ComputeCxx/Subgraph/NodeCache.cpp | 6 +- Sources/ComputeCxx/Subgraph/NodeCache.h | 10 +- Sources/ComputeCxx/Subgraph/Subgraph.cpp | 57 +- Sources/ComputeCxx/Subgraph/Subgraph.h | 50 +- .../ComputeCxx/Swift/ContextDescriptor.cpp | 4 +- Sources/ComputeCxx/Swift/ContextDescriptor.h | 10 +- .../Swift/{AGTuple.cpp => IAGTuple.cpp} | 112 +- .../Swift/{AGType.cpp => IAGType.cpp} | 194 +-- Sources/ComputeCxx/Swift/Metadata.cpp | 8 +- Sources/ComputeCxx/Swift/Metadata.h | 10 +- Sources/ComputeCxx/Swift/MetadataVisitor.cpp | 4 +- Sources/ComputeCxx/Swift/MetadataVisitor.h | 10 +- Sources/ComputeCxx/Swift/SwiftShims.h | 20 +- .../ComputeCxx/Swift/_SwiftStdlibCxxOverlay.h | 4 +- Sources/ComputeCxx/Time/Time.cpp | 4 +- Sources/ComputeCxx/Time/Time.h | 8 +- Sources/ComputeCxx/Trace/ExternalTrace.cpp | 158 +-- Sources/ComputeCxx/Trace/ExternalTrace.h | 110 +- Sources/ComputeCxx/Trace/Trace.cpp | 4 +- Sources/ComputeCxx/Trace/Trace.h | 20 +- .../{AGUniqueID.cpp => IAGUniqueID.cpp} | 4 +- .../ComputeCxx/Vector/IndirectPointerVector.h | 10 +- Sources/ComputeCxx/Vector/Vector.h | 10 +- .../include/ComputeCxx/AGAttribute.h | 21 - .../include/ComputeCxx/AGAttributeInfo.h | 17 - .../include/ComputeCxx/AGAttributeType.h | 67 - .../ComputeCxx/include/ComputeCxx/AGBase.h | 215 ---- .../include/ComputeCxx/AGCachedValueOptions.h | 16 - .../include/ComputeCxx/AGChangedValue.h | 26 - .../ComputeCxx/include/ComputeCxx/AGClosure.h | 24 - .../include/ComputeCxx/AGComparison.h | 70 -- .../include/ComputeCxx/AGDescription.h | 37 - .../ComputeCxx/include/ComputeCxx/AGGraph.h | 382 ------ .../ComputeCxx/AGGraphCounterQueryType.h | 20 - .../include/ComputeCxx/AGGraphTracing.h | 102 -- .../include/ComputeCxx/AGInputOptions.h | 20 - .../include/ComputeCxx/AGSearchOptions.h | 17 - .../include/ComputeCxx/AGSubgraph.h | 186 --- .../include/ComputeCxx/AGTraceType.h | 82 -- .../include/ComputeCxx/AGTreeElement.h | 81 -- .../include/ComputeCxx/AGTreeValue.h | 31 - .../ComputeCxx/include/ComputeCxx/AGTuple.h | 89 -- .../ComputeCxx/include/ComputeCxx/AGType.h | 129 -- .../include/ComputeCxx/AGUniqueID.h | 15 - .../ComputeCxx/include/ComputeCxx/AGValue.h | 32 - .../include/ComputeCxx/AGWeakAttribute.h | 27 - .../include/ComputeCxx/ComputeCxx.h | 48 +- .../include/ComputeCxx/IAGAttribute.h | 21 + .../include/ComputeCxx/IAGAttributeInfo.h | 17 + .../include/ComputeCxx/IAGAttributeType.h | 67 + .../ComputeCxx/include/ComputeCxx/IAGBase.h | 215 ++++ .../ComputeCxx/IAGCachedValueOptions.h | 16 + .../include/ComputeCxx/IAGChangedValue.h | 26 + .../include/ComputeCxx/IAGClosure.h | 24 + .../include/ComputeCxx/IAGComparison.h | 70 ++ .../include/ComputeCxx/IAGDescription.h | 37 + .../ComputeCxx/include/ComputeCxx/IAGGraph.h | 382 ++++++ .../ComputeCxx/IAGGraphCounterQueryType.h | 20 + .../include/ComputeCxx/IAGGraphTracing.h | 102 ++ .../include/ComputeCxx/IAGInputOptions.h | 20 + .../include/ComputeCxx/IAGSearchOptions.h | 17 + .../include/ComputeCxx/IAGSubgraph.h | 186 +++ ...Conditionals.h => IAGTargetConditionals.h} | 0 .../include/ComputeCxx/IAGTraceType.h | 82 ++ .../include/ComputeCxx/IAGTreeElement.h | 81 ++ .../include/ComputeCxx/IAGTreeValue.h | 31 + .../ComputeCxx/include/ComputeCxx/IAGTuple.h | 89 ++ .../ComputeCxx/include/ComputeCxx/IAGType.h | 129 ++ .../include/ComputeCxx/IAGUniqueID.h | 15 + .../ComputeCxx/include/ComputeCxx/IAGValue.h | 32 + .../include/ComputeCxx/IAGWeakAttribute.h | 27 + .../CoreFoundationPrivate/CFRuntime.h | 2 +- .../ComputeCxxSwiftSupport.swift | 4 +- .../Shared/CompareValuesTests.swift | 6 +- .../Shared/PrefetchCompareValuesTests.swift | 120 +- .../Shared/Attribute/AttributeTests.swift | 18 +- .../Shared/Graph/GraphTests.swift | 18 +- .../Shared/Subgraph/SubgraphTests.swift | 4 +- .../Scripts/process_headers_inputs.xcfilelist | 48 +- .../process_headers_outputs.xcfilelist | 48 +- 171 files changed, 4603 insertions(+), 4602 deletions(-) delete mode 100644 Sources/ComputeCxx/Attribute/AttributeID/AGAttribute.cpp delete mode 100644 Sources/ComputeCxx/Attribute/AttributeID/AGWeakAttribute.cpp create mode 100644 Sources/ComputeCxx/Attribute/AttributeID/IAGAttribute.cpp create mode 100644 Sources/ComputeCxx/Attribute/AttributeID/IAGWeakAttribute.cpp rename Sources/ComputeCxx/Closure/{AGClosure.cpp => IAGClosure.cpp} (66%) delete mode 100644 Sources/ComputeCxx/Comparison/AGComparison-Private.h delete mode 100644 Sources/ComputeCxx/Comparison/AGComparison.cpp create mode 100644 Sources/ComputeCxx/Comparison/IAGComparison-Private.h create mode 100644 Sources/ComputeCxx/Comparison/IAGComparison.cpp delete mode 100644 Sources/ComputeCxx/Graph/AGDescription.mm delete mode 100644 Sources/ComputeCxx/Graph/AGGraph.cpp delete mode 100644 Sources/ComputeCxx/Graph/AGGraph.mm create mode 100644 Sources/ComputeCxx/Graph/IAGDescription.mm rename Sources/ComputeCxx/Graph/{AGGraph-Private.h => IAGGraph-Private.h} (53%) create mode 100644 Sources/ComputeCxx/Graph/IAGGraph.cpp create mode 100644 Sources/ComputeCxx/Graph/IAGGraph.mm delete mode 100644 Sources/ComputeCxx/Graph/Tree/AGTreeElement.cpp delete mode 100644 Sources/ComputeCxx/Graph/Tree/AGTreeValue.cpp create mode 100644 Sources/ComputeCxx/Graph/Tree/IAGTreeElement.cpp create mode 100644 Sources/ComputeCxx/Graph/Tree/IAGTreeValue.cpp delete mode 100644 Sources/ComputeCxx/Subgraph/AGSubgraph-Private.h delete mode 100644 Sources/ComputeCxx/Subgraph/AGSubgraph.cpp create mode 100644 Sources/ComputeCxx/Subgraph/IAGSubgraph-Private.h create mode 100644 Sources/ComputeCxx/Subgraph/IAGSubgraph.cpp rename Sources/ComputeCxx/Swift/{AGTuple.cpp => IAGTuple.cpp} (60%) rename Sources/ComputeCxx/Swift/{AGType.cpp => IAGType.cpp} (59%) rename Sources/ComputeCxx/UniqueID/{AGUniqueID.cpp => IAGUniqueID.cpp} (66%) delete mode 100644 Sources/ComputeCxx/include/ComputeCxx/AGAttribute.h delete mode 100644 Sources/ComputeCxx/include/ComputeCxx/AGAttributeInfo.h delete mode 100644 Sources/ComputeCxx/include/ComputeCxx/AGAttributeType.h delete mode 100644 Sources/ComputeCxx/include/ComputeCxx/AGBase.h delete mode 100644 Sources/ComputeCxx/include/ComputeCxx/AGCachedValueOptions.h delete mode 100644 Sources/ComputeCxx/include/ComputeCxx/AGChangedValue.h delete mode 100644 Sources/ComputeCxx/include/ComputeCxx/AGClosure.h delete mode 100644 Sources/ComputeCxx/include/ComputeCxx/AGComparison.h delete mode 100644 Sources/ComputeCxx/include/ComputeCxx/AGDescription.h delete mode 100644 Sources/ComputeCxx/include/ComputeCxx/AGGraph.h delete mode 100644 Sources/ComputeCxx/include/ComputeCxx/AGGraphCounterQueryType.h delete mode 100644 Sources/ComputeCxx/include/ComputeCxx/AGGraphTracing.h delete mode 100644 Sources/ComputeCxx/include/ComputeCxx/AGInputOptions.h delete mode 100644 Sources/ComputeCxx/include/ComputeCxx/AGSearchOptions.h delete mode 100644 Sources/ComputeCxx/include/ComputeCxx/AGSubgraph.h delete mode 100644 Sources/ComputeCxx/include/ComputeCxx/AGTraceType.h delete mode 100644 Sources/ComputeCxx/include/ComputeCxx/AGTreeElement.h delete mode 100644 Sources/ComputeCxx/include/ComputeCxx/AGTreeValue.h delete mode 100644 Sources/ComputeCxx/include/ComputeCxx/AGTuple.h delete mode 100644 Sources/ComputeCxx/include/ComputeCxx/AGType.h delete mode 100644 Sources/ComputeCxx/include/ComputeCxx/AGUniqueID.h delete mode 100644 Sources/ComputeCxx/include/ComputeCxx/AGValue.h delete mode 100644 Sources/ComputeCxx/include/ComputeCxx/AGWeakAttribute.h create mode 100644 Sources/ComputeCxx/include/ComputeCxx/IAGAttribute.h create mode 100644 Sources/ComputeCxx/include/ComputeCxx/IAGAttributeInfo.h create mode 100644 Sources/ComputeCxx/include/ComputeCxx/IAGAttributeType.h create mode 100644 Sources/ComputeCxx/include/ComputeCxx/IAGBase.h create mode 100644 Sources/ComputeCxx/include/ComputeCxx/IAGCachedValueOptions.h create mode 100644 Sources/ComputeCxx/include/ComputeCxx/IAGChangedValue.h create mode 100644 Sources/ComputeCxx/include/ComputeCxx/IAGClosure.h create mode 100644 Sources/ComputeCxx/include/ComputeCxx/IAGComparison.h create mode 100644 Sources/ComputeCxx/include/ComputeCxx/IAGDescription.h create mode 100644 Sources/ComputeCxx/include/ComputeCxx/IAGGraph.h create mode 100644 Sources/ComputeCxx/include/ComputeCxx/IAGGraphCounterQueryType.h create mode 100644 Sources/ComputeCxx/include/ComputeCxx/IAGGraphTracing.h create mode 100644 Sources/ComputeCxx/include/ComputeCxx/IAGInputOptions.h create mode 100644 Sources/ComputeCxx/include/ComputeCxx/IAGSearchOptions.h create mode 100644 Sources/ComputeCxx/include/ComputeCxx/IAGSubgraph.h rename Sources/ComputeCxx/include/ComputeCxx/{AGTargetConditionals.h => IAGTargetConditionals.h} (100%) create mode 100644 Sources/ComputeCxx/include/ComputeCxx/IAGTraceType.h create mode 100644 Sources/ComputeCxx/include/ComputeCxx/IAGTreeElement.h create mode 100644 Sources/ComputeCxx/include/ComputeCxx/IAGTreeValue.h create mode 100644 Sources/ComputeCxx/include/ComputeCxx/IAGTuple.h create mode 100644 Sources/ComputeCxx/include/ComputeCxx/IAGType.h create mode 100644 Sources/ComputeCxx/include/ComputeCxx/IAGUniqueID.h create mode 100644 Sources/ComputeCxx/include/ComputeCxx/IAGValue.h create mode 100644 Sources/ComputeCxx/include/ComputeCxx/IAGWeakAttribute.h diff --git a/Sources/Compute/Attribute/AnyAttribute.swift b/Sources/Compute/Attribute/AnyAttribute.swift index 1467d39c..6b6677d3 100644 --- a/Sources/Compute/Attribute/AnyAttribute.swift +++ b/Sources/Compute/Attribute/AnyAttribute.swift @@ -1,15 +1,15 @@ import ComputeCxx -@_silgen_name("AGGraphMutateAttribute") -func AGGraphMutateAttribute( +@_silgen_name("IAGGraphMutateAttribute") +func IAGGraphMutateAttribute( _ attribute: AnyAttribute, type: Metadata, invalidating: Bool, modify: (UnsafeMutableRawPointer) -> Void ) -@_silgen_name("AGGraphSearch") -func AGGraphSearch( +@_silgen_name("IAGGraphSearch") +func IAGGraphSearch( attribute: AnyAttribute, options: SearchOptions, predicate: (AnyAttribute) -> Bool @@ -18,7 +18,7 @@ func AGGraphSearch( extension AnyAttribute { public static var current: AnyAttribute? { - let attribute = __AGGraphGetCurrentAttribute() + let attribute = __IAGGraphGetCurrentAttribute() return attribute == .nil ? nil : attribute } @@ -39,7 +39,7 @@ extension AnyAttribute { let modify: (UnsafeMutableRawPointer) -> Void = { pointer in escapingMutator(&pointer.assumingMemoryBound(to: Body.self).pointee) } - AGGraphMutateAttribute( + IAGGraphMutateAttribute( self, type: Metadata(type), invalidating: invalidating, @@ -54,33 +54,33 @@ extension AnyAttribute { flags = flags.subtracting(mask).union(newFlags.intersection(mask)) } - public func addInput(_ input: AnyAttribute, options: AGInputOptions, token: Int) { + public func addInput(_ input: AnyAttribute, options: IAGInputOptions, token: Int) { addInput(input, options: options) } - public func addInput(_ input: Attribute, options: AGInputOptions, token: Int) { + public func addInput(_ input: Attribute, options: IAGInputOptions, token: Int) { addInput(input.identifier, options: options, token: token) } // Indirect Node public func unsafeOffset(at offset: Int) -> AnyAttribute { - return __AGGraphCreateOffsetAttribute(self, UInt32(offset)) + return __IAGGraphCreateOffsetAttribute(self, UInt32(offset)) } public var indirectDependency: AnyAttribute? { get { - let indirectDependency = __AGGraphGetIndirectDependency(self) + let indirectDependency = __IAGGraphGetIndirectDependency(self) return indirectDependency == .nil ? nil : indirectDependency } nonmutating set { - __AGGraphSetIndirectDependency(self, newValue ?? .nil) + __IAGGraphSetIndirectDependency(self, newValue ?? .nil) } } public func breadthFirstSearch(options: SearchOptions, _ predicate: (AnyAttribute) -> Bool) -> Bool { return withoutActuallyEscaping(predicate) { escapingPredicate in - return AGGraphSearch(attribute: self, options: options, predicate: escapingPredicate) + return IAGGraphSearch(attribute: self, options: options, predicate: escapingPredicate) } } diff --git a/Sources/Compute/Attribute/Attribute.swift b/Sources/Compute/Attribute/Attribute.swift index 82c7f393..f17b31bf 100644 --- a/Sources/Compute/Attribute/Attribute.swift +++ b/Sources/Compute/Attribute/Attribute.swift @@ -102,11 +102,11 @@ public struct Attribute { identifier.mutateBody(as: bodyType, invalidating: invalidating, mutator) } - public func addInput(_ input: Attribute, options: AGInputOptions, token: Int) { + public func addInput(_ input: Attribute, options: IAGInputOptions, token: Int) { identifier.addInput(input, options: options, token: token) } - public func addInput(_ input: AnyAttribute, options: AGInputOptions, token: Int) { + public func addInput(_ input: AnyAttribute, options: IAGInputOptions, token: Int) { identifier.addInput(input, options: options, token: token) } @@ -120,7 +120,7 @@ public struct Attribute { public var value: Value { unsafeAddress { - return __AGGraphGetValue(identifier, [], Metadata(Value.self)) + return __IAGGraphGetValue(identifier, [], Metadata(Value.self)) .value .assumingMemoryBound(to: Value.self) } @@ -131,7 +131,7 @@ public struct Attribute { public func setValue(_ value: Value) -> Bool { return withUnsafePointer(to: value) { valuePointer in - return __AGGraphSetValue(identifier, valuePointer, Metadata(Value.self)) + return __IAGGraphSetValue(identifier, valuePointer, Metadata(Value.self)) } } @@ -139,7 +139,7 @@ public struct Attribute { return identifier.hasValue } - public var valueState: AGValueState { + public var valueState: IAGValueState { return identifier.valueState } @@ -155,16 +155,16 @@ public struct Attribute { identifier.invalidateValue() } - public func changedValue(options: AGValueOptions = []) -> (value: Value, changed: Bool) { - let value = __AGGraphGetValue(identifier, options, Metadata(Value.self)) + public func changedValue(options: IAGValueOptions = []) -> (value: Value, changed: Bool) { + let value = __IAGGraphGetValue(identifier, options, Metadata(Value.self)) return ( value.value.assumingMemoryBound(to: Value.self).pointee, value.flags.contains(.changed) ) } - public func valueAndFlags(options: AGValueOptions) -> (value: Value, flags: AGChangedValueFlags) { - let value = __AGGraphGetValue(identifier, options, Metadata(Value.self)) + public func valueAndFlags(options: IAGValueOptions) -> (value: Value, flags: IAGChangedValueFlags) { + let value = __IAGGraphGetValue(identifier, options, Metadata(Value.self)) return ( value.value.assumingMemoryBound(to: Value.self).pointee, value.flags @@ -173,7 +173,7 @@ public struct Attribute { public var wrappedValue: Value { unsafeAddress { - __AGGraphGetValue(identifier, [], Metadata(Value.self)) + __IAGGraphGetValue(identifier, [], Metadata(Value.self)) .value .assumingMemoryBound(to: Value.self) } @@ -213,7 +213,7 @@ public struct Attribute { public func unsafeOffset(at offset: Int, as type: Member.Type) -> Attribute { return Attribute( - identifier: __AGGraphCreateOffsetAttribute2(identifier, UInt32(offset), MemoryLayout.size) + identifier: __IAGGraphCreateOffsetAttribute2(identifier, UInt32(offset), MemoryLayout.size) ) } diff --git a/Sources/Compute/Attribute/AttributeType.swift b/Sources/Compute/Attribute/AttributeType.swift index e533d18f..c55b8c08 100644 --- a/Sources/Compute/Attribute/AttributeType.swift +++ b/Sources/Compute/Attribute/AttributeType.swift @@ -6,21 +6,21 @@ struct ProtocolConformance { var witnessTable: UnsafeRawPointer } -@_silgen_name("AGGraphInternAttributeType") -func AGGraphInternAttributeType( +@_silgen_name("IAGGraphInternAttributeType") +func IAGGraphInternAttributeType( _ graph: UnsafeRawPointer, type: Metadata, makeAttributeType: () -> UnsafePointer<_AttributeType> ) -> UInt32 -extension AGUnownedGraphContextRef { +extension IAGUnownedGraphContextRef { @inline(__always) func internAttributeType( type: Metadata, makeAttributeType: () -> UnsafePointer<_AttributeType> ) -> UInt32 { - return AGGraphInternAttributeType( + return IAGGraphInternAttributeType( unsafeBitCast(self, to: UnsafeRawPointer.self), type: type, makeAttributeType: makeAttributeType @@ -37,10 +37,10 @@ extension String { } -@_silgen_name("AGRetainClosure") -func AGRetainClosure( +@_silgen_name("IAGRetainClosure") +func IAGRetainClosure( _ closure: (UnsafeMutableRawPointer, AnyAttribute) -> Void -) -> _AGClosureStorage +) -> _IAGClosureStorage extension _AttributeType { @@ -109,7 +109,7 @@ extension _AttributeType { flags.insert(.hasDestroySelf) } - let retainedUpdate = AGRetainClosure(update) + let retainedUpdate = IAGRetainClosure(update) let conformance = unsafeBitCast( selfType as any _AttributeBody.Type, to: ProtocolConformance.self diff --git a/Sources/Compute/Attribute/Indirect/IndirectAttribute.swift b/Sources/Compute/Attribute/Indirect/IndirectAttribute.swift index dac6631b..979299c2 100644 --- a/Sources/Compute/Attribute/Indirect/IndirectAttribute.swift +++ b/Sources/Compute/Attribute/Indirect/IndirectAttribute.swift @@ -7,7 +7,7 @@ public struct IndirectAttribute { public var identifier: AnyAttribute public init(source: Attribute) { - identifier = __AGGraphCreateIndirectAttribute2(source.identifier, MemoryLayout.size) + identifier = __IAGGraphCreateIndirectAttribute2(source.identifier, MemoryLayout.size) } public var source: Attribute { @@ -24,7 +24,7 @@ public struct IndirectAttribute { } public func resetSource() { - __AGGraphResetIndirectAttribute(identifier, false) + __IAGGraphResetIndirectAttribute(identifier, false) } public var dependency: AnyAttribute? { @@ -48,7 +48,7 @@ public struct IndirectAttribute { } } - public func changedValue(options: AGValueOptions) -> (value: Value, changed: Bool) { + public func changedValue(options: IAGValueOptions) -> (value: Value, changed: Bool) { return Attribute(identifier: identifier).changedValue(options: options) } diff --git a/Sources/Compute/Attribute/Optional/AnyOptionalAttribute.swift b/Sources/Compute/Attribute/Optional/AnyOptionalAttribute.swift index 79b14356..09f5bbf5 100644 --- a/Sources/Compute/Attribute/Optional/AnyOptionalAttribute.swift +++ b/Sources/Compute/Attribute/Optional/AnyOptionalAttribute.swift @@ -13,7 +13,7 @@ public struct AnyOptionalAttribute { } public init(_ weakAttribute: AnyWeakAttribute) { - identifier = __AGWeakAttributeGetAttribute(weakAttribute) + identifier = __IAGWeakAttributeGetAttribute(weakAttribute) } public init(_ attribute: AnyAttribute?) { diff --git a/Sources/Compute/Attribute/Optional/OptionalAttribute.swift b/Sources/Compute/Attribute/Optional/OptionalAttribute.swift index 87c9577b..a41f650b 100644 --- a/Sources/Compute/Attribute/Optional/OptionalAttribute.swift +++ b/Sources/Compute/Attribute/Optional/OptionalAttribute.swift @@ -39,7 +39,7 @@ public struct OptionalAttribute { return attribute?.value } - public func changedValue(options: AGValueOptions = []) -> (value: Value, changed: Bool)? { + public func changedValue(options: IAGValueOptions = []) -> (value: Value, changed: Bool)? { return attribute?.changedValue(options: options) } diff --git a/Sources/Compute/Attribute/Rule/Rule.swift b/Sources/Compute/Attribute/Rule/Rule.swift index 002d2c8d..f6de32cf 100644 --- a/Sources/Compute/Attribute/Rule/Rule.swift +++ b/Sources/Compute/Attribute/Rule/Rule.swift @@ -50,8 +50,8 @@ extension Rule { } -@_silgen_name("AGGraphReadCachedAttribute") -func AGGraphReadCachedAttribute( +@_silgen_name("IAGGraphReadCachedAttribute") +func IAGGraphReadCachedAttribute( hash: Int, type: Metadata, body: UnsafeRawPointer, @@ -59,7 +59,7 @@ func AGGraphReadCachedAttribute( options: CachedValueOptions, owner: AnyAttribute, changed: UnsafeMutablePointer?, - attributeTypeID: (AGUnownedGraphContextRef) -> UInt32 + attributeTypeID: (IAGUnownedGraphContextRef) -> UInt32 ) -> UnsafeRawPointer extension Rule where Self: Hashable { @@ -78,7 +78,7 @@ extension Rule where Self: Hashable { public func cachedValueIfExists(options: CachedValueOptions, owner: AnyAttribute?) -> Value? { return withUnsafePointer(to: self) { bodyPointer in - let value = __AGGraphReadCachedAttributeIfExists( + let value = __IAGGraphReadCachedAttributeIfExists( hashValue, Metadata(Self.self), bodyPointer, @@ -101,7 +101,7 @@ extension Rule where Self: Hashable { bodyPtr: UnsafeRawPointer, update: () -> (UnsafeMutableRawPointer, AnyAttribute) -> Void ) -> UnsafePointer { - let value = AGGraphReadCachedAttribute( + let value = IAGGraphReadCachedAttribute( hash: hashValue, type: Metadata(Self.self), body: bodyPtr, diff --git a/Sources/Compute/Attribute/Rule/StatefulRule.swift b/Sources/Compute/Attribute/Rule/StatefulRule.swift index 51481c8d..d49b5f96 100644 --- a/Sources/Compute/Attribute/Rule/StatefulRule.swift +++ b/Sources/Compute/Attribute/Rule/StatefulRule.swift @@ -38,7 +38,7 @@ extension StatefulRule { public var value: Value { unsafeAddress { - guard let result = __AGGraphGetOutputValue(Metadata(Value.self)) else { + guard let result = __IAGGraphGetOutputValue(Metadata(Value.self)) else { preconditionFailure() } let pointer = result.assumingMemoryBound(to: Value.self) diff --git a/Sources/Compute/Attribute/RuleContext/AnyRuleContext.swift b/Sources/Compute/Attribute/RuleContext/AnyRuleContext.swift index 28182585..cf7441cd 100644 --- a/Sources/Compute/Attribute/RuleContext/AnyRuleContext.swift +++ b/Sources/Compute/Attribute/RuleContext/AnyRuleContext.swift @@ -1,7 +1,7 @@ import ComputeCxx -@_silgen_name("AGGraphWithUpdate") -func AGGraphWithUpdate(_ attribute: AnyAttribute, body: () -> Void) +@_silgen_name("IAGGraphWithUpdate") +func IAGGraphWithUpdate(_ attribute: AnyAttribute, body: () -> Void) public struct AnyRuleContext { @@ -20,16 +20,16 @@ public struct AnyRuleContext { } public func update(body: () -> Void) { - AGGraphWithUpdate(attribute, body: body) + IAGGraphWithUpdate(attribute, body: body) } public func changedValue( of input: Attribute, - options: AGValueOptions + options: IAGValueOptions ) -> ( value: Value, changed: Bool ) { - let result = __AGGraphGetInputValue(attribute, input.identifier, options, Metadata(Value.self)) + let result = __IAGGraphGetInputValue(attribute, input.identifier, options, Metadata(Value.self)) return ( result.value.assumingMemoryBound(to: Value.self).pointee, result.flags.contains(.changed) @@ -38,11 +38,11 @@ public struct AnyRuleContext { public func valueAndFlags( of input: Attribute, - options: AGValueOptions + options: IAGValueOptions ) -> ( - value: Value, flags: AGChangedValueFlags + value: Value, flags: IAGChangedValueFlags ) { - let result = __AGGraphGetInputValue(attribute, input.identifier, options, Metadata(Value.self)) + let result = __IAGGraphGetInputValue(attribute, input.identifier, options, Metadata(Value.self)) return ( result.value.assumingMemoryBound(to: Value.self).pointee, result.flags.contains(.changed) ? .changed : [] @@ -51,7 +51,7 @@ public struct AnyRuleContext { public subscript(_ attribute: Attribute) -> Value { unsafeAddress { - return __AGGraphGetInputValue(self.attribute, attribute.identifier, [], Metadata(Value.self)) + return __IAGGraphGetInputValue(self.attribute, attribute.identifier, [], Metadata(Value.self)) .value .assumingMemoryBound(to: Value.self) } diff --git a/Sources/Compute/Attribute/RuleContext/RuleContext.swift b/Sources/Compute/Attribute/RuleContext/RuleContext.swift index 98a2dab8..7efebe0c 100644 --- a/Sources/Compute/Attribute/RuleContext/RuleContext.swift +++ b/Sources/Compute/Attribute/RuleContext/RuleContext.swift @@ -14,7 +14,7 @@ public struct RuleContext { public var value: Value { unsafeAddress { - return UnsafePointer(__AGGraphGetOutputValue(Metadata(Value.self))!.assumingMemoryBound(to: Value.self)) + return UnsafePointer(__IAGGraphGetOutputValue(Metadata(Value.self))!.assumingMemoryBound(to: Value.self)) } nonmutating set { withUnsafePointer(to: newValue) { newValuePointer in @@ -24,12 +24,12 @@ public struct RuleContext { } public var hasValue: Bool { - let valuePointer = __AGGraphGetOutputValue(Metadata(Value.self)) + let valuePointer = __IAGGraphGetOutputValue(Metadata(Value.self)) return valuePointer != nil } - public func changedValue(of input: Attribute, options: AGValueOptions) -> (value: T, changed: Bool) { - let value = __AGGraphGetInputValue( + public func changedValue(of input: Attribute, options: IAGValueOptions) -> (value: T, changed: Bool) { + let value = __IAGGraphGetInputValue( attribute.identifier, input.identifier, options, @@ -43,11 +43,11 @@ public struct RuleContext { public func valueAndFlags( of input: Attribute, - options: AGValueOptions + options: IAGValueOptions ) -> ( - value: InputValue, flags: AGChangedValueFlags + value: InputValue, flags: IAGChangedValueFlags ) { - let value = __AGGraphGetInputValue( + let value = __IAGGraphGetInputValue( attribute.identifier, input.identifier, options, @@ -61,7 +61,7 @@ public struct RuleContext { public subscript(_ input: Attribute) -> InputValue { unsafeAddress { - return __AGGraphGetInputValue(attribute.identifier, input.identifier, [], Metadata(InputValue.self)) + return __IAGGraphGetInputValue(attribute.identifier, input.identifier, [], Metadata(InputValue.self)) .value .assumingMemoryBound(to: InputValue.self) } diff --git a/Sources/Compute/Attribute/Weak/AnyWeakAttribute.swift b/Sources/Compute/Attribute/Weak/AnyWeakAttribute.swift index 2dc6a28a..5dcf7a93 100644 --- a/Sources/Compute/Attribute/Weak/AnyWeakAttribute.swift +++ b/Sources/Compute/Attribute/Weak/AnyWeakAttribute.swift @@ -7,7 +7,7 @@ extension AnyWeakAttribute { } public init(_ attribute: AnyAttribute?) { - self = __AGCreateWeakAttribute(attribute ?? .nil) + self = __IAGCreateWeakAttribute(attribute ?? .nil) } public func unsafeCast(to type: Value.Type) -> WeakAttribute { @@ -16,7 +16,7 @@ extension AnyWeakAttribute { public var attribute: AnyAttribute? { get { - let attribute = __AGWeakAttributeGetAttribute(self) + let attribute = __IAGWeakAttributeGetAttribute(self) return attribute == .nil ? nil : attribute } set { diff --git a/Sources/Compute/Attribute/Weak/WeakAttribute.swift b/Sources/Compute/Attribute/Weak/WeakAttribute.swift index 08daed9f..8de55fc0 100644 --- a/Sources/Compute/Attribute/Weak/WeakAttribute.swift +++ b/Sources/Compute/Attribute/Weak/WeakAttribute.swift @@ -24,12 +24,12 @@ public struct WeakAttribute { base = AnyWeakAttribute(attribute?.identifier) } - public func changedValue(options: AGValueOptions = []) -> (value: Value, changed: Bool)? { + public func changedValue(options: IAGValueOptions = []) -> (value: Value, changed: Bool)? { return attribute?.changedValue(options: options) } public var value: Value? { - return __AGGraphGetWeakValue(base, [], Metadata(Value.self)) + return __IAGGraphGetWeakValue(base, [], Metadata(Value.self)) .value? .assumingMemoryBound(to: Value.self) .pointee diff --git a/Sources/Compute/Graph/Graph.swift b/Sources/Compute/Graph/Graph.swift index 097269e7..82c9fec1 100644 --- a/Sources/Compute/Graph/Graph.swift +++ b/Sources/Compute/Graph/Graph.swift @@ -1,16 +1,16 @@ import ComputeCxx -@_silgen_name("AGGraphSetOutputValue") +@_silgen_name("IAGGraphSetOutputValue") @inline(__always) @inlinable -func AGGraphSetOutputValue(_ value: UnsafeRawPointer, of type: Metadata) +func IAGGraphSetOutputValue(_ value: UnsafeRawPointer, of type: Metadata) extension Graph { @inline(__always) @inlinable public static func setOutputValue(_ value: UnsafePointer) { - AGGraphSetOutputValue(UnsafeRawPointer(value), of: Metadata(Value.self)) + IAGGraphSetOutputValue(UnsafeRawPointer(value), of: Metadata(Value.self)) } @_transparent @@ -23,25 +23,25 @@ extension Graph { @_transparent public static func anyInputsChanged(excluding excludedAttributes: [AnyAttribute]) -> Bool { - return __AGGraphAnyInputsChanged(excludedAttributes, excludedAttributes.count) + return __IAGGraphAnyInputsChanged(excludedAttributes, excludedAttributes.count) } } -@_silgen_name("AGGraphSetUpdateCallback") -func AGGraphSetUpdateCallback( +@_silgen_name("IAGGraphSetUpdateCallback") +func IAGGraphSetUpdateCallback( _ graph: UnsafeRawPointer, callback: (() -> Void)? ) -@_silgen_name("AGGraphSetInvalidationCallback") -func AGGraphSetInvalidationCallback( +@_silgen_name("IAGGraphSetInvalidationCallback") +func IAGGraphSetInvalidationCallback( _ graph: UnsafeRawPointer, callback: ((AnyAttribute) -> Void)? ) -@_silgen_name("AGGraphWithMainThreadHandler") -func AGGraphWithMainThreadHandler( +@_silgen_name("IAGGraphWithMainThreadHandler") +func IAGGraphWithMainThreadHandler( _ graph: UnsafeRawPointer, body: () -> Void, mainThreadHandler: (() -> Void) -> Void @@ -50,11 +50,11 @@ func AGGraphWithMainThreadHandler( extension Graph { public func onUpdate(_ handler: @escaping () -> Void) { - AGGraphSetUpdateCallback(unsafeBitCast(self, to: UnsafeRawPointer.self), callback: handler) + IAGGraphSetUpdateCallback(unsafeBitCast(self, to: UnsafeRawPointer.self), callback: handler) } public func onInvalidation(_ handler: @escaping (AnyAttribute) -> Void) { - AGGraphSetInvalidationCallback(unsafeBitCast(self, to: UnsafeRawPointer.self), callback: handler) + IAGGraphSetInvalidationCallback(unsafeBitCast(self, to: UnsafeRawPointer.self), callback: handler) } public func withDeadline(_ deadline: UInt64, _ body: () -> T) -> T { @@ -81,7 +81,7 @@ extension Graph { } public func withMainThreadHandler(_ mainThreadHandler: (() -> Void) -> Void, do body: () -> Void) { - AGGraphWithMainThreadHandler( + IAGGraphWithMainThreadHandler( unsafeBitCast(self, to: UnsafeRawPointer.self), body: body, mainThreadHandler: mainThreadHandler diff --git a/Sources/Compute/Graph/Subgraph.swift b/Sources/Compute/Graph/Subgraph.swift index 8ef44554..546a9650 100644 --- a/Sources/Compute/Graph/Subgraph.swift +++ b/Sources/Compute/Graph/Subgraph.swift @@ -1,19 +1,19 @@ import ComputeCxx -@_silgen_name("AGSubgraphAddObserver") -func AGSubgraphAddObserver( +@_silgen_name("IAGSubgraphAddObserver") +func IAGSubgraphAddObserver( _ subgraph: UnsafeRawPointer, observer: () -> Void ) -> Int extension Subgraph { public func addObserver(_ observer: @escaping () -> Void) -> Int { - AGSubgraphAddObserver(unsafeBitCast(self, to: UnsafeRawPointer.self), observer: observer) + IAGSubgraphAddObserver(unsafeBitCast(self, to: UnsafeRawPointer.self), observer: observer) } } -@_silgen_name("AGSubgraphApply") -func AGSubgraphApply( +@_silgen_name("IAGSubgraphApply") +func IAGSubgraphApply( _ subgraph: UnsafeRawPointer, _ flags: Subgraph.Flags, _ body: (AnyAttribute) -> Void @@ -36,7 +36,7 @@ extension Subgraph { _ flags: Subgraph.Flags, _ body: (AnyAttribute) -> Void ) { - AGSubgraphApply(unsafeBitCast(self, to: UnsafeRawPointer.self), flags, body) + IAGSubgraphApply(unsafeBitCast(self, to: UnsafeRawPointer.self), flags, body) } } @@ -48,7 +48,7 @@ extension Subgraph { flags: UInt32 ) { if shouldRecordTree { - __AGSubgraphBeginTreeElement( + __IAGSubgraphBeginTreeElement( value.identifier, Metadata(Value.self), flags @@ -58,7 +58,7 @@ extension Subgraph { public static func endTreeElement(value: Attribute) { if shouldRecordTree { - __AGSubgraphEndTreeElement(value.identifier) + __IAGSubgraphEndTreeElement(value.identifier) } } @@ -68,7 +68,7 @@ extension Subgraph { flags: UInt32 ) { if shouldRecordTree { - __AGSubgraphAddTreeValue(value.identifier, Metadata(Value.self), key, flags) + __IAGSubgraphAddTreeValue(value.identifier, Metadata(Value.self), key, flags) } } diff --git a/Sources/Compute/Graph/TreeElement.swift b/Sources/Compute/Graph/TreeElement.swift index 4868a237..e1611690 100644 --- a/Sources/Compute/Graph/TreeElement.swift +++ b/Sources/Compute/Graph/TreeElement.swift @@ -3,7 +3,7 @@ import ComputeCxx extension TreeElement { public var value: AnyAttribute? { - let result = __AGTreeElementGetValue(self) + let result = __IAGTreeElementGetValue(self) return result == .nil ? nil : result } @@ -14,7 +14,7 @@ extension Nodes: @retroactive IteratorProtocol { @inlinable public mutating func next() -> AnyAttribute? { - let result = __AGTreeElementGetNextNode(&self) + let result = __IAGTreeElementGetNextNode(&self) return result == .nil ? nil : result } diff --git a/Sources/Compute/Runtime/CompareValues.swift b/Sources/Compute/Runtime/CompareValues.swift index 3d8a69a9..15a3a278 100644 --- a/Sources/Compute/Runtime/CompareValues.swift +++ b/Sources/Compute/Runtime/CompareValues.swift @@ -15,7 +15,7 @@ public func compareValues(_ lhs: Value, _ rhs: Value, mode: ComparisonMod public func compareValues(_ lhs: Value, _ rhs: Value, options: ComparisonOptions) -> Bool { return withUnsafePointer(to: lhs) { lhsPointer in return withUnsafePointer(to: rhs) { rhsPointer in - return __AGCompareValues(lhsPointer, rhsPointer, Metadata(Value.self), options.union(.copyOnWrite)) + return __IAGCompareValues(lhsPointer, rhsPointer, Metadata(Value.self), options.union(.copyOnWrite)) } } } diff --git a/Sources/Compute/Runtime/Enum.swift b/Sources/Compute/Runtime/Enum.swift index 6c4b6036..dd584f15 100644 --- a/Sources/Compute/Runtime/Enum.swift +++ b/Sources/Compute/Runtime/Enum.swift @@ -1,7 +1,7 @@ import ComputeCxx -@_silgen_name("AGTypeApplyEnumData") -func AGTypeApplyEnumData( +@_silgen_name("IAGTypeApplyEnumData") +func IAGTypeApplyEnumData( _ type: Metadata, value: UnsafeRawPointer, body: (Int, Metadata, UnsafeRawPointer) -> Void @@ -11,13 +11,13 @@ public func withUnsafePointerToEnumCase( of enumValue: UnsafeMutablePointer, do body: (Int, Any.Type, UnsafeRawPointer) -> Void ) -> Bool { - return AGTypeApplyEnumData(Metadata(Value.self), value: enumValue) { tag, fieldType, fieldValue in + return IAGTypeApplyEnumData(Metadata(Value.self), value: enumValue) { tag, fieldType, fieldValue in body(tag, fieldType.type, fieldValue) } } -@_silgen_name("AGTypeApplyMutableEnumData") -func AGTypeApplyMutableEnumData( +@_silgen_name("IAGTypeApplyMutableEnumData") +func IAGTypeApplyMutableEnumData( _ type: Metadata, value: UnsafeRawPointer, body: (Int, Metadata, UnsafeMutableRawPointer) -> Void @@ -27,7 +27,7 @@ public func withUnsafeMutablePointerToEnumCase( of enumValue: UnsafeMutablePointer, do body: (Int, Any.Type, UnsafeMutableRawPointer) -> Void ) -> Bool { - return AGTypeApplyMutableEnumData(Metadata(Value.self), value: enumValue) { tag, fieldType, fieldValue in + return IAGTypeApplyMutableEnumData(Metadata(Value.self), value: enumValue) { tag, fieldType, fieldValue in body(tag, fieldType.type, fieldValue) } } diff --git a/Sources/Compute/Runtime/Metadata.swift b/Sources/Compute/Runtime/Metadata.swift index 44787fd8..b6494fbf 100644 --- a/Sources/Compute/Runtime/Metadata.swift +++ b/Sources/Compute/Runtime/Metadata.swift @@ -1,16 +1,16 @@ import ComputeCxx -@_silgen_name("AGTypeApplyFields") -func AGTypeApplyFields(_ type: Metadata, body: (UnsafePointer, Int, Metadata) -> Void) +@_silgen_name("IAGTypeApplyFields") +func IAGTypeApplyFields(_ type: Metadata, body: (UnsafePointer, Int, Metadata) -> Void) public func forEachField(of type: Any.Type, do body: (UnsafePointer, Int, Any.Type) -> Void) { - AGTypeApplyFields(Metadata(type)) { fieldName, fieldOffset, fieldType in + IAGTypeApplyFields(Metadata(type)) { fieldName, fieldOffset, fieldType in body(fieldName, fieldOffset, fieldType.type) } } -@_silgen_name("AGTypeApplyFields2") -func AGTypeApplyFields2( +@_silgen_name("IAGTypeApplyFields2") +func IAGTypeApplyFields2( _ type: Metadata, options: Metadata.ApplyOptions, body: (UnsafePointer, Int, Metadata) -> Bool @@ -32,7 +32,7 @@ extension Metadata { ) -> Bool { - return AGTypeApplyFields2(self, options: options) { fieldName, fieldOffset, fieldType in + return IAGTypeApplyFields2(self, options: options) { fieldName, fieldOffset, fieldType in return body(fieldName, fieldOffset, fieldType.type) } } @@ -43,9 +43,9 @@ extension Metadata: @retroactive CustomStringConvertible { public var description: String { #if os(iOS) || os(macOS) - return __AGTypeDescription(self) as String + return __IAGTypeDescription(self) as String #else - return String(__AGTypeCopyDescription(self)) + return String(__IAGTypeCopyDescription(self)) #endif } diff --git a/Sources/Compute/Runtime/Tuple.swift b/Sources/Compute/Runtime/Tuple.swift index e43a3c4a..6643a5bd 100644 --- a/Sources/Compute/Runtime/Tuple.swift +++ b/Sources/Compute/Runtime/Tuple.swift @@ -1,7 +1,7 @@ import ComputeCxx -@_silgen_name("AGTupleWithBuffer") -func AGTupleWithBuffer( +@_silgen_name("IAGTupleWithBuffer") +func IAGTupleWithBuffer( of type: TupleType, count: Int, body: (UnsafeMutableTuple) -> Void @@ -12,7 +12,7 @@ public func withUnsafeTuple( count: Int, body: (UnsafeMutableTuple) -> Void ) { - return AGTupleWithBuffer(of: type, count: count, body: body) + return IAGTupleWithBuffer(of: type, count: count, body: body) } extension TupleType { @@ -53,7 +53,7 @@ extension TupleType { to destinationValue: UnsafeMutablePointer, options: CopyOptions ) { - __AGTupleGetElement( + __IAGTupleGetElement( self, tupleValue, index, @@ -69,7 +69,7 @@ extension TupleType { from sourceValue: UnsafePointer, options: CopyOptions ) { - __AGTupleSetElement( + __IAGTupleSetElement( self, tupleValue, index, diff --git a/Sources/ComputeCxx/Array/ArrayRef.h b/Sources/ComputeCxx/Array/ArrayRef.h index ecf1b357..e9f43f6a 100644 --- a/Sources/ComputeCxx/Array/ArrayRef.h +++ b/Sources/ComputeCxx/Array/ArrayRef.h @@ -2,11 +2,11 @@ #include -#include +#include -AG_ASSUME_NONNULL_BEGIN +IAG_ASSUME_NONNULL_BEGIN -namespace AG { +namespace IAG { template class ArrayRef { public: @@ -61,6 +61,6 @@ template class ArrayRef { size_type size() const { return _size; }; }; -} // namespace AG +} // namespace IAG -AG_ASSUME_NONNULL_END +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/Attribute/AttributeData/Edge/InputEdge.h b/Sources/ComputeCxx/Attribute/AttributeData/Edge/InputEdge.h index 343b670d..aa91c1df 100644 --- a/Sources/ComputeCxx/Attribute/AttributeData/Edge/InputEdge.h +++ b/Sources/ComputeCxx/Attribute/AttributeData/Edge/InputEdge.h @@ -1,18 +1,18 @@ #pragma once #include "Attribute/AttributeID/AttributeID.h" -#include "ComputeCxx/AGInputOptions.h" +#include "ComputeCxx/IAGInputOptions.h" -namespace AG { +namespace IAG { struct InputEdge { AttributeID attribute; - AGInputOptions options; + IAGInputOptions options; struct Comparator { AttributeID attribute; - AGInputOptions options_mask; - AGInputOptions options; + IAGInputOptions options_mask; + IAGInputOptions options; bool match(const InputEdge &input_edge) { return input_edge.attribute == attribute && (input_edge.options & options_mask) == options; @@ -25,4 +25,4 @@ struct InputEdge { } }; -} // namespace AG +} // namespace IAG diff --git a/Sources/ComputeCxx/Attribute/AttributeData/Edge/OutputEdge.h b/Sources/ComputeCxx/Attribute/AttributeData/Edge/OutputEdge.h index b1c685a6..4ea49992 100644 --- a/Sources/ComputeCxx/Attribute/AttributeData/Edge/OutputEdge.h +++ b/Sources/ComputeCxx/Attribute/AttributeData/Edge/OutputEdge.h @@ -3,7 +3,7 @@ #include "Array/ArrayRef.h" #include "Attribute/AttributeID/AttributeID.h" -namespace AG { +namespace IAG { struct OutputEdge { AttributeID attribute; @@ -11,4 +11,4 @@ struct OutputEdge { using ConstOutputEdgeArrayRef = ArrayRef; -} // namespace AG +} // namespace IAG diff --git a/Sources/ComputeCxx/Attribute/AttributeData/Node/IndirectNode.cpp b/Sources/ComputeCxx/Attribute/AttributeData/Node/IndirectNode.cpp index 515f6c71..a0b4a2bd 100644 --- a/Sources/ComputeCxx/Attribute/AttributeData/Node/IndirectNode.cpp +++ b/Sources/ComputeCxx/Attribute/AttributeData/Node/IndirectNode.cpp @@ -2,7 +2,7 @@ #include -namespace AG { +namespace IAG { MutableIndirectNode &IndirectNode::to_mutable() { assert(is_mutable()); @@ -19,4 +19,4 @@ void IndirectNode::modify(WeakAttributeID source, size_t offset) { _offset = offset; } -} // namespace AG +} // namespace IAG diff --git a/Sources/ComputeCxx/Attribute/AttributeData/Node/IndirectNode.h b/Sources/ComputeCxx/Attribute/AttributeData/Node/IndirectNode.h index 44fdfde9..d0504af2 100644 --- a/Sources/ComputeCxx/Attribute/AttributeData/Node/IndirectNode.h +++ b/Sources/ComputeCxx/Attribute/AttributeData/Node/IndirectNode.h @@ -4,12 +4,12 @@ #include "Attribute/AttributeID/AttributeID.h" #include "Attribute/AttributeID/RelativeAttributeID.h" #include "Attribute/AttributeID/WeakAttributeID.h" -#include "ComputeCxx/AGBase.h" +#include "ComputeCxx/IAGBase.h" #include "Data/Vector.h" -AG_ASSUME_NONNULL_BEGIN +IAG_ASSUME_NONNULL_BEGIN -namespace AG { +namespace IAG { class MutableIndirectNode; @@ -89,6 +89,6 @@ class MutableIndirectNode : public IndirectNode { data::vector &output_edges() { return _output_edges; }; }; -} // namespace AG +} // namespace IAG -AG_ASSUME_NONNULL_END +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/Attribute/AttributeData/Node/Node.cpp b/Sources/ComputeCxx/Attribute/AttributeData/Node/Node.cpp index ba581977..9b24b131 100644 --- a/Sources/ComputeCxx/Attribute/AttributeData/Node/Node.cpp +++ b/Sources/ComputeCxx/Attribute/AttributeData/Node/Node.cpp @@ -6,7 +6,7 @@ #include "Graph/Graph.h" #include "Swift/Metadata.h" -namespace AG { +namespace IAG { void *Node::get_self(const AttributeType &type) const { void *self = ((char *)this + type.body_offset()); @@ -103,4 +103,4 @@ void Node::destroy(Graph &graph) { } } -} // namespace AG +} // namespace IAG diff --git a/Sources/ComputeCxx/Attribute/AttributeData/Node/Node.h b/Sources/ComputeCxx/Attribute/AttributeData/Node/Node.h index 1155a3ce..26176919 100644 --- a/Sources/ComputeCxx/Attribute/AttributeData/Node/Node.h +++ b/Sources/ComputeCxx/Attribute/AttributeData/Node/Node.h @@ -3,15 +3,15 @@ #include "Attribute/AttributeData/Edge/InputEdge.h" #include "Attribute/AttributeData/Edge/OutputEdge.h" #include "Attribute/AttributeID/RelativeAttributeID.h" -#include "ComputeCxx/AGAttribute.h" -#include "ComputeCxx/AGBase.h" -#include "ComputeCxx/AGGraph.h" +#include "ComputeCxx/IAGAttribute.h" +#include "ComputeCxx/IAGBase.h" +#include "ComputeCxx/IAGGraph.h" #include "Data/Pointer.h" #include "Data/Vector.h" -AG_ASSUME_NONNULL_BEGIN +IAG_ASSUME_NONNULL_BEGIN -namespace AG { +namespace IAG { namespace data { class zone; @@ -46,7 +46,7 @@ class Node { // Subgraph RelativeAttributeID _next_attribute; - AGAttributeFlags _subgraph_flags = AGAttributeFlags(0); + IAGAttributeFlags _subgraph_flags = IAGAttributeFlags(0); // Data flags unsigned int _has_indirect_self : 1 = 0; @@ -108,12 +108,12 @@ class Node { uint8_t count() const { return (uint8_t)_state >> 6; }; // TODO: test this - AGValueState flags() const { - return (is_dirty() ? AGValueStateDirty : 0) | (is_pending() ? AGValueStatePending : 0) | - (is_updating() ? AGValueStateUpdating : 0) | (is_value_initialized() ? AGValueStateValueExists : 0) | - (is_main_thread() ? AGValueStateMainThread : 0) | (_main_ref ? AGValueStateMainRef : 0) | - (requires_main_thread() ? AGValueStateRequiresMainThread : 0) | - (_self_modified ? AGValueStateSelfModified : 0); + IAGValueState flags() const { + return (is_dirty() ? IAGValueStateDirty : 0) | (is_pending() ? IAGValueStatePending : 0) | + (is_updating() ? IAGValueStateUpdating : 0) | (is_value_initialized() ? IAGValueStateValueExists : 0) | + (is_main_thread() ? IAGValueStateMainThread : 0) | (_main_ref ? IAGValueStateMainRef : 0) | + (requires_main_thread() ? IAGValueStateRequiresMainThread : 0) | + (_self_modified ? IAGValueStateSelfModified : 0); }; uint32_t type_id() const { return _type_id; }; @@ -121,8 +121,8 @@ class Node { const RelativeAttributeID next_attribute() const { return _next_attribute; } void set_next_attribute(RelativeAttributeID next_attribute) { _next_attribute = next_attribute; } - AGAttributeFlags subgraph_flags() const { return _subgraph_flags; }; - void set_subgraph_flags(AGAttributeFlags subgraph_flags) { _subgraph_flags = subgraph_flags; }; + IAGAttributeFlags subgraph_flags() const { return _subgraph_flags; }; + void set_subgraph_flags(IAGAttributeFlags subgraph_flags) { _subgraph_flags = subgraph_flags; }; // MARK: Data @@ -179,6 +179,6 @@ class Node { void destroy(Graph &graph); }; -} // namespace AG +} // namespace IAG -AG_ASSUME_NONNULL_END +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/Attribute/AttributeID/AGAttribute.cpp b/Sources/ComputeCxx/Attribute/AttributeID/AGAttribute.cpp deleted file mode 100644 index fc0bf491..00000000 --- a/Sources/ComputeCxx/Attribute/AttributeID/AGAttribute.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "ComputeCxx/AGAttribute.h" - -#include "AttributeID.h" - -const AGAttribute AGAttributeNil = AGAttribute(AG::AttributeID::Kind::NilAttribute); diff --git a/Sources/ComputeCxx/Attribute/AttributeID/AGWeakAttribute.cpp b/Sources/ComputeCxx/Attribute/AttributeID/AGWeakAttribute.cpp deleted file mode 100644 index c0aca98e..00000000 --- a/Sources/ComputeCxx/Attribute/AttributeID/AGWeakAttribute.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "ComputeCxx/AGWeakAttribute.h" -#include "AttributeID.h" -#include "Data/Zone.h" -#include "Subgraph/Subgraph.h" -#include "WeakAttributeID.h" - -AGWeakAttribute AGCreateWeakAttribute(AGAttribute attribute) { - auto attribute_id = AG::AttributeID(attribute); - if (!attribute_id || attribute_id.is_nil()) { - return AGWeakAttribute({attribute_id, 0}); - } - - auto subgraph_id = attribute_id.subgraph()->subgraph_id(); - return AGWeakAttribute({attribute_id, uint32_t(subgraph_id)}); -} - -// TODO: add test that evaluate checks deleted bit in zone id -AGAttribute AGWeakAttributeGetAttribute(AGWeakAttribute weak_attribute) { - auto weak_attribute_id = AG::WeakAttributeID(weak_attribute); - return weak_attribute_id.evaluate(); -} diff --git a/Sources/ComputeCxx/Attribute/AttributeID/AttributeID.cpp b/Sources/ComputeCxx/Attribute/AttributeID/AttributeID.cpp index 10dd4e8e..5e7c8c8c 100644 --- a/Sources/ComputeCxx/Attribute/AttributeID/AttributeID.cpp +++ b/Sources/ComputeCxx/Attribute/AttributeID/AttributeID.cpp @@ -9,11 +9,11 @@ #include "OffsetAttributeID.h" #include "Subgraph/Subgraph.h" -namespace AG { +namespace IAG { bool AttributeID::has_subgraph_flags() const { if (auto node = get_node()) { - return node->subgraph_flags() != AGAttributeFlagsNone; + return node->subgraph_flags() != IAGAttributeFlagsNone; } return false; } @@ -67,7 +67,7 @@ OffsetAttributeID AttributeID::resolve_slow(TraversalOptions options) const { if (dependency) { auto subgraph = dependency.subgraph(); if (subgraph) { - subgraph->graph()->update_attribute(dependency.get_node(), AGGraphUpdateOptionsNone); + subgraph->graph()->update_attribute(dependency.get_node(), IAGGraphUpdateOptionsNone); } } } @@ -78,7 +78,7 @@ OffsetAttributeID AttributeID::resolve_slow(TraversalOptions options) const { if (options & TraversalOptions::AssertNotNil) { precondition_failure("invalid indirect ref: %u", _value); } - return OffsetAttributeID(AttributeID(AGAttributeNil)); + return OffsetAttributeID(AttributeID(IAGAttributeNil)); } } @@ -93,4 +93,4 @@ OffsetAttributeID AttributeID::resolve_slow(TraversalOptions options) const { return OffsetAttributeID(result, offset); } -} // namespace AG +} // namespace IAG diff --git a/Sources/ComputeCxx/Attribute/AttributeID/AttributeID.h b/Sources/ComputeCxx/Attribute/AttributeID/AttributeID.h index 1d9d713b..5827155d 100644 --- a/Sources/ComputeCxx/Attribute/AttributeID/AttributeID.h +++ b/Sources/ComputeCxx/Attribute/AttributeID/AttributeID.h @@ -3,15 +3,15 @@ #include #include -#include "ComputeCxx/AGAttribute.h" -#include "ComputeCxx/AGBase.h" +#include "ComputeCxx/IAGAttribute.h" +#include "ComputeCxx/IAGBase.h" #include "Data/Page.h" #include "Data/Pointer.h" #include "Data/Zone.h" -AG_ASSUME_NONNULL_BEGIN +IAG_ASSUME_NONNULL_BEGIN -namespace AG { +namespace IAG { class Subgraph; class Node; @@ -75,8 +75,8 @@ class AttributeID { explicit AttributeID(data::ptr indirect_node) : _value(indirect_node.offset() | Kind::IndirectNode) {}; - operator AGAttribute() const { return _value; } - explicit constexpr AttributeID(AGAttribute storage) : _value(storage) {} + operator IAGAttribute() const { return _value; } + explicit constexpr AttributeID(IAGAttribute storage) : _value(storage) {} // MARK: Operators @@ -129,6 +129,6 @@ class AttributeID { OffsetAttributeID resolve(TraversalOptions options) const; }; -} // namespace AG +} // namespace IAG -AG_ASSUME_NONNULL_END +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/Attribute/AttributeID/IAGAttribute.cpp b/Sources/ComputeCxx/Attribute/AttributeID/IAGAttribute.cpp new file mode 100644 index 00000000..76bf6ca6 --- /dev/null +++ b/Sources/ComputeCxx/Attribute/AttributeID/IAGAttribute.cpp @@ -0,0 +1,5 @@ +#include "ComputeCxx/IAGAttribute.h" + +#include "AttributeID.h" + +const IAGAttribute IAGAttributeNil = IAGAttribute(IAG::AttributeID::Kind::NilAttribute); diff --git a/Sources/ComputeCxx/Attribute/AttributeID/IAGWeakAttribute.cpp b/Sources/ComputeCxx/Attribute/AttributeID/IAGWeakAttribute.cpp new file mode 100644 index 00000000..50c2b86b --- /dev/null +++ b/Sources/ComputeCxx/Attribute/AttributeID/IAGWeakAttribute.cpp @@ -0,0 +1,21 @@ +#include "ComputeCxx/IAGWeakAttribute.h" +#include "AttributeID.h" +#include "Data/Zone.h" +#include "Subgraph/Subgraph.h" +#include "WeakAttributeID.h" + +IAGWeakAttribute IAGCreateWeakAttribute(IAGAttribute attribute) { + auto attribute_id = IAG::AttributeID(attribute); + if (!attribute_id || attribute_id.is_nil()) { + return IAGWeakAttribute({attribute_id, 0}); + } + + auto subgraph_id = attribute_id.subgraph()->subgraph_id(); + return IAGWeakAttribute({attribute_id, uint32_t(subgraph_id)}); +} + +// TODO: add test that evaluate checks deleted bit in zone id +IAGAttribute IAGWeakAttributeGetAttribute(IAGWeakAttribute weak_attribute) { + auto weak_attribute_id = IAG::WeakAttributeID(weak_attribute); + return weak_attribute_id.evaluate(); +} diff --git a/Sources/ComputeCxx/Attribute/AttributeID/OffsetAttributeID.h b/Sources/ComputeCxx/Attribute/AttributeID/OffsetAttributeID.h index cc34624c..f4e9ef47 100644 --- a/Sources/ComputeCxx/Attribute/AttributeID/OffsetAttributeID.h +++ b/Sources/ComputeCxx/Attribute/AttributeID/OffsetAttributeID.h @@ -1,12 +1,12 @@ #pragma once -#include "ComputeCxx/AGBase.h" +#include "ComputeCxx/IAGBase.h" #include "AttributeID.h" -AG_ASSUME_NONNULL_BEGIN +IAG_ASSUME_NONNULL_BEGIN -namespace AG { +namespace IAG { class OffsetAttributeID { private: @@ -22,6 +22,6 @@ class OffsetAttributeID { uint32_t offset() const { return _offset; }; }; -} // namespace AG +} // namespace IAG -AG_ASSUME_NONNULL_END +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/Attribute/AttributeID/RelativeAttributeID.h b/Sources/ComputeCxx/Attribute/AttributeID/RelativeAttributeID.h index 78a1aecb..dfe13034 100644 --- a/Sources/ComputeCxx/Attribute/AttributeID/RelativeAttributeID.h +++ b/Sources/ComputeCxx/Attribute/AttributeID/RelativeAttributeID.h @@ -3,7 +3,7 @@ #include "AttributeID.h" #include "Data/Pointer.h" -namespace AG { +namespace IAG { class RelativeAttributeID { private: @@ -27,4 +27,4 @@ class RelativeAttributeID { AttributeID resolve(data::ptr page_ptr) { return AttributeID(page_ptr.offset() + _value); } }; -} // namespace AG +} // namespace IAG diff --git a/Sources/ComputeCxx/Attribute/AttributeID/WeakAttributeID.cpp b/Sources/ComputeCxx/Attribute/AttributeID/WeakAttributeID.cpp index 288065cd..12915d12 100644 --- a/Sources/ComputeCxx/Attribute/AttributeID/WeakAttributeID.cpp +++ b/Sources/ComputeCxx/Attribute/AttributeID/WeakAttributeID.cpp @@ -4,7 +4,7 @@ #include "Data/Table.h" #include "Data/Zone.h" -namespace AG { +namespace IAG { bool WeakAttributeID::expired() const { uint64_t raw_page_seed = data::table::shared().raw_page_seed(_identifier.page_ptr()); @@ -18,7 +18,7 @@ bool WeakAttributeID::expired() const { } const AttributeID WeakAttributeID::evaluate() const { - return _identifier && !expired() ? _identifier : AttributeID(AGAttributeNil); + return _identifier && !expired() ? _identifier : AttributeID(IAGAttributeNil); }; -} // namespace AG +} // namespace IAG diff --git a/Sources/ComputeCxx/Attribute/AttributeID/WeakAttributeID.h b/Sources/ComputeCxx/Attribute/AttributeID/WeakAttributeID.h index 5d46f59e..eed9129c 100644 --- a/Sources/ComputeCxx/Attribute/AttributeID/WeakAttributeID.h +++ b/Sources/ComputeCxx/Attribute/AttributeID/WeakAttributeID.h @@ -1,12 +1,12 @@ #pragma once #include "AttributeID.h" -#include "ComputeCxx/AGBase.h" -#include "ComputeCxx/AGWeakAttribute.h" +#include "ComputeCxx/IAGBase.h" +#include "ComputeCxx/IAGWeakAttribute.h" -AG_ASSUME_NONNULL_BEGIN +IAG_ASSUME_NONNULL_BEGIN -namespace AG { +namespace IAG { class WeakAttributeID { private: @@ -16,8 +16,8 @@ class WeakAttributeID { public: WeakAttributeID(AttributeID identifier, uint32_t seed) : _identifier(identifier), _seed(seed) {} - operator AGWeakAttribute() const { return *reinterpret_cast(this); } - explicit constexpr WeakAttributeID(AGWeakAttribute storage) + operator IAGWeakAttribute() const { return *reinterpret_cast(this); } + explicit constexpr WeakAttributeID(IAGWeakAttribute storage) : _identifier(storage._details.identifier), _seed(storage._details.seed) {} // MARK: Accessing data @@ -31,6 +31,6 @@ class WeakAttributeID { const AttributeID evaluate() const; }; -} // namespace AG +} // namespace IAG -AG_ASSUME_NONNULL_END +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/Attribute/AttributeType/AttributeType.h b/Sources/ComputeCxx/Attribute/AttributeType/AttributeType.h index ec0ad2e6..73d59ceb 100644 --- a/Sources/ComputeCxx/Attribute/AttributeType/AttributeType.h +++ b/Sources/ComputeCxx/Attribute/AttributeType/AttributeType.h @@ -2,24 +2,24 @@ #include "Attribute/AttributeData/Node/Node.h" #include "Comparison/LayoutDescriptor.h" -#include "ComputeCxx/AGBase.h" -#include "ComputeCxx/AGAttribute.h" -#include "ComputeCxx/AGAttributeType.h" -#include "ComputeCxx/AGComparison.h" +#include "ComputeCxx/IAGBase.h" +#include "ComputeCxx/IAGAttribute.h" +#include "ComputeCxx/IAGAttributeType.h" +#include "ComputeCxx/IAGComparison.h" #include "Swift/Metadata.h" -AG_ASSUME_NONNULL_BEGIN +IAG_ASSUME_NONNULL_BEGIN -namespace AG { +namespace IAG { class AttributeType { private: swift::metadata *_body_metadata; swift::metadata *_value_metadata; - void (*_update)(void *body, AGAttribute attribute, void *context AG_SWIFT_CONTEXT) AG_SWIFT_CC(swift); + void (*_update)(void *body, IAGAttribute attribute, void *context IAG_SWIFT_CONTEXT) IAG_SWIFT_CC(swift); void *_update_context; - const AGAttributeVTable *_vtable; - AGAttributeTypeFlags _flags; + const IAGAttributeVTable *_vtable; + IAGAttributeTypeFlags _flags; // set after construction uint32_t _body_offset; @@ -33,7 +33,7 @@ class AttributeType { public: void operator()(AttributeType *ptr) { if (ptr != nullptr) { - ptr->vtable().type_destroy(reinterpret_cast(ptr)); + ptr->vtable().type_destroy(reinterpret_cast(ptr)); } } }; @@ -41,10 +41,10 @@ class AttributeType { const swift::metadata &body_metadata() const { return *_body_metadata; }; const swift::metadata &value_metadata() const { return *_value_metadata; }; - void update(void *body, AGAttribute attribute) const { _update(body, attribute, _update_context); }; + void update(void *body, IAGAttribute attribute) const { _update(body, attribute, _update_context); }; - const AGAttributeVTable &vtable() const { return *_vtable; } - AGAttributeTypeFlags flags() const { return _flags; }; + const IAGAttributeVTable &vtable() const { return *_vtable; } + IAGAttributeTypeFlags flags() const { return _flags; }; /// Returns the offset in bytes from a Node to the attribute body, /// aligned to the body's alignment. @@ -55,13 +55,13 @@ class AttributeType { } void fetch_layout() { - AGComparisonMode comparison_mode = AGComparisonMode(_flags & AGAttributeTypeFlagsComparisonModeMask); - _layout = LayoutDescriptor::fetch(value_metadata(), AGComparisonOptions(comparison_mode), 1); + IAGComparisonMode comparison_mode = IAGComparisonMode(_flags & IAGAttributeTypeFlagsComparisonModeMask); + _layout = LayoutDescriptor::fetch(value_metadata(), IAGComparisonOptions(comparison_mode), 1); }; bool compare_values(const void *lhs, const void *rhs) { - AGComparisonOptions comparison_options = AGComparisonOptions(_flags & AGAttributeTypeFlagsComparisonModeMask) | - AGComparisonOptionsCopyOnWrite | AGComparisonOptionsTraceCompareFailed; + IAGComparisonOptions comparison_options = IAGComparisonOptions(_flags & IAGAttributeTypeFlagsComparisonModeMask) | + IAGComparisonOptionsCopyOnWrite | IAGComparisonOptionsTraceCompareFailed; if (_layout == nullptr) { _layout = LayoutDescriptor::fetch(value_metadata(), comparison_options, 0); } @@ -72,8 +72,8 @@ class AttributeType { } bool compare_values_partial(const void *lhs, const void *rhs, size_t offset, size_t size) { - AGComparisonOptions comparison_options = - AGComparisonOptions(_flags & AGAttributeTypeFlagsComparisonModeMask) | AGComparisonOptionsCopyOnWrite; + IAGComparisonOptions comparison_options = + IAGComparisonOptions(_flags & IAGAttributeTypeFlagsComparisonModeMask) | IAGComparisonOptionsCopyOnWrite; if (_layout == nullptr) { _layout = LayoutDescriptor::fetch(value_metadata(), comparison_options, 0); } @@ -84,9 +84,9 @@ class AttributeType { } void destroy_self(Node &node) const { - if (_flags & AGAttributeTypeFlagsHasDestroySelf) { + if (_flags & IAGAttributeTypeFlagsHasDestroySelf) { void *body = node.get_self(*this); - vtable().self_destroy(reinterpret_cast(this), body); + vtable().self_destroy(reinterpret_cast(this), body); } } @@ -98,34 +98,34 @@ class AttributeType { #if TARGET_OS_MAC CFStringRef _Nullable self_description(void *body) const { if (auto self_description = vtable().self_description) { - return self_description(reinterpret_cast(this), body); + return self_description(reinterpret_cast(this), body); } return nullptr; } CFStringRef _Nullable value_description(void *value) const { if (auto value_description = vtable().value_description) { - return value_description(reinterpret_cast(this), value); + return value_description(reinterpret_cast(this), value); } return nullptr; } #else CFStringRef _Nullable copy_self_description(void *body) const { if (auto copy_self_description = vtable().copy_self_description) { - return copy_self_description(reinterpret_cast(this), body); + return copy_self_description(reinterpret_cast(this), body); } return nullptr; } CFStringRef _Nullable copy_value_description(void *value) const { if (auto copy_value_description = vtable().copy_value_description) { - return copy_value_description(reinterpret_cast(this), value); + return copy_value_description(reinterpret_cast(this), value); } return nullptr; } #endif }; -} // namespace AG +} // namespace IAG -AG_ASSUME_NONNULL_END +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/Attribute/AttributeView/AttributeView.h b/Sources/ComputeCxx/Attribute/AttributeView/AttributeView.h index 2746c0cb..9b2b68f8 100644 --- a/Sources/ComputeCxx/Attribute/AttributeView/AttributeView.h +++ b/Sources/ComputeCxx/Attribute/AttributeView/AttributeView.h @@ -4,7 +4,7 @@ #include "Attribute/AttributeData/Node/Node.h" #include "Data/Page.h" -namespace AG { +namespace IAG { class attribute_iterator { private: @@ -56,4 +56,4 @@ class const_attribute_view: public attribute_view { attribute_iterator end() { return attribute_iterator(_page, RelativeAttributeID(nullptr)); }; }; -} // namespace AG +} // namespace IAG diff --git a/Sources/ComputeCxx/Closure/ClosureFunction.h b/Sources/ComputeCxx/Closure/ClosureFunction.h index 9e980d35..55a6d303 100644 --- a/Sources/ComputeCxx/Closure/ClosureFunction.h +++ b/Sources/ComputeCxx/Closure/ClosureFunction.h @@ -2,15 +2,15 @@ #include -#include "ComputeCxx/AGBase.h" +#include "ComputeCxx/IAGBase.h" -namespace AG { +namespace IAG { /// C++ function type that is equivalent to the lowered Swift closure type. template class ClosureFunction { public: using Context = const void *_Nullable; - using Function = AG_SWIFT_CC(swift) Result (*_Nullable)(Args..., Context AG_SWIFT_CONTEXT); + using Function = IAG_SWIFT_CC(swift) Result (*_Nullable)(Args..., Context IAG_SWIFT_CONTEXT); private: Function _function; @@ -107,4 +107,4 @@ template requires std::unsigned_integral using ClosureFunctionCI = ClosureFunction; -} // namespace AG +} // namespace IAG diff --git a/Sources/ComputeCxx/Closure/AGClosure.cpp b/Sources/ComputeCxx/Closure/IAGClosure.cpp similarity index 66% rename from Sources/ComputeCxx/Closure/AGClosure.cpp rename to Sources/ComputeCxx/Closure/IAGClosure.cpp index 6ea5b1bb..cc06871d 100644 --- a/Sources/ComputeCxx/Closure/AGClosure.cpp +++ b/Sources/ComputeCxx/Closure/IAGClosure.cpp @@ -1,17 +1,17 @@ -#include "ComputeCxx/AGClosure.h" +#include "ComputeCxx/IAGClosure.h" #include -AGClosureStorage AGRetainClosure(const void *thunk, const void *_Nullable context) { +IAGClosureStorage IAGRetainClosure(const void *thunk, const void *_Nullable context) { const void *retained_context = context; if (context) { void *mutable_context = const_cast(context); retained_context = ::swift::swift_retain(reinterpret_cast<::swift::HeapObject *>(mutable_context)); } - return AGClosureStorage((void *)thunk, retained_context); + return IAGClosureStorage((void *)thunk, retained_context); } -void AGReleaseClosure(AGClosureStorage closure) { +void IAGReleaseClosure(IAGClosureStorage closure) { if (closure.context) { void *mutable_context = const_cast(closure.context); ::swift::swift_release(reinterpret_cast<::swift::HeapObject *>(mutable_context)); diff --git a/Sources/ComputeCxx/Comparison/AGComparison-Private.h b/Sources/ComputeCxx/Comparison/AGComparison-Private.h deleted file mode 100644 index 2a9050a4..00000000 --- a/Sources/ComputeCxx/Comparison/AGComparison-Private.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include "ComputeCxx/AGBase.h" -#include "ComputeCxx/AGComparison.h" - -AG_ASSUME_NONNULL_BEGIN - -typedef struct AGComparisonStateStorage { - const void *destination; - const void *source; - AGFieldRange field_range; - AGTypeID field_type; -} AGComparisonStateStorage; - -AG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/Comparison/AGComparison.cpp b/Sources/ComputeCxx/Comparison/AGComparison.cpp deleted file mode 100644 index b3bb4e2d..00000000 --- a/Sources/ComputeCxx/Comparison/AGComparison.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "AGComparison-Private.h" - -#include "Comparison/LayoutDescriptor.h" -#include "Swift/ContextDescriptor.h" -#include "Swift/Metadata.h" - -const void *AGComparisonStateGetDestination(AGComparisonState state) { return state->destination; } - -const void *AGComparisonStateGetSource(AGComparisonState state) { return state->source; } - -AGFieldRange AGComparisonStateGetFieldRange(AGComparisonState state) { return state->field_range; } - -AGTypeID AGComparisonStateGetFieldType(AGComparisonState state) { return state->field_type; } - -bool AGCompareValues(const void *destination, const void *source, AGTypeID type_id, AGComparisonOptions options) { - auto type = reinterpret_cast(type_id); - auto layout = AG::LayoutDescriptor::fetch(*type, options, 0); - if (layout == AG::ValueLayoutTrivial) { - layout = nullptr; - } - return AG::LayoutDescriptor::compare(layout, (const unsigned char *)destination, (const unsigned char *)source, - type->vw_size(), options); -} - -const unsigned char *AGPrefetchCompareValues(AGTypeID type_id, AGComparisonOptions options, uint32_t priority) { - auto type = reinterpret_cast(type_id); - return AG::LayoutDescriptor::fetch(*type, options, priority); -} - -void AGOverrideComparisonForTypeDescriptor(void *descriptor, AGComparisonMode mode) { - AG::LayoutDescriptor::add_type_descriptor_override( - reinterpret_cast(descriptor), mode); -} diff --git a/Sources/ComputeCxx/Comparison/Builder.h b/Sources/ComputeCxx/Comparison/Builder.h index 7455dacd..c863d5f0 100644 --- a/Sources/ComputeCxx/Comparison/Builder.h +++ b/Sources/ComputeCxx/Comparison/Builder.h @@ -2,15 +2,15 @@ #include -#include "ComputeCxx/AGBase.h" -#include "ComputeCxx/AGComparison.h" +#include "ComputeCxx/IAGBase.h" +#include "ComputeCxx/IAGComparison.h" #include "LayoutDescriptor.h" #include "Swift/MetadataVisitor.h" #include "Vector/Vector.h" -AG_ASSUME_NONNULL_BEGIN +IAG_ASSUME_NONNULL_BEGIN -namespace AG { +namespace IAG { namespace LayoutDescriptor { class Builder : public swift::metadata_visitor { @@ -117,7 +117,7 @@ class Builder : public swift::metadata_visitor { static void lock() { platform_lock_lock(&_lock); }; static void unlock() { platform_lock_unlock(&_lock); }; - AGComparisonMode _current_comparison_mode; + IAGComparisonMode _current_comparison_mode; HeapMode _heap_mode; size_t _current_offset = 0; uint64_t _enum_case_depth = 0; @@ -125,11 +125,11 @@ class Builder : public swift::metadata_visitor { vector _items; public: - Builder(AGComparisonMode comparison_mode, HeapMode heap_mode) + Builder(IAGComparisonMode comparison_mode, HeapMode heap_mode) : _current_comparison_mode(comparison_mode), _heap_mode(heap_mode) {} size_t current_offset() { return _current_offset; }; - AGComparisonMode current_comparison_mode() { return _current_comparison_mode; }; + IAGComparisonMode current_comparison_mode() { return _current_comparison_mode; }; vector &get_items() { return _current_enum_case != nullptr ? _current_enum_case->children : _items; }; @@ -156,6 +156,6 @@ class Builder : public swift::metadata_visitor { }; } // namespace LayoutDescriptor -} // namespace AG +} // namespace IAG -AG_ASSUME_NONNULL_END +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/Comparison/Compare.cpp b/Sources/ComputeCxx/Comparison/Compare.cpp index 767b52b8..e4870a52 100644 --- a/Sources/ComputeCxx/Comparison/Compare.cpp +++ b/Sources/ComputeCxx/Comparison/Compare.cpp @@ -5,7 +5,7 @@ #include "Swift/SwiftShims.h" #include "ValueLayout.h" -namespace AG { +namespace IAG { namespace LayoutDescriptor { Compare::Enum::Enum(const swift::metadata *type, Mode mode, unsigned int enum_tag, size_t offset, @@ -60,7 +60,7 @@ Compare::Frame::~Frame() { } bool Compare::operator()(ValueLayout layout, const unsigned char *lhs, const unsigned char *rhs, size_t offset, - size_t size, AGComparisonOptions options) { + size_t size, IAGComparisonOptions options) { Frame frame = Frame(&_enums); size_t end = size < 0 ? ~0 : offset + size; @@ -117,7 +117,7 @@ bool Compare::operator()(ValueLayout layout, const unsigned char *lhs, const uns return false; } } else { - if (!AGDispatchEquatable((const void *)(lhs + offset), (const void *)(rhs + offset), type, equatable)) { + if (!IAGDispatchEquatable((const void *)(lhs + offset), (const void *)(rhs + offset), type, equatable)) { failed(options, lhs, rhs, offset, item_size, type); return false; } @@ -134,7 +134,7 @@ bool Compare::operator()(ValueLayout layout, const unsigned char *lhs, const uns size_t item_end = offset + item_size; if (!compare_indirect(&indirect_layout, *_enums.back().type, *type, - options & ~AGComparisonOptionsTraceCompareFailed, lhs + offset, rhs + offset)) { + options & ~IAGComparisonOptionsTraceCompareFailed, lhs + offset, rhs + offset)) { failed(options, lhs, rhs, offset, item_size, type); return false; } @@ -150,7 +150,7 @@ bool Compare::operator()(ValueLayout layout, const unsigned char *lhs, const uns if (!compare_existential_values(*reinterpret_cast(type), lhs + offset, rhs + offset, - options & ~AGComparisonOptionsTraceCompareFailed)) { + options & ~IAGComparisonOptionsTraceCompareFailed)) { failed(options, lhs, rhs, offset, item_size, type); return false; } @@ -165,7 +165,7 @@ bool Compare::operator()(ValueLayout layout, const unsigned char *lhs, const uns size_t item_end = offset + 8; if (lhs + offset != rhs + offset) { - if (!compare_heap_objects(lhs + offset, rhs + offset, options & ~AGComparisonOptionsTraceCompareFailed, + if (!compare_heap_objects(lhs + offset, rhs + offset, options & ~IAGComparisonOptionsTraceCompareFailed, is_function)) { failed(options, lhs, rhs, offset, 8, nullptr); return false; @@ -231,7 +231,7 @@ bool Compare::operator()(ValueLayout layout, const unsigned char *lhs, const uns // Push enum - bool is_copy = options & AGComparisonOptionsCopyOnWrite; + bool is_copy = options & IAGComparisonOptionsCopyOnWrite; const unsigned char *_Nonnull lhs_enum; const unsigned char *_Nonnull rhs_enum; bool owns_copies = false; @@ -313,12 +313,12 @@ bool Compare::operator()(ValueLayout layout, const unsigned char *lhs, const uns } } -void Compare::failed(AGComparisonOptions options, const unsigned char *lhs, const unsigned char *rhs, size_t offset, +void Compare::failed(IAGComparisonOptions options, const unsigned char *lhs, const unsigned char *rhs, size_t offset, size_t size, const swift::metadata *type) { - if (options & AGComparisonOptionsTraceCompareFailed) { + if (options & IAGComparisonOptionsTraceCompareFailed) { Graph::compare_failed(lhs, rhs, offset, size, type); } } } // namespace LayoutDescriptor -} // namespace AG +} // namespace IAG diff --git a/Sources/ComputeCxx/Comparison/Compare.h b/Sources/ComputeCxx/Comparison/Compare.h index 5dfef3a2..cef88104 100644 --- a/Sources/ComputeCxx/Comparison/Compare.h +++ b/Sources/ComputeCxx/Comparison/Compare.h @@ -2,13 +2,13 @@ #include "LayoutDescriptor.h" -#include "ComputeCxx/AGBase.h" -#include "ComputeCxx/AGComparison.h" +#include "ComputeCxx/IAGBase.h" +#include "ComputeCxx/IAGComparison.h" #include "Vector/Vector.h" -AG_ASSUME_NONNULL_BEGIN +IAG_ASSUME_NONNULL_BEGIN -namespace AG { +namespace IAG { namespace LayoutDescriptor { class Compare { @@ -60,13 +60,13 @@ class Compare { public: bool operator()(ValueLayout layout, const unsigned char *lhs, const unsigned char *rhs, size_t offset, size_t size, - AGComparisonOptions options); + IAGComparisonOptions options); - void failed(AGComparisonOptions options, const unsigned char *lhs, const unsigned char *rhs, size_t offset, + void failed(IAGComparisonOptions options, const unsigned char *lhs, const unsigned char *rhs, size_t offset, size_t size, const swift::metadata *_Nullable type); }; } // namespace LayoutDescriptor -} // namespace AG +} // namespace IAG -AG_ASSUME_NONNULL_END +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/Comparison/IAGComparison-Private.h b/Sources/ComputeCxx/Comparison/IAGComparison-Private.h new file mode 100644 index 00000000..b05e3260 --- /dev/null +++ b/Sources/ComputeCxx/Comparison/IAGComparison-Private.h @@ -0,0 +1,15 @@ +#pragma once + +#include "ComputeCxx/IAGBase.h" +#include "ComputeCxx/IAGComparison.h" + +IAG_ASSUME_NONNULL_BEGIN + +typedef struct IAGComparisonStateStorage { + const void *destination; + const void *source; + IAGFieldRange field_range; + IAGTypeID field_type; +} IAGComparisonStateStorage; + +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/Comparison/IAGComparison.cpp b/Sources/ComputeCxx/Comparison/IAGComparison.cpp new file mode 100644 index 00000000..ef369378 --- /dev/null +++ b/Sources/ComputeCxx/Comparison/IAGComparison.cpp @@ -0,0 +1,33 @@ +#include "IAGComparison-Private.h" + +#include "Comparison/LayoutDescriptor.h" +#include "Swift/ContextDescriptor.h" +#include "Swift/Metadata.h" + +const void *IAGComparisonStateGetDestination(IAGComparisonState state) { return state->destination; } + +const void *IAGComparisonStateGetSource(IAGComparisonState state) { return state->source; } + +IAGFieldRange IAGComparisonStateGetFieldRange(IAGComparisonState state) { return state->field_range; } + +IAGTypeID IAGComparisonStateGetFieldType(IAGComparisonState state) { return state->field_type; } + +bool IAGCompareValues(const void *destination, const void *source, IAGTypeID type_id, IAGComparisonOptions options) { + auto type = reinterpret_cast(type_id); + auto layout = IAG::LayoutDescriptor::fetch(*type, options, 0); + if (layout == IAG::ValueLayoutTrivial) { + layout = nullptr; + } + return IAG::LayoutDescriptor::compare(layout, (const unsigned char *)destination, (const unsigned char *)source, + type->vw_size(), options); +} + +const unsigned char *IAGPrefetchCompareValues(IAGTypeID type_id, IAGComparisonOptions options, uint32_t priority) { + auto type = reinterpret_cast(type_id); + return IAG::LayoutDescriptor::fetch(*type, options, priority); +} + +void IAGOverrideComparisonForTypeDescriptor(void *descriptor, IAGComparisonMode mode) { + IAG::LayoutDescriptor::add_type_descriptor_override( + reinterpret_cast(descriptor), mode); +} diff --git a/Sources/ComputeCxx/Comparison/LayoutDescriptor.cpp b/Sources/ComputeCxx/Comparison/LayoutDescriptor.cpp index 9e3fe738..aaef2bbd 100644 --- a/Sources/ComputeCxx/Comparison/LayoutDescriptor.cpp +++ b/Sources/ComputeCxx/Comparison/LayoutDescriptor.cpp @@ -10,19 +10,19 @@ #include "Builder.h" #include "Compare.h" -#include "ComputeCxx/AGComparison.h" +#include "ComputeCxx/IAGComparison.h" #include "Graph/Graph.h" #include "Swift/Metadata.h" #include "Time/Time.h" #include "ValueLayout.h" -namespace AG { +namespace IAG { namespace { unsigned int print_layouts() { static unsigned int print_layouts = print_layouts = []() -> bool { - char *result = getenv("AG_PRINT_LAYOUTS"); + char *result = getenv("IAG_PRINT_LAYOUTS"); if (result) { return atoi(result) != 0; } @@ -41,7 +41,7 @@ class TypeDescriptorCache { public: struct QueueEntry { const swift::metadata *type; - AGComparisonMode comparison_mode; + IAGComparisonMode comparison_mode; LayoutDescriptor::HeapMode heap_mode; uint32_t priority; @@ -54,7 +54,7 @@ class TypeDescriptorCache { vector _async_queue; void *_field_0xf0; uint64_t _async_queue_running; - vector> _modes; + vector> _modes; void *_field_0x118; uint64_t _cache_hit_count; uint64_t _cache_miss_count; @@ -77,19 +77,19 @@ class TypeDescriptorCache { void lock() { platform_lock_lock(&_lock); }; void unlock() { platform_lock_unlock(&_lock); }; - vector> &modes() { return _modes; }; + vector> &modes() { return _modes; }; - static void *make_key(const swift::metadata *type, AGComparisonMode comparison_mode, + static void *make_key(const swift::metadata *type, IAGComparisonMode comparison_mode, LayoutDescriptor::HeapMode heap_mode); - ValueLayout fetch(const swift::metadata &type, AGComparisonOptions options, LayoutDescriptor::HeapMode heap_mode, + ValueLayout fetch(const swift::metadata &type, IAGComparisonOptions options, LayoutDescriptor::HeapMode heap_mode, uint32_t priority); - ValueLayout insert_sync(void *key, const swift::metadata &type, AGComparisonMode comparison_mode, + ValueLayout insert_sync(void *key, const swift::metadata &type, IAGComparisonMode comparison_mode, LayoutDescriptor::HeapMode heap_mode); #if TARGET_OS_MAC - void insert_async(void *key, const swift::metadata &type, AGComparisonMode comparison_mode, + void insert_async(void *key, const swift::metadata &type, IAGComparisonMode comparison_mode, LayoutDescriptor::HeapMode heap_mode, uint32_t priority); static void drain_queue(void *cache); @@ -99,7 +99,7 @@ class TypeDescriptorCache { TypeDescriptorCache *TypeDescriptorCache::_shared_cache = nullptr; platform_once_t TypeDescriptorCache::_shared_once = 0; -void *TypeDescriptorCache::make_key(const swift::metadata *type, AGComparisonMode comparison_mode, +void *TypeDescriptorCache::make_key(const swift::metadata *type, IAGComparisonMode comparison_mode, LayoutDescriptor::HeapMode heap_mode) { uintptr_t type_address = (uintptr_t)type; uintptr_t result = @@ -108,9 +108,9 @@ void *TypeDescriptorCache::make_key(const swift::metadata *type, AGComparisonMod return (void *)result; } -ValueLayout TypeDescriptorCache::fetch(const swift::metadata &type, AGComparisonOptions options, +ValueLayout TypeDescriptorCache::fetch(const swift::metadata &type, IAGComparisonOptions options, LayoutDescriptor::HeapMode heap_mode, uint32_t priority) { - AGComparisonMode comparison_mode = AGComparisonMode(options & AGComparisonOptionsComparisonModeMask); + IAGComparisonMode comparison_mode = IAGComparisonMode(options & IAGComparisonOptionsComparisonModeMask); void *key = make_key(&type, comparison_mode, heap_mode); @@ -129,14 +129,14 @@ ValueLayout TypeDescriptorCache::fetch(const swift::metadata &type, AGComparison #if TARGET_OS_MAC static bool async_layouts = []() { - char *result = getenv("AG_ASYNC_LAYOUTS"); + char *result = getenv("IAG_ASYNC_LAYOUTS"); if (result) { return atoi(result) != 0; } return true; }(); - if ((options & AGComparisonOptionsFetchLayoutsSynchronously) || !async_layouts) { + if ((options & IAGComparisonOptionsFetchLayoutsSynchronously) || !async_layouts) { return insert_sync(key, type, comparison_mode, heap_mode); } @@ -147,7 +147,7 @@ ValueLayout TypeDescriptorCache::fetch(const swift::metadata &type, AGComparison #endif } -ValueLayout TypeDescriptorCache::insert_sync(void *key, const swift::metadata &type, AGComparisonMode comparison_mode, +ValueLayout TypeDescriptorCache::insert_sync(void *key, const swift::metadata &type, IAGComparisonMode comparison_mode, LayoutDescriptor::HeapMode heap_mode) { double start_time = current_time(); ValueLayout layout = LayoutDescriptor::make_layout(type, comparison_mode, heap_mode); @@ -172,7 +172,7 @@ ValueLayout TypeDescriptorCache::insert_sync(void *key, const swift::metadata &t #if TARGET_OS_MAC -void TypeDescriptorCache::insert_async(void *key, const swift::metadata &type, AGComparisonMode comparison_mode, +void TypeDescriptorCache::insert_async(void *key, const swift::metadata &type, IAGComparisonMode comparison_mode, LayoutDescriptor::HeapMode heap_mode, uint32_t priority) { lock(); _table.insert((void *)key, nullptr); @@ -249,7 +249,7 @@ namespace LayoutDescriptor { unsigned char base_address = '\0'; -AGComparisonMode mode_for_type(const swift::metadata *type, AGComparisonMode default_mode) { +IAGComparisonMode mode_for_type(const swift::metadata *type, IAGComparisonMode default_mode) { if (!type) { return default_mode; } @@ -258,7 +258,7 @@ AGComparisonMode mode_for_type(const swift::metadata *type, AGComparisonMode def return default_mode; } - AGComparisonMode result = default_mode; + IAGComparisonMode result = default_mode; TypeDescriptorCache::shared_cache().lock(); auto &modes = TypeDescriptorCache::shared_cache().modes(); auto iter = std::find_if(modes.begin(), modes.end(), @@ -271,7 +271,7 @@ AGComparisonMode mode_for_type(const swift::metadata *type, AGComparisonMode def } void add_type_descriptor_override(const swift::context_descriptor *_Nullable type_descriptor, - AGComparisonMode override_mode) { + IAGComparisonMode override_mode) { if (!type_descriptor) { return; } @@ -288,12 +288,12 @@ void add_type_descriptor_override(const swift::context_descriptor *_Nullable typ TypeDescriptorCache::shared_cache().unlock(); } -ValueLayout _Nullable fetch(const swift::metadata &type, AGComparisonOptions options, uint32_t priority) { +ValueLayout _Nullable fetch(const swift::metadata &type, IAGComparisonOptions options, uint32_t priority) { return TypeDescriptorCache::shared_cache().fetch(type, options, HeapMode(0), priority); } -ValueLayout make_layout(const swift::metadata &type, AGComparisonMode default_mode, HeapMode heap_mode) { - AGComparisonMode comparison_mode = mode_for_type(&type, default_mode); +ValueLayout make_layout(const swift::metadata &type, IAGComparisonMode default_mode, HeapMode heap_mode) { + IAGComparisonMode comparison_mode = mode_for_type(&type, default_mode); Builder builder = Builder(comparison_mode, heap_mode); if (heap_mode == HeapMode::Locals) { @@ -305,9 +305,9 @@ ValueLayout make_layout(const swift::metadata &type, AGComparisonMode default_mo if (heap_mode == HeapMode::Class) { if (type.isClassObject()) { - AGComparisonMode equatable_minimum_mode = type.getValueWitnesses()->isPOD() - ? AGComparisonModeEquatableAlways - : AGComparisonModeEquatableUnlessPOD; + IAGComparisonMode equatable_minimum_mode = type.getValueWitnesses()->isPOD() + ? IAGComparisonModeEquatableAlways + : IAGComparisonModeEquatableUnlessPOD; if (equatable_minimum_mode <= builder.current_comparison_mode()) { if (auto equatable = type.equatable()) { size_t offset = builder.current_offset(); @@ -327,8 +327,8 @@ ValueLayout make_layout(const swift::metadata &type, AGComparisonMode default_mo return nullptr; } - AGComparisonMode equtable_minimum_mode = - type.getValueWitnesses()->isPOD() ? AGComparisonModeEquatableAlways : AGComparisonModeEquatableUnlessPOD; + IAGComparisonMode equtable_minimum_mode = + type.getValueWitnesses()->isPOD() ? IAGComparisonModeEquatableAlways : IAGComparisonModeEquatableUnlessPOD; if (equtable_minimum_mode <= builder.current_comparison_mode()) { if (auto equatable = type.equatable()) { size_t offset = builder.current_offset(); @@ -420,7 +420,7 @@ size_t length(ValueLayout layout) { // MARK: Comparing values bool compare(ValueLayout layout, const unsigned char *lhs, const unsigned char *rhs, size_t size, - AGComparisonOptions options) { + IAGComparisonOptions options) { if (lhs == rhs) { return true; } @@ -432,10 +432,10 @@ bool compare(ValueLayout layout, const unsigned char *lhs, const unsigned char * } bool compare_bytes_top_level(const unsigned char *lhs, const unsigned char *rhs, size_t size, - AGComparisonOptions options) { + IAGComparisonOptions options) { size_t failure_location = 0; bool result = compare_bytes(lhs, rhs, size, &failure_location); - if ((options & AGComparisonOptionsTraceCompareFailed) && !result) { + if ((options & IAGComparisonOptionsTraceCompareFailed) && !result) { Graph::compare_failed(lhs, rhs, failure_location, 1, nullptr); } return result; @@ -482,7 +482,7 @@ bool compare_bytes(const unsigned char *lhs, const unsigned char *rhs, size_t si return true; } -bool compare_heap_objects(const unsigned char *lhs, const unsigned char *rhs, AGComparisonOptions options, +bool compare_heap_objects(const unsigned char *lhs, const unsigned char *rhs, IAGComparisonOptions options, bool is_function) { if (lhs == rhs) { return true; @@ -498,12 +498,12 @@ bool compare_heap_objects(const unsigned char *lhs, const unsigned char *rhs, AG } HeapMode heap_mode = is_function ? HeapMode::Locals : HeapMode::Class; - AGComparisonOptions fetch_options = - options & AGComparisonOptionsComparisonModeMask; // this has the effect of allowing async fetch + IAGComparisonOptions fetch_options = + options & IAGComparisonOptionsComparisonModeMask; // this has the effect of allowing async fetch ValueLayout layout = TypeDescriptorCache::shared_cache().fetch(*lhs_type, fetch_options, heap_mode, 1); if (layout > ValueLayoutTrivial) { - return compare(layout, lhs, rhs, -1, options & ~AGComparisonOptionsCopyOnWrite); + return compare(layout, lhs, rhs, -1, options & ~IAGComparisonOptionsCopyOnWrite); } return false; @@ -511,7 +511,7 @@ bool compare_heap_objects(const unsigned char *lhs, const unsigned char *rhs, AG // https://www.swift.org/blog/how-mirror-works/ bool compare_indirect(ValueLayout *layout_ref, const swift::metadata &enum_type, const swift::metadata &layout_type, - AGComparisonOptions options, const unsigned char *lhs, const unsigned char *rhs) { + IAGComparisonOptions options, const unsigned char *lhs, const unsigned char *rhs) { size_t enum_size = enum_type.vw_size(); bool large_allocation = enum_size > 0x1000; @@ -553,7 +553,7 @@ bool compare_indirect(ValueLayout *layout_ref, const swift::metadata &enum_type, result = true; } else { if (*layout_ref == nullptr) { - *layout_ref = fetch(layout_type, options & ~AGComparisonOptionsCopyOnWrite, 0); + *layout_ref = fetch(layout_type, options & ~IAGComparisonOptionsCopyOnWrite, 0); } ValueLayout layout = *layout_ref == ValueLayoutTrivial ? nullptr : *layout_ref; @@ -565,7 +565,7 @@ bool compare_indirect(ValueLayout *layout_ref, const swift::metadata &enum_type, unsigned char *rhs_value = (unsigned char *)(*(unsigned char **)rhs_copy + offset); result = - compare(layout, lhs_value, rhs_value, layout_type.vw_size(), options & ~AGComparisonOptionsCopyOnWrite); + compare(layout, lhs_value, rhs_value, layout_type.vw_size(), options & ~IAGComparisonOptionsCopyOnWrite); } if (large_allocation) { @@ -577,7 +577,7 @@ bool compare_indirect(ValueLayout *layout_ref, const swift::metadata &enum_type, } bool compare_existential_values(const swift::existential_type_metadata &type, const unsigned char *lhs, - const unsigned char *rhs, AGComparisonOptions options) { + const unsigned char *rhs, IAGComparisonOptions options) { if (auto lhs_dynamic_type = type.dynamic_type((void *)lhs)) { if (auto rhs_dynamic_type = type.dynamic_type((void *)rhs)) { @@ -589,7 +589,7 @@ bool compare_existential_values(const swift::existential_type_metadata &type, co } if (lhs_value != lhs || rhs_value != rhs) { - options = options & ~AGComparisonOptionsCopyOnWrite; + options = options & ~IAGComparisonOptionsCopyOnWrite; } ValueLayout wrapped_layout = fetch(reinterpret_cast(type), options, 0); @@ -603,7 +603,7 @@ bool compare_existential_values(const swift::existential_type_metadata &type, co } bool compare_partial(ValueLayout layout, const unsigned char *lhs, const unsigned char *rhs, size_t offset, size_t size, - AGComparisonOptions options) { + IAGComparisonOptions options) { if (lhs == rhs) { return true; } @@ -1024,8 +1024,8 @@ void Builder::add_field(size_t field_size) { bool Builder::should_visit_fields(const swift::metadata &type, bool no_fetch) { if (!no_fetch) { if (auto layout = fetch(type, - AGComparisonOptions(_current_comparison_mode) | AGComparisonOptionsTraceCompareFailed | - AGComparisonOptionsFetchLayoutsSynchronously, + IAGComparisonOptions(_current_comparison_mode) | IAGComparisonOptionsTraceCompareFailed | + IAGComparisonOptionsFetchLayoutsSynchronously, true)) { if (layout == ValueLayoutTrivial) { add_field(type.vw_size()); @@ -1041,8 +1041,8 @@ bool Builder::should_visit_fields(const swift::metadata &type, bool no_fetch) { } } - AGComparisonMode equtable_minimum_mode = - type.getValueWitnesses()->isPOD() ? AGComparisonModeEquatableAlways : AGComparisonModeEquatableUnlessPOD; + IAGComparisonMode equtable_minimum_mode = + type.getValueWitnesses()->isPOD() ? IAGComparisonModeEquatableAlways : IAGComparisonModeEquatableUnlessPOD; if (equtable_minimum_mode <= _current_comparison_mode) { if (auto equatable = type.equatable()) { EqualsItem item = { @@ -1078,7 +1078,7 @@ bool Builder::visit_element(const swift::metadata &type, const swift::metadata:: _current_offset += element_offset; if (kind == swift::metadata::ref_kind::strong) { - AGComparisonMode prev_comparison_mode = _current_comparison_mode; + IAGComparisonMode prev_comparison_mode = _current_comparison_mode; _current_comparison_mode = mode_for_type(&type, _current_comparison_mode); if (should_visit_fields(type, false)) { @@ -1164,7 +1164,7 @@ bool Builder::visit_case(const swift::metadata &type, const swift::field_record } result = true; } else { - AGComparisonMode prev_comparison_mode = _current_comparison_mode; + IAGComparisonMode prev_comparison_mode = _current_comparison_mode; _current_comparison_mode = mode_for_type(&type, _current_comparison_mode); if (should_visit_fields(*field_type, false)) { @@ -1418,4 +1418,4 @@ void Builder::Emitter>::finish() { } // namespace LayoutDescriptor -} // namespace AG +} // namespace IAG diff --git a/Sources/ComputeCxx/Comparison/LayoutDescriptor.h b/Sources/ComputeCxx/Comparison/LayoutDescriptor.h index 73497779..86715b76 100644 --- a/Sources/ComputeCxx/Comparison/LayoutDescriptor.h +++ b/Sources/ComputeCxx/Comparison/LayoutDescriptor.h @@ -2,12 +2,12 @@ #include -#include "ComputeCxx/AGBase.h" -#include "ComputeCxx/AGComparison.h" +#include "ComputeCxx/IAGBase.h" +#include "ComputeCxx/IAGComparison.h" -AG_ASSUME_NONNULL_BEGIN +IAG_ASSUME_NONNULL_BEGIN -namespace AG { +namespace IAG { namespace swift { class metadata; @@ -35,15 +35,15 @@ extern unsigned char base_address; // MARK: Managing comparison modes -AGComparisonMode mode_for_type(const swift::metadata *_Nullable type, AGComparisonMode default_mode); +IAGComparisonMode mode_for_type(const swift::metadata *_Nullable type, IAGComparisonMode default_mode); void add_type_descriptor_override(const swift::context_descriptor *_Nullable type_descriptor, - AGComparisonMode override_mode); + IAGComparisonMode override_mode); // MARK: Obtaining layouts -ValueLayout fetch(const swift::metadata &type, AGComparisonOptions options, uint32_t priority); +ValueLayout fetch(const swift::metadata &type, IAGComparisonOptions options, uint32_t priority); -ValueLayout make_layout(const swift::metadata &type, AGComparisonMode default_mode, HeapMode heap_mode); +ValueLayout make_layout(const swift::metadata &type, IAGComparisonMode default_mode, HeapMode heap_mode); // MARK: Comparing values @@ -54,20 +54,20 @@ size_t length(ValueLayout layout); // MARK: Comparing values bool compare(ValueLayout layout, const unsigned char *lhs, const unsigned char *rhs, size_t size, - AGComparisonOptions options); + IAGComparisonOptions options); bool compare_bytes_top_level(const unsigned char *lhs, const unsigned char *rhs, size_t size, - AGComparisonOptions options); + IAGComparisonOptions options); bool compare_bytes(char unsigned const *lhs, char unsigned const *rhs, size_t size, size_t *_Nullable failure_location); -bool compare_heap_objects(char unsigned const *lhs, char unsigned const *rhs, AGComparisonOptions options, +bool compare_heap_objects(char unsigned const *lhs, char unsigned const *rhs, IAGComparisonOptions options, bool is_function); bool compare_indirect(ValueLayout _Nullable *_Nullable layout_ref, const swift::metadata &lhs_type, - const swift::metadata &rhs_type, AGComparisonOptions options, const unsigned char *lhs, + const swift::metadata &rhs_type, IAGComparisonOptions options, const unsigned char *lhs, const unsigned char *rhs); bool compare_existential_values(const swift::existential_type_metadata &type, const unsigned char *lhs, - const unsigned char *rhs, AGComparisonOptions options); + const unsigned char *rhs, IAGComparisonOptions options); bool compare_partial(ValueLayout layout, const unsigned char *lhs, const unsigned char *rhs, size_t offset, size_t size, - AGComparisonOptions options); + IAGComparisonOptions options); struct Partial { ValueLayout layout; size_t location; @@ -80,6 +80,6 @@ void print(std::string &output, ValueLayout layout); } // namespace LayoutDescriptor -} // namespace AG +} // namespace IAG -AG_ASSUME_NONNULL_END +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/Comparison/ValueLayout.h b/Sources/ComputeCxx/Comparison/ValueLayout.h index dfb2eb9d..8e1d0d7f 100644 --- a/Sources/ComputeCxx/Comparison/ValueLayout.h +++ b/Sources/ComputeCxx/Comparison/ValueLayout.h @@ -2,7 +2,7 @@ #include -namespace AG { +namespace IAG { namespace LayoutDescriptor { enum class ValueLayoutEntryKind : uint8_t { @@ -74,4 +74,4 @@ struct ValueLayoutReader { }; } // namespace LayoutDescriptor -} // namespace AG +} // namespace IAG diff --git a/Sources/ComputeCxx/Data/Constants.h b/Sources/ComputeCxx/Data/Constants.h index bf82ed94..091294f5 100644 --- a/Sources/ComputeCxx/Data/Constants.h +++ b/Sources/ComputeCxx/Data/Constants.h @@ -1,16 +1,16 @@ #pragma once -#include "ComputeCxx/AGBase.h" +#include "ComputeCxx/IAGBase.h" -AG_ASSUME_NONNULL_BEGIN +IAG_ASSUME_NONNULL_BEGIN -namespace AG { +namespace IAG { namespace data { constexpr uint32_t page_size = 0x200; constexpr uint32_t page_alignment_mask = page_size - 1; } // namespace data -} // namespace AG +} // namespace IAG -AG_ASSUME_NONNULL_END +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/Data/Page.h b/Sources/ComputeCxx/Data/Page.h index 84d1ef3c..0c82918a 100644 --- a/Sources/ComputeCxx/Data/Page.h +++ b/Sources/ComputeCxx/Data/Page.h @@ -1,12 +1,12 @@ #pragma once -#include "ComputeCxx/AGBase.h" +#include "ComputeCxx/IAGBase.h" #include "Pointer.h" -AG_ASSUME_NONNULL_BEGIN +IAG_ASSUME_NONNULL_BEGIN -namespace AG { +namespace IAG { namespace data { class zone; @@ -54,6 +54,6 @@ class page_ptr_list { }; } // namespace data -} // namespace AG +} // namespace IAG -AG_ASSUME_NONNULL_END +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/Data/Pointer.h b/Sources/ComputeCxx/Data/Pointer.h index 98097618..96ac5f79 100644 --- a/Sources/ComputeCxx/Data/Pointer.h +++ b/Sources/ComputeCxx/Data/Pointer.h @@ -3,14 +3,14 @@ #include #include -#include "ComputeCxx/AGBase.h" +#include "ComputeCxx/IAGBase.h" #include "Constants.h" #include "Table.h" -AG_ASSUME_NONNULL_BEGIN +IAG_ASSUME_NONNULL_BEGIN -namespace AG { +namespace IAG { namespace data { struct page; @@ -83,15 +83,15 @@ template class ptr { }; } // namespace data -} // namespace AG +} // namespace IAG namespace std { -template class hash> { +template class hash> { public: - std::uint64_t operator()(const AG::data::ptr &pointer) const { return pointer.offset(); } + std::uint64_t operator()(const IAG::data::ptr &pointer) const { return pointer.offset(); } }; } // namespace std -AG_ASSUME_NONNULL_END +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/Data/Table.cpp b/Sources/ComputeCxx/Data/Table.cpp index 063f9a55..ce1d178d 100644 --- a/Sources/ComputeCxx/Data/Table.cpp +++ b/Sources/ComputeCxx/Data/Table.cpp @@ -18,9 +18,9 @@ #include "Page.h" #include "Zone.h" -static void *AGGraphVMRegionBaseAddress; +static void *IAGGraphVMRegionBaseAddress; -namespace AG { +namespace IAG { namespace data { table _shared_table_bytes; @@ -52,7 +52,7 @@ table::table() { precondition_failure("memory allocation failure (%u bytes, %u)", initial_size, errno); } #else - _vm_region_fd = memfd_create("AGGraphVMRegion", MFD_CLOEXEC); + _vm_region_fd = memfd_create("IAGGraphVMRegion", MFD_CLOEXEC); if (_vm_region_fd < 0) { precondition_failure("memfd_create failure (%u)", errno); } @@ -70,7 +70,7 @@ table::table() { _vm_region_base_address = reinterpret_cast(region); _vm_region_size = initial_size; - AGGraphVMRegionBaseAddress = region; + IAGGraphVMRegionBaseAddress = region; _ptr_base = reinterpret_cast(region) - page_size; _ptr_max_offset = initial_size + page_size; @@ -132,7 +132,7 @@ void table::grow_region() { _remapped_regions.push_back({this->_vm_region_base_address, this->_vm_region_size}); _vm_region_base_address = reinterpret_cast(new_region); - AGGraphVMRegionBaseAddress = new_region; + IAGGraphVMRegionBaseAddress = new_region; _vm_region_size = static_cast(new_size); _ptr_base = reinterpret_cast(new_region) - page_size; @@ -283,7 +283,7 @@ void table::make_pages_reusable(uint32_t page_index, bool reusable) { madvise(mapped_pages_address, mapped_pages_size, advice); static bool unmap_reusable = []() -> bool { - char *result = getenv("AG_UNMAP_REUSABLE"); + char *result = getenv("IAG_UNMAP_REUSABLE"); if (result) { return atoi(result) != 0; } @@ -328,4 +328,4 @@ void table::print() { } } // namespace data -} // namespace AG +} // namespace IAG diff --git a/Sources/ComputeCxx/Data/Table.h b/Sources/ComputeCxx/Data/Table.h index 185980df..f06af29a 100644 --- a/Sources/ComputeCxx/Data/Table.h +++ b/Sources/ComputeCxx/Data/Table.h @@ -7,12 +7,12 @@ #include #include -#include "ComputeCxx/AGBase.h" +#include "ComputeCxx/IAGBase.h" #include "Vector/Vector.h" -AG_ASSUME_NONNULL_BEGIN +IAG_ASSUME_NONNULL_BEGIN -namespace AG { +namespace IAG { namespace data { class zone; @@ -88,6 +88,6 @@ class table { }; } // namespace data -} // namespace AG +} // namespace IAG -AG_ASSUME_NONNULL_END +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/Data/Vector.h b/Sources/ComputeCxx/Data/Vector.h index d5ad3759..28ba5b20 100644 --- a/Sources/ComputeCxx/Data/Vector.h +++ b/Sources/ComputeCxx/Data/Vector.h @@ -1,12 +1,12 @@ #pragma once -#include "ComputeCxx/AGBase.h" +#include "ComputeCxx/IAGBase.h" #include "Pointer.h" #include "Zone.h" -AG_ASSUME_NONNULL_BEGIN +IAG_ASSUME_NONNULL_BEGIN -namespace AG { +namespace IAG { namespace data { template class vector { @@ -202,6 +202,6 @@ template void vector::push_back(zone *zone, T &&value) { } } // namespace data -} // namespace AG +} // namespace IAG -AG_ASSUME_NONNULL_END +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/Data/Zone.cpp b/Sources/ComputeCxx/Data/Zone.cpp index 4578465e..0978275d 100644 --- a/Sources/ComputeCxx/Data/Zone.cpp +++ b/Sources/ComputeCxx/Data/Zone.cpp @@ -9,7 +9,7 @@ #include "Page.h" #include "Table.h" -namespace AG { +namespace IAG { namespace data { zone::zone() : _info(info(table::shared().make_zone_id())) {} @@ -229,4 +229,4 @@ void zone::print() { } } // namespace data -} // namespace AG +} // namespace IAG diff --git a/Sources/ComputeCxx/Data/Zone.h b/Sources/ComputeCxx/Data/Zone.h index d09bedd5..99572c65 100644 --- a/Sources/ComputeCxx/Data/Zone.h +++ b/Sources/ComputeCxx/Data/Zone.h @@ -1,14 +1,14 @@ #pragma once -#include "ComputeCxx/AGBase.h" +#include "ComputeCxx/IAGBase.h" #include "Page.h" #include "Pointer.h" #include "Table.h" -AG_ASSUME_NONNULL_BEGIN +IAG_ASSUME_NONNULL_BEGIN -namespace AG { +namespace IAG { namespace data { class zone { @@ -70,6 +70,6 @@ class zone { }; } // namespace data -} // namespace AG +} // namespace IAG -AG_ASSUME_NONNULL_END +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/Errors/Errors.cpp b/Sources/ComputeCxx/Errors/Errors.cpp index 557ad14b..33d691b7 100644 --- a/Sources/ComputeCxx/Errors/Errors.cpp +++ b/Sources/ComputeCxx/Errors/Errors.cpp @@ -5,7 +5,7 @@ char *error_message = nullptr; -namespace AG { +namespace IAG { platform_log_t error_log() { static platform_log_t log = platform_log_create("dev.incrematic.compute", "error"); @@ -46,4 +46,4 @@ void non_fatal_precondition_failure(const char *format, ...) { } } -} // namespace AG +} // namespace IAG diff --git a/Sources/ComputeCxx/Errors/Errors.h b/Sources/ComputeCxx/Errors/Errors.h index 3e3b04ac..9c9ba5bb 100644 --- a/Sources/ComputeCxx/Errors/Errors.h +++ b/Sources/ComputeCxx/Errors/Errors.h @@ -1,14 +1,14 @@ #pragma once -#include "ComputeCxx/AGBase.h" +#include "ComputeCxx/IAGBase.h" -AG_ASSUME_NONNULL_BEGIN +IAG_ASSUME_NONNULL_BEGIN -namespace AG { +namespace IAG { [[noreturn]] void precondition_failure(const char *format, ...); void non_fatal_precondition_failure(const char *format, ...); -} // namespace AG +} // namespace IAG -AG_ASSUME_NONNULL_END +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/Graph/AGDescription.mm b/Sources/ComputeCxx/Graph/AGDescription.mm deleted file mode 100644 index e00dde77..00000000 --- a/Sources/ComputeCxx/Graph/AGDescription.mm +++ /dev/null @@ -1,8 +0,0 @@ -#include "ComputeCxx/AGDescription.h" - -#if TARGET_OS_MAC -const AGDescriptionOption AGDescriptionFormat = CFSTR("format"); -const AGDescriptionOption AGDescriptionMaxFrames = CFSTR("max-frames"); -const AGDescriptionOption AGDescriptionIncludeValues = CFSTR("include-values"); -const AGDescriptionOption AGDescriptionTruncationLimit = CFSTR("truncation-limit"); -#endif diff --git a/Sources/ComputeCxx/Graph/AGGraph.cpp b/Sources/ComputeCxx/Graph/AGGraph.cpp deleted file mode 100644 index 9a48f2ec..00000000 --- a/Sources/ComputeCxx/Graph/AGGraph.cpp +++ /dev/null @@ -1,1089 +0,0 @@ -#include "AGGraph-Private.h" - -#if TARGET_OS_MAC -#include "CoreFoundationPrivate/CFRuntime.h" -#include -#else -#include -#include -#endif - -#include -#include - -#include "Attribute/AttributeData/Node/IndirectNode.h" -#include "Attribute/AttributeID/OffsetAttributeID.h" -#include "Context.h" -#include "Graph.h" -#include "Trace/ExternalTrace.h" -#include "UpdateStack.h" - -namespace { - -CFRuntimeClass &graph_type_id() { - static auto finalize = [](CFTypeRef graph_ref) { - AGGraphStorage *storage = (AGGraphRef)graph_ref; - if (!storage->context.invalidated()) { - storage->context.AG::Graph::Context::~Context(); - } - }; - static CFRuntimeClass klass = { - 0, // version - "AGGraphStorage", // className - NULL, // init - NULL, // copy - finalize, - NULL, // equal - NULL, // hash - NULL, // copyFormattingDesc - NULL, // copyDebugDesc, - NULL, // reclaim - NULL, // refcount - 0 // requiredAlignment - }; - return klass; -} - -} // namespace - -CFTypeID AGGraphGetTypeID() { - static CFTypeID type = _CFRuntimeRegisterClass(&graph_type_id()); - return type; -} - -AGGraphRef AGGraphCreate() { return AGGraphCreateShared(nullptr); }; - -AGGraphRef AGGraphCreateShared(AGGraphRef original) { - CFIndex extra_bytes = sizeof(struct AGGraphStorage) - sizeof(CFRuntimeBase); - AGGraphRef instance = - (AGGraphRef)_CFRuntimeCreateInstance(kCFAllocatorDefault, AGGraphGetTypeID(), extra_bytes, NULL); - if (!instance) { - AG::precondition_failure("memory allocation failure."); - } - - AG::Graph *graph; - if (original) { - if (original->context.invalidated()) { - AG::precondition_failure("invalidated graph"); - } - graph = &original->context.graph(); - AG::Graph::retain(graph); - } else { - graph = new AG::Graph(); - } - - new (&instance->context) AG::Graph::Context(graph); // performs a retain - AG::Graph::release(graph); - - instance->context.set_invalidated(false); - - return instance; -}; - -AGUnownedGraphContextRef AGGraphGetGraphContext(AGGraphRef graph) { - AG::Graph::Context *graph_context = AG::Graph::Context::from_cf(graph); - AG::Graph *unowned_graph = &graph_context->graph(); - return reinterpret_cast(unowned_graph); -} - -AGGraphRef AGGraphContextGetGraph(void *storage) { - auto graph_context = reinterpret_cast(storage); - return graph_context->to_cf(); -} - -void AGGraphInvalidate(AGGraphRef graph) { - if (graph->context.invalidated()) { - return; - } - graph->context.~Context(); - graph->context.set_invalidated(true); -} - -#pragma mark - User context - -const void *AGGraphGetContext(AGGraphRef graph) { - auto graph_context = AG::Graph::Context::from_cf(graph); - return graph_context->context(); -} - -void AGGraphSetContext(AGGraphRef graph, const void *context) { - auto graph_context = AG::Graph::Context::from_cf(graph); - graph_context->set_context(context); -} - -#pragma mark - Counter - -uint64_t AGGraphGetCounter(AGGraphRef graph, AGGraphCounterQueryType query) { - auto graph_context = AG::Graph::Context::from_cf(graph); - switch (query) { - case AGGraphCounterQueryTypeNodes: - return graph_context->graph().num_nodes(); - case AGGraphCounterQueryTypeTransactions: - return graph_context->graph().transaction_count(); - case AGGraphCounterQueryTypeUpdates: - return graph_context->graph().update_count(); - case AGGraphCounterQueryTypeChanges: - return graph_context->graph().change_count(); - case AGGraphCounterQueryTypeContextID: - return graph_context->id(); - case AGGraphCounterQueryTypeGraphID: - return graph_context->graph().id(); - case AGGraphCounterQueryTypeContextThreadUpdating: - return graph_context->thread_is_updating(); - case AGGraphCounterQueryTypeThreadUpdating: - return graph_context->graph().thread_is_updating(); - case AGGraphCounterQueryTypeContextNeedsUpdate: - return graph_context->needs_update(); - case AGGraphCounterQueryTypeNeedsUpdate: - return graph_context->graph().needs_update(); - case AGGraphCounterQueryTypeMainThreadUpdates: - return graph_context->graph().main_thread_update_count(); - case AGGraphCounterQueryTypeCreatedNodes: - return graph_context->graph().num_nodes_total(); - case AGGraphCounterQueryTypeSubgraphs: - return graph_context->graph().num_subgraphs(); - case AGGraphCounterQueryTypeCreatedSubgraphs: - return graph_context->graph().num_subgraphs_total(); - default: - return 0; - } -} - -#pragma mark - Main handler - -void AGGraphWithMainThreadHandler(AGGraphRef graph, - void (*body)(const void *context AG_SWIFT_CONTEXT) AG_SWIFT_CC(swift), - const void *body_context, - void (*main_thread_handler)(void (*trampoline_thunk)(const void *), - const void *trampoline, - const void *context AG_SWIFT_CONTEXT) AG_SWIFT_CC(swift), - const void *main_thread_handler_context) { - auto graph_context = AG::Graph::Context::from_cf(graph); - graph_context->graph().with_main_handler(AG::ClosureFunctionVV(body, body_context), main_thread_handler, - main_thread_handler_context); -} - -#pragma mark - Subgraph - -bool AGGraphBeginDeferringSubgraphInvalidation(AGGraphRef graph) { - auto graph_context = AG::Graph::Context::from_cf(graph); - return graph_context->graph().begin_deferring_subgraph_invalidation(); -} - -void AGGraphEndDeferringSubgraphInvalidation(AGGraphRef graph, bool was_deferring) { - auto graph_context = AG::Graph::Context::from_cf(graph); - graph_context->graph().end_deferring_subgraph_invalidation(was_deferring); -} - -#pragma mark - Attribute types - -uint32_t AGGraphInternAttributeType(AGUnownedGraphContextRef unowned_graph, AGTypeID type, - const AGAttributeType *(*make_attribute_type)(const void *context AG_SWIFT_CONTEXT) - AG_SWIFT_CC(swift), - const void *make_attribute_type_context) { - auto metadata = reinterpret_cast(type); - AG::Graph *graph = reinterpret_cast(unowned_graph); - return graph->intern_type( - metadata, AG::ClosureFunctionVP(make_attribute_type, make_attribute_type_context)); -} - -void AGGraphVerifyType(AGAttribute attribute, AGTypeID type) { - auto attribute_id = AG::AttributeID(attribute); - attribute_id.validate_data_offset(); - - auto subgraph = attribute_id.subgraph(); - if (!subgraph) { - AG::precondition_failure("no graph: %u", attribute); - } - - if (auto node = attribute_id.get_node()) { - auto metadata = reinterpret_cast(type); - auto attribute_type = subgraph->graph()->attribute_type(node->type_id()); - if (&attribute_type.value_metadata() != metadata) { - AG::precondition_failure("type check failed: %u, expected %s, got %s", attribute, metadata->name(false), - attribute_type.value_metadata().name(false)); - } - } -} - -#pragma mark - Attributes - -AGAttribute AGGraphCreateAttribute(uint32_t type_id, const void *body, const void *_Nullable value) { - auto subgraph = AG::Subgraph::current_subgraph(); - if (!subgraph) { - AG::precondition_failure("no subgraph active while adding attribute"); - } - auto node = subgraph->graph()->add_attribute(*subgraph, type_id, body, value); - return AGAttribute(AG::AttributeID(node)); -} - -AGGraphRef AGGraphGetAttributeGraph(AGAttribute attribute) { - auto attribute_id = AG::AttributeID(attribute); - attribute_id.validate_data_offset(); - - if (auto subgraph = attribute_id.subgraph()) { - if (auto context_id = subgraph->context_id()) { - if (auto context = subgraph->graph()->context_with_id(context_id)) { - return context->to_cf(); - } - } - } - AG::precondition_failure("no graph: %u", attribute); -} - -AGAttributeInfo AGGraphGetAttributeInfo(AGAttribute attribute) { - auto attribute_id = AG::AttributeID(attribute); - auto node = attribute_id.get_node(); - if (!node) { - AG::precondition_failure("non-direct attribute id: %u", attribute); - } - - node.assert_valid(); - - auto subgraph = attribute_id.subgraph(); - if (!subgraph) { - AG::precondition_failure("no graph: %u", attribute); - } - - const void *body = nullptr; - const AG::AttributeType &type = subgraph->graph()->attribute_ref(node, &body); - return AGAttributeInfo(reinterpret_cast(&type), body); -} - -AGAttributeFlags AGGraphGetFlags(AGAttribute attribute) { - auto attribute_id = AG::AttributeID(attribute); - auto node = attribute_id.get_node(); - if (!node) { - AG::precondition_failure("non-direct attribute id: %u", attribute); - } - - return node->subgraph_flags(); -} - -void AGGraphSetFlags(AGAttribute attribute, AGAttributeFlags flags) { - auto attribute_id = AG::AttributeID(attribute); - auto node = attribute_id.get_node(); - if (!node) { - AG::precondition_failure("non-direct attribute id: %u", attribute); - } - - attribute_id.subgraph()->set_flags(node, flags); -} - -uint32_t AGGraphAddInput(AGAttribute attribute, AGAttribute input, AGInputOptions options) { - auto attribute_id = AG::AttributeID(attribute); - auto node = attribute_id.get_node(); - if (!node) { - AG::precondition_failure("non-direct attribute id: %u", attribute); - } - node.assert_valid(); - - auto subgraph = attribute_id.subgraph(); - if (!subgraph) { - AG::precondition_failure("no graph: %u", attribute); - } - - auto input_attribute_id = AG::AttributeID(input); - input_attribute_id.validate_data_offset(); - - if (input_attribute_id.subgraph() != nullptr && input_attribute_id.subgraph()->graph() != subgraph->graph()) { - AG::precondition_failure("accessing attribute in a different namespace: %u", input); - } - - return subgraph->graph()->add_input(node, input_attribute_id, false, options); -} - -#pragma mark - Offset attributes - -namespace { - -AG::AttributeID create_offset_attribute(AG::AttributeID attribute_id, uint32_t offset, std::optional size) { - if (offset == 0) { - if (size.has_value() && attribute_id.is_indirect_node()) { - auto calculated_size = attribute_id.size(); - if (calculated_size.has_value() && calculated_size.value() == size.value()) { - return attribute_id; - } - } - } else if (offset > AG::IndirectNode::MaximumOffset) { - AG::precondition_failure("invalid offset: %u, %lu", offset, size.value()); - } - - auto current_subgraph = AG::Subgraph::current_subgraph(); - if (!current_subgraph) { - AG::precondition_failure("no subgraph active while adding attribute"); - } - - AG::data::ptr indirect_node = - current_subgraph->graph()->add_indirect_attribute(*current_subgraph, attribute_id, offset, size, false); - return AG::AttributeID(indirect_node); -} - -} // namespace - -AGAttribute AGGraphCreateOffsetAttribute(AGAttribute attribute, uint32_t offset) { - auto attribute_id = AG::AttributeID(attribute); - return create_offset_attribute(attribute_id, offset, std::optional()); -} - -AGAttribute AGGraphCreateOffsetAttribute2(AGAttribute attribute, uint32_t offset, size_t size) { - auto attribute_id = AG::AttributeID(attribute); - return create_offset_attribute(attribute_id, offset, std::optional(size)); -} - -#pragma mark - Indirect attributes - -namespace { - -AG::AttributeID create_indirect_attribute(AG::AttributeID attribute_id, std::optional size) { - auto current_subgraph = AG::Subgraph::current_subgraph(); - if (!current_subgraph) { - AG::precondition_failure("no subgraph active while making indirection"); - } - - AG::data::ptr indirect_node = - current_subgraph->graph()->add_indirect_attribute(*current_subgraph, attribute_id, 0, size, true); - return AG::AttributeID(indirect_node); -} - -} // namespace - -AGAttribute AGGraphCreateIndirectAttribute(AGAttribute attribute) { - auto attribute_id = AG::AttributeID(attribute); - return create_indirect_attribute(attribute_id, std::optional()); -} - -AGAttribute AGGraphCreateIndirectAttribute2(AGAttribute attribute, size_t size) { - auto attribute_id = AG::AttributeID(attribute); - return create_indirect_attribute(attribute_id, std::optional(size)); -} - -AGAttribute AGGraphGetIndirectAttribute(AGAttribute attribute) { - auto attribute_id = AG::AttributeID(attribute); - if (auto indirect_node = attribute_id.get_indirect_node()) { - return indirect_node->source().identifier(); - } - return attribute_id; -} - -void AGGraphSetIndirectAttribute(AGAttribute attribute, AGAttribute source) { - auto attribute_id = AG::AttributeID(attribute); - auto indirect_node = attribute_id.get_indirect_node(); - if (!indirect_node || !attribute_id.subgraph()) { - AG::precondition_failure("invalid indirect attribute: %u", attribute); - } - - auto source_id = AG::AttributeID(source); - if (source_id.is_nil()) { - attribute_id.subgraph()->graph()->indirect_attribute_reset(indirect_node, false); - } else { - attribute_id.subgraph()->graph()->indirect_attribute_set(indirect_node, source_id); - } -} - -void AGGraphResetIndirectAttribute(AGAttribute attribute, bool non_nil) { - auto attribute_id = AG::AttributeID(attribute); - auto indirect_node = attribute_id.get_indirect_node(); - if (!indirect_node || !attribute_id.subgraph()) { - AG::precondition_failure("invalid indirect attribute: %u", attribute); - } - - attribute_id.subgraph()->graph()->indirect_attribute_reset(indirect_node, non_nil); -} - -AGAttribute AGGraphGetIndirectDependency(AGAttribute attribute) { - auto attribute_id = AG::AttributeID(attribute); - auto indirect_node = attribute_id.get_indirect_node(); - if (!indirect_node || !attribute_id.subgraph()) { - AG::precondition_failure("invalid indirect attribute: %u", attribute); - } - - return attribute_id.subgraph()->graph()->indirect_attribute_dependency(indirect_node); -} - -void AGGraphSetIndirectDependency(AGAttribute attribute, AGAttribute dependency) { - auto attribute_id = AG::AttributeID(attribute); - auto indirect_node = attribute_id.get_indirect_node(); - if (!indirect_node || !attribute_id.subgraph()) { - AG::precondition_failure("invalid indirect attribute: %u", attribute); - } - - return attribute_id.subgraph()->graph()->indirect_attribute_set_dependency(indirect_node, - AG::AttributeID(dependency)); -} - -#pragma mark - Search - -bool AGGraphSearch(AGAttribute attribute, AGSearchOptions options, - bool (*predicate)(AGAttribute attribute, const void *context AG_SWIFT_CONTEXT) AG_SWIFT_CC(swift), - const void *predicate_context) { - auto attribute_id = AG::AttributeID(attribute); - attribute_id.validate_data_offset(); - - auto subgraph = attribute_id.subgraph(); - if (!subgraph) { - AG::precondition_failure("no graph: %u", attribute); - } - - return subgraph->graph()->breadth_first_search( - attribute_id, options, AG::ClosureFunctionAB(predicate, predicate_context)); -} - -#pragma mark - Body - -void AGGraphMutateAttribute(AGAttribute attribute, AGTypeID type, bool invalidating, - void (*modify)(void *body, const void *context AG_SWIFT_CONTEXT) AG_SWIFT_CC(swift), - const void *modify_context) { - auto attribute_id = AG::AttributeID(attribute); - auto node = attribute_id.get_node(); - if (!node) { - AG::precondition_failure("non-direct attribute id: %u", attribute); - } - attribute_id.validate_data_offset(); - - auto subgraph = attribute_id.subgraph(); - if (!subgraph) { - AG::precondition_failure("no graph: %u", attribute); - } - - subgraph->graph()->attribute_modify(node, *reinterpret_cast(type), - AG::ClosureFunctionPV(modify, modify_context), invalidating); -} - -#pragma mark - Value - -namespace { - -inline AGChangedValue get_value(AG::AttributeID attribute_id, uint32_t seed, AGValueOptions options, - const AG::swift::metadata &metadata) { - if (!(options & AGValueOptionsIncrementGraphVersion)) { - auto update_ptr = AG::Graph::current_update(); - if (update_ptr.tag() == 0 && update_ptr.get() != nullptr) { - auto &update = *update_ptr.get(); - - auto graph = update.graph(); - auto &frame = update.frames().back(); - - AGChangedValueFlags flags = 0; - void *value = graph->input_value_ref(frame.attribute, attribute_id, seed, - options & AGValueOptionsInputOptionsMask, metadata, &flags); - return {value, flags}; - } - } - - attribute_id.validate_data_offset(); - - auto subgraph = attribute_id.subgraph(); - if (!subgraph) { - AG::precondition_failure("no graph: %u", attribute_id); - } - - AGChangedValueFlags flags = 0; - void *value = subgraph->graph()->value_ref(attribute_id, seed, metadata, &flags); - return {value, flags}; -} - -} // namespace - -AGChangedValue AGGraphGetValue(AGAttribute attribute, AGValueOptions options, AGTypeID type) { - auto attribute_id = AG::AttributeID(attribute); - auto metadata = reinterpret_cast(type); - return get_value(attribute_id, 0, options, *metadata); -} - -AGWeakChangedValue AGGraphGetWeakValue(AGWeakAttribute attribute, AGValueOptions options, AGTypeID type) { - auto weak_attribute_id = AG::WeakAttributeID(attribute); - auto attribute_id = weak_attribute_id.evaluate(); - if (attribute_id.is_nil()) { - return {nullptr, false}; - } - - auto metadata = reinterpret_cast(type); - auto value = get_value(attribute_id, weak_attribute_id.seed(), options, *metadata); - return *reinterpret_cast(&value); -} - -AGChangedValue AGGraphGetInputValue(AGAttribute attribute, AGAttribute input, AGValueOptions options, AGTypeID type) { - auto attribute_id = AG::AttributeID(attribute); - if (options & AGValueOptionsIncrementGraphVersion || attribute_id.is_nil()) { - return AGGraphGetValue(input, options, type); - } - - auto node = attribute_id.get_node(); - if (!node) { - AG::precondition_failure("non-direct attribute id: %u", attribute); - } - attribute_id.validate_data_offset(); - - auto subgraph = attribute_id.subgraph(); - if (!subgraph) { - AG::precondition_failure("no graph: %u", attribute); - } - - auto input_id = AG::AttributeID(input); - auto metadata = reinterpret_cast(type); - - AGChangedValueFlags flags = 0; - void *value = subgraph->graph()->input_value_ref(attribute, input_id, 0, options & AGValueOptionsInputOptionsMask, - *metadata, &flags); - return {value, flags}; -} - -bool AGGraphSetValue(AGAttribute attribute, const void *value, AGTypeID type) { - auto attribute_id = AG::AttributeID(attribute); - auto node = attribute_id.get_node(); - if (!node) { - AG::precondition_failure("non-direct attribute id: %u", attribute); - } - attribute_id.validate_data_offset(); - - auto subgraph = attribute_id.subgraph(); - if (!subgraph) { - AG::precondition_failure("no graph: %u", attribute); - } - - auto metadata = reinterpret_cast(type); - return subgraph->graph()->value_set(attribute_id.get_node(), *metadata, value); -} - -bool AGGraphHasValue(AGAttribute attribute) { - auto attribute_id = AG::AttributeID(attribute); - auto node = attribute_id.get_node(); - if (!node) { - AG::precondition_failure("non-direct attribute id: %u", attribute); - } - attribute_id.validate_data_offset(); - - auto subgraph = attribute_id.subgraph(); - if (!subgraph) { - AG::precondition_failure("no graph: %u", attribute); - } - - return subgraph->graph()->value_exists(attribute_id.get_node()); -} - -AGValueState AGGraphGetValueState(AGAttribute attribute) { - auto attribute_id = AG::AttributeID(attribute); - attribute_id.validate_data_offset(); - - auto subgraph = attribute_id.subgraph(); - if (!subgraph) { - AG::precondition_failure("no graph: %u", attribute); - } - - return subgraph->graph()->value_state(attribute_id); -} - -void AGGraphUpdateValue(AGAttribute attribute, AGGraphUpdateOptions options) { - auto attribute_id = AG::AttributeID(attribute); - auto node = attribute_id.get_node(); - if (!node) { - AG::precondition_failure("non-direct attribute id: %u", attribute); - } - - node.assert_valid(); - - auto subgraph = attribute_id.subgraph(); - if (!subgraph) { - AG::precondition_failure("no graph: %u", attribute); - } - - subgraph->graph()->update_attribute(node, options); -} - -uint32_t AGGraphPrefetchValue(AGAttribute attribute) { - auto attribute_id = AG::AttributeID(attribute); - attribute_id.validate_data_offset(); - - auto subgraph = attribute_id.subgraph(); - if (!subgraph) { - AG::precondition_failure("no graph: %u", attribute); - } - - if (subgraph->graph()->passed_deadline()) { - return AGGraphUpdateStatusChanged; - } - - auto resolved = attribute_id.resolve(AG::TraversalOptions::AssertNotNil); - return (uint32_t)subgraph->graph()->update_attribute( - resolved.attribute().get_node(), - AGGraphUpdateOptions(AGGraphUpdateOptionsAbortIfCancelled | AGGraphUpdateOptionsCancelIfPassedDeadline)); -} - -void AGGraphInvalidateValue(AGAttribute attribute) { - auto attribute_id = AG::AttributeID(attribute); - auto node = attribute_id.get_node(); - if (!node) { - AG::precondition_failure("non-direct attribute id: %u", attribute); - } - attribute_id.validate_data_offset(); - - auto subgraph = attribute_id.subgraph(); - if (!subgraph) { - AG::precondition_failure("no graph: %u", attribute); - } - - subgraph->graph()->value_mark(node); -} - -void AGGraphInvalidateAllValues(AGGraphRef graph) { - auto graph_context = AG::Graph::Context::from_cf(graph); - graph_context->graph().value_mark_all(); -} - -void AGGraphSetInvalidationCallback(AGGraphRef graph, - void (*callback)(AGAttribute, const void *context AG_SWIFT_CONTEXT) - AG_SWIFT_CC(swift), - const void *callback_context) { - auto graph_context = AG::Graph::Context::from_cf(graph); - graph_context->set_invalidation_callback(AG::ClosureFunctionAV(callback, callback_context)); -} - -#pragma mark - Cached value - -namespace { - -void *read_cached_attribute(size_t hash, const AG::swift::metadata &metadata, const void *body, - const AG::swift::metadata &value_metadata, AGCachedValueOptions options, - AG::AttributeID owner_id, AGChangedValueFlags *flags_out, - AG::ClosureFunctionCI get_attribute_type_id) { - auto update = AG::Graph::current_update(); - auto update_stack = update.tag() == 0 ? update.get() : nullptr; - - AG::Subgraph *subgraph = nullptr; - if (owner_id && !owner_id.is_nil()) { - owner_id.validate_data_offset(); - subgraph = owner_id.subgraph(); - } else { - if (update_stack != nullptr) { - subgraph = AG::AttributeID(update_stack->frames().back().attribute).subgraph(); - } else { - subgraph = AG::Subgraph::current_subgraph(); - } - } - if (subgraph == nullptr) { - AG::precondition_failure("no subgraph"); - } - - AG::data::ptr cached_node = subgraph->cache_fetch(hash, metadata, body, get_attribute_type_id); - if (cached_node == nullptr) { - return nullptr; - } - - if (update_stack == nullptr) { - void *value = subgraph->graph()->value_ref(AG::AttributeID(cached_node), 0, value_metadata, flags_out); - subgraph->cache_insert(cached_node); // TODO: when this becomes an input, is it removed from cache? - return value; - } - - AGInputOptions input_options = options & AGCachedValueOptionsUnprefetched ? AGInputOptionsUnprefetched : AGInputOptionsNone; - return subgraph->graph()->input_value_ref(update_stack->frames().back().attribute, AG::AttributeID(cached_node), 0, - input_options, value_metadata, flags_out); -} - -} // namespace - -void *AGGraphReadCachedAttribute(size_t hash, AGTypeID type, const void *body, AGTypeID value_type, - AGCachedValueOptions options, AGAttribute owner, bool *_Nullable changed_out, - uint32_t (*closure)(AGUnownedGraphContextRef graph_context, - const void *context AG_SWIFT_CONTEXT) AG_SWIFT_CC(swift), - const void *closure_context) { - auto metadata = reinterpret_cast(type); - auto value_metadata = reinterpret_cast(value_type); - auto owner_id = AG::AttributeID(owner); - - AGChangedValueFlags flags = 0; - void *value = - read_cached_attribute(hash, *metadata, body, *value_metadata, options, owner_id, &flags, - AG::ClosureFunctionCI(closure, closure_context)); - if (changed_out) { - *changed_out = flags & AGChangedValueFlagsChanged ? true : false; - } - return value; -} - -void *AGGraphReadCachedAttributeIfExists(size_t hash, AGTypeID type, const void *body, AGTypeID value_type, - AGCachedValueOptions options, AGAttribute owner, bool *_Nullable changed_out) { - - auto metadata = reinterpret_cast(type); - auto value_metadata = reinterpret_cast(value_type); - auto owner_id = AG::AttributeID(owner); - - AGChangedValueFlags flags = 0; - void *value = read_cached_attribute(hash, *metadata, body, *value_metadata, options, owner_id, &flags, nullptr); - if (changed_out) { - *changed_out = flags & AGChangedValueFlagsChanged ? true : false; - } - return value; -} - -#pragma mark - Update - -void AGGraphSetUpdate(const void *update) { - AG::Graph::set_current_update(util::tagged_ptr((AG::Graph::UpdateStack *)update)); -} - -const void *AGGraphClearUpdate() { - auto update = AG::Graph::current_update(); - if (update != nullptr && update.tag() == 0) { - AG::Graph::set_current_update(update.with_tag(true)); - } - return (const void *)update.value(); -} - -void AGGraphCancelUpdate() { - auto update = AG::Graph::current_update().get(); - if (update == nullptr) { - AG::precondition_failure("no attribute updating"); - } - - AG::Graph::UpdateStack::cancel(); -} - -bool AGGraphCancelUpdateIfNeeded() { - auto update = AG::Graph::current_update().get(); - if (update == nullptr) { - AG::precondition_failure("no attribute updating"); - } - - if (update->cancelled()) { - return true; - } - - if (update->graph()->passed_deadline()) { - update->cancel(); - return true; - } - - return false; -} - -bool AGGraphUpdateWasCancelled() { - auto update = AG::Graph::current_update(); - if (update.tag() != 0 || update.get() == nullptr) { - AG::precondition_failure("no attribute updating"); - } - - return update.get()->cancelled(); -} - -uint64_t AGGraphGetDeadline(AGGraphRef graph) { - auto graph_context = AG::Graph::Context::from_cf(graph); - return graph_context->deadline(); -} - -void AGGraphSetDeadline(AGGraphRef graph, uint64_t deadline) { - auto graph_context = AG::Graph::Context::from_cf(graph); - graph_context->set_deadline(deadline); -} - -bool AGGraphHasDeadlinePassed() { - auto update = AG::Graph::current_update().get(); - if (update != nullptr) { - return update->graph()->passed_deadline(); - } - return false; -} - -void AGGraphSetNeedsUpdate(AGGraphRef graph) { - auto graph_context = AG::Graph::Context::from_cf(graph); - graph_context->set_needs_update(); -} - -void AGGraphWithUpdate(AGAttribute attribute, void (*body)(const void *context AG_SWIFT_CONTEXT) AG_SWIFT_CC(swift), - const void *body_context) { - auto attribute_id = AG::AttributeID(attribute); - if (!attribute_id || attribute_id.is_nil()) { - // TODO: check - AGGraphWithoutUpdate(body, body_context); - return; - } - - auto node = attribute_id.get_node(); - if (!node) { - AG::precondition_failure("non-direct attribute id: %u", attribute); - } - attribute_id.validate_data_offset(); - - auto subgraph = attribute_id.subgraph(); - if (!subgraph) { - AG::precondition_failure("no graph: %u", attribute); - } - - subgraph->graph()->with_update(node, AG::ClosureFunctionVV(body, body_context)); -} - -void AGGraphWithoutUpdate(void (*body)(const void *context AG_SWIFT_CONTEXT) AG_SWIFT_CC(swift), - const void *body_context) { - AG::Graph::without_update(AG::ClosureFunctionVV(body, body_context)); -} - -void AGGraphSetUpdateCallback(AGGraphRef graph, - void (*callback)(const void *context AG_SWIFT_CONTEXT) AG_SWIFT_CC(swift), - const void *callback_context) { - auto graph_context = AG::Graph::Context::from_cf(graph); - graph_context->set_update_callback(AG::ClosureFunctionVV(callback, callback_context)); -} - -AGAttribute AGGraphGetCurrentAttribute() { - auto update_ptr = AG::Graph::current_update(); - if (update_ptr.tag() != 0 || update_ptr.get() == nullptr) { - return AGAttributeNil; - } - - auto &update = *update_ptr.get(); - if (update.frames().empty()) { - return AGAttributeNil; - } - auto &frame = update.frames().back(); - if (!frame.attribute) { - return AGAttributeNil; - } - - return AGAttribute(AG::AttributeID(frame.attribute)); -} - -bool AGGraphCurrentAttributeWasModified() { - auto update_ptr = AG::Graph::current_update(); - if (update_ptr.tag() != 0 || update_ptr.get() == nullptr) { - return false; - } - - auto &update = *update_ptr.get(); - auto &frame = update.frames().back(); - if (!frame.attribute) { - return false; - } - - return frame.attribute->is_self_modified(); -} - -bool AGGraphAnyInputsChanged(const AGAttribute *exclude_attributes, size_t exclude_attributes_count) { - auto update = AG::Graph::current_update(); - if (update.tag() != 0 || update.get() == nullptr) { - AG::precondition_failure("no attribute updating"); - } - - auto &frame = update.get()->frames().back(); - return update.get()->graph()->any_inputs_changed( - frame.attribute, reinterpret_cast(exclude_attributes), exclude_attributes_count); -} - -void *AGGraphGetOutputValue(AGTypeID type) { - auto update_ptr = AG::Graph::current_update(); - if (update_ptr.tag() != 0 || update_ptr.get() == nullptr) { - AG::precondition_failure("no attribute updating"); - } - - auto &update = *update_ptr.get(); - auto &frame = update.frames().back(); - auto graph = update.graph(); - auto metadata = reinterpret_cast(type); - return graph->output_value_ref(frame.attribute, *metadata); -} - -void AGGraphSetOutputValue(const void *value, AGTypeID type) { - auto update_ptr = AG::Graph::current_update(); - if (update_ptr.tag() != 0 || update_ptr.get() == nullptr) { - AG::precondition_failure("no attribute updating"); - } - - auto &update = *update_ptr.get(); - auto &frame = update.frames().back(); - if (!frame.attribute->is_updating()) { - AG::precondition_failure("writing attribute that is not evaluating: %", frame.attribute); - } - - auto graph = update.graph(); - auto metadata = reinterpret_cast(type); - graph->value_set_internal(frame.attribute, *frame.attribute.get(), value, *metadata); -} - -#pragma mark - Trace - -void AGGraphStartTracing(AGGraphRef graph, AGGraphTraceOptions trace_options) { AGGraphStartTracing2(graph, trace_options, NULL); } - -void AGGraphStartTracing2(AGGraphRef graph, AGGraphTraceOptions trace_options, CFArrayRef subsystems) { - auto subsystems_vector = AG::vector, 0, uint64_t>(); - if (subsystems) { - auto subsystems_count = CFArrayGetCount(subsystems); - for (CFIndex index = 0; index < subsystems_count; ++index) { - CFTypeRef value = CFArrayGetValueAtIndex(subsystems, index); - if (CFGetTypeID(value) != CFStringGetTypeID()) { - continue; - } - - CFIndex length = CFStringGetLength((CFStringRef)value); - CFIndex bufferSize = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8) + 1; - char *subsystem = (char *)malloc(bufferSize); - if (CFStringGetCString((CFStringRef)value, subsystem, bufferSize, kCFStringEncodingUTF8)) { - subsystems_vector.push_back(std::unique_ptr(subsystem)); - } else { - free(subsystem); - } - } - } - - std::span subsystems_span = - std::span((const char **)subsystems_vector.data(), subsystems_vector.size()); - - if (graph == nullptr) { - AG::Graph::all_start_tracing(trace_options, subsystems_span); - return; - } - - auto graph_context = AG::Graph::Context::from_cf(graph); - graph_context->graph().start_tracing(trace_options, subsystems_span); -} - -void AGGraphStopTracing(AGGraphRef graph) { - if (graph == nullptr) { - AG::Graph::all_stop_tracing(); - return; - } - - auto graph_context = AG::Graph::Context::from_cf(graph); - graph_context->graph().stop_tracing(); -} - -void AGGraphSyncTracing(AGGraphRef graph) { - if (graph == nullptr) { - AG::Graph::all_sync_tracing(); - return; - } - - auto graph_context = AG::Graph::Context::from_cf(graph); - graph_context->graph().sync_tracing(); -} - -CFStringRef AGGraphCopyTracePath(AGGraphRef graph) { - if (graph == nullptr) { - return AG::Graph::all_copy_trace_path(); - } - - auto graph_context = AG::Graph::Context::from_cf(graph); - return graph_context->graph().copy_trace_path(); -} - -uint64_t AGGraphAddTrace(AGGraphRef graph, const AGTraceTypeRef trace, void *context) { - auto graph_context = AG::Graph::Context::from_cf(graph); - auto external_trace = new ExternalTrace(trace, context); - graph_context->graph().add_trace(external_trace); - return external_trace->id(); -} - -void AGGraphRemoveTrace(AGGraphRef graph, uint64_t trace_id) { - auto graph_context = AG::Graph::Context::from_cf(graph); - graph_context->graph().remove_trace(trace_id); -} - -void AGGraphSetTrace(AGGraphRef graph, const AGTraceTypeRef trace, void *context) { - auto graph_context = AG::Graph::Context::from_cf(graph); - graph_context->graph().remove_trace(0); - - auto external_trace = new ExternalTrace(0, trace, context); - graph_context->graph().add_trace(external_trace); -} - -void AGGraphResetTrace(AGGraphRef graph) { - auto graph_context = AG::Graph::Context::from_cf(graph); - graph_context->graph().remove_trace(0); -} - -bool AGGraphIsTracingActive(AGGraphRef graph) { - auto graph_context = AG::Graph::Context::from_cf(graph); - return graph_context->graph().traces().size() > 0; -} - -void AGGraphPrepareTrace(AGGraphRef graph, const AGTraceTypeRef trace, void *context) { - auto graph_context = AG::Graph::Context::from_cf(graph); - auto external_trace = new ExternalTrace(trace, context); - graph_context->graph().prepare_trace(*external_trace); -} - -bool AGGraphTraceEventEnabled(AGGraphRef graph, uint32_t event_id) { - auto graph_context = AG::Graph::Context::from_cf(graph); - for (auto trace : graph_context->graph().traces()) { - if (trace->named_event_enabled(event_id)) { - return true; - } - } - return false; -} - -void AGGraphAddTraceEvent(AGGraphRef graph, const char *event_name, const void *value, AGTypeID type) { - auto graph_context = AG::Graph::Context::from_cf(graph); - graph_context->graph().foreach_trace([&graph_context, &event_name, &value, &type](AG::Trace &trace) { - trace.custom_event(*graph_context, event_name, value, *reinterpret_cast(type)); - }); -} - -void AGGraphAddNamedTraceEvent(AGGraphRef graph, uint32_t event_id, uint32_t event_arg_count, const void *event_args, - CFDataRef data, uint32_t arg6) { - auto graph_context = AG::Graph::Context::from_cf(graph); - graph_context->graph().foreach_trace( - [&graph_context, &event_id, &event_arg_count, &event_args, &data, &arg6](AG::Trace &trace) { - trace.named_event(*graph_context, event_id, event_arg_count, event_args, data, arg6); - }); -} - -namespace NamedEvents { - -static platform_lock lock = PLATFORM_LOCK_INIT; -static AG::vector, 0, uint32_t> *names; - -} // namespace NamedEvents - -const char *AGGraphGetTraceEventName(uint32_t event_id) { - const char *event_name = nullptr; - - platform_lock_lock(&NamedEvents::lock); - if (NamedEvents::names != nullptr && event_id < NamedEvents::names->size()) { - event_name = (*NamedEvents::names)[event_id].second; - } - platform_lock_unlock(&NamedEvents::lock); - - return event_name; -} - -const char *AGGraphGetTraceEventSubsystem(uint32_t event_id) { - const char *event_subsystem = nullptr; - - platform_lock_lock(&NamedEvents::lock); - if (NamedEvents::names != nullptr && event_id < NamedEvents::names->size()) { - event_subsystem = (*NamedEvents::names)[event_id].first; - } - platform_lock_unlock(&NamedEvents::lock); - - return event_subsystem; -} - -uint32_t AGGraphRegisterNamedTraceEvent(const char *event_name, const char *event_subsystem) { - platform_lock_lock(&NamedEvents::lock); - - if (!NamedEvents::names) { - NamedEvents::names = new AG::vector, 0, uint32_t>(); - NamedEvents::names->push_back({0, 0}); // Disallow 0 as event ID - } - - uint32_t event_id = NamedEvents::names->size(); - if (event_subsystem != nullptr) { - event_subsystem = strdup(event_subsystem); - } - event_name = strdup(event_name); - NamedEvents::names->push_back({event_subsystem, event_name}); - - platform_lock_unlock(&NamedEvents::lock); - - return event_id; -} - -// MARK: Description - -#if TARGET_OS_MAC -void AGGraphArchiveJSON(const char *filename) { AG::Graph::write_to_file(nullptr, filename, false); } - -void AGGraphArchiveJSON2(const char *filename, bool exclude_values) { - AG::Graph::write_to_file(nullptr, filename, exclude_values); -} -#endif diff --git a/Sources/ComputeCxx/Graph/AGGraph.mm b/Sources/ComputeCxx/Graph/AGGraph.mm deleted file mode 100644 index 3d55c806..00000000 --- a/Sources/ComputeCxx/Graph/AGGraph.mm +++ /dev/null @@ -1,24 +0,0 @@ -#include "AGGraph-Private.h" - -#if TARGET_OS_MAC - -#import - -#include "Context.h" -#include "Graph.h" - -#pragma mark - Description - -CFTypeRef AGGraphDescription(AGGraphRef graph, CFDictionaryRef options) { - if (graph == nullptr) { - return (__bridge CFTypeRef)AG::Graph::description(nullptr, (__bridge NSDictionary *)options); - } - - auto graph_context = AG::Graph::Context::from_cf(graph); - if (graph_context->invalidated()) { - AG::precondition_failure("invalidated graph"); - } - return (__bridge CFTypeRef)AG::Graph::description(&graph_context->graph(), (__bridge NSDictionary *)options); -} - -#endif diff --git a/Sources/ComputeCxx/Graph/Context.cpp b/Sources/ComputeCxx/Graph/Context.cpp index 194f7299..a9869921 100644 --- a/Sources/ComputeCxx/Graph/Context.cpp +++ b/Sources/ComputeCxx/Graph/Context.cpp @@ -1,15 +1,15 @@ #include "Context.h" -#include "AGGraph-Private.h" +#include "IAGGraph-Private.h" #include "Attribute/AttributeID/AttributeID.h" -#include "ComputeCxx/AGUniqueID.h" +#include "ComputeCxx/IAGUniqueID.h" #include "Subgraph/Subgraph.h" #include "Trace/Trace.h" #include "UpdateStack.h" -namespace AG { +namespace IAG { -Graph::Context::Context(Graph *graph) : _graph(graph), _id(AGMakeUniqueID()) { +Graph::Context::Context(Graph *graph) : _graph(graph), _id(IAGMakeUniqueID()) { Graph::retain(graph); graph->_contexts_by_id.insert(_id, this); graph->foreach_trace([this](Trace &trace) { trace.created(*this); }); @@ -43,7 +43,7 @@ Graph::Context::~Context() { Graph::release(_graph); } -Graph::Context *Graph::Context::from_cf(AGGraphStorage *storage) { +Graph::Context *Graph::Context::from_cf(IAGGraphStorage *storage) { if (storage->context._invalidated) { precondition_failure("invalidated graph"); } @@ -112,8 +112,8 @@ void Graph::Context::call_update() { if (_update_callback) { auto update = - UpdateStack(_graph, AGGraphUpdateOptions(AGGraphUpdateOptionsInitializeCleared | - AGGraphUpdateOptionsEndDeferringSubgraphInvalidationOnExit)); + UpdateStack(_graph, IAGGraphUpdateOptions(IAGGraphUpdateOptionsInitializeCleared | + IAGGraphUpdateOptionsEndDeferringSubgraphInvalidationOnExit)); _graph->foreach_trace([this](Trace &trace) { trace.begin_update(*this); }); _update_callback(); @@ -123,4 +123,4 @@ void Graph::Context::call_update() { } } -} // namespace AG +} // namespace IAG diff --git a/Sources/ComputeCxx/Graph/Context.h b/Sources/ComputeCxx/Graph/Context.h index e3fbbfa2..09abc562 100644 --- a/Sources/ComputeCxx/Graph/Context.h +++ b/Sources/ComputeCxx/Graph/Context.h @@ -1,6 +1,6 @@ #pragma once -#include "ComputeCxx/AGBase.h" +#include "ComputeCxx/IAGBase.h" #if TARGET_OS_MAC #include "CoreFoundationPrivate/CFRuntime.h" @@ -10,11 +10,11 @@ #include "Graph.h" -AG_ASSUME_NONNULL_BEGIN +IAG_ASSUME_NONNULL_BEGIN -struct AGGraphStorage; +struct IAGGraphStorage; -namespace AG { +namespace IAG { class Graph::Context { private: @@ -22,7 +22,7 @@ class Graph::Context { const void *_context = nullptr; uint64_t _id; - ClosureFunctionAV _invalidation_callback = {nullptr, nullptr}; + ClosureFunctionAV _invalidation_callback = {nullptr, nullptr}; ClosureFunctionVV _update_callback = {nullptr, nullptr}; uint64_t _deadline = UINT64_MAX; @@ -38,18 +38,18 @@ class Graph::Context { uint64_t id() const { return _id; } - AGGraphStorage *to_cf() const { return reinterpret_cast((char *)this - sizeof(CFRuntimeBase)); }; - static Context *from_cf(AGGraphStorage *storage); + IAGGraphStorage *to_cf() const { return reinterpret_cast((char *)this - sizeof(CFRuntimeBase)); }; + static Context *from_cf(IAGGraphStorage *storage); Graph &graph() const { return *_graph; }; const void *_Nullable context() const { return _context; }; void set_context(const void *_Nullable context) { _context = context; }; - void set_invalidation_callback(AG::ClosureFunctionAV callback) { + void set_invalidation_callback(IAG::ClosureFunctionAV callback) { _invalidation_callback = callback; } - void set_update_callback(AG::ClosureFunctionVV callback) { _update_callback = callback; } + void set_update_callback(IAG::ClosureFunctionVV callback) { _update_callback = callback; } uint64_t deadline() const { return _deadline; }; void set_deadline(uint64_t deadline); @@ -73,6 +73,6 @@ class Graph::Context { void call_update(); }; -} // namespace AG +} // namespace IAG -AG_ASSUME_NONNULL_END +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/Graph/Graph.cpp b/Sources/ComputeCxx/Graph/Graph.cpp index 605c8e46..01b773dc 100644 --- a/Sources/ComputeCxx/Graph/Graph.cpp +++ b/Sources/ComputeCxx/Graph/Graph.cpp @@ -20,8 +20,8 @@ #include "Attribute/AttributeID/OffsetAttributeID.h" #include "Attribute/AttributeType/AttributeType.h" #include "Attribute/AttributeView/AttributeView.h" -#include "ComputeCxx/AGGraphTracing.h" -#include "ComputeCxx/AGUniqueID.h" +#include "ComputeCxx/IAGGraphTracing.h" +#include "ComputeCxx/IAGUniqueID.h" #include "Context.h" #include "KeyTable.h" #include "Log/Log.h" @@ -29,7 +29,7 @@ #include "TraceRecorder.h" #include "UpdateStack.h" -namespace AG { +namespace IAG { Graph *Graph::_all_graphs = nullptr; platform_lock Graph::_all_graphs_lock = PLATFORM_LOCK_INIT; @@ -38,7 +38,7 @@ pthread_key_t Graph::_current_update_key = 0; Graph::Graph() : _heap(nullptr, 0, 0), _interned_types(nullptr, nullptr, nullptr, nullptr, &_heap), - _contexts_by_id(nullptr, nullptr, nullptr, nullptr, &_heap), _id(AGMakeUniqueID()) { + _contexts_by_id(nullptr, nullptr, nullptr, nullptr, &_heap), _id(IAGMakeUniqueID()) { static platform_once_t make_keys; platform_once(&make_keys, []() { @@ -55,8 +55,8 @@ Graph::Graph() vector, 0, uint64_t> trace_subsystems = {}; - AGGraphTraceOptions trace_options = 0; - const char *trace_string = getenv("AG_TRACE"); + IAGGraphTraceOptions trace_options = 0; + const char *trace_string = getenv("IAG_TRACE"); if (trace_string) { char *endptr = nullptr; trace_options = (uint32_t)strtol(trace_string, &endptr, 0); @@ -71,22 +71,22 @@ Graph::Graph() option[option_length] = 0; if (strcasecmp(option, "enabled") == 0) { - trace_options |= AGGraphTraceOptionsEnabled; + trace_options |= IAGGraphTraceOptionsEnabled; free(option); } else if (strcasecmp(option, "full") == 0) { - trace_options |= AGGraphTraceOptionsFull; + trace_options |= IAGGraphTraceOptionsFull; free(option); } else if (strcasecmp(option, "backtrace") == 0) { - trace_options |= AGGraphTraceOptionsBacktrace; + trace_options |= IAGGraphTraceOptionsBacktrace; free(option); } else if (strcasecmp(option, "prepare") == 0) { - trace_options |= AGGraphTraceOptionsPrepare; + trace_options |= IAGGraphTraceOptionsPrepare; free(option); } else if (strcasecmp(option, "custom") == 0) { - trace_options |= AGGraphTraceOptionsCustom; + trace_options |= IAGGraphTraceOptionsCustom; free(option); } else if (strcasecmp(option, "all") == 0) { - trace_options |= AGGraphTraceOptionsAll; + trace_options |= IAGGraphTraceOptionsAll; free(option); } else { trace_subsystems.push_back(std::unique_ptr(option)); @@ -302,7 +302,7 @@ const AttributeType &Graph::attribute_ref(data::ptr attribute, const void return type; } -uint32_t Graph::intern_type(const swift::metadata *metadata, ClosureFunctionVP make_type) { +uint32_t Graph::intern_type(const swift::metadata *metadata, ClosureFunctionVP make_type) { uint32_t type_id = uint32_t(reinterpret_cast(_interned_types.lookup(metadata, nullptr))); if (type_id) { return type_id; @@ -312,7 +312,7 @@ uint32_t Graph::intern_type(const swift::metadata *metadata, ClosureFunctionVPinit_body_offset(); static bool prefetch_layouts = []() -> bool { - char *result = getenv("AG_PREFETCH_LAYOUTS"); + char *result = getenv("IAG_PREFETCH_LAYOUTS"); if (result) { return atoi(result) != 0; } @@ -352,7 +352,7 @@ data::ptr Graph::add_attribute(Subgraph &subgraph, uint32_t type_id, const // TODO: test this combo const void *initial_value = nullptr; if (value == nullptr && type.value_metadata().vw_size() == 0) { - if (type.flags() & AGAttributeTypeFlagsExternal) { + if (type.flags() & IAGAttributeTypeFlagsExternal) { initial_value = this; } } else { @@ -381,7 +381,7 @@ data::ptr Graph::add_attribute(Subgraph &subgraph, uint32_t type_id, const .unsafe_cast(); } - bool main_thread = type.flags() & AGAttributeTypeFlagsMainThread; + bool main_thread = type.flags() & IAGAttributeTypeFlagsMainThread; new (node_ptr.get()) Node(type_id, main_thread); node_ptr->set_main_ref(true); // setting here and below aain? @@ -392,7 +392,7 @@ data::ptr Graph::add_attribute(Subgraph &subgraph, uint32_t type_id, const void *self = (uint8_t *)node_ptr.get() + type.body_offset(); node_ptr->set_self_initialized(true); - if (type.value_metadata().getValueWitnesses()->isPOD() || type.flags() & AGAttributeTypeFlagsAsyncThread) { + if (type.value_metadata().getValueWitnesses()->isPOD() || type.flags() & IAGAttributeTypeFlagsAsyncThread) { node_ptr->set_main_ref(false); } else { if (node_ptr->requires_main_thread()) { @@ -599,7 +599,7 @@ bool Graph::remove_removed_output(AttributeID attribute, AttributeID output, boo auto dependency = output_indirect_node->to_mutable().dependency(); if (dependency && dependency == attribute) { foreach_trace([&output_indirect_node](Trace &trace) { - trace.set_dependency(output_indirect_node, AttributeID(AGAttributeNil)); + trace.set_dependency(output_indirect_node, AttributeID(IAGAttributeNil)); }); output_indirect_node->to_mutable().set_dependency(AttributeID(nullptr)); return true; @@ -609,7 +609,7 @@ bool Graph::remove_removed_output(AttributeID attribute, AttributeID output, boo } // reset source - WeakAttributeID new_source = {AttributeID(AGAttributeNil), 0}; + WeakAttributeID new_source = {AttributeID(IAGAttributeNil), 0}; uint32_t new_offset = 0; if (output_indirect_node->is_mutable()) { auto &mutable_output_indirect_node = output_indirect_node->to_mutable(); @@ -636,7 +636,7 @@ bool Graph::remove_removed_output(AttributeID attribute, AttributeID output, boo return false; } -uint32_t Graph::add_input(data::ptr node, AttributeID input, bool allow_nil, AGInputOptions options) { +uint32_t Graph::add_input(data::ptr node, AttributeID input, bool allow_nil, IAGInputOptions options) { auto resolved_input = input.resolve(TraversalOptions::EvaluateWeakReferences).attribute(); if (!resolved_input || resolved_input.is_nil()) { if (allow_nil) { @@ -662,8 +662,8 @@ uint32_t Graph::add_input(data::ptr node, AttributeID input, bool allow_ni InputEdge new_input_edge = { input, - static_cast((options & (AGInputOptionsUnprefetched | AGInputOptionsAlwaysEnabled)) | - (node->is_dirty() ? AGInputOptionsChanged : AGInputOptionsNone)), + static_cast((options & (IAGInputOptionsUnprefetched | IAGInputOptionsAlwaysEnabled)) | + (node->is_dirty() ? IAGInputOptionsChanged : IAGInputOptionsNone)), }; uint32_t index = node->insert_input_edge(subgraph, new_input_edge); @@ -706,7 +706,7 @@ void Graph::remove_all_inputs(data::ptr node) { void Graph::all_inputs_removed(data::ptr node) { node->set_input_edges_traverse_contexts(false); node->set_needs_sort_input_edges(false); - if (node->requires_main_thread() && !attribute_type(node->type_id()).flags() && AGAttributeTypeFlagsMainThread) { + if (node->requires_main_thread() && !attribute_type(node->type_id()).flags() && IAGAttributeTypeFlagsMainThread) { node->set_requires_main_thread(false); } } @@ -779,7 +779,7 @@ void Graph::update_main_refs(AttributeID attribute) { // copy constructor? bool main_ref = false; - if (type.value_metadata().getValueWitnesses()->isPOD() || type.flags() & AGAttributeTypeFlagsAsyncThread) { + if (type.value_metadata().getValueWitnesses()->isPOD() || type.flags() & IAGAttributeTypeFlagsAsyncThread) { main_ref = false; } else { if (node->requires_main_thread()) { @@ -899,7 +899,7 @@ bool Graph::indirect_attribute_reset(data::ptr indirect_node, bool precondition_failure("not an indirect attribute: %u", indirect_node); } - WeakAttributeID new_source = {AttributeID(AGAttributeNil), 0}; + WeakAttributeID new_source = {AttributeID(IAGAttributeNil), 0}; uint32_t new_offset = 0; auto initial_source = indirect_node->to_mutable().initial_source(); @@ -982,8 +982,8 @@ void Graph::indirect_attribute_set_dependency(data::ptr indirect_n #pragma mark - Search -bool Graph::breadth_first_search(AttributeID attribute, AGSearchOptions options, - ClosureFunctionAB predicate) const { +bool Graph::breadth_first_search(AttributeID attribute, IAGSearchOptions options, + ClosureFunctionAB predicate) const { auto resolved = attribute.resolve(TraversalOptions::SkipMutableReference); if (!resolved.attribute() || resolved.attribute().is_nil()) { return false; @@ -1006,7 +1006,7 @@ bool Graph::breadth_first_search(AttributeID attribute, AGSearchOptions options, return true; } - if (options & AGSearchOptionsSearchInputs) { + if (options & IAGSearchOptionsSearchInputs) { if (auto candidate_node = candidate.get_node()) { for (auto input_edge : candidate_node->input_edges()) { auto input = input_edge.attribute.resolve(TraversalOptions::SkipMutableReference).attribute(); @@ -1014,7 +1014,7 @@ bool Graph::breadth_first_search(AttributeID attribute, AGSearchOptions options, continue; } - if (options & AGSearchOptionsTraverseGraphContexts || + if (options & IAGSearchOptionsTraverseGraphContexts || candidate.subgraph()->context_id() == input.subgraph()->context_id()) { seen.insert(input); queue.push_back(input); @@ -1026,7 +1026,7 @@ bool Graph::breadth_first_search(AttributeID attribute, AGSearchOptions options, .resolve(TraversalOptions::SkipMutableReference) .attribute(); if (!seen.contains(source)) { - if (options & AGSearchOptionsTraverseGraphContexts || + if (options & IAGSearchOptionsTraverseGraphContexts || candidate.subgraph()->context_id() == source.subgraph()->context_id()) { seen.insert(source); queue.push_back(source); @@ -1035,7 +1035,7 @@ bool Graph::breadth_first_search(AttributeID attribute, AGSearchOptions options, } } - if (options & AGSearchOptionsSearchOutputs) { + if (options & IAGSearchOptionsSearchOutputs) { // outputs should never be non-mutable nodes - check! if (auto candidate_node = candidate.get_node()) { for (auto output_edge : candidate_node->output_edges()) { @@ -1043,7 +1043,7 @@ bool Graph::breadth_first_search(AttributeID attribute, AGSearchOptions options, continue; } - if (options & AGSearchOptionsTraverseGraphContexts || + if (options & IAGSearchOptionsTraverseGraphContexts || candidate.subgraph()->context_id() == output_edge.attribute.subgraph()->context_id()) { seen.insert(output_edge.attribute); queue.push_back(output_edge.attribute); @@ -1056,7 +1056,7 @@ bool Graph::breadth_first_search(AttributeID attribute, AGSearchOptions options, continue; } - if (options & AGSearchOptionsTraverseGraphContexts || + if (options & IAGSearchOptionsTraverseGraphContexts || candidate.subgraph()->context_id() == output_edge.attribute.subgraph()->context_id()) { seen.insert(output_edge.attribute); queue.push_back(output_edge.attribute); @@ -1122,26 +1122,26 @@ void Graph::reset_update(data::ptr node) { } } -void Graph::with_update(data::ptr node, ClosureFunctionVV body) { +void Graph::with_update(data::ptr node, ClosureFunctionVV body) { class scoped_update : public UpdateStack { public: - scoped_update(Graph *graph, AGGraphUpdateOptions options, data::ptr node) + scoped_update(Graph *graph, IAGGraphUpdateOptions options, data::ptr node) : UpdateStack(graph, options) { frames().push_back({node, node->is_pending()}); }; ~scoped_update() { frames().pop_back(); } }; - scoped_update update = scoped_update(this, AGGraphUpdateOptionsNone, node); + scoped_update update = scoped_update(this, IAGGraphUpdateOptionsNone, node); body(); // ~scoped_update } void Graph::without_update(ClosureFunctionVV body) { auto old_update = current_update(); - AG::Graph::set_current_update(old_update != nullptr ? old_update.with_tag(true) : nullptr); + IAG::Graph::set_current_update(old_update != nullptr ? old_update.with_tag(true) : nullptr); body(); - AG::Graph::set_current_update(old_update); + IAG::Graph::set_current_update(old_update); } void Graph::collect_stack(vector, 0, uint64_t> &nodes) { @@ -1152,8 +1152,8 @@ void Graph::collect_stack(vector, 0, uint64_t> &nodes) { } } -Graph::UpdateStatus Graph::update_attribute(data::ptr node, AGGraphUpdateOptions options) { - if (!(options & AGGraphUpdateOptionsInTransaction) && _needs_update) { +Graph::UpdateStatus Graph::update_attribute(data::ptr node, IAGGraphUpdateOptions options) { + if (!(options & IAGGraphUpdateOptionsInTransaction) && _needs_update) { if (!thread_is_updating()) { call_update(); } @@ -1174,7 +1174,7 @@ Graph::UpdateStatus Graph::update_attribute(data::ptr node, AGGraphUpdateO [¤t_update, &node, &options](Trace &trace) { trace.begin_update(current_update, node, options); }); UpdateStatus status = UpdateStatus::Changed; - if (current_update.push(node, *node.get(), false, !(options & AGGraphUpdateOptionsInTransaction))) { + if (current_update.push(node, *node.get(), false, !(options & IAGGraphUpdateOptionsInTransaction))) { status = current_update.update(); if (status == UpdateStatus::NeedsCallMainHandler) { std::pair context = {¤t_update, UpdateStatus::NeedsCallMainHandler}; @@ -1191,7 +1191,7 @@ Graph::UpdateStatus Graph::update_attribute(data::ptr node, AGGraphUpdateO } foreach_trace([¤t_update, &node, &status](Trace &trace) { - trace.end_update(current_update, node, AGGraphUpdateStatus(status)); + trace.end_update(current_update, node, IAGGraphUpdateStatus(status)); }); // ~UpdateStack called @@ -1215,7 +1215,7 @@ void Graph::mark_changed(data::ptr node, AttributeType *_Nullable type, co if (input_edge.attribute.resolve(TraversalOptions::None).attribute() != AttributeID(node)) { continue; } - if (input_edge.options & AGInputOptionsChanged) { + if (input_edge.options & IAGInputOptionsChanged) { continue; } if (!input_edge.attribute.is_node()) { @@ -1223,7 +1223,7 @@ void Graph::mark_changed(data::ptr node, AttributeType *_Nullable type, co continue; } } - input_edge.options |= AGInputOptionsChanged; + input_edge.options |= IAGInputOptionsChanged; break; } output_index += 1; @@ -1280,7 +1280,7 @@ void Graph::mark_changed(AttributeID attribute, AttributeType *_Nullable type, c if (input_edge.attribute.resolve(TraversalOptions::SkipMutableReference).attribute() != attribute) { continue; } - if (input_edge.options & AGInputOptionsChanged) { + if (input_edge.options & IAGInputOptionsChanged) { continue; } if (!input_edge.attribute.is_node()) { @@ -1291,7 +1291,7 @@ void Graph::mark_changed(AttributeID attribute, AttributeType *_Nullable type, c foreach_trace([&output_node, &input_edge](Trace &trace) { trace.set_edge_pending(output_node, input_edge.attribute, true); }); - input_edge.options |= AGInputOptionsChanged; + input_edge.options |= IAGInputOptionsChanged; } } else if (auto output_indirect_node = output_edge->attribute.get_indirect_node()) { if (output_indirect_node->to_mutable().dependency() != attribute) { @@ -1387,7 +1387,7 @@ void Graph::mark_pending(data::ptr node_ptr, Node *node) { foreach_trace([&node_ptr](Trace &trace) { trace.set_dirty(node_ptr, true); }); node->set_dirty(true); - AGAttributeFlags subgraph_flags = node->subgraph_flags(); + IAGAttributeFlags subgraph_flags = node->subgraph_flags(); Subgraph *subgraph = AttributeID(node_ptr).subgraph(); if (subgraph_flags && subgraph != nullptr) { subgraph->add_dirty_flags(subgraph_flags); @@ -1401,13 +1401,13 @@ void Graph::mark_pending(data::ptr node_ptr, Node *node) { bool Graph::value_exists(data::ptr node) { return node->is_value_initialized(); } -AGValueState Graph::value_state(AttributeID attribute) { +IAGValueState Graph::value_state(AttributeID attribute) { auto resolved = attribute.resolve(TraversalOptions::AssertNotNil); if (auto node = resolved.attribute().get_node()) { return node->flags(); } - return AGValueStateNone; + return IAGValueStateNone; } namespace { @@ -1431,8 +1431,8 @@ inline void *value_ref_checked(data::ptr node, uint32_t offset, const Attr } // namespace -bool Graph::update_attribute_checked(data::ptr node, uint32_t subgraph_id, AGGraphUpdateOptions options, - AGChangedValueFlags *flags_out) { +bool Graph::update_attribute_checked(data::ptr node, uint32_t subgraph_id, IAGGraphUpdateOptions options, + IAGChangedValueFlags *flags_out) { uint64_t page_seed_before_update = 0; if (subgraph_id != 0) { page_seed_before_update = data::table::shared().raw_page_seed(node.page_ptr()); @@ -1441,7 +1441,7 @@ bool Graph::update_attribute_checked(data::ptr node, uint32_t subgraph_id, UpdateStatus status = update_attribute(node, options); if (status != UpdateStatus::Unchanged) { if (flags_out) { - *flags_out |= AGChangedValueFlagsChanged; + *flags_out |= IAGChangedValueFlagsChanged; } } @@ -1459,7 +1459,7 @@ bool Graph::update_attribute_checked(data::ptr node, uint32_t subgraph_id, } void *Graph::value_ref(AttributeID attribute, uint32_t subgraph_id, const swift::metadata &value_type, - AGChangedValueFlags *_Nonnull flags_out) { + IAGChangedValueFlags *_Nonnull flags_out) { _version += 1; OffsetAttributeID resolved = attribute.resolve( @@ -1472,9 +1472,9 @@ void *Graph::value_ref(AttributeID attribute, uint32_t subgraph_id, const swift: auto node = resolved.attribute().get_node(); const AttributeType &type = attribute_type(node->type_id()); - if ((type.flags() & AGAttributeTypeFlagsExternal) == 0) { + if ((type.flags() & IAGAttributeTypeFlagsExternal) == 0) { increment_transaction_count_if_needed(); - if (!update_attribute_checked(node, subgraph_id, AGGraphUpdateOptionsNone, flags_out)) { + if (!update_attribute_checked(node, subgraph_id, IAGGraphUpdateOptionsNone, flags_out)) { return nullptr; } } @@ -1482,25 +1482,25 @@ void *Graph::value_ref(AttributeID attribute, uint32_t subgraph_id, const swift: return value_ref_checked(node, resolved.offset(), type, value_type); } -void *Graph::input_value_ref(data::ptr node, AttributeID input, uint32_t subgraph_id, - AGInputOptions input_options, const swift::metadata &value_type, - AGChangedValueFlags *_Nonnull flags_out) { +void *Graph::input_value_ref(data::ptr node, AttributeID input, uint32_t subgraph_id, + IAGInputOptions input_options, const swift::metadata &value_type, + IAGChangedValueFlags *_Nonnull flags_out) { auto comparator = InputEdge::Comparator( - input, AGInputOptionsUnprefetched | AGInputOptionsSyncMainRef | AGInputOptionsAlwaysEnabled, input_options); + input, IAGInputOptionsUnprefetched | IAGInputOptionsSyncMainRef | IAGInputOptionsAlwaysEnabled, input_options); uint32_t index = index_of_input(*node.get(), comparator); if (index < UINT32_MAX) { - AG::OffsetAttributeID resolved_input = - input.resolve(AG::TraversalOptions::UpdateDependencies | AG::TraversalOptions::AssertNotNil); + IAG::OffsetAttributeID resolved_input = + input.resolve(IAG::TraversalOptions::UpdateDependencies | IAG::TraversalOptions::AssertNotNil); assert(resolved_input.attribute().is_node()); auto input_node = resolved_input.attribute().get_node(); if (input_node->is_value_initialized() && !input_node->is_dirty()) { InputEdge &input_edge = node->input_edges()[index]; - input_edge.options |= AGInputOptionsEnabled; + input_edge.options |= IAGInputOptionsEnabled; - if (input_edge.options & AGInputOptionsChanged) { - *flags_out |= AGChangedValueFlagsChanged; + if (input_edge.options & IAGInputOptionsChanged) { + *flags_out |= IAGChangedValueFlagsChanged; } void *value = input_node->get_value(); @@ -1513,13 +1513,13 @@ void *Graph::input_value_ref(data::ptr node, AttributeID input, uint32 return input_value_ref_slow(node, input, subgraph_id, input_options, value_type, flags_out, index); } -void *Graph::input_value_ref_slow(data::ptr node, AttributeID input, uint32_t subgraph_id, - AGInputOptions input_options, const swift::metadata &value_type, - AGChangedValueFlags *_Nonnull flags_out, uint32_t index) { +void *Graph::input_value_ref_slow(data::ptr node, AttributeID input, uint32_t subgraph_id, + IAGInputOptions input_options, const swift::metadata &value_type, + IAGChangedValueFlags *_Nonnull flags_out, uint32_t index) { - if (input_options & AGInputOptionsSyncMainRef) { - auto comparator = InputEdge::Comparator(input, AGInputOptionsUnprefetched | AGInputOptionsAlwaysEnabled, - input_options & AGInputOptionsUnprefetched); + if (input_options & IAGInputOptionsSyncMainRef) { + auto comparator = InputEdge::Comparator(input, IAGInputOptionsUnprefetched | IAGInputOptionsAlwaysEnabled, + input_options & IAGInputOptionsUnprefetched); index = index_of_input(*node.get(), comparator); } @@ -1536,18 +1536,18 @@ void *Graph::input_value_ref_slow(data::ptr node, AttributeID input, u return nullptr; } - update_attribute(resolved.attribute().get_node(), AGGraphUpdateOptionsNone); + update_attribute(resolved.attribute().get_node(), IAGGraphUpdateOptionsNone); } - index = add_input(node, input, subgraph_id != 0, input_options & AGInputOptionsUnprefetched); + index = add_input(node, input, subgraph_id != 0, input_options & IAGInputOptionsUnprefetched); if (index == UINT32_MAX) { return nullptr; } } InputEdge &input_edge = node->input_edges()[index]; - input_edge.options |= input_options & AGInputOptionsUnprefetched; - input_edge.options |= AGInputOptionsEnabled; + input_edge.options |= input_options & IAGInputOptionsUnprefetched; + input_edge.options |= IAGInputOptionsEnabled; OffsetAttributeID resolved = input_edge.attribute.resolve( TraversalOptions::UpdateDependencies | TraversalOptions::ReportIndirectionInOffset | @@ -1560,18 +1560,18 @@ void *Graph::input_value_ref_slow(data::ptr node, AttributeID input, u const AttributeType &input_type = attribute_type(input_node->type_id()); if (!input_node->is_value_initialized() || input_node->is_dirty()) { - if (!update_attribute_checked(input_node, subgraph_id, AGGraphUpdateOptionsNone, nullptr)) { + if (!update_attribute_checked(input_node, subgraph_id, IAGGraphUpdateOptionsNone, nullptr)) { return nullptr; } } - if (input_edge.options & AGInputOptionsChanged) { - *flags_out |= AGChangedValueFlagsChanged; + if (input_edge.options & IAGInputOptionsChanged) { + *flags_out |= IAGChangedValueFlagsChanged; } - if (input_options & AGInputOptionsSyncMainRef && input_node->is_main_ref() && + if (input_options & IAGInputOptionsSyncMainRef && input_node->is_main_ref() && !value_type.getValueWitnesses()->isPOD()) { input_node->set_requires_main_thread(true); - *flags_out |= AGChangedValueFlagsRequiresMainThread; + *flags_out |= IAGChangedValueFlagsRequiresMainThread; } return value_ref_checked(input_node, resolved.offset(), input_type, value_type); @@ -1639,7 +1639,7 @@ void Graph::value_mark(data::ptr node) { foreach_trace([&node](Trace &trace) { trace.mark_value(node); }); const AttributeType &type = attribute_type(node->type_id()); - if (type.flags() & AGAttributeTypeFlagsExternal) { + if (type.flags() & IAGAttributeTypeFlagsExternal) { mark_changed(node, nullptr, nullptr, nullptr); } else { node->set_self_modified(true); // TODO: check this @@ -1676,13 +1676,13 @@ void Graph::value_mark_all() { } if (auto node = attribute.get_node()) { const AttributeType &type = attribute_type(node->type_id()); - if (!(type.flags() & AGAttributeTypeFlagsExternal)) { + if (!(type.flags() & IAGAttributeTypeFlagsExternal)) { node->set_dirty(true); node->set_pending(true); subgraph->add_dirty_flags(node->subgraph_flags()); } for (auto &input_edge : node->input_edges()) { - input_edge.options |= AGInputOptionsChanged; + input_edge.options |= IAGInputOptionsChanged; } } } @@ -1835,8 +1835,8 @@ inline size_t find_attribute(const AttributeID *attributes, AttributeID search, bool Graph::any_inputs_changed(data::ptr node, const AttributeID *exclude_attributes, uint64_t exclude_attributes_count) { for (auto &input_edge : node->input_edges()) { - input_edge.options |= AGInputOptionsEnabled; - if (input_edge.options & AGInputOptionsChanged) { + input_edge.options |= IAGInputOptionsEnabled; + if (input_edge.options & IAGInputOptionsChanged) { if (find_attribute(exclude_attributes, input_edge.attribute, exclude_attributes_count) == exclude_attributes_count) { return true; @@ -1846,18 +1846,18 @@ bool Graph::any_inputs_changed(data::ptr node, const AttributeID *exclude_ return false; } -void Graph::input_value_add(data::ptr node, AttributeID input, AGInputOptions options) { +void Graph::input_value_add(data::ptr node, AttributeID input, IAGInputOptions options) { input.validate_data_offset(); - auto comparator = InputEdge::Comparator(input, options & AGInputOptionsUnprefetched, - AGInputOptionsUnprefetched | AGInputOptionsAlwaysEnabled); + auto comparator = InputEdge::Comparator(input, options & IAGInputOptionsUnprefetched, + IAGInputOptionsUnprefetched | IAGInputOptionsAlwaysEnabled); auto index = index_of_input(*node.get(), comparator); if (index == UINT32_MAX) { - index = add_input(node, input, false, options & AGInputOptionsUnprefetched); + index = add_input(node, input, false, options & IAGInputOptionsUnprefetched); } if (index >= 0) { auto &input_edge = node->input_edges()[index]; - input_edge.options |= AGInputOptionsEnabled; + input_edge.options |= IAGInputOptionsEnabled; } } @@ -1881,8 +1881,8 @@ void *Graph::output_value_ref(data::ptr node, const swift::metadata &value #pragma mark - Trace -void Graph::start_tracing(AGGraphTraceOptions trace_options, std::span subsystems) { - if ((trace_options & AGGraphTraceOptionsEnabled) == 0) { +void Graph::start_tracing(IAGGraphTraceOptions trace_options, std::span subsystems) { + if ((trace_options & IAGGraphTraceOptionsEnabled) == 0) { return; } if (_trace_recorder) { @@ -1890,7 +1890,7 @@ void Graph::start_tracing(AGGraphTraceOptions trace_options, std::spaninput_edges()) { trace.add_edge(node, input_edge.attribute, input_edge.options); - if (input_edge.options & AGInputOptionsChanged) { + if (input_edge.options & IAGInputOptionsChanged) { trace.set_edge_pending(node, input_edge.attribute, true); } } @@ -2015,7 +2015,7 @@ void Graph::remove_trace(uint64_t trace_id) { } } -void Graph::all_start_tracing(AGGraphTraceOptions trace_options, std::span span) { +void Graph::all_start_tracing(IAGGraphTraceOptions trace_options, std::span span) { all_lock(); for (auto graph = _all_graphs; graph != nullptr; graph = graph->_next) { graph->start_tracing(trace_options, span); @@ -2085,7 +2085,7 @@ const char *Graph::key_name(uint32_t key_id) const { if (_keys != nullptr && key_id < _keys->size()) { return _keys->get(key_id); } - AG::precondition_failure("invalid string key id: %u", key_id); + IAG::precondition_failure("invalid string key id: %u", key_id); } -} // namespace AG +} // namespace IAG diff --git a/Sources/ComputeCxx/Graph/Graph.h b/Sources/ComputeCxx/Graph/Graph.h index c503852e..e7063296 100644 --- a/Sources/ComputeCxx/Graph/Graph.h +++ b/Sources/ComputeCxx/Graph/Graph.h @@ -1,6 +1,6 @@ #pragma once -#include "ComputeCxx/AGBase.h" +#include "ComputeCxx/IAGBase.h" #include #include @@ -19,13 +19,13 @@ #include "Attribute/AttributeID/AttributeID.h" #include "Attribute/AttributeType/AttributeType.h" #include "Closure/ClosureFunction.h" -#include "ComputeCxx/AGGraphTracing.h" +#include "ComputeCxx/IAGGraphTracing.h" #include "Swift/Metadata.h" #include "Vector/Vector.h" -AG_ASSUME_NONNULL_BEGIN +IAG_ASSUME_NONNULL_BEGIN -namespace AG { +namespace IAG { class Trace; @@ -66,7 +66,7 @@ class Graph { typedef void (*MainHandler)(void (*trampoline_thunk)(const void *), const void *trampoline, - const void *_Nullable context AG_SWIFT_CONTEXT) AG_SWIFT_CC(swift); + const void *_Nullable context IAG_SWIFT_CONTEXT) IAG_SWIFT_CC(swift); private: static Graph *_Nullable _all_graphs; @@ -154,8 +154,8 @@ class Graph { void remove_input_dependencies(AttributeID attribute, AttributeID input); void update_main_refs(AttributeID attribute); - void *input_value_ref_slow(data::ptr node, AttributeID input, uint32_t seed, AGInputOptions input_options, - const swift::metadata &value_type, AGChangedValueFlags *_Nonnull flags_out, + void *input_value_ref_slow(data::ptr node, AttributeID input, uint32_t seed, IAGInputOptions input_options, + const swift::metadata &value_type, IAGChangedValueFlags *_Nonnull flags_out, uint32_t index); uint32_t index_of_input(Node &node, InputEdge::Comparator comparator); @@ -168,8 +168,8 @@ class Graph { bool compare_edge_values(InputEdge input_edge, AttributeType *_Nullable type, const void *destination_value, const void *source_value); - inline bool update_attribute_checked(data::ptr node, uint32_t subgraph_id, AGGraphUpdateOptions options, - AGChangedValueFlags *_Nullable flags_out); + inline bool update_attribute_checked(data::ptr node, uint32_t subgraph_id, IAGGraphUpdateOptions options, + IAGChangedValueFlags *_Nullable flags_out); static pthread_key_t _current_update_key; @@ -283,7 +283,7 @@ class Graph { const AttributeType &attribute_type(uint32_t type_id) const { return *_types[type_id]; }; const AttributeType &attribute_ref(data::ptr attribute, const void *_Nullable *_Nullable ref_out) const; - uint32_t intern_type(const swift::metadata *metadata, ClosureFunctionVP make_type); + uint32_t intern_type(const swift::metadata *metadata, ClosureFunctionVP make_type); // MARK: Attributes @@ -294,7 +294,7 @@ class Graph { void remove_node(data::ptr node); void remove_indirect_node(data::ptr node); - uint32_t add_input(data::ptr node, AttributeID input, bool allow_nil, AGInputOptions options); + uint32_t add_input(data::ptr node, AttributeID input, bool allow_nil, IAGInputOptions options); void remove_all_inputs(data::ptr node); void indirect_attribute_set(data::ptr indirect_node, AttributeID source); @@ -305,8 +305,8 @@ class Graph { // MARK: Search - bool breadth_first_search(AttributeID attribute, AGSearchOptions options, - ClosureFunctionAB predicate) const; + bool breadth_first_search(AttributeID attribute, IAGSearchOptions options, + ClosureFunctionAB predicate) const; // MARK: Body @@ -316,13 +316,13 @@ class Graph { // MARK: Value bool value_exists(data::ptr node); - AGValueState value_state(AttributeID attribute); + IAGValueState value_state(AttributeID attribute); void *value_ref(AttributeID attribute, uint32_t seed, const swift::metadata &value_type, - AGChangedValueFlags *_Nonnull flags_out); + IAGChangedValueFlags *_Nonnull flags_out); - void *input_value_ref(data::ptr node, AttributeID input, uint32_t seed, AGInputOptions input_options, - const swift::metadata &value_type, AGChangedValueFlags *_Nonnull flags_out); + void *input_value_ref(data::ptr node, AttributeID input, uint32_t seed, IAGInputOptions input_options, + const swift::metadata &value_type, IAGChangedValueFlags *_Nonnull flags_out); bool value_set(data::ptr node, const swift::metadata &metadata, const void *value); bool value_set_internal(data::ptr node_ptr, Node &node, const void *value, const swift::metadata &metadata); @@ -335,7 +335,7 @@ class Graph { bool any_inputs_changed(data::ptr node, const AttributeID *exclude_attributes, uint64_t exclude_attributes_count); - void input_value_add(data::ptr node, AttributeID input, AGInputOptions options); + void input_value_add(data::ptr node, AttributeID input, IAGInputOptions options); void *output_value_ref(data::ptr node, const swift::metadata &value_type); @@ -377,7 +377,7 @@ class Graph { void with_update(data::ptr node, ClosureFunctionVV body); static void without_update(ClosureFunctionVV body); - UpdateStatus update_attribute(data::ptr node, AGGraphUpdateOptions options); + UpdateStatus update_attribute(data::ptr node, IAGGraphUpdateOptions options); void reset_update(data::ptr node); void mark_changed(data::ptr node, AttributeType *_Nullable type, const void *_Nullable destination_value, @@ -390,7 +390,7 @@ class Graph { // MARK: Trace - void start_tracing(AGGraphTraceOptions trace_options, std::span subsystems); + void start_tracing(IAGGraphTraceOptions trace_options, std::span subsystems); void stop_tracing(); void sync_tracing(); CFStringRef copy_trace_path(); @@ -400,7 +400,7 @@ class Graph { void add_trace(Trace *_Nullable trace); void remove_trace(uint64_t trace_id); - static void all_start_tracing(AGGraphTraceOptions trace_options, std::span span); + static void all_start_tracing(IAGGraphTraceOptions trace_options, std::span span); static void all_stop_tracing(); static void all_sync_tracing(); static CFStringRef all_copy_trace_path(); @@ -448,6 +448,6 @@ class Graph { #endif }; -} // namespace AG +} // namespace IAG -AG_ASSUME_NONNULL_END +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/Graph/Graph.mm b/Sources/ComputeCxx/Graph/Graph.mm index 7453e8a9..ffe8dcaf 100644 --- a/Sources/ComputeCxx/Graph/Graph.mm +++ b/Sources/ComputeCxx/Graph/Graph.mm @@ -8,7 +8,7 @@ #include "Attribute/AttributeID/OffsetAttributeID.h" #include "Attribute/AttributeView/AttributeView.h" -#include "ComputeCxx/AGDescription.h" +#include "ComputeCxx/IAGDescription.h" #include "Graph/UpdateStack.h" #include "Subgraph/Subgraph.h" #include "Swift/SwiftShims.h" @@ -25,7 +25,7 @@ } // namespace -namespace AG { +namespace IAG { #pragma mark - Printing @@ -56,7 +56,7 @@ namespace { int cycle_verbosity() { - const char *print_cycles = getenv("AG_PRINT_CYCLES"); + const char *print_cycles = getenv("IAG_PRINT_CYCLES"); if (print_cycles) { return atoi(print_cycles); } @@ -64,7 +64,7 @@ int cycle_verbosity() { } int trap_cycles() { - const char *trap_cycles = getenv("AG_TRAP_CYCLES"); + const char *trap_cycles = getenv("IAG_TRAP_CYCLES"); if (trap_cycles) { return atoi(trap_cycles) != 0; } @@ -89,7 +89,7 @@ int trap_cycles() { } NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:@{ - (__bridge NSString *)AGDescriptionFormat : @"graph/dot", + (__bridge NSString *)IAGDescriptionFormat : @"graph/dot", @"attribute-ids" : indexSet }]; @@ -105,7 +105,7 @@ int trap_cycles() { std::cout << "===\n"; if (verbosity >= 4 /* && os_variant_has_internal_diagnostics() */) { - AGGraphArchiveJSON("cycle.ag-json"); + IAGGraphArchiveJSON("cycle.ag-json"); } } } @@ -183,7 +183,7 @@ int trap_cycles() { if (auto selfDescription = type.vtable().self_description) { if (node->is_self_initialized()) { void *body = node->get_self(type); - if (auto desc = selfDescription(reinterpret_cast(&type), body)) { + if (auto desc = selfDescription(reinterpret_cast(&type), body)) { [array addObject:[NSString stringWithFormat:@"self = %@", desc]]; } } @@ -191,7 +191,7 @@ int trap_cycles() { if (auto valueDescription = type.vtable().value_description) { if (node->is_value_initialized()) { void *value = node->get_value(); - if (auto desc = valueDescription(reinterpret_cast(&type), value)) { + if (auto desc = valueDescription(reinterpret_cast(&type), value)) { [array addObject:[NSString stringWithFormat:@"value = %@", desc]]; } } @@ -200,7 +200,7 @@ int trap_cycles() { if (auto copySelfDescription = type.vtable().copy_self_description) { if (node->is_self_initialized()) { void *body = node->get_self(type); - if (auto desc = copySelfDescription(reinterpret_cast(&type), body)) { + if (auto desc = copySelfDescription(reinterpret_cast(&type), body)) { [array addObject:[NSString stringWithFormat:@"self = %@", desc]]; CFRelease(desc); } @@ -209,7 +209,7 @@ int trap_cycles() { if (auto copyValueDescription = type.vtable().copy_value_description) { if (node->is_value_initialized()) { void *value = node->get_value(); - if (auto desc = copyValueDescription(reinterpret_cast(&type), value)) { + if (auto desc = copyValueDescription(reinterpret_cast(&type), value)) { [array addObject:[NSString stringWithFormat:@"value = %@", desc]]; CFRelease(desc); } @@ -222,7 +222,7 @@ int trap_cycles() { } NSObject *Graph::description(Graph *graph, NSDictionary *options) { - NSString *format = options[(__bridge NSString *)AGDescriptionFormat]; + NSString *format = options[(__bridge NSString *)IAGDescriptionFormat]; if ([format isEqualToString:@"graph/dict"]) { return description_graph(graph, options); } @@ -246,13 +246,13 @@ int trap_cycles() { } NSDictionary *Graph::description_graph(Graph *graph, NSDictionary *options) { - NSNumber *include_values_number = options[(__bridge NSString *)AGDescriptionIncludeValues]; + NSNumber *include_values_number = options[(__bridge NSString *)IAGDescriptionIncludeValues]; bool include_values = false; if (include_values_number) { include_values = [include_values_number boolValue]; } - NSNumber *truncation_limit_number = options[(__bridge NSString *)AGDescriptionTruncationLimit]; + NSNumber *truncation_limit_number = options[(__bridge NSString *)IAGDescriptionTruncationLimit]; uint64_t truncation_limit = 1024; if (truncation_limit_number) { truncation_limit = [truncation_limit_number unsignedLongValue]; @@ -436,10 +436,10 @@ int trap_cycles() { edge_dict[@"offset"] = @(resolved.offset()); } } - if (indirect || input_edge.options & AGInputOptionsAlwaysEnabled || - input_edge.options & AGInputOptionsChanged || - input_edge.options & AGInputOptionsEnabled || - input_edge.options & AGInputOptionsUnprefetched) { + if (indirect || input_edge.options & IAGInputOptionsAlwaysEnabled || + input_edge.options & IAGInputOptionsChanged || + input_edge.options & IAGInputOptionsEnabled || + input_edge.options & IAGInputOptionsUnprefetched) { edge_dict[@"flags"] = @(input_edge.options); } @@ -508,7 +508,7 @@ int trap_cycles() { for (auto page : subgraph->pages()) { for (auto attribute : attribute_view(page)) { if (auto node = attribute.get_node()) { - AGAttributeFlags subgraph_flags = node->subgraph_flags(); + IAGAttributeFlags subgraph_flags = node->subgraph_flags(); auto found_node_index = node_indices_by_id.find(node); if (found_node_index != node_indices_by_id.end()) { [subgraph_node_dicts addObject:@(found_node_index->second)]; @@ -535,7 +535,7 @@ int trap_cycles() { auto tree_stack = std::stack, vector, 0, uint64_t>>(); auto tree_element_indices = std::unordered_map, uint64_t>(); - auto trees = AG::vector, 0ul, unsigned long>(); + auto trees = IAG::vector, 0ul, unsigned long>(); if (!graph->subgraphs().empty()) { for (auto subgraph : graph->subgraphs()) { @@ -679,7 +679,7 @@ int trap_cycles() { } NSString *Graph::description_graph_dot(NSDictionary *options) { - NSNumber *include_values_number = options[(__bridge NSString *)AGDescriptionIncludeValues]; + NSNumber *include_values_number = options[(__bridge NSString *)IAGDescriptionIncludeValues]; bool include_values = false; if (include_values_number) { include_values = [include_values_number boolValue]; @@ -690,7 +690,7 @@ int trap_cycles() { attribute_ids = nil; } - NSNumber *truncation_limit_number = options[(__bridge NSString *)AGDescriptionTruncationLimit]; + NSNumber *truncation_limit_number = options[(__bridge NSString *)IAGDescriptionTruncationLimit]; uint64_t truncation_limit = 40; if (truncation_limit_number) { truncation_limit = [truncation_limit_number unsignedLongValue]; @@ -712,7 +712,7 @@ int trap_cycles() { if (!attribute_ids || [attribute_ids containsIndex:attribute]) { - [result appendFormat:@" _%d[label=\"%d", AGAttribute(attribute), AGAttribute(attribute)]; + [result appendFormat:@" _%d[label=\"%d", IAGAttribute(attribute), IAGAttribute(attribute)]; data::ptr node = attribute.get_node(); const AttributeType &node_type = attribute_type(node->type_id()); @@ -720,7 +720,7 @@ int trap_cycles() { if (auto selfDescription = node_type.vtable().self_description) { void *self = node->get_self(node_type); if (auto desc = - selfDescription(reinterpret_cast(&node_type), self)) { + selfDescription(reinterpret_cast(&node_type), self)) { [result appendString:@": "]; [result appendString:escaped_string((__bridge NSString *)desc, truncation_limit)]; } @@ -730,7 +730,7 @@ int trap_cycles() { if (auto valueDescription = node_type.vtable().value_description) { void *value = node->get_value(); if (auto value_desc = valueDescription( - reinterpret_cast(&node_type), value)) { + reinterpret_cast(&node_type), value)) { [result appendString:@" → "]; [result appendString:escaped_string((__bridge NSString *)value_desc, truncation_limit)]; @@ -808,7 +808,7 @@ int trap_cycles() { (!attribute_ids || [attribute_ids containsIndex:resolved_input_attribute])) { [result appendFormat:@" _%d -> _%d[", (uint32_t)input_edge.attribute, - AGAttribute(attribute)]; + IAGAttribute(attribute)]; // collect source inputs AttributeID intermediate = input_edge.attribute; @@ -824,7 +824,7 @@ int trap_cycles() { intermediate = source.resolve(TraversalOptions::SkipMutableReference).attribute(); } - if (input_edge.options & AGInputOptionsChanged) { + if (input_edge.options & IAGInputOptionsChanged) { [result appendString:@" color=red"]; } @@ -865,7 +865,7 @@ int trap_cycles() { if (indirect_node->is_mutable()) { if (auto dependency = indirect_node->to_mutable().dependency()) { [result - appendFormat:@" _%d -> _%d[color=blue];\n", AGAttribute(dependency), indirect_node.offset()]; + appendFormat:@" _%d -> _%d[color=blue];\n", IAGAttribute(dependency), indirect_node.offset()]; } } } @@ -880,7 +880,7 @@ int trap_cycles() { NSMutableString *description = [NSMutableString string]; - NSNumber *max_frames_number = [options objectForKeyedSubscript:(__bridge NSString *)AGDescriptionMaxFrames]; + NSNumber *max_frames_number = [options objectForKeyedSubscript:(__bridge NSString *)IAGDescriptionMaxFrames]; int max_frames = max_frames_number ? [max_frames_number unsignedIntValue] : -1; int frame_count = 0; @@ -897,7 +897,7 @@ int trap_cycles() { for (auto &input_edge : frame->attribute->input_edges()) { OffsetAttributeID resolved = input_edge.attribute.resolve(TraversalOptions::ReportIndirectionInOffset); - [description appendFormat:@" %u", AGAttribute(resolved.attribute())]; + [description appendFormat:@" %u", IAGAttribute(resolved.attribute())]; if (resolved.offset() != 0) { [description appendFormat:@"[@%d]", resolved.offset() - 1]; } @@ -906,13 +906,13 @@ int trap_cycles() { [description appendFormat:@" %s -> %s", input_type.body_metadata().name(false), input_type.value_metadata().name(false)]; } - if (input_edge.options & AGInputOptionsChanged) { + if (input_edge.options & IAGInputOptionsChanged) { [description appendString:@", changed"]; } - if (input_edge.options & AGInputOptionsAlwaysEnabled) { + if (input_edge.options & IAGInputOptionsAlwaysEnabled) { [description appendString:@", always-enabled"]; } - if (input_edge.options & AGInputOptionsUnprefetched) { // TODO: check is not inverse + if (input_edge.options & IAGInputOptionsUnprefetched) { // TODO: check is not inverse [description appendString:@", unprefetched"]; } [description appendString:@"\n"]; @@ -933,7 +933,7 @@ int trap_cycles() { NSArray *Graph::description_stack_nodes(NSDictionary *options) { NSMutableArray *nodes = [NSMutableArray array]; - NSNumber *max_frames_number = [options objectForKeyedSubscript:(__bridge NSString *)AGDescriptionMaxFrames]; + NSNumber *max_frames_number = [options objectForKeyedSubscript:(__bridge NSString *)IAGDescriptionMaxFrames]; int max_frames = max_frames_number ? [max_frames_number unsignedIntValue] : -1; int frame_count = 0; @@ -974,8 +974,8 @@ int trap_cycles() { const AttributeType &type = graph->attribute_type(frame.attribute->type_id()); - AGSetTypeForKey(dictionary, @"self-type", &type.body_metadata()); - AGSetTypeForKey(dictionary, @"value-type", &type.value_metadata()); + IAGSetTypeForKey(dictionary, @"self-type", &type.body_metadata()); + IAGSetTypeForKey(dictionary, @"value-type", &type.value_metadata()); if (!frame.attribute->input_edges().empty()) { NSMutableArray *inputs = [NSMutableArray array]; @@ -996,16 +996,16 @@ int trap_cycles() { if (resolved.attribute().is_node()) { const AttributeType &input_type = graph->attribute_type(resolved.attribute().get_node()->type_id()); - AGSetTypeForKey(input_dictionary, @"self-type", &input_type.body_metadata()); - AGSetTypeForKey(input_dictionary, @"value-type", &input_type.value_metadata()); + IAGSetTypeForKey(input_dictionary, @"self-type", &input_type.body_metadata()); + IAGSetTypeForKey(input_dictionary, @"value-type", &input_type.value_metadata()); } - if (input_edge.options & AGInputOptionsChanged) { + if (input_edge.options & IAGInputOptionsChanged) { input_dictionary[@"changed"] = @YES; } - if (input_edge.options & AGInputOptionsAlwaysEnabled) { + if (input_edge.options & IAGInputOptionsAlwaysEnabled) { input_dictionary[@"always-enabled"] = @YES; } - if (!(input_edge.options & AGInputOptionsUnprefetched)) { // TODO: check is inverses + if (!(input_edge.options & IAGInputOptionsUnprefetched)) { // TODO: check is inverses input_dictionary[@"prefetched"] = @NO; } @@ -1027,8 +1027,8 @@ int trap_cycles() { void Graph::write_to_file(Graph *graph, const char *_Nullable filename, bool exclude_values) { NSDictionary *options = @{ - (__bridge NSString *)AGDescriptionFormat : @"graph/dict", - (__bridge NSString *)AGDescriptionIncludeValues : @(!exclude_values), + (__bridge NSString *)IAGDescriptionFormat : @"graph/dict", + (__bridge NSString *)IAGDescriptionIncludeValues : @(!exclude_values), @"all_graphs" : @(graph == nullptr) }; NSDictionary *json = (NSDictionary *)description(graph, options); @@ -1065,6 +1065,6 @@ int trap_cycles() { fprintf(stdout, "Wrote graph data to \"%s\".\n", [path UTF8String]); } -} // namespace AG +} // namespace IAG #endif diff --git a/Sources/ComputeCxx/Graph/IAGDescription.mm b/Sources/ComputeCxx/Graph/IAGDescription.mm new file mode 100644 index 00000000..d7ba46d2 --- /dev/null +++ b/Sources/ComputeCxx/Graph/IAGDescription.mm @@ -0,0 +1,8 @@ +#include "ComputeCxx/IAGDescription.h" + +#if TARGET_OS_MAC +const IAGDescriptionOption IAGDescriptionFormat = CFSTR("format"); +const IAGDescriptionOption IAGDescriptionMaxFrames = CFSTR("max-frames"); +const IAGDescriptionOption IAGDescriptionIncludeValues = CFSTR("include-values"); +const IAGDescriptionOption IAGDescriptionTruncationLimit = CFSTR("truncation-limit"); +#endif diff --git a/Sources/ComputeCxx/Graph/AGGraph-Private.h b/Sources/ComputeCxx/Graph/IAGGraph-Private.h similarity index 53% rename from Sources/ComputeCxx/Graph/AGGraph-Private.h rename to Sources/ComputeCxx/Graph/IAGGraph-Private.h index 9cebffc5..0a0be223 100644 --- a/Sources/ComputeCxx/Graph/AGGraph-Private.h +++ b/Sources/ComputeCxx/Graph/IAGGraph-Private.h @@ -1,6 +1,6 @@ #pragma once -#include "ComputeCxx/AGBase.h" +#include "ComputeCxx/IAGBase.h" #if TARGET_OS_MAC #include "CoreFoundationPrivate/CFRuntime.h" @@ -8,14 +8,14 @@ #include #endif -#include "ComputeCxx/AGGraph.h" +#include "ComputeCxx/IAGGraph.h" #include "Graph/Context.h" -AG_ASSUME_NONNULL_BEGIN +IAG_ASSUME_NONNULL_BEGIN -struct AGGraphStorage { +struct IAGGraphStorage { CFRuntimeBase base; - AG::Graph::Context context; + IAG::Graph::Context context; }; -AG_ASSUME_NONNULL_END +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/Graph/IAGGraph.cpp b/Sources/ComputeCxx/Graph/IAGGraph.cpp new file mode 100644 index 00000000..c2f130a1 --- /dev/null +++ b/Sources/ComputeCxx/Graph/IAGGraph.cpp @@ -0,0 +1,1089 @@ +#include "IAGGraph-Private.h" + +#if TARGET_OS_MAC +#include "CoreFoundationPrivate/CFRuntime.h" +#include +#else +#include +#include +#endif + +#include +#include + +#include "Attribute/AttributeData/Node/IndirectNode.h" +#include "Attribute/AttributeID/OffsetAttributeID.h" +#include "Context.h" +#include "Graph.h" +#include "Trace/ExternalTrace.h" +#include "UpdateStack.h" + +namespace { + +CFRuntimeClass &graph_type_id() { + static auto finalize = [](CFTypeRef graph_ref) { + IAGGraphStorage *storage = (IAGGraphRef)graph_ref; + if (!storage->context.invalidated()) { + storage->context.IAG::Graph::Context::~Context(); + } + }; + static CFRuntimeClass klass = { + 0, // version + "IAGGraphStorage", // className + NULL, // init + NULL, // copy + finalize, + NULL, // equal + NULL, // hash + NULL, // copyFormattingDesc + NULL, // copyDebugDesc, + NULL, // reclaim + NULL, // refcount + 0 // requiredAlignment + }; + return klass; +} + +} // namespace + +CFTypeID IAGGraphGetTypeID() { + static CFTypeID type = _CFRuntimeRegisterClass(&graph_type_id()); + return type; +} + +IAGGraphRef IAGGraphCreate() { return IAGGraphCreateShared(nullptr); }; + +IAGGraphRef IAGGraphCreateShared(IAGGraphRef original) { + CFIndex extra_bytes = sizeof(struct IAGGraphStorage) - sizeof(CFRuntimeBase); + IAGGraphRef instance = + (IAGGraphRef)_CFRuntimeCreateInstance(kCFAllocatorDefault, IAGGraphGetTypeID(), extra_bytes, NULL); + if (!instance) { + IAG::precondition_failure("memory allocation failure."); + } + + IAG::Graph *graph; + if (original) { + if (original->context.invalidated()) { + IAG::precondition_failure("invalidated graph"); + } + graph = &original->context.graph(); + IAG::Graph::retain(graph); + } else { + graph = new IAG::Graph(); + } + + new (&instance->context) IAG::Graph::Context(graph); // performs a retain + IAG::Graph::release(graph); + + instance->context.set_invalidated(false); + + return instance; +}; + +IAGUnownedGraphContextRef IAGGraphGetGraphContext(IAGGraphRef graph) { + IAG::Graph::Context *graph_context = IAG::Graph::Context::from_cf(graph); + IAG::Graph *unowned_graph = &graph_context->graph(); + return reinterpret_cast(unowned_graph); +} + +IAGGraphRef IAGGraphContextGetGraph(void *storage) { + auto graph_context = reinterpret_cast(storage); + return graph_context->to_cf(); +} + +void IAGGraphInvalidate(IAGGraphRef graph) { + if (graph->context.invalidated()) { + return; + } + graph->context.~Context(); + graph->context.set_invalidated(true); +} + +#pragma mark - User context + +const void *IAGGraphGetContext(IAGGraphRef graph) { + auto graph_context = IAG::Graph::Context::from_cf(graph); + return graph_context->context(); +} + +void IAGGraphSetContext(IAGGraphRef graph, const void *context) { + auto graph_context = IAG::Graph::Context::from_cf(graph); + graph_context->set_context(context); +} + +#pragma mark - Counter + +uint64_t IAGGraphGetCounter(IAGGraphRef graph, IAGGraphCounterQueryType query) { + auto graph_context = IAG::Graph::Context::from_cf(graph); + switch (query) { + case IAGGraphCounterQueryTypeNodes: + return graph_context->graph().num_nodes(); + case IAGGraphCounterQueryTypeTransactions: + return graph_context->graph().transaction_count(); + case IAGGraphCounterQueryTypeUpdates: + return graph_context->graph().update_count(); + case IAGGraphCounterQueryTypeChanges: + return graph_context->graph().change_count(); + case IAGGraphCounterQueryTypeContextID: + return graph_context->id(); + case IAGGraphCounterQueryTypeGraphID: + return graph_context->graph().id(); + case IAGGraphCounterQueryTypeContextThreadUpdating: + return graph_context->thread_is_updating(); + case IAGGraphCounterQueryTypeThreadUpdating: + return graph_context->graph().thread_is_updating(); + case IAGGraphCounterQueryTypeContextNeedsUpdate: + return graph_context->needs_update(); + case IAGGraphCounterQueryTypeNeedsUpdate: + return graph_context->graph().needs_update(); + case IAGGraphCounterQueryTypeMainThreadUpdates: + return graph_context->graph().main_thread_update_count(); + case IAGGraphCounterQueryTypeCreatedNodes: + return graph_context->graph().num_nodes_total(); + case IAGGraphCounterQueryTypeSubgraphs: + return graph_context->graph().num_subgraphs(); + case IAGGraphCounterQueryTypeCreatedSubgraphs: + return graph_context->graph().num_subgraphs_total(); + default: + return 0; + } +} + +#pragma mark - Main handler + +void IAGGraphWithMainThreadHandler(IAGGraphRef graph, + void (*body)(const void *context IAG_SWIFT_CONTEXT) IAG_SWIFT_CC(swift), + const void *body_context, + void (*main_thread_handler)(void (*trampoline_thunk)(const void *), + const void *trampoline, + const void *context IAG_SWIFT_CONTEXT) IAG_SWIFT_CC(swift), + const void *main_thread_handler_context) { + auto graph_context = IAG::Graph::Context::from_cf(graph); + graph_context->graph().with_main_handler(IAG::ClosureFunctionVV(body, body_context), main_thread_handler, + main_thread_handler_context); +} + +#pragma mark - Subgraph + +bool IAGGraphBeginDeferringSubgraphInvalidation(IAGGraphRef graph) { + auto graph_context = IAG::Graph::Context::from_cf(graph); + return graph_context->graph().begin_deferring_subgraph_invalidation(); +} + +void IAGGraphEndDeferringSubgraphInvalidation(IAGGraphRef graph, bool was_deferring) { + auto graph_context = IAG::Graph::Context::from_cf(graph); + graph_context->graph().end_deferring_subgraph_invalidation(was_deferring); +} + +#pragma mark - Attribute types + +uint32_t IAGGraphInternAttributeType(IAGUnownedGraphContextRef unowned_graph, IAGTypeID type, + const IAGAttributeType *(*make_attribute_type)(const void *context IAG_SWIFT_CONTEXT) + IAG_SWIFT_CC(swift), + const void *make_attribute_type_context) { + auto metadata = reinterpret_cast(type); + IAG::Graph *graph = reinterpret_cast(unowned_graph); + return graph->intern_type( + metadata, IAG::ClosureFunctionVP(make_attribute_type, make_attribute_type_context)); +} + +void IAGGraphVerifyType(IAGAttribute attribute, IAGTypeID type) { + auto attribute_id = IAG::AttributeID(attribute); + attribute_id.validate_data_offset(); + + auto subgraph = attribute_id.subgraph(); + if (!subgraph) { + IAG::precondition_failure("no graph: %u", attribute); + } + + if (auto node = attribute_id.get_node()) { + auto metadata = reinterpret_cast(type); + auto attribute_type = subgraph->graph()->attribute_type(node->type_id()); + if (&attribute_type.value_metadata() != metadata) { + IAG::precondition_failure("type check failed: %u, expected %s, got %s", attribute, metadata->name(false), + attribute_type.value_metadata().name(false)); + } + } +} + +#pragma mark - Attributes + +IAGAttribute IAGGraphCreateAttribute(uint32_t type_id, const void *body, const void *_Nullable value) { + auto subgraph = IAG::Subgraph::current_subgraph(); + if (!subgraph) { + IAG::precondition_failure("no subgraph active while adding attribute"); + } + auto node = subgraph->graph()->add_attribute(*subgraph, type_id, body, value); + return IAGAttribute(IAG::AttributeID(node)); +} + +IAGGraphRef IAGGraphGetAttributeGraph(IAGAttribute attribute) { + auto attribute_id = IAG::AttributeID(attribute); + attribute_id.validate_data_offset(); + + if (auto subgraph = attribute_id.subgraph()) { + if (auto context_id = subgraph->context_id()) { + if (auto context = subgraph->graph()->context_with_id(context_id)) { + return context->to_cf(); + } + } + } + IAG::precondition_failure("no graph: %u", attribute); +} + +IAGAttributeInfo IAGGraphGetAttributeInfo(IAGAttribute attribute) { + auto attribute_id = IAG::AttributeID(attribute); + auto node = attribute_id.get_node(); + if (!node) { + IAG::precondition_failure("non-direct attribute id: %u", attribute); + } + + node.assert_valid(); + + auto subgraph = attribute_id.subgraph(); + if (!subgraph) { + IAG::precondition_failure("no graph: %u", attribute); + } + + const void *body = nullptr; + const IAG::AttributeType &type = subgraph->graph()->attribute_ref(node, &body); + return IAGAttributeInfo(reinterpret_cast(&type), body); +} + +IAGAttributeFlags IAGGraphGetFlags(IAGAttribute attribute) { + auto attribute_id = IAG::AttributeID(attribute); + auto node = attribute_id.get_node(); + if (!node) { + IAG::precondition_failure("non-direct attribute id: %u", attribute); + } + + return node->subgraph_flags(); +} + +void IAGGraphSetFlags(IAGAttribute attribute, IAGAttributeFlags flags) { + auto attribute_id = IAG::AttributeID(attribute); + auto node = attribute_id.get_node(); + if (!node) { + IAG::precondition_failure("non-direct attribute id: %u", attribute); + } + + attribute_id.subgraph()->set_flags(node, flags); +} + +uint32_t IAGGraphAddInput(IAGAttribute attribute, IAGAttribute input, IAGInputOptions options) { + auto attribute_id = IAG::AttributeID(attribute); + auto node = attribute_id.get_node(); + if (!node) { + IAG::precondition_failure("non-direct attribute id: %u", attribute); + } + node.assert_valid(); + + auto subgraph = attribute_id.subgraph(); + if (!subgraph) { + IAG::precondition_failure("no graph: %u", attribute); + } + + auto input_attribute_id = IAG::AttributeID(input); + input_attribute_id.validate_data_offset(); + + if (input_attribute_id.subgraph() != nullptr && input_attribute_id.subgraph()->graph() != subgraph->graph()) { + IAG::precondition_failure("accessing attribute in a different namespace: %u", input); + } + + return subgraph->graph()->add_input(node, input_attribute_id, false, options); +} + +#pragma mark - Offset attributes + +namespace { + +IAG::AttributeID create_offset_attribute(IAG::AttributeID attribute_id, uint32_t offset, std::optional size) { + if (offset == 0) { + if (size.has_value() && attribute_id.is_indirect_node()) { + auto calculated_size = attribute_id.size(); + if (calculated_size.has_value() && calculated_size.value() == size.value()) { + return attribute_id; + } + } + } else if (offset > IAG::IndirectNode::MaximumOffset) { + IAG::precondition_failure("invalid offset: %u, %lu", offset, size.value()); + } + + auto current_subgraph = IAG::Subgraph::current_subgraph(); + if (!current_subgraph) { + IAG::precondition_failure("no subgraph active while adding attribute"); + } + + IAG::data::ptr indirect_node = + current_subgraph->graph()->add_indirect_attribute(*current_subgraph, attribute_id, offset, size, false); + return IAG::AttributeID(indirect_node); +} + +} // namespace + +IAGAttribute IAGGraphCreateOffsetAttribute(IAGAttribute attribute, uint32_t offset) { + auto attribute_id = IAG::AttributeID(attribute); + return create_offset_attribute(attribute_id, offset, std::optional()); +} + +IAGAttribute IAGGraphCreateOffsetAttribute2(IAGAttribute attribute, uint32_t offset, size_t size) { + auto attribute_id = IAG::AttributeID(attribute); + return create_offset_attribute(attribute_id, offset, std::optional(size)); +} + +#pragma mark - Indirect attributes + +namespace { + +IAG::AttributeID create_indirect_attribute(IAG::AttributeID attribute_id, std::optional size) { + auto current_subgraph = IAG::Subgraph::current_subgraph(); + if (!current_subgraph) { + IAG::precondition_failure("no subgraph active while making indirection"); + } + + IAG::data::ptr indirect_node = + current_subgraph->graph()->add_indirect_attribute(*current_subgraph, attribute_id, 0, size, true); + return IAG::AttributeID(indirect_node); +} + +} // namespace + +IAGAttribute IAGGraphCreateIndirectAttribute(IAGAttribute attribute) { + auto attribute_id = IAG::AttributeID(attribute); + return create_indirect_attribute(attribute_id, std::optional()); +} + +IAGAttribute IAGGraphCreateIndirectAttribute2(IAGAttribute attribute, size_t size) { + auto attribute_id = IAG::AttributeID(attribute); + return create_indirect_attribute(attribute_id, std::optional(size)); +} + +IAGAttribute IAGGraphGetIndirectAttribute(IAGAttribute attribute) { + auto attribute_id = IAG::AttributeID(attribute); + if (auto indirect_node = attribute_id.get_indirect_node()) { + return indirect_node->source().identifier(); + } + return attribute_id; +} + +void IAGGraphSetIndirectAttribute(IAGAttribute attribute, IAGAttribute source) { + auto attribute_id = IAG::AttributeID(attribute); + auto indirect_node = attribute_id.get_indirect_node(); + if (!indirect_node || !attribute_id.subgraph()) { + IAG::precondition_failure("invalid indirect attribute: %u", attribute); + } + + auto source_id = IAG::AttributeID(source); + if (source_id.is_nil()) { + attribute_id.subgraph()->graph()->indirect_attribute_reset(indirect_node, false); + } else { + attribute_id.subgraph()->graph()->indirect_attribute_set(indirect_node, source_id); + } +} + +void IAGGraphResetIndirectAttribute(IAGAttribute attribute, bool non_nil) { + auto attribute_id = IAG::AttributeID(attribute); + auto indirect_node = attribute_id.get_indirect_node(); + if (!indirect_node || !attribute_id.subgraph()) { + IAG::precondition_failure("invalid indirect attribute: %u", attribute); + } + + attribute_id.subgraph()->graph()->indirect_attribute_reset(indirect_node, non_nil); +} + +IAGAttribute IAGGraphGetIndirectDependency(IAGAttribute attribute) { + auto attribute_id = IAG::AttributeID(attribute); + auto indirect_node = attribute_id.get_indirect_node(); + if (!indirect_node || !attribute_id.subgraph()) { + IAG::precondition_failure("invalid indirect attribute: %u", attribute); + } + + return attribute_id.subgraph()->graph()->indirect_attribute_dependency(indirect_node); +} + +void IAGGraphSetIndirectDependency(IAGAttribute attribute, IAGAttribute dependency) { + auto attribute_id = IAG::AttributeID(attribute); + auto indirect_node = attribute_id.get_indirect_node(); + if (!indirect_node || !attribute_id.subgraph()) { + IAG::precondition_failure("invalid indirect attribute: %u", attribute); + } + + return attribute_id.subgraph()->graph()->indirect_attribute_set_dependency(indirect_node, + IAG::AttributeID(dependency)); +} + +#pragma mark - Search + +bool IAGGraphSearch(IAGAttribute attribute, IAGSearchOptions options, + bool (*predicate)(IAGAttribute attribute, const void *context IAG_SWIFT_CONTEXT) IAG_SWIFT_CC(swift), + const void *predicate_context) { + auto attribute_id = IAG::AttributeID(attribute); + attribute_id.validate_data_offset(); + + auto subgraph = attribute_id.subgraph(); + if (!subgraph) { + IAG::precondition_failure("no graph: %u", attribute); + } + + return subgraph->graph()->breadth_first_search( + attribute_id, options, IAG::ClosureFunctionAB(predicate, predicate_context)); +} + +#pragma mark - Body + +void IAGGraphMutateAttribute(IAGAttribute attribute, IAGTypeID type, bool invalidating, + void (*modify)(void *body, const void *context IAG_SWIFT_CONTEXT) IAG_SWIFT_CC(swift), + const void *modify_context) { + auto attribute_id = IAG::AttributeID(attribute); + auto node = attribute_id.get_node(); + if (!node) { + IAG::precondition_failure("non-direct attribute id: %u", attribute); + } + attribute_id.validate_data_offset(); + + auto subgraph = attribute_id.subgraph(); + if (!subgraph) { + IAG::precondition_failure("no graph: %u", attribute); + } + + subgraph->graph()->attribute_modify(node, *reinterpret_cast(type), + IAG::ClosureFunctionPV(modify, modify_context), invalidating); +} + +#pragma mark - Value + +namespace { + +inline IAGChangedValue get_value(IAG::AttributeID attribute_id, uint32_t seed, IAGValueOptions options, + const IAG::swift::metadata &metadata) { + if (!(options & IAGValueOptionsIncrementGraphVersion)) { + auto update_ptr = IAG::Graph::current_update(); + if (update_ptr.tag() == 0 && update_ptr.get() != nullptr) { + auto &update = *update_ptr.get(); + + auto graph = update.graph(); + auto &frame = update.frames().back(); + + IAGChangedValueFlags flags = 0; + void *value = graph->input_value_ref(frame.attribute, attribute_id, seed, + options & IAGValueOptionsInputOptionsMask, metadata, &flags); + return {value, flags}; + } + } + + attribute_id.validate_data_offset(); + + auto subgraph = attribute_id.subgraph(); + if (!subgraph) { + IAG::precondition_failure("no graph: %u", attribute_id); + } + + IAGChangedValueFlags flags = 0; + void *value = subgraph->graph()->value_ref(attribute_id, seed, metadata, &flags); + return {value, flags}; +} + +} // namespace + +IAGChangedValue IAGGraphGetValue(IAGAttribute attribute, IAGValueOptions options, IAGTypeID type) { + auto attribute_id = IAG::AttributeID(attribute); + auto metadata = reinterpret_cast(type); + return get_value(attribute_id, 0, options, *metadata); +} + +IAGWeakChangedValue IAGGraphGetWeakValue(IAGWeakAttribute attribute, IAGValueOptions options, IAGTypeID type) { + auto weak_attribute_id = IAG::WeakAttributeID(attribute); + auto attribute_id = weak_attribute_id.evaluate(); + if (attribute_id.is_nil()) { + return {nullptr, false}; + } + + auto metadata = reinterpret_cast(type); + auto value = get_value(attribute_id, weak_attribute_id.seed(), options, *metadata); + return *reinterpret_cast(&value); +} + +IAGChangedValue IAGGraphGetInputValue(IAGAttribute attribute, IAGAttribute input, IAGValueOptions options, IAGTypeID type) { + auto attribute_id = IAG::AttributeID(attribute); + if (options & IAGValueOptionsIncrementGraphVersion || attribute_id.is_nil()) { + return IAGGraphGetValue(input, options, type); + } + + auto node = attribute_id.get_node(); + if (!node) { + IAG::precondition_failure("non-direct attribute id: %u", attribute); + } + attribute_id.validate_data_offset(); + + auto subgraph = attribute_id.subgraph(); + if (!subgraph) { + IAG::precondition_failure("no graph: %u", attribute); + } + + auto input_id = IAG::AttributeID(input); + auto metadata = reinterpret_cast(type); + + IAGChangedValueFlags flags = 0; + void *value = subgraph->graph()->input_value_ref(attribute, input_id, 0, options & IAGValueOptionsInputOptionsMask, + *metadata, &flags); + return {value, flags}; +} + +bool IAGGraphSetValue(IAGAttribute attribute, const void *value, IAGTypeID type) { + auto attribute_id = IAG::AttributeID(attribute); + auto node = attribute_id.get_node(); + if (!node) { + IAG::precondition_failure("non-direct attribute id: %u", attribute); + } + attribute_id.validate_data_offset(); + + auto subgraph = attribute_id.subgraph(); + if (!subgraph) { + IAG::precondition_failure("no graph: %u", attribute); + } + + auto metadata = reinterpret_cast(type); + return subgraph->graph()->value_set(attribute_id.get_node(), *metadata, value); +} + +bool IAGGraphHasValue(IAGAttribute attribute) { + auto attribute_id = IAG::AttributeID(attribute); + auto node = attribute_id.get_node(); + if (!node) { + IAG::precondition_failure("non-direct attribute id: %u", attribute); + } + attribute_id.validate_data_offset(); + + auto subgraph = attribute_id.subgraph(); + if (!subgraph) { + IAG::precondition_failure("no graph: %u", attribute); + } + + return subgraph->graph()->value_exists(attribute_id.get_node()); +} + +IAGValueState IAGGraphGetValueState(IAGAttribute attribute) { + auto attribute_id = IAG::AttributeID(attribute); + attribute_id.validate_data_offset(); + + auto subgraph = attribute_id.subgraph(); + if (!subgraph) { + IAG::precondition_failure("no graph: %u", attribute); + } + + return subgraph->graph()->value_state(attribute_id); +} + +void IAGGraphUpdateValue(IAGAttribute attribute, IAGGraphUpdateOptions options) { + auto attribute_id = IAG::AttributeID(attribute); + auto node = attribute_id.get_node(); + if (!node) { + IAG::precondition_failure("non-direct attribute id: %u", attribute); + } + + node.assert_valid(); + + auto subgraph = attribute_id.subgraph(); + if (!subgraph) { + IAG::precondition_failure("no graph: %u", attribute); + } + + subgraph->graph()->update_attribute(node, options); +} + +uint32_t IAGGraphPrefetchValue(IAGAttribute attribute) { + auto attribute_id = IAG::AttributeID(attribute); + attribute_id.validate_data_offset(); + + auto subgraph = attribute_id.subgraph(); + if (!subgraph) { + IAG::precondition_failure("no graph: %u", attribute); + } + + if (subgraph->graph()->passed_deadline()) { + return IAGGraphUpdateStatusChanged; + } + + auto resolved = attribute_id.resolve(IAG::TraversalOptions::AssertNotNil); + return (uint32_t)subgraph->graph()->update_attribute( + resolved.attribute().get_node(), + IAGGraphUpdateOptions(IAGGraphUpdateOptionsAbortIfCancelled | IAGGraphUpdateOptionsCancelIfPassedDeadline)); +} + +void IAGGraphInvalidateValue(IAGAttribute attribute) { + auto attribute_id = IAG::AttributeID(attribute); + auto node = attribute_id.get_node(); + if (!node) { + IAG::precondition_failure("non-direct attribute id: %u", attribute); + } + attribute_id.validate_data_offset(); + + auto subgraph = attribute_id.subgraph(); + if (!subgraph) { + IAG::precondition_failure("no graph: %u", attribute); + } + + subgraph->graph()->value_mark(node); +} + +void IAGGraphInvalidateAllValues(IAGGraphRef graph) { + auto graph_context = IAG::Graph::Context::from_cf(graph); + graph_context->graph().value_mark_all(); +} + +void IAGGraphSetInvalidationCallback(IAGGraphRef graph, + void (*callback)(IAGAttribute, const void *context IAG_SWIFT_CONTEXT) + IAG_SWIFT_CC(swift), + const void *callback_context) { + auto graph_context = IAG::Graph::Context::from_cf(graph); + graph_context->set_invalidation_callback(IAG::ClosureFunctionAV(callback, callback_context)); +} + +#pragma mark - Cached value + +namespace { + +void *read_cached_attribute(size_t hash, const IAG::swift::metadata &metadata, const void *body, + const IAG::swift::metadata &value_metadata, IAGCachedValueOptions options, + IAG::AttributeID owner_id, IAGChangedValueFlags *flags_out, + IAG::ClosureFunctionCI get_attribute_type_id) { + auto update = IAG::Graph::current_update(); + auto update_stack = update.tag() == 0 ? update.get() : nullptr; + + IAG::Subgraph *subgraph = nullptr; + if (owner_id && !owner_id.is_nil()) { + owner_id.validate_data_offset(); + subgraph = owner_id.subgraph(); + } else { + if (update_stack != nullptr) { + subgraph = IAG::AttributeID(update_stack->frames().back().attribute).subgraph(); + } else { + subgraph = IAG::Subgraph::current_subgraph(); + } + } + if (subgraph == nullptr) { + IAG::precondition_failure("no subgraph"); + } + + IAG::data::ptr cached_node = subgraph->cache_fetch(hash, metadata, body, get_attribute_type_id); + if (cached_node == nullptr) { + return nullptr; + } + + if (update_stack == nullptr) { + void *value = subgraph->graph()->value_ref(IAG::AttributeID(cached_node), 0, value_metadata, flags_out); + subgraph->cache_insert(cached_node); // TODO: when this becomes an input, is it removed from cache? + return value; + } + + IAGInputOptions input_options = options & IAGCachedValueOptionsUnprefetched ? IAGInputOptionsUnprefetched : IAGInputOptionsNone; + return subgraph->graph()->input_value_ref(update_stack->frames().back().attribute, IAG::AttributeID(cached_node), 0, + input_options, value_metadata, flags_out); +} + +} // namespace + +void *IAGGraphReadCachedAttribute(size_t hash, IAGTypeID type, const void *body, IAGTypeID value_type, + IAGCachedValueOptions options, IAGAttribute owner, bool *_Nullable changed_out, + uint32_t (*closure)(IAGUnownedGraphContextRef graph_context, + const void *context IAG_SWIFT_CONTEXT) IAG_SWIFT_CC(swift), + const void *closure_context) { + auto metadata = reinterpret_cast(type); + auto value_metadata = reinterpret_cast(value_type); + auto owner_id = IAG::AttributeID(owner); + + IAGChangedValueFlags flags = 0; + void *value = + read_cached_attribute(hash, *metadata, body, *value_metadata, options, owner_id, &flags, + IAG::ClosureFunctionCI(closure, closure_context)); + if (changed_out) { + *changed_out = flags & IAGChangedValueFlagsChanged ? true : false; + } + return value; +} + +void *IAGGraphReadCachedAttributeIfExists(size_t hash, IAGTypeID type, const void *body, IAGTypeID value_type, + IAGCachedValueOptions options, IAGAttribute owner, bool *_Nullable changed_out) { + + auto metadata = reinterpret_cast(type); + auto value_metadata = reinterpret_cast(value_type); + auto owner_id = IAG::AttributeID(owner); + + IAGChangedValueFlags flags = 0; + void *value = read_cached_attribute(hash, *metadata, body, *value_metadata, options, owner_id, &flags, nullptr); + if (changed_out) { + *changed_out = flags & IAGChangedValueFlagsChanged ? true : false; + } + return value; +} + +#pragma mark - Update + +void IAGGraphSetUpdate(const void *update) { + IAG::Graph::set_current_update(util::tagged_ptr((IAG::Graph::UpdateStack *)update)); +} + +const void *IAGGraphClearUpdate() { + auto update = IAG::Graph::current_update(); + if (update != nullptr && update.tag() == 0) { + IAG::Graph::set_current_update(update.with_tag(true)); + } + return (const void *)update.value(); +} + +void IAGGraphCancelUpdate() { + auto update = IAG::Graph::current_update().get(); + if (update == nullptr) { + IAG::precondition_failure("no attribute updating"); + } + + IAG::Graph::UpdateStack::cancel(); +} + +bool IAGGraphCancelUpdateIfNeeded() { + auto update = IAG::Graph::current_update().get(); + if (update == nullptr) { + IAG::precondition_failure("no attribute updating"); + } + + if (update->cancelled()) { + return true; + } + + if (update->graph()->passed_deadline()) { + update->cancel(); + return true; + } + + return false; +} + +bool IAGGraphUpdateWasCancelled() { + auto update = IAG::Graph::current_update(); + if (update.tag() != 0 || update.get() == nullptr) { + IAG::precondition_failure("no attribute updating"); + } + + return update.get()->cancelled(); +} + +uint64_t IAGGraphGetDeadline(IAGGraphRef graph) { + auto graph_context = IAG::Graph::Context::from_cf(graph); + return graph_context->deadline(); +} + +void IAGGraphSetDeadline(IAGGraphRef graph, uint64_t deadline) { + auto graph_context = IAG::Graph::Context::from_cf(graph); + graph_context->set_deadline(deadline); +} + +bool IAGGraphHasDeadlinePassed() { + auto update = IAG::Graph::current_update().get(); + if (update != nullptr) { + return update->graph()->passed_deadline(); + } + return false; +} + +void IAGGraphSetNeedsUpdate(IAGGraphRef graph) { + auto graph_context = IAG::Graph::Context::from_cf(graph); + graph_context->set_needs_update(); +} + +void IAGGraphWithUpdate(IAGAttribute attribute, void (*body)(const void *context IAG_SWIFT_CONTEXT) IAG_SWIFT_CC(swift), + const void *body_context) { + auto attribute_id = IAG::AttributeID(attribute); + if (!attribute_id || attribute_id.is_nil()) { + // TODO: check + IAGGraphWithoutUpdate(body, body_context); + return; + } + + auto node = attribute_id.get_node(); + if (!node) { + IAG::precondition_failure("non-direct attribute id: %u", attribute); + } + attribute_id.validate_data_offset(); + + auto subgraph = attribute_id.subgraph(); + if (!subgraph) { + IAG::precondition_failure("no graph: %u", attribute); + } + + subgraph->graph()->with_update(node, IAG::ClosureFunctionVV(body, body_context)); +} + +void IAGGraphWithoutUpdate(void (*body)(const void *context IAG_SWIFT_CONTEXT) IAG_SWIFT_CC(swift), + const void *body_context) { + IAG::Graph::without_update(IAG::ClosureFunctionVV(body, body_context)); +} + +void IAGGraphSetUpdateCallback(IAGGraphRef graph, + void (*callback)(const void *context IAG_SWIFT_CONTEXT) IAG_SWIFT_CC(swift), + const void *callback_context) { + auto graph_context = IAG::Graph::Context::from_cf(graph); + graph_context->set_update_callback(IAG::ClosureFunctionVV(callback, callback_context)); +} + +IAGAttribute IAGGraphGetCurrentAttribute() { + auto update_ptr = IAG::Graph::current_update(); + if (update_ptr.tag() != 0 || update_ptr.get() == nullptr) { + return IAGAttributeNil; + } + + auto &update = *update_ptr.get(); + if (update.frames().empty()) { + return IAGAttributeNil; + } + auto &frame = update.frames().back(); + if (!frame.attribute) { + return IAGAttributeNil; + } + + return IAGAttribute(IAG::AttributeID(frame.attribute)); +} + +bool IAGGraphCurrentAttributeWasModified() { + auto update_ptr = IAG::Graph::current_update(); + if (update_ptr.tag() != 0 || update_ptr.get() == nullptr) { + return false; + } + + auto &update = *update_ptr.get(); + auto &frame = update.frames().back(); + if (!frame.attribute) { + return false; + } + + return frame.attribute->is_self_modified(); +} + +bool IAGGraphAnyInputsChanged(const IAGAttribute *exclude_attributes, size_t exclude_attributes_count) { + auto update = IAG::Graph::current_update(); + if (update.tag() != 0 || update.get() == nullptr) { + IAG::precondition_failure("no attribute updating"); + } + + auto &frame = update.get()->frames().back(); + return update.get()->graph()->any_inputs_changed( + frame.attribute, reinterpret_cast(exclude_attributes), exclude_attributes_count); +} + +void *IAGGraphGetOutputValue(IAGTypeID type) { + auto update_ptr = IAG::Graph::current_update(); + if (update_ptr.tag() != 0 || update_ptr.get() == nullptr) { + IAG::precondition_failure("no attribute updating"); + } + + auto &update = *update_ptr.get(); + auto &frame = update.frames().back(); + auto graph = update.graph(); + auto metadata = reinterpret_cast(type); + return graph->output_value_ref(frame.attribute, *metadata); +} + +void IAGGraphSetOutputValue(const void *value, IAGTypeID type) { + auto update_ptr = IAG::Graph::current_update(); + if (update_ptr.tag() != 0 || update_ptr.get() == nullptr) { + IAG::precondition_failure("no attribute updating"); + } + + auto &update = *update_ptr.get(); + auto &frame = update.frames().back(); + if (!frame.attribute->is_updating()) { + IAG::precondition_failure("writing attribute that is not evaluating: %", frame.attribute); + } + + auto graph = update.graph(); + auto metadata = reinterpret_cast(type); + graph->value_set_internal(frame.attribute, *frame.attribute.get(), value, *metadata); +} + +#pragma mark - Trace + +void IAGGraphStartTracing(IAGGraphRef graph, IAGGraphTraceOptions trace_options) { IAGGraphStartTracing2(graph, trace_options, NULL); } + +void IAGGraphStartTracing2(IAGGraphRef graph, IAGGraphTraceOptions trace_options, CFArrayRef subsystems) { + auto subsystems_vector = IAG::vector, 0, uint64_t>(); + if (subsystems) { + auto subsystems_count = CFArrayGetCount(subsystems); + for (CFIndex index = 0; index < subsystems_count; ++index) { + CFTypeRef value = CFArrayGetValueAtIndex(subsystems, index); + if (CFGetTypeID(value) != CFStringGetTypeID()) { + continue; + } + + CFIndex length = CFStringGetLength((CFStringRef)value); + CFIndex bufferSize = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8) + 1; + char *subsystem = (char *)malloc(bufferSize); + if (CFStringGetCString((CFStringRef)value, subsystem, bufferSize, kCFStringEncodingUTF8)) { + subsystems_vector.push_back(std::unique_ptr(subsystem)); + } else { + free(subsystem); + } + } + } + + std::span subsystems_span = + std::span((const char **)subsystems_vector.data(), subsystems_vector.size()); + + if (graph == nullptr) { + IAG::Graph::all_start_tracing(trace_options, subsystems_span); + return; + } + + auto graph_context = IAG::Graph::Context::from_cf(graph); + graph_context->graph().start_tracing(trace_options, subsystems_span); +} + +void IAGGraphStopTracing(IAGGraphRef graph) { + if (graph == nullptr) { + IAG::Graph::all_stop_tracing(); + return; + } + + auto graph_context = IAG::Graph::Context::from_cf(graph); + graph_context->graph().stop_tracing(); +} + +void IAGGraphSyncTracing(IAGGraphRef graph) { + if (graph == nullptr) { + IAG::Graph::all_sync_tracing(); + return; + } + + auto graph_context = IAG::Graph::Context::from_cf(graph); + graph_context->graph().sync_tracing(); +} + +CFStringRef IAGGraphCopyTracePath(IAGGraphRef graph) { + if (graph == nullptr) { + return IAG::Graph::all_copy_trace_path(); + } + + auto graph_context = IAG::Graph::Context::from_cf(graph); + return graph_context->graph().copy_trace_path(); +} + +uint64_t IAGGraphAddTrace(IAGGraphRef graph, const IAGTraceTypeRef trace, void *context) { + auto graph_context = IAG::Graph::Context::from_cf(graph); + auto external_trace = new ExternalTrace(trace, context); + graph_context->graph().add_trace(external_trace); + return external_trace->id(); +} + +void IAGGraphRemoveTrace(IAGGraphRef graph, uint64_t trace_id) { + auto graph_context = IAG::Graph::Context::from_cf(graph); + graph_context->graph().remove_trace(trace_id); +} + +void IAGGraphSetTrace(IAGGraphRef graph, const IAGTraceTypeRef trace, void *context) { + auto graph_context = IAG::Graph::Context::from_cf(graph); + graph_context->graph().remove_trace(0); + + auto external_trace = new ExternalTrace(0, trace, context); + graph_context->graph().add_trace(external_trace); +} + +void IAGGraphResetTrace(IAGGraphRef graph) { + auto graph_context = IAG::Graph::Context::from_cf(graph); + graph_context->graph().remove_trace(0); +} + +bool IAGGraphIsTracingActive(IAGGraphRef graph) { + auto graph_context = IAG::Graph::Context::from_cf(graph); + return graph_context->graph().traces().size() > 0; +} + +void IAGGraphPrepareTrace(IAGGraphRef graph, const IAGTraceTypeRef trace, void *context) { + auto graph_context = IAG::Graph::Context::from_cf(graph); + auto external_trace = new ExternalTrace(trace, context); + graph_context->graph().prepare_trace(*external_trace); +} + +bool IAGGraphTraceEventEnabled(IAGGraphRef graph, uint32_t event_id) { + auto graph_context = IAG::Graph::Context::from_cf(graph); + for (auto trace : graph_context->graph().traces()) { + if (trace->named_event_enabled(event_id)) { + return true; + } + } + return false; +} + +void IAGGraphAddTraceEvent(IAGGraphRef graph, const char *event_name, const void *value, IAGTypeID type) { + auto graph_context = IAG::Graph::Context::from_cf(graph); + graph_context->graph().foreach_trace([&graph_context, &event_name, &value, &type](IAG::Trace &trace) { + trace.custom_event(*graph_context, event_name, value, *reinterpret_cast(type)); + }); +} + +void IAGGraphAddNamedTraceEvent(IAGGraphRef graph, uint32_t event_id, uint32_t event_arg_count, const void *event_args, + CFDataRef data, uint32_t arg6) { + auto graph_context = IAG::Graph::Context::from_cf(graph); + graph_context->graph().foreach_trace( + [&graph_context, &event_id, &event_arg_count, &event_args, &data, &arg6](IAG::Trace &trace) { + trace.named_event(*graph_context, event_id, event_arg_count, event_args, data, arg6); + }); +} + +namespace NamedEvents { + +static platform_lock lock = PLATFORM_LOCK_INIT; +static IAG::vector, 0, uint32_t> *names; + +} // namespace NamedEvents + +const char *IAGGraphGetTraceEventName(uint32_t event_id) { + const char *event_name = nullptr; + + platform_lock_lock(&NamedEvents::lock); + if (NamedEvents::names != nullptr && event_id < NamedEvents::names->size()) { + event_name = (*NamedEvents::names)[event_id].second; + } + platform_lock_unlock(&NamedEvents::lock); + + return event_name; +} + +const char *IAGGraphGetTraceEventSubsystem(uint32_t event_id) { + const char *event_subsystem = nullptr; + + platform_lock_lock(&NamedEvents::lock); + if (NamedEvents::names != nullptr && event_id < NamedEvents::names->size()) { + event_subsystem = (*NamedEvents::names)[event_id].first; + } + platform_lock_unlock(&NamedEvents::lock); + + return event_subsystem; +} + +uint32_t IAGGraphRegisterNamedTraceEvent(const char *event_name, const char *event_subsystem) { + platform_lock_lock(&NamedEvents::lock); + + if (!NamedEvents::names) { + NamedEvents::names = new IAG::vector, 0, uint32_t>(); + NamedEvents::names->push_back({0, 0}); // Disallow 0 as event ID + } + + uint32_t event_id = NamedEvents::names->size(); + if (event_subsystem != nullptr) { + event_subsystem = strdup(event_subsystem); + } + event_name = strdup(event_name); + NamedEvents::names->push_back({event_subsystem, event_name}); + + platform_lock_unlock(&NamedEvents::lock); + + return event_id; +} + +// MARK: Description + +#if TARGET_OS_MAC +void IAGGraphArchiveJSON(const char *filename) { IAG::Graph::write_to_file(nullptr, filename, false); } + +void IAGGraphArchiveJSON2(const char *filename, bool exclude_values) { + IAG::Graph::write_to_file(nullptr, filename, exclude_values); +} +#endif diff --git a/Sources/ComputeCxx/Graph/IAGGraph.mm b/Sources/ComputeCxx/Graph/IAGGraph.mm new file mode 100644 index 00000000..ceaf7785 --- /dev/null +++ b/Sources/ComputeCxx/Graph/IAGGraph.mm @@ -0,0 +1,24 @@ +#include "IAGGraph-Private.h" + +#if TARGET_OS_MAC + +#import + +#include "Context.h" +#include "Graph.h" + +#pragma mark - Description + +CFTypeRef IAGGraphDescription(IAGGraphRef graph, CFDictionaryRef options) { + if (graph == nullptr) { + return (__bridge CFTypeRef)IAG::Graph::description(nullptr, (__bridge NSDictionary *)options); + } + + auto graph_context = IAG::Graph::Context::from_cf(graph); + if (graph_context->invalidated()) { + IAG::precondition_failure("invalidated graph"); + } + return (__bridge CFTypeRef)IAG::Graph::description(&graph_context->graph(), (__bridge NSDictionary *)options); +} + +#endif diff --git a/Sources/ComputeCxx/Graph/KeyTable.cpp b/Sources/ComputeCxx/Graph/KeyTable.cpp index 560bf884..d4f44367 100644 --- a/Sources/ComputeCxx/Graph/KeyTable.cpp +++ b/Sources/ComputeCxx/Graph/KeyTable.cpp @@ -1,6 +1,6 @@ #include "KeyTable.h" -namespace AG { +namespace IAG { Graph::KeyTable::KeyTable(util::Heap *_Nullable heap) : _table( @@ -26,4 +26,4 @@ uint32_t Graph::KeyTable::insert(const char *key) { const char *Graph::KeyTable::get(uint32_t key_id) { return _keys[key_id]; } -}; // namespace AG +}; // namespace IAG diff --git a/Sources/ComputeCxx/Graph/KeyTable.h b/Sources/ComputeCxx/Graph/KeyTable.h index e925fbb6..5978ede8 100644 --- a/Sources/ComputeCxx/Graph/KeyTable.h +++ b/Sources/ComputeCxx/Graph/KeyTable.h @@ -2,12 +2,12 @@ #include -#include "ComputeCxx/AGBase.h" +#include "ComputeCxx/IAGBase.h" #include "Graph.h" -AG_ASSUME_NONNULL_BEGIN +IAG_ASSUME_NONNULL_BEGIN -namespace AG { +namespace IAG { class Graph::KeyTable { private: @@ -25,6 +25,6 @@ class Graph::KeyTable { uint32_t insert(const char *key); }; -} // namespace AG +} // namespace IAG -AG_ASSUME_NONNULL_END +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/Graph/TraceRecorder.cpp b/Sources/ComputeCxx/Graph/TraceRecorder.cpp index 9e1631bf..13ebe072 100644 --- a/Sources/ComputeCxx/Graph/TraceRecorder.cpp +++ b/Sources/ComputeCxx/Graph/TraceRecorder.cpp @@ -5,17 +5,17 @@ #include "Attribute/AttributeData/Node/IndirectNode.h" #include "Attribute/AttributeType/AttributeType.h" -#include "ComputeCxx/AGGraph.h" -#include "ComputeCxx/AGGraphTracing.h" -#include "ComputeCxx/AGUniqueID.h" +#include "ComputeCxx/IAGGraph.h" +#include "ComputeCxx/IAGGraphTracing.h" +#include "ComputeCxx/IAGUniqueID.h" #include "Context.h" #include "Log/Log.h" #include "Subgraph/Subgraph.h" #include "Time/Time.h" -namespace AG { +namespace IAG { -Graph::TraceRecorder::TraceRecorder(Graph *graph, AGGraphTraceOptions trace_options, std::span subsystems) { +Graph::TraceRecorder::TraceRecorder(Graph *graph, IAGGraphTraceOptions trace_options, std::span subsystems) { // TODO: not implemented } @@ -59,7 +59,7 @@ void Graph::TraceRecorder::begin_update(const Graph::UpdateStack &update_stack, } void Graph::TraceRecorder::end_update(const Graph::UpdateStack &update_stack, data::ptr node, - AGGraphUpdateStatus update_status) { + IAGGraphUpdateStatus update_status) { // TODO: not implemented } @@ -139,7 +139,7 @@ void Graph::TraceRecorder::added(data::ptr node) { // TODO: not implemented } -void Graph::TraceRecorder::add_edge(data::ptr node, AttributeID input, AGInputOptions input_options) { +void Graph::TraceRecorder::add_edge(data::ptr node, AttributeID input, IAGInputOptions input_options) { // TODO: not implemented } @@ -206,4 +206,4 @@ bool Graph::TraceRecorder::named_event_enabled(uint32_t event_id) { return false; } -} // namespace AG +} // namespace IAG diff --git a/Sources/ComputeCxx/Graph/TraceRecorder.h b/Sources/ComputeCxx/Graph/TraceRecorder.h index 96e169c4..a6219368 100644 --- a/Sources/ComputeCxx/Graph/TraceRecorder.h +++ b/Sources/ComputeCxx/Graph/TraceRecorder.h @@ -2,17 +2,17 @@ #include -#include "ComputeCxx/AGBase.h" -#include "ComputeCxx/AGGraph.h" +#include "ComputeCxx/IAGBase.h" +#include "ComputeCxx/IAGGraph.h" #include "Trace/Trace.h" -AG_ASSUME_NONNULL_BEGIN +IAG_ASSUME_NONNULL_BEGIN -namespace AG { +namespace IAG { class Graph::TraceRecorder : public Trace { public: - TraceRecorder(Graph *graph, AGGraphTraceOptions trace_options, std::span subsystems); + TraceRecorder(Graph *graph, IAGGraphTraceOptions trace_options, std::span subsystems); ~TraceRecorder(); uint64_t id() { return _id; }; @@ -37,7 +37,7 @@ class Graph::TraceRecorder : public Trace { void end_update(const Subgraph &subgraph) override; void begin_update(const Graph::UpdateStack &update_stack, data::ptr node, uint32_t options) override; void end_update(const Graph::UpdateStack &update_stack, data::ptr node, - AGGraphUpdateStatus update_status) override; + IAGGraphUpdateStatus update_status) override; void begin_update(data::ptr node) override; void end_update(data::ptr node, bool changed) override; void begin_update(const Graph::Context &context) override; @@ -65,7 +65,7 @@ class Graph::TraceRecorder : public Trace { void added(data::ptr node) override; - void add_edge(data::ptr node, AttributeID input, AGInputOptions input_options) override; + void add_edge(data::ptr node, AttributeID input, IAGInputOptions input_options) override; void remove_edge(data::ptr node, uint32_t input_index) override; void set_edge_pending(data::ptr node, AttributeID input, bool pending) override; @@ -94,6 +94,6 @@ class Graph::TraceRecorder : public Trace { // compare_failed not overridden }; -} // namespace AG +} // namespace IAG -AG_ASSUME_NONNULL_END +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/Graph/Tree/AGTreeElement.cpp b/Sources/ComputeCxx/Graph/Tree/AGTreeElement.cpp deleted file mode 100644 index f0261843..00000000 --- a/Sources/ComputeCxx/Graph/Tree/AGTreeElement.cpp +++ /dev/null @@ -1,94 +0,0 @@ -#include "ComputeCxx/AGTreeElement.h" - -#include "Subgraph/Subgraph.h" -#include "TreeElement.h" - -AGTypeID AGTreeElementGetType(AGTreeElement tree_element) { - auto tree_element_id = AG::Graph::TreeElementID(tree_element); - auto type = tree_element_id->type; - return AGTypeID(type); -} - -AGAttribute AGTreeElementGetValue(AGTreeElement tree_element) { - auto tree_element_id = AG::Graph::TreeElementID(tree_element); - auto value = tree_element_id->value; - return AGAttribute(value); -} - -uint32_t AGTreeElementGetFlags(AGTreeElement tree_element) { - auto tree_element_id = AG::Graph::TreeElementID(tree_element); - return tree_element_id->flags; -} - -AGTreeElement AGTreeElementGetParent(AGTreeElement tree_element) { - auto tree_element_id = AG::Graph::TreeElementID(tree_element); - return AGTreeElement(uintptr_t(tree_element_id->parent)); -} - -#pragma mark - Iterating values - -AGTreeElementValueIterator -AGTreeElementMakeValueIterator(AGTreeElement tree_element) { - auto tree_element_id = AG::Graph::TreeElementID(tree_element); - return AGTreeElementValueIterator(uintptr_t(tree_element), - tree_element_id->first_value); -} - -AGTreeValue AGTreeElementGetNextValue(AGTreeElementValueIterator *iter) { - AGTreeValue next_value = reinterpret_cast(iter->next_elt); - if (next_value) { - auto next_value_id = AG::Graph::TreeValueID(next_value); - iter->next_elt = next_value_id->next; - } - return next_value; -} - -#pragma mark - Iterating nodes - -AGTreeElementNodeIterator -AGTreeElementMakeNodeIterator(AGTreeElement tree_element) { - return {uintptr_t(tree_element), 0}; -} - -AGAttribute AGTreeElementGetNextNode(AGTreeElementNodeIterator *iter) { - AGTreeElement tree_element = reinterpret_cast(iter->elt); - auto tree_element_id = AG::Graph::TreeElementID(tree_element); - AG::AttributeID node = tree_element_id.subgraph()->tree_node_at_index( - tree_element_id, iter->node_index); - if (!node || node.is_nil()) { - return AGAttributeNil; - } - iter->node_index += 1; - return AGAttribute(node); -} - -#pragma mark - Iterating children - -AGTreeElementChildIterator -AGTreeElementMakeChildIterator(AGTreeElement tree_element) { - auto tree_element_id = AG::Graph::TreeElementID(tree_element); - auto child = tree_element_id->first_child; - return AGTreeElementChildIterator((uintptr_t)tree_element, child, 0); -} - -AGTreeElement AGTreeElementGetNextChild(AGTreeElementChildIterator *iter) { - AGTreeElement next_child = reinterpret_cast(iter->next_elt); - if (next_child) { - iter->next_elt = AG::Graph::TreeElementID(next_child)->next_sibling; - return next_child; - } - - if (!iter->subgraph_index) { - iter->subgraph_index = true; // +1 or set to true? - auto tree_element = reinterpret_cast(iter->parent_elt); - auto tree_element_id = AG::Graph::TreeElementID(tree_element); - auto subgraph = tree_element_id.subgraph(); - auto subgraph_child = subgraph->tree_subgraph_child(tree_element_id); - if (subgraph_child) { - iter->next_elt = subgraph_child->next_sibling; - return AGTreeElement((uintptr_t)subgraph_child); - } - } - - return 0; -} diff --git a/Sources/ComputeCxx/Graph/Tree/AGTreeValue.cpp b/Sources/ComputeCxx/Graph/Tree/AGTreeValue.cpp deleted file mode 100644 index 4e9ab058..00000000 --- a/Sources/ComputeCxx/Graph/Tree/AGTreeValue.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "ComputeCxx/AGTreeValue.h" - -#include "Graph/Graph.h" -#include "Subgraph/Subgraph.h" -#include "TreeElement.h" - -AGTypeID AGTreeValueGetType(AGTreeValue tree_value) { - auto tree_value_id = AG::Graph::TreeValueID(tree_value); - return AGTypeID(tree_value_id->type); -} - -AGAttribute AGTreeValueGetValue(AGTreeValue tree_value) { - auto tree_value_id = AG::Graph::TreeValueID(tree_value); - return AGAttribute(tree_value_id->value); -} - -const char *AGTreeValueGetKey(AGTreeValue tree_value) { - auto tree_value_id = AG::Graph::TreeValueID(tree_value); - auto key_id = tree_value_id->key_id; - return tree_value_id.subgraph()->graph()->key_name(key_id); -} - -uint32_t AGTreeValueGetFlags(AGTreeValue tree_value) { - auto tree_value_id = AG::Graph::TreeValueID(tree_value); - return tree_value_id->flags; -} diff --git a/Sources/ComputeCxx/Graph/Tree/IAGTreeElement.cpp b/Sources/ComputeCxx/Graph/Tree/IAGTreeElement.cpp new file mode 100644 index 00000000..2f542256 --- /dev/null +++ b/Sources/ComputeCxx/Graph/Tree/IAGTreeElement.cpp @@ -0,0 +1,94 @@ +#include "ComputeCxx/IAGTreeElement.h" + +#include "Subgraph/Subgraph.h" +#include "TreeElement.h" + +IAGTypeID IAGTreeElementGetType(IAGTreeElement tree_element) { + auto tree_element_id = IAG::Graph::TreeElementID(tree_element); + auto type = tree_element_id->type; + return IAGTypeID(type); +} + +IAGAttribute IAGTreeElementGetValue(IAGTreeElement tree_element) { + auto tree_element_id = IAG::Graph::TreeElementID(tree_element); + auto value = tree_element_id->value; + return IAGAttribute(value); +} + +uint32_t IAGTreeElementGetFlags(IAGTreeElement tree_element) { + auto tree_element_id = IAG::Graph::TreeElementID(tree_element); + return tree_element_id->flags; +} + +IAGTreeElement IAGTreeElementGetParent(IAGTreeElement tree_element) { + auto tree_element_id = IAG::Graph::TreeElementID(tree_element); + return IAGTreeElement(uintptr_t(tree_element_id->parent)); +} + +#pragma mark - Iterating values + +IAGTreeElementValueIterator +IAGTreeElementMakeValueIterator(IAGTreeElement tree_element) { + auto tree_element_id = IAG::Graph::TreeElementID(tree_element); + return IAGTreeElementValueIterator(uintptr_t(tree_element), + tree_element_id->first_value); +} + +IAGTreeValue IAGTreeElementGetNextValue(IAGTreeElementValueIterator *iter) { + IAGTreeValue next_value = reinterpret_cast(iter->next_elt); + if (next_value) { + auto next_value_id = IAG::Graph::TreeValueID(next_value); + iter->next_elt = next_value_id->next; + } + return next_value; +} + +#pragma mark - Iterating nodes + +IAGTreeElementNodeIterator +IAGTreeElementMakeNodeIterator(IAGTreeElement tree_element) { + return {uintptr_t(tree_element), 0}; +} + +IAGAttribute IAGTreeElementGetNextNode(IAGTreeElementNodeIterator *iter) { + IAGTreeElement tree_element = reinterpret_cast(iter->elt); + auto tree_element_id = IAG::Graph::TreeElementID(tree_element); + IAG::AttributeID node = tree_element_id.subgraph()->tree_node_at_index( + tree_element_id, iter->node_index); + if (!node || node.is_nil()) { + return IAGAttributeNil; + } + iter->node_index += 1; + return IAGAttribute(node); +} + +#pragma mark - Iterating children + +IAGTreeElementChildIterator +IAGTreeElementMakeChildIterator(IAGTreeElement tree_element) { + auto tree_element_id = IAG::Graph::TreeElementID(tree_element); + auto child = tree_element_id->first_child; + return IAGTreeElementChildIterator((uintptr_t)tree_element, child, 0); +} + +IAGTreeElement IAGTreeElementGetNextChild(IAGTreeElementChildIterator *iter) { + IAGTreeElement next_child = reinterpret_cast(iter->next_elt); + if (next_child) { + iter->next_elt = IAG::Graph::TreeElementID(next_child)->next_sibling; + return next_child; + } + + if (!iter->subgraph_index) { + iter->subgraph_index = true; // +1 or set to true? + auto tree_element = reinterpret_cast(iter->parent_elt); + auto tree_element_id = IAG::Graph::TreeElementID(tree_element); + auto subgraph = tree_element_id.subgraph(); + auto subgraph_child = subgraph->tree_subgraph_child(tree_element_id); + if (subgraph_child) { + iter->next_elt = subgraph_child->next_sibling; + return IAGTreeElement((uintptr_t)subgraph_child); + } + } + + return 0; +} diff --git a/Sources/ComputeCxx/Graph/Tree/IAGTreeValue.cpp b/Sources/ComputeCxx/Graph/Tree/IAGTreeValue.cpp new file mode 100644 index 00000000..c4539e8a --- /dev/null +++ b/Sources/ComputeCxx/Graph/Tree/IAGTreeValue.cpp @@ -0,0 +1,26 @@ +#include "ComputeCxx/IAGTreeValue.h" + +#include "Graph/Graph.h" +#include "Subgraph/Subgraph.h" +#include "TreeElement.h" + +IAGTypeID IAGTreeValueGetType(IAGTreeValue tree_value) { + auto tree_value_id = IAG::Graph::TreeValueID(tree_value); + return IAGTypeID(tree_value_id->type); +} + +IAGAttribute IAGTreeValueGetValue(IAGTreeValue tree_value) { + auto tree_value_id = IAG::Graph::TreeValueID(tree_value); + return IAGAttribute(tree_value_id->value); +} + +const char *IAGTreeValueGetKey(IAGTreeValue tree_value) { + auto tree_value_id = IAG::Graph::TreeValueID(tree_value); + auto key_id = tree_value_id->key_id; + return tree_value_id.subgraph()->graph()->key_name(key_id); +} + +uint32_t IAGTreeValueGetFlags(IAGTreeValue tree_value) { + auto tree_value_id = IAG::Graph::TreeValueID(tree_value); + return tree_value_id->flags; +} diff --git a/Sources/ComputeCxx/Graph/Tree/TreeDataElement.cpp b/Sources/ComputeCxx/Graph/Tree/TreeDataElement.cpp index 1f9a0be8..7f3656e9 100644 --- a/Sources/ComputeCxx/Graph/Tree/TreeDataElement.cpp +++ b/Sources/ComputeCxx/Graph/Tree/TreeDataElement.cpp @@ -1,6 +1,6 @@ #include "Graph/Graph.h" -namespace AG { +namespace IAG { void Graph::TreeDataElement::sort_nodes() { if (!_sorted) { @@ -11,4 +11,4 @@ void Graph::TreeDataElement::sort_nodes() { } }; -}; // namespace AG +}; // namespace IAG diff --git a/Sources/ComputeCxx/Graph/Tree/TreeElement.h b/Sources/ComputeCxx/Graph/Tree/TreeElement.h index 704ca389..e920e13f 100644 --- a/Sources/ComputeCxx/Graph/Tree/TreeElement.h +++ b/Sources/ComputeCxx/Graph/Tree/TreeElement.h @@ -1,14 +1,14 @@ #pragma once -#include "ComputeCxx/AGBase.h" -#include "ComputeCxx/AGTreeElement.h" +#include "ComputeCxx/IAGBase.h" +#include "ComputeCxx/IAGTreeElement.h" #include "Data/Pointer.h" #include "Graph/Graph.h" #include "TreeValue.h" -AG_ASSUME_NONNULL_BEGIN +IAG_ASSUME_NONNULL_BEGIN -namespace AG { +namespace IAG { namespace swift { class metadata; @@ -21,7 +21,7 @@ class Graph::TreeElementID : public data::ptr { : ptr(tree_element.offset()) {}; operator uintptr_t() const { return offset(); } - explicit TreeElementID(AGTreeElement storage) + explicit TreeElementID(IAGTreeElement storage) : ptr((uint32_t)(uint64_t)storage) {} // MARK: Accessing graph data @@ -45,6 +45,6 @@ struct Graph::TreeElement { }; static_assert(sizeof(Graph::TreeElement) == 0x20); -} // namespace AG +} // namespace IAG -AG_ASSUME_NONNULL_END +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/Graph/Tree/TreeValue.h b/Sources/ComputeCxx/Graph/Tree/TreeValue.h index 3a010c4c..a2aacdd7 100644 --- a/Sources/ComputeCxx/Graph/Tree/TreeValue.h +++ b/Sources/ComputeCxx/Graph/Tree/TreeValue.h @@ -1,13 +1,13 @@ #pragma once -#include "ComputeCxx/AGBase.h" -#include "ComputeCxx/AGTreeValue.h" +#include "ComputeCxx/IAGBase.h" +#include "ComputeCxx/IAGTreeValue.h" #include "Data/Pointer.h" #include "Graph/Graph.h" -AG_ASSUME_NONNULL_BEGIN +IAG_ASSUME_NONNULL_BEGIN -namespace AG { +namespace IAG { namespace swift { class metadata; @@ -20,7 +20,7 @@ class Graph::TreeValueID : public data::ptr { : ptr(tree_value.offset()) {}; operator uintptr_t() const { return offset(); } - explicit TreeValueID(AGTreeValue storage) + explicit TreeValueID(IAGTreeValue storage) : ptr((uint32_t)(uint64_t)storage) {} // MARK: Accessing graph data @@ -39,6 +39,6 @@ struct Graph::TreeValue { }; static_assert(sizeof(Graph::TreeValue) == 0x18); -} // namespace AG +} // namespace IAG -AG_ASSUME_NONNULL_END +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/Graph/UpdateStack.cpp b/Sources/ComputeCxx/Graph/UpdateStack.cpp index e4724cd7..d7b62708 100644 --- a/Sources/ComputeCxx/Graph/UpdateStack.cpp +++ b/Sources/ComputeCxx/Graph/UpdateStack.cpp @@ -7,25 +7,25 @@ #include "Subgraph/Subgraph.h" #include "Trace/Trace.h" -namespace AG { +namespace IAG { -Graph::UpdateStack::UpdateStack(Graph *graph, AGGraphUpdateOptions options) +Graph::UpdateStack::UpdateStack(Graph *graph, IAGGraphUpdateOptions options) : _graph(graph), _thread(pthread_self()), _next(current_update()), _next_thread(graph->_current_update_thread), _options(options) { if (_next != nullptr) { _options = - AGGraphUpdateOptions(_options | (_next.get()->_options & AGGraphUpdateOptionsCancelIfPassedDeadline)); + IAGGraphUpdateOptions(_options | (_next.get()->_options & IAGGraphUpdateOptionsCancelIfPassedDeadline)); } graph->_current_update_thread = _thread; if (graph->_deferring_subgraph_invalidation == false) { graph->_deferring_subgraph_invalidation = true; - _options = AGGraphUpdateOptions(_options & AGGraphUpdateOptionsEndDeferringSubgraphInvalidationOnExit); + _options = IAGGraphUpdateOptions(_options & IAGGraphUpdateOptionsEndDeferringSubgraphInvalidationOnExit); } - Graph::set_current_update(util::tagged_ptr(this, options & AGGraphUpdateOptionsInitializeCleared)); + Graph::set_current_update(util::tagged_ptr(this, options & IAGGraphUpdateOptionsInitializeCleared)); } Graph::UpdateStack::~UpdateStack() { @@ -40,7 +40,7 @@ Graph::UpdateStack::~UpdateStack() { _graph->_current_update_thread = _next_thread; Graph::set_current_update(_next); - if (_options & AGGraphUpdateOptionsEndDeferringSubgraphInvalidationOnExit) { + if (_options & IAGGraphUpdateOptionsEndDeferringSubgraphInvalidationOnExit) { _graph->_deferring_subgraph_invalidation = false; } } @@ -62,7 +62,7 @@ void Graph::UpdateStack::cancel() { } frame.cancelled = true; } - if (update.get()->_options & AGGraphUpdateOptionsAbortIfCancelled) { + if (update.get()->_options & IAGGraphUpdateOptionsAbortIfCancelled) { break; } } @@ -124,7 +124,7 @@ bool Graph::UpdateStack::push_slow(data::ptr node_ptr, Node &node, bool ig _frames.push_back(frame); void *self = node.get_self(attribute_type); - updateDefault(reinterpret_cast(&attribute_type), self); + updateDefault(reinterpret_cast(&attribute_type), self); _frames.pop_back(); @@ -159,14 +159,14 @@ Graph::UpdateStatus Graph::UpdateStack::update() { // Check cancelled - if (_options & AGGraphUpdateOptionsCancelIfPassedDeadline) { + if (_options & IAGGraphUpdateOptionsCancelIfPassedDeadline) { if (!frame.cancelled && _graph->passed_deadline()) { cancel(); } } if (frame.cancelled) { - if (_options & AGGraphUpdateOptionsAbortIfCancelled) { + if (_options & IAGGraphUpdateOptionsAbortIfCancelled) { return UpdateStatus::Aborted; } @@ -177,7 +177,7 @@ Graph::UpdateStatus Graph::UpdateStack::update() { const AttributeType &attribute_type = _graph->attribute_type(node->type_id()); if (auto callback = attribute_type.vtable().update_default) { void *self = node->get_self(attribute_type); - callback(reinterpret_cast(&attribute_type), self); + callback(reinterpret_cast(&attribute_type), self); changed = true; } @@ -193,7 +193,7 @@ Graph::UpdateStatus Graph::UpdateStack::update() { } if (!frame.pending && frame.num_pushed_inputs > 0 && - node->input_edges()[frame.num_pushed_inputs - 1].options & AGInputOptionsChanged) { + node->input_edges()[frame.num_pushed_inputs - 1].options & IAGInputOptionsChanged) { frame.pending = true; } @@ -222,13 +222,13 @@ Graph::UpdateStatus Graph::UpdateStack::update() { } if (auto input_node = input_attribute.get_node()) { - if (input_edge.options & AGInputOptionsChanged) { + if (input_edge.options & IAGInputOptionsChanged) { frame.pending = true; } if (!input_node->is_value_initialized() || input_node->is_dirty()) { - if (!(input_edge.options & AGInputOptionsChanged) && input_attribute.subgraph()->is_valid()) { + if (!(input_edge.options & IAGInputOptionsChanged) && input_attribute.subgraph()->is_valid()) { frame.num_pushed_inputs = input_index + 1; if (push(input_node, *input_node.get(), true, true)) { // go to top @@ -255,7 +255,7 @@ Graph::UpdateStatus Graph::UpdateStack::update() { const AttributeType &attribute_type = _graph->attribute_type(node->type_id()); void *self = node->get_self(attribute_type); - attribute_type.update(self, AGAttribute(AttributeID(frame.attribute))); + attribute_type.update(self, IAGAttribute(AttributeID(frame.attribute))); if (!node->is_value_initialized()) { if (attribute_type.value_metadata().vw_size() > 0) { @@ -266,7 +266,7 @@ Graph::UpdateStatus Graph::UpdateStack::update() { // set a dummy 0-byte value struct { } value = {}; - AGGraphSetOutputValue(&value, AGTypeID(&attribute_type.value_metadata())); + IAGGraphSetOutputValue(&value, IAGTypeID(&attribute_type.value_metadata())); } changed = _graph->_change_count != old_change_count; @@ -294,19 +294,19 @@ Graph::UpdateStatus Graph::UpdateStack::update() { if (reset_edge_pending) { if (frame.pending && !frame.cancelled) { - if (input_edge.options & AGInputOptionsChanged) { + if (input_edge.options & IAGInputOptionsChanged) { _graph->foreach_trace([&frame, &input_edge](Trace &trace) { trace.set_edge_pending(frame.attribute, input_edge.attribute, false); }); - input_edge.options &= ~AGInputOptionsChanged; + input_edge.options &= ~IAGInputOptionsChanged; } } } if (frame.pending && !frame.cancelled) { - bool was_enabled = input_edge.options & AGInputOptionsEnabled; - input_edge.options &= ~AGInputOptionsEnabled; - if (!was_enabled && !(input_edge.options & AGInputOptionsAlwaysEnabled)) { + bool was_enabled = input_edge.options & IAGInputOptionsEnabled; + input_edge.options &= ~IAGInputOptionsEnabled; + if (!was_enabled && !(input_edge.options & IAGInputOptionsAlwaysEnabled)) { _graph->remove_input(frame.attribute, input_index); } } @@ -338,4 +338,4 @@ Graph::UpdateStatus Graph::UpdateStack::update() { } } -} // namespace AG +} // namespace IAG diff --git a/Sources/ComputeCxx/Graph/UpdateStack.h b/Sources/ComputeCxx/Graph/UpdateStack.h index c0d9ff25..0d0f320a 100644 --- a/Sources/ComputeCxx/Graph/UpdateStack.h +++ b/Sources/ComputeCxx/Graph/UpdateStack.h @@ -1,11 +1,11 @@ #pragma once -#include "ComputeCxx/AGBase.h" +#include "ComputeCxx/IAGBase.h" #include "Graph.h" -AG_ASSUME_NONNULL_BEGIN +IAG_ASSUME_NONNULL_BEGIN -namespace AG { +namespace IAG { class Graph::UpdateStack { protected: @@ -27,12 +27,12 @@ class Graph::UpdateStack { util::tagged_ptr _next; pthread_t _next_thread; vector _frames; - AGGraphUpdateOptions _options; + IAGGraphUpdateOptions _options; bool push_slow(data::ptr node_ptr, Node &node, bool ignore_cycles, bool initialize_value); public: - UpdateStack(Graph *graph, AGGraphUpdateOptions options); + UpdateStack(Graph *graph, IAGGraphUpdateOptions options); ~UpdateStack(); // Non-copyable @@ -57,6 +57,6 @@ class Graph::UpdateStack { Graph::UpdateStatus update(); }; -} // namespace AG +} // namespace IAG -AG_ASSUME_NONNULL_END +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/Log/Log.cpp b/Sources/ComputeCxx/Log/Log.cpp index db41c053..e29d0091 100644 --- a/Sources/ComputeCxx/Log/Log.cpp +++ b/Sources/ComputeCxx/Log/Log.cpp @@ -1,10 +1,10 @@ #include "Log/Log.h" -namespace AG { +namespace IAG { platform_log_t misc_log() { static platform_log_t log = platform_log_create("dev.incrematic.compute", "misc"); return log; } -} // namespace AG +} // namespace IAG diff --git a/Sources/ComputeCxx/Log/Log.h b/Sources/ComputeCxx/Log/Log.h index 05e4dcff..3587045c 100644 --- a/Sources/ComputeCxx/Log/Log.h +++ b/Sources/ComputeCxx/Log/Log.h @@ -2,14 +2,14 @@ #include -#include "ComputeCxx/AGBase.h" +#include "ComputeCxx/IAGBase.h" -AG_ASSUME_NONNULL_BEGIN +IAG_ASSUME_NONNULL_BEGIN -namespace AG { +namespace IAG { platform_log_t misc_log(); -} // namespace AG +} // namespace IAG -AG_ASSUME_NONNULL_END +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/Subgraph/AGSubgraph-Private.h b/Sources/ComputeCxx/Subgraph/AGSubgraph-Private.h deleted file mode 100644 index 82174c4d..00000000 --- a/Sources/ComputeCxx/Subgraph/AGSubgraph-Private.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once - -#include "ComputeCxx/AGBase.h" - -#if TARGET_OS_MAC -#include "CoreFoundationPrivate/CFRuntime.h" -#else -#include -#endif - -#include "ComputeCxx/AGSubgraph.h" - -AG_ASSUME_NONNULL_BEGIN - -namespace AG { -class Subgraph; -} - -struct AGSubgraphStorage { - CFRuntimeBase base; - AG::Subgraph *_Nullable subgraph; -}; - -AG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/Subgraph/AGSubgraph.cpp b/Sources/ComputeCxx/Subgraph/AGSubgraph.cpp deleted file mode 100644 index 2c7727e5..00000000 --- a/Sources/ComputeCxx/Subgraph/AGSubgraph.cpp +++ /dev/null @@ -1,369 +0,0 @@ -#include "AGSubgraph-Private.h" - -#include - -#include "Graph/Context.h" -#include "Subgraph.h" - -namespace { - -CFRuntimeClass &subgraph_type_id() { - static auto finalize = [](CFTypeRef subgraph_ref) { - AGSubgraphStorage *storage = (AGSubgraphStorage *)subgraph_ref; - AG::Subgraph *subgraph = storage->subgraph; - if (subgraph) { - subgraph->clear_object(); - subgraph->invalidate_and_delete_(false); - } - }; - static CFRuntimeClass klass = { - 0, // version - "AGSubgraph", // className - NULL, // init - NULL, // copy, - finalize, - NULL, // equal - NULL, // hash - NULL, // copyFormattingDesc - NULL, // copyDebugDesc, - NULL, // reclaim - NULL, // refcount - 0 // requiredAlignment - }; - return klass; -} - -} // namespace - -CFTypeID AGSubgraphGetTypeID() { - static CFTypeID type = _CFRuntimeRegisterClass(&subgraph_type_id()); - return type; -} - -#pragma mark - Current subgraph - -AGSubgraphRef AGSubgraphGetCurrent() { - auto current = AG::Subgraph::current_subgraph(); - if (current == nullptr) { - return nullptr; - } - return current->to_cf(); -} - -void AGSubgraphSetCurrent(AGSubgraphRef subgraph) { - AG::Subgraph *old_subgraph = AG::Subgraph::current_subgraph(); - if (subgraph != nullptr) { - AG::Subgraph::set_current_subgraph(AG::Subgraph::from_cf(subgraph)); - if (AG::Subgraph::from_cf(subgraph) != nullptr) { - CFRetain(subgraph); - } - } else { - AG::Subgraph::set_current_subgraph(nullptr); - } - if (old_subgraph && old_subgraph->to_cf()) { - CFRelease(old_subgraph->to_cf()); - } -} - -#pragma mark - Graph context - -AGSubgraphRef AGSubgraphCreate(AGGraphRef graph) { return AGSubgraphCreate2(graph, AGAttributeNil); }; - -AGSubgraphRef AGSubgraphCreate2(AGGraphRef graph, AGAttribute attribute) { - CFIndex extra_bytes = sizeof(struct AGSubgraphStorage) - sizeof(CFRuntimeBase); - AGSubgraphRef instance = - (AGSubgraphRef)_CFRuntimeCreateInstance(kCFAllocatorDefault, AGSubgraphGetTypeID(), extra_bytes, NULL); - if (!instance) { - AG::precondition_failure("memory allocation failure."); - } - - AG::Graph::Context *context = AG::Graph::Context::from_cf(graph); - - instance->subgraph = new AG::Subgraph((AG::SubgraphObject *)instance, *context, AG::AttributeID(attribute)); - return instance; -}; - -AGUnownedGraphContextRef AGSubgraphGetCurrentGraphContext() { - AG::Subgraph *current_subgraph = AG::Subgraph::current_subgraph(); - if (current_subgraph == nullptr) { - return nullptr; - } - - AG::Graph *graph = current_subgraph->graph(); - return reinterpret_cast(graph); -} - -AGGraphRef AGSubgraphGetGraph(AGSubgraphRef subgraph) { - if (AG::Subgraph::from_cf(subgraph) == nullptr) { - AG::precondition_failure("accessing invalidated subgraph"); - } - - auto context_id = AG::Subgraph::from_cf(subgraph)->context_id(); - if (context_id != 0) { - if (AG::Graph::Context *context = AG::Subgraph::from_cf(subgraph)->graph()->context_with_id(context_id)) { - return AGGraphContextGetGraph(context); - } - } - - AG::precondition_failure("accessing invalidated context"); -} - -bool AGSubgraphIsValid(AGSubgraphRef subgraph) { - if (AG::Subgraph::from_cf(subgraph) == nullptr) { - return false; - } - - return AG::Subgraph::from_cf(subgraph)->is_valid(); -} - -void AGSubgraphInvalidate(AGSubgraphRef subgraph) { - if (AG::Subgraph::from_cf(subgraph) == nullptr) { - return; - } - - AG::Subgraph::from_cf(subgraph)->invalidate_and_delete_(false); -} - -#pragma mark - Index - -uint32_t AGSubgraphGetIndex(AGSubgraphRef subgraph) { - if (AG::Subgraph::from_cf(subgraph) == nullptr) { - AG::precondition_failure("accessing invalidated subgraph"); - } - - return AG::Subgraph::from_cf(subgraph)->index(); -} - -void AGSubgraphSetIndex(AGSubgraphRef subgraph, uint32_t index) { - if (AG::Subgraph::from_cf(subgraph) == nullptr) { - AG::precondition_failure("accessing invalidated subgraph"); - } - - AG::Subgraph::from_cf(subgraph)->set_index(index); -} - -#pragma mark - Observers - -AGUniqueID AGSubgraphAddObserver(AGSubgraphRef subgraph, - void (*observer)(const void *context AG_SWIFT_CONTEXT) AG_SWIFT_CC(swift), - const void *observer_context) { - if (AG::Subgraph::from_cf(subgraph) == nullptr) { - AG::precondition_failure("accessing invalidated subgraph"); - } - - auto callback = AG::ClosureFunctionVV(observer, observer_context); - return AG::Subgraph::from_cf(subgraph)->add_observer(callback); -} - -void AGSubgraphRemoveObserver(AGSubgraphRef subgraph, AGUniqueID observer_id) { - if (AG::Subgraph::from_cf(subgraph) == nullptr) { - AG::precondition_failure("accessing invalidated subgraph"); - } - - AG::Subgraph::from_cf(subgraph)->remove_observer(observer_id); -} - -#pragma mark - Children - -void AGSubgraphAddChild(AGSubgraphRef subgraph, AGSubgraphRef child) { AGSubgraphAddChild2(subgraph, child, 0); } - -void AGSubgraphAddChild2(AGSubgraphRef subgraph, AGSubgraphRef child, uint8_t tag) { - if (AG::Subgraph::from_cf(subgraph) == nullptr) { - AG::precondition_failure("accessing invalidated subgraph"); - } - if (AG::Subgraph::from_cf(child) == nullptr) { - return; - } - - AG::Subgraph::from_cf(subgraph)->add_child(*AG::Subgraph::from_cf(child), tag); -} - -void AGSubgraphRemoveChild(AGSubgraphRef subgraph, AGSubgraphRef child) { - if (AG::Subgraph::from_cf(subgraph) == nullptr) { - AG::precondition_failure("accessing invalidated subgraph"); - } - - if (child->subgraph) { - AG::Subgraph::from_cf(subgraph)->remove_child(*AG::Subgraph::from_cf(child), false); - } -} - -AGSubgraphRef AGSubgraphGetChild(AGSubgraphRef subgraph, uint32_t index, uint8_t *tag_out) { - if (AG::Subgraph::from_cf(subgraph) == nullptr) { - AG::precondition_failure("accessing invalidated subgraph"); - } - if (index >= AG::Subgraph::from_cf(subgraph)->children().size()) { - AG::precondition_failure("invalid child index: %u", index); - } - - AG::Subgraph::SubgraphChild &child = AG::Subgraph::from_cf(subgraph)->children()[index]; - if (tag_out) { - *tag_out = child.tag(); - } - return child.subgraph()->to_cf(); -} - -uint32_t AGSubgraphGetChildCount(AGSubgraphRef subgraph) { - if (AG::Subgraph::from_cf(subgraph) == nullptr) { - AG::precondition_failure("accessing invalidated subgraph"); - } - - return AG::Subgraph::from_cf(subgraph)->children().size(); -} - -AGSubgraphRef AGSubgraphGetParent(AGSubgraphRef subgraph, int64_t index) { - if (AG::Subgraph::from_cf(subgraph) == nullptr) { - AG::precondition_failure("accessing invalidated subgraph"); - } - if (index >= AG::Subgraph::from_cf(subgraph)->parents().size()) { - AG::precondition_failure("invalid parent index: %u", index); - } - - return AG::Subgraph::from_cf(subgraph)->parents()[index]->to_cf(); -} - -uint64_t AGSubgraphGetParentCount(AGSubgraphRef subgraph) { - if (AG::Subgraph::from_cf(subgraph) == nullptr) { - return 0; - } - - return AG::Subgraph::from_cf(subgraph)->parents().size(); -} - -bool AGSubgraphIsAncestor(AGSubgraphRef subgraph, AGSubgraphRef other) { - if (AG::Subgraph::from_cf(subgraph) == nullptr) { - return false; - } - if (AG::Subgraph::from_cf(other) == nullptr) { - return false; - } - - return AG::Subgraph::from_cf(subgraph)->ancestor_of(*AG::Subgraph::from_cf(other)); -} - -#pragma mark - Flags - -bool AGSubgraphIntersects(AGSubgraphRef subgraph, AGAttributeFlags flags) { - if (AG::Subgraph::from_cf(subgraph) == nullptr) { - return false; - } - - return AG::Subgraph::from_cf(subgraph)->intersects(flags); -} - -bool AGSubgraphIsDirty(AGSubgraphRef subgraph, AGAttributeFlags flags) { - if (AG::Subgraph::from_cf(subgraph) == nullptr) { - return false; - } - - return AG::Subgraph::from_cf(subgraph)->is_dirty(flags); -} - -#pragma mark - Graph - -AGSubgraphRef AGGraphGetAttributeSubgraph(AGAttribute attribute) { - auto subgraph = AGGraphGetAttributeSubgraph2(attribute); - if (subgraph == nullptr) { - AG::precondition_failure("no subgraph"); - } - - return subgraph; -} - -AGSubgraphRef AGGraphGetAttributeSubgraph2(AGAttribute attribute) { - auto attribute_id = AG::AttributeID(attribute); - attribute_id.validate_data_offset(); - - auto subgraph = attribute_id.subgraph(); - if (subgraph == nullptr) { - AG::precondition_failure("internal error"); - } - - return subgraph->to_cf(); -} - -void AGSubgraphApply(AGSubgraphRef subgraph, uint32_t options, - void (*body)(AGAttribute, const void *context AG_SWIFT_CONTEXT) AG_SWIFT_CC(swift), const void *body_context) { - if (AG::Subgraph::from_cf(subgraph) == nullptr) { - return; - } - - AG::Subgraph::from_cf(subgraph)->apply(options, AG::ClosureFunctionAV(body, body_context)); -} - -void AGSubgraphUpdate(AGSubgraphRef subgraph, AGAttributeFlags flags) { - if (AG::Subgraph::from_cf(subgraph) == nullptr) { - return; - } - - AG::Subgraph::from_cf(subgraph)->update(flags); -} - -#pragma mark - Tree - -AGTreeElement AGSubgraphGetTreeRoot(AGSubgraphRef subgraph) { - if (AG::Subgraph::from_cf(subgraph) == nullptr) { - return AGTreeElement(); - } - - auto tree_root = AG::Subgraph::from_cf(subgraph)->tree_root(); - return AGTreeElement((uintptr_t)tree_root); -} - -void AGSubgraphSetTreeOwner(AGSubgraphRef subgraph, AGAttribute owner) { - if (AG::Subgraph::from_cf(subgraph) == nullptr) { - AG::precondition_failure("accessing invalidated subgraph"); - } - AG::Subgraph::from_cf(subgraph)->set_tree_owner(AG::AttributeID(owner)); -} - -void AGSubgraphAddTreeValue(AGAttribute value, AGTypeID type, const char *key, uint32_t flags) { - AG::Subgraph *current_subgraph = AG::Subgraph::current_subgraph(); - if (current_subgraph == nullptr) { - return; - } - - auto metadata = reinterpret_cast(type); - current_subgraph->add_tree_value(AG::AttributeID(value), metadata, key, flags); -} - -void AGSubgraphBeginTreeElement(AGAttribute value, AGTypeID type, uint32_t flags) { - AG::Subgraph *current_subgraph = AG::Subgraph::current_subgraph(); - if (current_subgraph == nullptr) { - return; - } - - auto metadata = reinterpret_cast(type); - current_subgraph->begin_tree(AG::AttributeID(value), metadata, flags); -} - -void AGSubgraphEndTreeElement(AGAttribute value) { - AG::Subgraph *current_subgraph = AG::Subgraph::current_subgraph(); - if (current_subgraph == nullptr) { - return; - } - - current_subgraph->end_tree(); -} - -static platform_once_t should_record_tree_once = 0; -static bool should_record_tree = true; - -void init_should_record_tree() { - char *result = getenv("AG_TREE"); - if (result) { - should_record_tree = atoi(result) != 0; - } else { - should_record_tree = false; - } -} - -bool AGSubgraphShouldRecordTree() { - platform_once(&should_record_tree_once, init_should_record_tree); - return should_record_tree; -} - -void AGSubgraphSetShouldRecordTree() { - platform_once(&should_record_tree_once, init_should_record_tree); - should_record_tree = true; -} diff --git a/Sources/ComputeCxx/Subgraph/IAGSubgraph-Private.h b/Sources/ComputeCxx/Subgraph/IAGSubgraph-Private.h new file mode 100644 index 00000000..26882c77 --- /dev/null +++ b/Sources/ComputeCxx/Subgraph/IAGSubgraph-Private.h @@ -0,0 +1,24 @@ +#pragma once + +#include "ComputeCxx/IAGBase.h" + +#if TARGET_OS_MAC +#include "CoreFoundationPrivate/CFRuntime.h" +#else +#include +#endif + +#include "ComputeCxx/IAGSubgraph.h" + +IAG_ASSUME_NONNULL_BEGIN + +namespace IAG { +class Subgraph; +} + +struct IAGSubgraphStorage { + CFRuntimeBase base; + IAG::Subgraph *_Nullable subgraph; +}; + +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/Subgraph/IAGSubgraph.cpp b/Sources/ComputeCxx/Subgraph/IAGSubgraph.cpp new file mode 100644 index 00000000..c719c31b --- /dev/null +++ b/Sources/ComputeCxx/Subgraph/IAGSubgraph.cpp @@ -0,0 +1,369 @@ +#include "IAGSubgraph-Private.h" + +#include + +#include "Graph/Context.h" +#include "Subgraph.h" + +namespace { + +CFRuntimeClass &subgraph_type_id() { + static auto finalize = [](CFTypeRef subgraph_ref) { + IAGSubgraphStorage *storage = (IAGSubgraphStorage *)subgraph_ref; + IAG::Subgraph *subgraph = storage->subgraph; + if (subgraph) { + subgraph->clear_object(); + subgraph->invalidate_and_delete_(false); + } + }; + static CFRuntimeClass klass = { + 0, // version + "IAGSubgraph", // className + NULL, // init + NULL, // copy, + finalize, + NULL, // equal + NULL, // hash + NULL, // copyFormattingDesc + NULL, // copyDebugDesc, + NULL, // reclaim + NULL, // refcount + 0 // requiredAlignment + }; + return klass; +} + +} // namespace + +CFTypeID IAGSubgraphGetTypeID() { + static CFTypeID type = _CFRuntimeRegisterClass(&subgraph_type_id()); + return type; +} + +#pragma mark - Current subgraph + +IAGSubgraphRef IAGSubgraphGetCurrent() { + auto current = IAG::Subgraph::current_subgraph(); + if (current == nullptr) { + return nullptr; + } + return current->to_cf(); +} + +void IAGSubgraphSetCurrent(IAGSubgraphRef subgraph) { + IAG::Subgraph *old_subgraph = IAG::Subgraph::current_subgraph(); + if (subgraph != nullptr) { + IAG::Subgraph::set_current_subgraph(IAG::Subgraph::from_cf(subgraph)); + if (IAG::Subgraph::from_cf(subgraph) != nullptr) { + CFRetain(subgraph); + } + } else { + IAG::Subgraph::set_current_subgraph(nullptr); + } + if (old_subgraph && old_subgraph->to_cf()) { + CFRelease(old_subgraph->to_cf()); + } +} + +#pragma mark - Graph context + +IAGSubgraphRef IAGSubgraphCreate(IAGGraphRef graph) { return IAGSubgraphCreate2(graph, IAGAttributeNil); }; + +IAGSubgraphRef IAGSubgraphCreate2(IAGGraphRef graph, IAGAttribute attribute) { + CFIndex extra_bytes = sizeof(struct IAGSubgraphStorage) - sizeof(CFRuntimeBase); + IAGSubgraphRef instance = + (IAGSubgraphRef)_CFRuntimeCreateInstance(kCFAllocatorDefault, IAGSubgraphGetTypeID(), extra_bytes, NULL); + if (!instance) { + IAG::precondition_failure("memory allocation failure."); + } + + IAG::Graph::Context *context = IAG::Graph::Context::from_cf(graph); + + instance->subgraph = new IAG::Subgraph((IAG::SubgraphObject *)instance, *context, IAG::AttributeID(attribute)); + return instance; +}; + +IAGUnownedGraphContextRef IAGSubgraphGetCurrentGraphContext() { + IAG::Subgraph *current_subgraph = IAG::Subgraph::current_subgraph(); + if (current_subgraph == nullptr) { + return nullptr; + } + + IAG::Graph *graph = current_subgraph->graph(); + return reinterpret_cast(graph); +} + +IAGGraphRef IAGSubgraphGetGraph(IAGSubgraphRef subgraph) { + if (IAG::Subgraph::from_cf(subgraph) == nullptr) { + IAG::precondition_failure("accessing invalidated subgraph"); + } + + auto context_id = IAG::Subgraph::from_cf(subgraph)->context_id(); + if (context_id != 0) { + if (IAG::Graph::Context *context = IAG::Subgraph::from_cf(subgraph)->graph()->context_with_id(context_id)) { + return IAGGraphContextGetGraph(context); + } + } + + IAG::precondition_failure("accessing invalidated context"); +} + +bool IAGSubgraphIsValid(IAGSubgraphRef subgraph) { + if (IAG::Subgraph::from_cf(subgraph) == nullptr) { + return false; + } + + return IAG::Subgraph::from_cf(subgraph)->is_valid(); +} + +void IAGSubgraphInvalidate(IAGSubgraphRef subgraph) { + if (IAG::Subgraph::from_cf(subgraph) == nullptr) { + return; + } + + IAG::Subgraph::from_cf(subgraph)->invalidate_and_delete_(false); +} + +#pragma mark - Index + +uint32_t IAGSubgraphGetIndex(IAGSubgraphRef subgraph) { + if (IAG::Subgraph::from_cf(subgraph) == nullptr) { + IAG::precondition_failure("accessing invalidated subgraph"); + } + + return IAG::Subgraph::from_cf(subgraph)->index(); +} + +void IAGSubgraphSetIndex(IAGSubgraphRef subgraph, uint32_t index) { + if (IAG::Subgraph::from_cf(subgraph) == nullptr) { + IAG::precondition_failure("accessing invalidated subgraph"); + } + + IAG::Subgraph::from_cf(subgraph)->set_index(index); +} + +#pragma mark - Observers + +IAGUniqueID IAGSubgraphAddObserver(IAGSubgraphRef subgraph, + void (*observer)(const void *context IAG_SWIFT_CONTEXT) IAG_SWIFT_CC(swift), + const void *observer_context) { + if (IAG::Subgraph::from_cf(subgraph) == nullptr) { + IAG::precondition_failure("accessing invalidated subgraph"); + } + + auto callback = IAG::ClosureFunctionVV(observer, observer_context); + return IAG::Subgraph::from_cf(subgraph)->add_observer(callback); +} + +void IAGSubgraphRemoveObserver(IAGSubgraphRef subgraph, IAGUniqueID observer_id) { + if (IAG::Subgraph::from_cf(subgraph) == nullptr) { + IAG::precondition_failure("accessing invalidated subgraph"); + } + + IAG::Subgraph::from_cf(subgraph)->remove_observer(observer_id); +} + +#pragma mark - Children + +void IAGSubgraphAddChild(IAGSubgraphRef subgraph, IAGSubgraphRef child) { IAGSubgraphAddChild2(subgraph, child, 0); } + +void IAGSubgraphAddChild2(IAGSubgraphRef subgraph, IAGSubgraphRef child, uint8_t tag) { + if (IAG::Subgraph::from_cf(subgraph) == nullptr) { + IAG::precondition_failure("accessing invalidated subgraph"); + } + if (IAG::Subgraph::from_cf(child) == nullptr) { + return; + } + + IAG::Subgraph::from_cf(subgraph)->add_child(*IAG::Subgraph::from_cf(child), tag); +} + +void IAGSubgraphRemoveChild(IAGSubgraphRef subgraph, IAGSubgraphRef child) { + if (IAG::Subgraph::from_cf(subgraph) == nullptr) { + IAG::precondition_failure("accessing invalidated subgraph"); + } + + if (child->subgraph) { + IAG::Subgraph::from_cf(subgraph)->remove_child(*IAG::Subgraph::from_cf(child), false); + } +} + +IAGSubgraphRef IAGSubgraphGetChild(IAGSubgraphRef subgraph, uint32_t index, uint8_t *tag_out) { + if (IAG::Subgraph::from_cf(subgraph) == nullptr) { + IAG::precondition_failure("accessing invalidated subgraph"); + } + if (index >= IAG::Subgraph::from_cf(subgraph)->children().size()) { + IAG::precondition_failure("invalid child index: %u", index); + } + + IAG::Subgraph::SubgraphChild &child = IAG::Subgraph::from_cf(subgraph)->children()[index]; + if (tag_out) { + *tag_out = child.tag(); + } + return child.subgraph()->to_cf(); +} + +uint32_t IAGSubgraphGetChildCount(IAGSubgraphRef subgraph) { + if (IAG::Subgraph::from_cf(subgraph) == nullptr) { + IAG::precondition_failure("accessing invalidated subgraph"); + } + + return IAG::Subgraph::from_cf(subgraph)->children().size(); +} + +IAGSubgraphRef IAGSubgraphGetParent(IAGSubgraphRef subgraph, int64_t index) { + if (IAG::Subgraph::from_cf(subgraph) == nullptr) { + IAG::precondition_failure("accessing invalidated subgraph"); + } + if (index >= IAG::Subgraph::from_cf(subgraph)->parents().size()) { + IAG::precondition_failure("invalid parent index: %u", index); + } + + return IAG::Subgraph::from_cf(subgraph)->parents()[index]->to_cf(); +} + +uint64_t IAGSubgraphGetParentCount(IAGSubgraphRef subgraph) { + if (IAG::Subgraph::from_cf(subgraph) == nullptr) { + return 0; + } + + return IAG::Subgraph::from_cf(subgraph)->parents().size(); +} + +bool IAGSubgraphIsAncestor(IAGSubgraphRef subgraph, IAGSubgraphRef other) { + if (IAG::Subgraph::from_cf(subgraph) == nullptr) { + return false; + } + if (IAG::Subgraph::from_cf(other) == nullptr) { + return false; + } + + return IAG::Subgraph::from_cf(subgraph)->ancestor_of(*IAG::Subgraph::from_cf(other)); +} + +#pragma mark - Flags + +bool IAGSubgraphIntersects(IAGSubgraphRef subgraph, IAGAttributeFlags flags) { + if (IAG::Subgraph::from_cf(subgraph) == nullptr) { + return false; + } + + return IAG::Subgraph::from_cf(subgraph)->intersects(flags); +} + +bool IAGSubgraphIsDirty(IAGSubgraphRef subgraph, IAGAttributeFlags flags) { + if (IAG::Subgraph::from_cf(subgraph) == nullptr) { + return false; + } + + return IAG::Subgraph::from_cf(subgraph)->is_dirty(flags); +} + +#pragma mark - Graph + +IAGSubgraphRef IAGGraphGetAttributeSubgraph(IAGAttribute attribute) { + auto subgraph = IAGGraphGetAttributeSubgraph2(attribute); + if (subgraph == nullptr) { + IAG::precondition_failure("no subgraph"); + } + + return subgraph; +} + +IAGSubgraphRef IAGGraphGetAttributeSubgraph2(IAGAttribute attribute) { + auto attribute_id = IAG::AttributeID(attribute); + attribute_id.validate_data_offset(); + + auto subgraph = attribute_id.subgraph(); + if (subgraph == nullptr) { + IAG::precondition_failure("internal error"); + } + + return subgraph->to_cf(); +} + +void IAGSubgraphApply(IAGSubgraphRef subgraph, uint32_t options, + void (*body)(IAGAttribute, const void *context IAG_SWIFT_CONTEXT) IAG_SWIFT_CC(swift), const void *body_context) { + if (IAG::Subgraph::from_cf(subgraph) == nullptr) { + return; + } + + IAG::Subgraph::from_cf(subgraph)->apply(options, IAG::ClosureFunctionAV(body, body_context)); +} + +void IAGSubgraphUpdate(IAGSubgraphRef subgraph, IAGAttributeFlags flags) { + if (IAG::Subgraph::from_cf(subgraph) == nullptr) { + return; + } + + IAG::Subgraph::from_cf(subgraph)->update(flags); +} + +#pragma mark - Tree + +IAGTreeElement IAGSubgraphGetTreeRoot(IAGSubgraphRef subgraph) { + if (IAG::Subgraph::from_cf(subgraph) == nullptr) { + return IAGTreeElement(); + } + + auto tree_root = IAG::Subgraph::from_cf(subgraph)->tree_root(); + return IAGTreeElement((uintptr_t)tree_root); +} + +void IAGSubgraphSetTreeOwner(IAGSubgraphRef subgraph, IAGAttribute owner) { + if (IAG::Subgraph::from_cf(subgraph) == nullptr) { + IAG::precondition_failure("accessing invalidated subgraph"); + } + IAG::Subgraph::from_cf(subgraph)->set_tree_owner(IAG::AttributeID(owner)); +} + +void IAGSubgraphAddTreeValue(IAGAttribute value, IAGTypeID type, const char *key, uint32_t flags) { + IAG::Subgraph *current_subgraph = IAG::Subgraph::current_subgraph(); + if (current_subgraph == nullptr) { + return; + } + + auto metadata = reinterpret_cast(type); + current_subgraph->add_tree_value(IAG::AttributeID(value), metadata, key, flags); +} + +void IAGSubgraphBeginTreeElement(IAGAttribute value, IAGTypeID type, uint32_t flags) { + IAG::Subgraph *current_subgraph = IAG::Subgraph::current_subgraph(); + if (current_subgraph == nullptr) { + return; + } + + auto metadata = reinterpret_cast(type); + current_subgraph->begin_tree(IAG::AttributeID(value), metadata, flags); +} + +void IAGSubgraphEndTreeElement(IAGAttribute value) { + IAG::Subgraph *current_subgraph = IAG::Subgraph::current_subgraph(); + if (current_subgraph == nullptr) { + return; + } + + current_subgraph->end_tree(); +} + +static platform_once_t should_record_tree_once = 0; +static bool should_record_tree = true; + +void init_should_record_tree() { + char *result = getenv("IAG_TREE"); + if (result) { + should_record_tree = atoi(result) != 0; + } else { + should_record_tree = false; + } +} + +bool IAGSubgraphShouldRecordTree() { + platform_once(&should_record_tree_once, init_should_record_tree); + return should_record_tree; +} + +void IAGSubgraphSetShouldRecordTree() { + platform_once(&should_record_tree_once, init_should_record_tree); + should_record_tree = true; +} diff --git a/Sources/ComputeCxx/Subgraph/NodeCache.cpp b/Sources/ComputeCxx/Subgraph/NodeCache.cpp index b3ac073c..eccdfb1c 100644 --- a/Sources/ComputeCxx/Subgraph/NodeCache.cpp +++ b/Sources/ComputeCxx/Subgraph/NodeCache.cpp @@ -2,7 +2,7 @@ #include "Swift/SwiftShims.h" -namespace AG { +namespace IAG { Subgraph::NodeCache::NodeCache() noexcept : _heap(nullptr, 0, 0), _types(nullptr, nullptr, nullptr, nullptr, &_heap), @@ -34,7 +34,7 @@ Subgraph::NodeCache::NodeCache() noexcept b_body = b->body; } - return AGDispatchEquatable(a_body, b_body, a->type->type, a->type->equatable); + return IAGDispatchEquatable(a_body, b_body, a->type->type, a->type->equatable); }, nullptr, nullptr, &_heap), _items_by_node(nullptr, nullptr, nullptr, nullptr, &_heap) {} @@ -49,4 +49,4 @@ Subgraph::NodeCache::~NodeCache() noexcept { nullptr); } -} // namespace AG +} // namespace IAG diff --git a/Sources/ComputeCxx/Subgraph/NodeCache.h b/Sources/ComputeCxx/Subgraph/NodeCache.h index 29dcc17b..a1b4457a 100644 --- a/Sources/ComputeCxx/Subgraph/NodeCache.h +++ b/Sources/ComputeCxx/Subgraph/NodeCache.h @@ -1,15 +1,15 @@ #pragma once -#include +#include #include #include #include #include "Subgraph.h" -AG_ASSUME_NONNULL_BEGIN +IAG_ASSUME_NONNULL_BEGIN -namespace AG { +namespace IAG { class Subgraph::NodeCache { public: @@ -66,6 +66,6 @@ class Subgraph::NodeCache { util::Table, Item *> &items_by_node() { return _items_by_node; }; }; -} // namespace AG +} // namespace IAG -AG_ASSUME_NONNULL_END +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/Subgraph/Subgraph.cpp b/Sources/ComputeCxx/Subgraph/Subgraph.cpp index bc97769a..fb4571b2 100644 --- a/Sources/ComputeCxx/Subgraph/Subgraph.cpp +++ b/Sources/ComputeCxx/Subgraph/Subgraph.cpp @@ -6,7 +6,7 @@ #include -#include "AGSubgraph-Private.h" +#include "IAGSubgraph-Private.h" #include "Attribute/AttributeData/Node/IndirectNode.h" #include "Attribute/AttributeData/Node/Node.h" #include "Attribute/AttributeID/OffsetAttributeID.h" @@ -17,7 +17,7 @@ #include "NodeCache.h" #include "Trace/Trace.h" -namespace AG { +namespace IAG { Subgraph::Subgraph(SubgraphObject *object, Graph::Context &context, AttributeID attribute) { _object = object; @@ -28,7 +28,7 @@ Subgraph::Subgraph(SubgraphObject *object, Graph::Context &context, AttributeID graph->add_subgraph(*this); - if (AGSubgraphShouldRecordTree()) { + if (IAGSubgraphShouldRecordTree()) { if (!attribute || attribute.is_nil()) { auto update = Graph::current_update(); if (update.tag() == 0 && update.get() != nullptr) { @@ -59,9 +59,9 @@ Subgraph::~Subgraph() { #pragma mark - CFType -Subgraph *Subgraph::from_cf(AGSubgraphStorage *storage) { return storage->subgraph; } +Subgraph *Subgraph::from_cf(IAGSubgraphStorage *storage) { return storage->subgraph; } -AGSubgraphStorage *Subgraph::to_cf() const { return reinterpret_cast(_object); } +IAGSubgraphStorage *Subgraph::to_cf() const { return reinterpret_cast(_object); } void Subgraph::clear_object() { auto object = _object; @@ -88,7 +88,7 @@ void Subgraph::set_current_subgraph(Subgraph *subgraph) { pthread_setspecific(_c #pragma mark - Observers -AGUniqueID Subgraph::add_observer(ClosureFunctionVV callback) { +IAGUniqueID Subgraph::add_observer(ClosureFunctionVV callback) { if (!_observers) { _observers = alloc_bytes(sizeof(vector *), 7).unsafe_cast *>(); @@ -96,12 +96,12 @@ AGUniqueID Subgraph::add_observer(ClosureFunctionVV callback) { ; } - auto observer_id = AGMakeUniqueID(); + auto observer_id = IAGMakeUniqueID(); (*_observers)->push_back(Observer(callback, observer_id)); return observer_id; } -void Subgraph::remove_observer(AGUniqueID observer_id) { +void Subgraph::remove_observer(IAGUniqueID observer_id) { if (auto observers_ptr = _observers.get()) { auto observers = *observers_ptr; auto iter = std::remove_if(observers->begin(), observers->end(), [&observer_id](auto observer) -> bool { @@ -339,13 +339,13 @@ void Subgraph::add_child(Subgraph &child, uint8_t tag) { graph()->foreach_trace([this, &child](Trace &trace) { trace.add_child(*this, child); }); _children.push_back(SubgraphChild(&child, tag)); - AGAttributeFlags descendent_flags = child._flags | child._descendent_flags; + IAGAttributeFlags descendent_flags = child._flags | child._descendent_flags; if (descendent_flags & ~_descendent_flags) { _descendent_flags |= descendent_flags; propagate_flags(); } - AGAttributeFlags descendent_dirty_flags = child._dirty_flags | child._descendent_dirty_flags; + IAGAttributeFlags descendent_dirty_flags = child._dirty_flags | child._descendent_dirty_flags; if (descendent_dirty_flags & ~_descendent_dirty_flags) { _descendent_dirty_flags |= descendent_dirty_flags; propagate_dirty_flags(); @@ -395,11 +395,11 @@ bool Subgraph::ancestor_of(const Subgraph &other) { #pragma mark - Flags -void Subgraph::set_flags(data::ptr node, AGAttributeFlags flags) { +void Subgraph::set_flags(data::ptr node, IAGAttributeFlags flags) { if (node->subgraph_flags() == flags) { return; } - if (node->subgraph_flags() == AGAttributeFlagsNone || flags == AGAttributeFlagsNone) { + if (node->subgraph_flags() == IAGAttributeFlagsNone || flags == IAGAttributeFlagsNone) { // unlink and reinsert to trigger a reorder unlink_attribute(AttributeID(node)); node->set_subgraph_flags(flags); @@ -414,7 +414,7 @@ void Subgraph::set_flags(data::ptr node, AGAttributeFlags flags) { } } -void Subgraph::add_flags(AGAttributeFlags flags) { +void Subgraph::add_flags(IAGAttributeFlags flags) { if (!(flags & ~_flags)) { return; } @@ -435,7 +435,7 @@ void Subgraph::propagate_flags() { }); } -void Subgraph::add_dirty_flags(AGAttributeFlags dirty_flags) { +void Subgraph::add_dirty_flags(IAGAttributeFlags dirty_flags) { if (!(dirty_flags & ~_dirty_flags)) { return; } @@ -459,7 +459,7 @@ void Subgraph::propagate_dirty_flags() { // MARK: Attributes void Subgraph::insert_attribute(AttributeID attribute, bool updatable) { - AttributeID previous_attribute = AttributeID(AGAttributeNil); + AttributeID previous_attribute = AttributeID(IAGAttributeNil); // sort attributes with flags before indirect attributes or attributes // without flags the attribute will only be non-updatable if it is a @@ -528,7 +528,7 @@ void Subgraph::unlink_attribute(AttributeID attribute) { } void Subgraph::add_node(data::ptr node) { - node->set_subgraph_flags(AGAttributeFlagsNone); + node->set_subgraph_flags(IAGAttributeFlagsNone); insert_attribute(AttributeID(node), true); if (_tree_root) { @@ -547,12 +547,12 @@ void Subgraph::add_indirect(data::ptr node, bool flag) { std::atomic Subgraph::_last_traversal_seed = {}; -void Subgraph::apply(uint32_t options, ClosureFunctionAV body) { +void Subgraph::apply(uint32_t options, ClosureFunctionAV body) { if (!is_valid()) { return; } - AGAttributeFlags flags = options & AGAttributeFlagsAll; + IAGAttributeFlags flags = options & IAGAttributeFlagsAll; if (!intersects(flags)) { return; } @@ -582,7 +582,7 @@ void Subgraph::apply(uint32_t options, ClosureFunctionAV body } if (auto node = attribute.get_node()) { if (options) { // TODO: options or mask? - if (node->subgraph_flags() == AGAttributeFlagsNone) { + if (node->subgraph_flags() == IAGAttributeFlagsNone) { // we know this attribute is sorted after // all nodes with flags so we aren't going // to match any more attributes after this @@ -617,7 +617,7 @@ void Subgraph::apply(uint32_t options, ClosureFunctionAV body } } -void Subgraph::update(AGAttributeFlags mask) { +void Subgraph::update(IAGAttributeFlags mask) { if (_graph->needs_update() && _graph->thread_is_updating()) { _graph->call_update(); } @@ -631,7 +631,7 @@ void Subgraph::update(AGAttributeFlags mask) { _last_traversal_seed += 1; auto subgraph_objects = - std::stack, vector, 32, uint64_t>>(); + std::stack, vector, 32, uint64_t>>(); auto dirty_nodes = vector, 256, uint64_t>(); subgraph_objects.push(util::cf_ptr(to_cf())); @@ -640,7 +640,7 @@ void Subgraph::update(AGAttributeFlags mask) { while (!subgraph_objects.empty()) { bool created_transaction = false; - util::cf_ptr subgraph_object = subgraph_objects.top(); + util::cf_ptr subgraph_object = subgraph_objects.top(); subgraph_objects.pop(); Subgraph *subgraph = Subgraph::from_cf(subgraph_object.get()); @@ -659,7 +659,7 @@ void Subgraph::update(AGAttributeFlags mask) { } if (auto node = attribute.get_node()) { if (mask) { - if (node->subgraph_flags() == AGAttributeFlagsNone) { + if (node->subgraph_flags() == IAGAttributeFlagsNone) { // we know this attribute is sorted after // all nodes with flags so we aren't going // to match any more attributes after this @@ -689,7 +689,7 @@ void Subgraph::update(AGAttributeFlags mask) { if (!created_transaction) { _graph->increment_transaction_count_if_needed(); } - _graph->update_attribute(node, AGGraphUpdateOptionsInTransaction); + _graph->update_attribute(node, IAGGraphUpdateOptionsInTransaction); created_transaction = true; if (!subgraph->is_valid()) { break; @@ -724,7 +724,7 @@ void Subgraph::update(AGAttributeFlags mask) { // age = 0xff: collected, removed from items(), in recycle list data::ptr Subgraph::cache_fetch(size_t hash, const swift::metadata &metadata, const void *body, - ClosureFunctionCI get_attribute_type_id) { + ClosureFunctionCI get_attribute_type_id) { if (_cache == nullptr) { _cache = alloc_bytes(sizeof(NodeCache), 7).unsafe_cast(); new (_cache.get()) NodeCache(); @@ -967,7 +967,7 @@ AttributeID Subgraph::tree_node_at_index(Graph::TreeElementID tree_element, uint --i; } } - return AttributeID(AGAttributeNil); + return AttributeID(IAGAttributeNil); } Graph::TreeElementID Subgraph::tree_subgraph_child(Graph::TreeElementID tree_element) { @@ -989,6 +989,7 @@ Graph::TreeElementID Subgraph::tree_subgraph_child(Graph::TreeElementID tree_ele auto subgraph_children = vector(); + // Check if any node created for _this_ tree element, is the tree owner for any child subgraph for (auto subgraph : _graph->subgraphs()) { if (!subgraph->is_valid()) { continue; @@ -1044,7 +1045,7 @@ void Subgraph::print(uint32_t indent_level) { for (auto page : pages()) { for (auto attribute : attribute_view(page)) { if (auto node = attribute.get_node()) { - fprintf(stdout, "%s%u", first ? "" : " ", AGAttribute(attribute)); + fprintf(stdout, "%s%u", first ? "" : " ", IAGAttribute(attribute)); if (auto subgraph_flags = node->subgraph_flags()) { fprintf(stdout, "(%u)", subgraph_flags); } @@ -1060,4 +1061,4 @@ void Subgraph::print(uint32_t indent_level) { } } -} // namespace AG +} // namespace IAG diff --git a/Sources/ComputeCxx/Subgraph/Subgraph.h b/Sources/ComputeCxx/Subgraph/Subgraph.h index 873f12c4..a2a01bff 100644 --- a/Sources/ComputeCxx/Subgraph/Subgraph.h +++ b/Sources/ComputeCxx/Subgraph/Subgraph.h @@ -1,24 +1,24 @@ #pragma once -#include "AGSubgraph-Private.h" +#include "IAGSubgraph-Private.h" #include "Attribute/AttributeID/AttributeID.h" #include "Closure/ClosureFunction.h" -#include "ComputeCxx/AGBase.h" -#include "ComputeCxx/AGUniqueID.h" +#include "ComputeCxx/IAGBase.h" +#include "ComputeCxx/IAGUniqueID.h" #include "Data/Zone.h" #include "Graph/Graph.h" #include "Graph/Tree/TreeElement.h" #include "Vector/IndirectPointerVector.h" -AG_ASSUME_NONNULL_BEGIN +IAG_ASSUME_NONNULL_BEGIN -struct AGSubgraphStorage; +struct IAGSubgraphStorage; -namespace AG { +namespace IAG { class SubgraphObject { private: - AGSubgraphStorage _storage; + IAGSubgraphStorage _storage; public: Subgraph *subgraph() { return _storage.subgraph; }; @@ -64,10 +64,10 @@ class Subgraph : public data::zone { data::ptr _cache = nullptr; Graph::TreeElementID _tree_root; - AGAttributeFlags _flags; - AGAttributeFlags _descendent_flags; - AGAttributeFlags _dirty_flags; - AGAttributeFlags _descendent_dirty_flags; + IAGAttributeFlags _flags; + IAGAttributeFlags _descendent_flags; + IAGAttributeFlags _dirty_flags; + IAGAttributeFlags _descendent_dirty_flags; enum class InvalidationState : uint8_t { None = 0, @@ -104,8 +104,8 @@ class Subgraph : public data::zone { // MARK: CFType - AGSubgraphStorage *to_cf() const; - static Subgraph *from_cf(AGSubgraphStorage *storage); + IAGSubgraphStorage *to_cf() const; + static Subgraph *from_cf(IAGSubgraphStorage *storage); void clear_object(); // MARK: Graph @@ -127,8 +127,8 @@ class Subgraph : public data::zone { // MARK: Observers - AGUniqueID add_observer(ClosureFunctionVV callback); - void remove_observer(AGUniqueID observer_id); + IAGUniqueID add_observer(ClosureFunctionVV callback); + void remove_observer(IAGUniqueID observer_id); void notify_observers(); // MARK: Invalidating @@ -167,16 +167,16 @@ class Subgraph : public data::zone { // MARK: Flags - void set_flags(data::ptr node, AGAttributeFlags flags); + void set_flags(data::ptr node, IAGAttributeFlags flags); - void add_flags(AGAttributeFlags flags); + void add_flags(IAGAttributeFlags flags); void propagate_flags(); - void add_dirty_flags(AGAttributeFlags dirty_flags); + void add_dirty_flags(IAGAttributeFlags dirty_flags); void propagate_dirty_flags(); - bool intersects(AGAttributeFlags mask) const { return (_flags | _descendent_flags) & mask; } - bool is_dirty(AGAttributeFlags mask) const { return (_dirty_flags | _descendent_dirty_flags) & mask; } + bool intersects(IAGAttributeFlags mask) const { return (_flags | _descendent_flags) & mask; } + bool is_dirty(IAGAttributeFlags mask) const { return (_dirty_flags | _descendent_dirty_flags) & mask; } // MARK: Attributes @@ -185,9 +185,9 @@ class Subgraph : public data::zone { static std::atomic _last_traversal_seed; - void apply(uint32_t options, ClosureFunctionAV body); + void apply(uint32_t options, ClosureFunctionAV body); - void update(AGAttributeFlags mask); + void update(IAGAttributeFlags mask); // MARK: Cache @@ -209,7 +209,7 @@ class Subgraph : public data::zone { }; data::ptr cache_fetch(size_t hash, const swift::metadata &metadata, const void *body, - ClosureFunctionCI get_attribute_type_id); + ClosureFunctionCI get_attribute_type_id); void cache_insert(data::ptr node); void cache_collect(); @@ -232,6 +232,6 @@ class Subgraph : public data::zone { void print(uint32_t indent_level); }; -} // namespace AG +} // namespace IAG -AG_ASSUME_NONNULL_END +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/Swift/ContextDescriptor.cpp b/Sources/ComputeCxx/Swift/ContextDescriptor.cpp index 7c84b7ae..6bd68958 100644 --- a/Sources/ComputeCxx/Swift/ContextDescriptor.cpp +++ b/Sources/ComputeCxx/Swift/ContextDescriptor.cpp @@ -2,7 +2,7 @@ #include "Metadata.h" -namespace AG { +namespace IAG { namespace swift { context_descriptor::generic_params_info::generic_params_info(const context_descriptor &context, @@ -155,4 +155,4 @@ uint64_t class_type_descriptor::field_offset_vector_offset() const { } } // namespace swift -} // namespace AG +} // namespace IAG diff --git a/Sources/ComputeCxx/Swift/ContextDescriptor.h b/Sources/ComputeCxx/Swift/ContextDescriptor.h index 487a5055..fa01d124 100644 --- a/Sources/ComputeCxx/Swift/ContextDescriptor.h +++ b/Sources/ComputeCxx/Swift/ContextDescriptor.h @@ -3,13 +3,13 @@ #include #include -#include "ComputeCxx/AGBase.h" +#include "ComputeCxx/IAGBase.h" #include "Metadata.h" #include "Vector/Vector.h" -AG_ASSUME_NONNULL_BEGIN +IAG_ASSUME_NONNULL_BEGIN -namespace AG { +namespace IAG { namespace swift { class context_descriptor : public ::swift::ContextDescriptor { @@ -62,6 +62,6 @@ class class_type_descriptor { }; } // namespace swift -} // namespace AG +} // namespace IAG -AG_ASSUME_NONNULL_END +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/Swift/AGTuple.cpp b/Sources/ComputeCxx/Swift/IAGTuple.cpp similarity index 60% rename from Sources/ComputeCxx/Swift/AGTuple.cpp rename to Sources/ComputeCxx/Swift/IAGTuple.cpp index e8e654a8..8fdedc19 100644 --- a/Sources/ComputeCxx/Swift/AGTuple.cpp +++ b/Sources/ComputeCxx/Swift/IAGTuple.cpp @@ -1,10 +1,10 @@ -#include "ComputeCxx/AGTuple.h" +#include "ComputeCxx/IAGTuple.h" #include #include "Errors/Errors.h" -AGTupleType AGNewTupleType(size_t count, const AGTypeID *elements) { +IAGTupleType IAGNewTupleType(size_t count, const IAGTypeID *elements) { if (count == 1) { return elements[0]; } @@ -13,12 +13,12 @@ AGTupleType AGNewTupleType(size_t count, const AGTypeID *elements) { ::swift::TupleTypeFlags().withNumElements((unsigned int)count), metadata_elements, nullptr, nullptr); if (response.State != ::swift::MetadataState::Complete) { - AG::precondition_failure("invalid tuple type."); + IAG::precondition_failure("invalid tuple type."); } - return reinterpret_cast(response.Value); + return reinterpret_cast(response.Value); } -size_t AGTupleCount(AGTupleType tuple_type) { +size_t IAGTupleCount(IAGTupleType tuple_type) { auto metadata = reinterpret_cast(tuple_type); if (metadata->getKind() != ::swift::MetadataKind::Tuple) { return 1; @@ -27,184 +27,184 @@ size_t AGTupleCount(AGTupleType tuple_type) { return static_cast(tuple_metadata->NumElements); } -size_t AGTupleSize(AGTupleType tuple_type) { +size_t IAGTupleSize(IAGTupleType tuple_type) { auto metadata = reinterpret_cast(tuple_type); return metadata->vw_size(); } -AGTypeID AGTupleElementType(AGTupleType tuple_type, size_t index) { +IAGTypeID IAGTupleElementType(IAGTupleType tuple_type, size_t index) { auto metadata = reinterpret_cast(tuple_type); if (metadata->getKind() != ::swift::MetadataKind::Tuple) { if (index != 0) { - AG::precondition_failure("index out of range: %d", index); + IAG::precondition_failure("index out of range: %d", index); } - return reinterpret_cast(metadata); + return reinterpret_cast(metadata); } auto tuple_metadata = static_cast(metadata); if (index >= tuple_metadata->NumElements) { - AG::precondition_failure("index out of range: %d", index); + IAG::precondition_failure("index out of range: %d", index); } auto element = tuple_metadata->getElement((unsigned int)index); - return reinterpret_cast(element.Type); + return reinterpret_cast(element.Type); } -size_t AGTupleElementSize(AGTupleType tuple_type, size_t index) { +size_t IAGTupleElementSize(IAGTupleType tuple_type, size_t index) { auto metadata = reinterpret_cast(tuple_type); if (metadata->getKind() != ::swift::MetadataKind::Tuple) { if (index != 0) { - AG::precondition_failure("index out of range: %d", index); + IAG::precondition_failure("index out of range: %d", index); } return metadata->vw_size(); } auto tuple_metadata = static_cast(metadata); if (index >= tuple_metadata->NumElements) { - AG::precondition_failure("index out of range: %d", index); + IAG::precondition_failure("index out of range: %d", index); } auto element = tuple_metadata->getElement((unsigned int)index); return element.Type->vw_size(); } -size_t AGTupleElementOffset(AGTupleType tuple_type, size_t index) { +size_t IAGTupleElementOffset(IAGTupleType tuple_type, size_t index) { auto metadata = reinterpret_cast(tuple_type); if (metadata->getKind() != ::swift::MetadataKind::Tuple) { if (index != 0) { - AG::precondition_failure("index out of range: %d", index); + IAG::precondition_failure("index out of range: %d", index); } return 0; } auto tuple_metadata = static_cast(metadata); if (index >= tuple_metadata->NumElements) { - AG::precondition_failure("index out of range: %d", index); + IAG::precondition_failure("index out of range: %d", index); } auto element = tuple_metadata->getElement((unsigned int)index); return element.Offset; } -size_t AGTupleElementOffsetChecked(AGTupleType tuple_type, size_t index, AGTypeID element_type) { +size_t IAGTupleElementOffsetChecked(IAGTupleType tuple_type, size_t index, IAGTypeID element_type) { auto metadata = reinterpret_cast(tuple_type); if (metadata->getKind() != ::swift::MetadataKind::Tuple) { if (index != 0) { - AG::precondition_failure("index out of range: %d", index); + IAG::precondition_failure("index out of range: %d", index); } - if (reinterpret_cast(metadata) != element_type) { - AG::precondition_failure("element type mismatch"); + if (reinterpret_cast(metadata) != element_type) { + IAG::precondition_failure("element type mismatch"); } return 0; } auto tuple_metadata = static_cast(metadata); if (index >= tuple_metadata->NumElements) { - AG::precondition_failure("index out of range: %d", index); + IAG::precondition_failure("index out of range: %d", index); } auto element = tuple_metadata->getElement((unsigned int)index); - if (reinterpret_cast(element.Type) != element_type) { - AG::precondition_failure("element type mismatch"); + if (reinterpret_cast(element.Type) != element_type) { + IAG::precondition_failure("element type mismatch"); } return element.Offset; } -void *update(void *dest_ptr, const void *src_ptr, const ::swift::Metadata *metadata, AGTupleCopyOptions options) { +void *update(void *dest_ptr, const void *src_ptr, const ::swift::Metadata *metadata, IAGTupleCopyOptions options) { auto dest = reinterpret_cast<::swift::OpaqueValue *>(dest_ptr); auto src = reinterpret_cast<::swift::OpaqueValue *>(const_cast(src_ptr)); switch (options) { - case AGTupleCopyOptionsAssignCopy: + case IAGTupleCopyOptionsAssignCopy: return metadata->vw_assignWithCopy(dest, src); - case AGTupleCopyOptionsInitCopy: + case IAGTupleCopyOptionsInitCopy: return metadata->vw_initializeWithCopy(dest, src); - case AGTupleCopyOptionsAssignTake: + case IAGTupleCopyOptionsAssignTake: return metadata->vw_assignWithTake(dest, src); - case AGTupleCopyOptionsInitTake: + case IAGTupleCopyOptionsInitTake: return metadata->vw_initializeWithTake(dest, src); default: - AG::precondition_failure("unknown copy options: %d", options); + IAG::precondition_failure("unknown copy options: %d", options); } }; -void *AGTupleGetElement(AGTupleType tuple_type, void *tuple_value, size_t index, void *element_value, - AGTypeID element_type, AGTupleCopyOptions options) { +void *IAGTupleGetElement(IAGTupleType tuple_type, void *tuple_value, size_t index, void *element_value, + IAGTypeID element_type, IAGTupleCopyOptions options) { auto metadata = reinterpret_cast(tuple_type); if (metadata->getKind() != ::swift::MetadataKind::Tuple) { if (index != 0) { - AG::precondition_failure("index out of range: %d", index); + IAG::precondition_failure("index out of range: %d", index); } - if (reinterpret_cast(metadata) != element_type) { - AG::precondition_failure("element type mismatch"); + if (reinterpret_cast(metadata) != element_type) { + IAG::precondition_failure("element type mismatch"); } return update(element_value, tuple_value, metadata, options); } auto tuple_metadata = static_cast(metadata); if (index >= tuple_metadata->NumElements) { - AG::precondition_failure("index out of range: %d", index); + IAG::precondition_failure("index out of range: %d", index); } auto element = tuple_metadata->getElement((unsigned int)index); - if (reinterpret_cast(element.Type) != element_type) { - AG::precondition_failure("element type mismatch"); + if (reinterpret_cast(element.Type) != element_type) { + IAG::precondition_failure("element type mismatch"); } return update(element_value, element.findIn(reinterpret_cast<::swift::OpaqueValue *>(tuple_value)), element.Type, options); } -void *AGTupleSetElement(AGTupleType tuple_type, void *tuple_value, size_t index, const void *element_value, - AGTypeID element_type, AGTupleCopyOptions options) { +void *IAGTupleSetElement(IAGTupleType tuple_type, void *tuple_value, size_t index, const void *element_value, + IAGTypeID element_type, IAGTupleCopyOptions options) { auto metadata = reinterpret_cast(tuple_type); if (metadata->getKind() != ::swift::MetadataKind::Tuple) { if (index != 0) { - AG::precondition_failure("index out of range: %d", index); + IAG::precondition_failure("index out of range: %d", index); } - if (reinterpret_cast(metadata) != element_type) { - AG::precondition_failure("element type mismatch"); + if (reinterpret_cast(metadata) != element_type) { + IAG::precondition_failure("element type mismatch"); } return update(tuple_value, element_value, metadata, options); } auto tuple_metadata = static_cast(metadata); if (index >= tuple_metadata->NumElements) { - AG::precondition_failure("index out of range: %d", index); + IAG::precondition_failure("index out of range: %d", index); } auto element = tuple_metadata->getElement((unsigned int)index); - if (reinterpret_cast(element.Type) != element_type) { - AG::precondition_failure("element type mismatch"); + if (reinterpret_cast(element.Type) != element_type) { + IAG::precondition_failure("element type mismatch"); } return update(element.findIn(reinterpret_cast<::swift::OpaqueValue *>(tuple_value)), element_value, element.Type, options); } -void AGTupleDestroy(AGTupleType tuple_type, void *tuple_value) { +void IAGTupleDestroy(IAGTupleType tuple_type, void *tuple_value) { auto metadata = reinterpret_cast(tuple_type); metadata->vw_destroy(reinterpret_cast<::swift::OpaqueValue *>(tuple_value)); } -void AGTupleDestroyElement(AGTupleType tuple_type, void *tuple_value, size_t index) { +void IAGTupleDestroyElement(IAGTupleType tuple_type, void *tuple_value, size_t index) { auto metadata = reinterpret_cast(tuple_type); if (metadata->getKind() != ::swift::MetadataKind::Tuple) { if (index != 0) { - AG::precondition_failure("index out of range: %d", index); + IAG::precondition_failure("index out of range: %d", index); } metadata->vw_destroy(reinterpret_cast<::swift::OpaqueValue *>(tuple_value)); } auto tuple_metadata = static_cast(metadata); if (index >= tuple_metadata->NumElements) { - AG::precondition_failure("index out of range: %d", index); + IAG::precondition_failure("index out of range: %d", index); } auto element = tuple_metadata->getElement((unsigned int)index); element.Type->vw_destroy(element.findIn(reinterpret_cast<::swift::OpaqueValue *>(tuple_value))); } -void AGTupleWithBuffer(AGTupleType tuple_type, size_t count, - void (*function)(const AGUnsafeMutableTuple mutable_tuple, void *context AG_SWIFT_CONTEXT) - AG_SWIFT_CC(swift), +void IAGTupleWithBuffer(IAGTupleType tuple_type, size_t count, + void (*function)(const IAGUnsafeMutableTuple mutable_tuple, void *context IAG_SWIFT_CONTEXT) + IAG_SWIFT_CC(swift), void *context) { auto metadata = reinterpret_cast(tuple_type); auto buffer_size = metadata->vw_stride() * count; if (buffer_size <= 0x1000) { void *buffer = (unsigned char *)alloca(buffer_size); bzero((void *)buffer, buffer_size); - AGUnsafeMutableTuple tuple = {tuple_type, buffer}; + IAGUnsafeMutableTuple tuple = {tuple_type, buffer}; function(tuple, context); } else { void *buffer = malloc(buffer_size); if (buffer == nullptr) { - AG::precondition_failure("memory allocation failure"); + IAG::precondition_failure("memory allocation failure"); } - AGUnsafeMutableTuple tuple = {tuple_type, buffer}; + IAGUnsafeMutableTuple tuple = {tuple_type, buffer}; function(tuple, context); free(buffer); } diff --git a/Sources/ComputeCxx/Swift/AGType.cpp b/Sources/ComputeCxx/Swift/IAGType.cpp similarity index 59% rename from Sources/ComputeCxx/Swift/AGType.cpp rename to Sources/ComputeCxx/Swift/IAGType.cpp index 90c3834b..5c2622a7 100644 --- a/Sources/ComputeCxx/Swift/AGType.cpp +++ b/Sources/ComputeCxx/Swift/IAGType.cpp @@ -1,4 +1,4 @@ -#include "ComputeCxx/AGType.h" +#include "ComputeCxx/IAGType.h" #if TARGET_OS_MAC #include @@ -12,8 +12,8 @@ #include "MetadataVisitor.h" #if TARGET_OS_MAC -CFStringRef AGTypeDescription(AGTypeID typeID) { - auto type = reinterpret_cast(typeID); +CFStringRef IAGTypeDescription(IAGTypeID typeID) { + auto type = reinterpret_cast(typeID); CFMutableStringRef description = CFStringCreateMutable(kCFAllocatorDefault, 0); type->append_description(description); @@ -21,8 +21,8 @@ CFStringRef AGTypeDescription(AGTypeID typeID) { return description; } #else -CFStringRef AGTypeCopyDescription(AGTypeID typeID) { - auto type = reinterpret_cast(typeID); +CFStringRef IAGTypeCopyDescription(IAGTypeID typeID) { + auto type = reinterpret_cast(typeID); CFMutableStringRef description = CFStringCreateMutable(kCFAllocatorDefault, 0); type->append_description(description); @@ -30,55 +30,55 @@ CFStringRef AGTypeCopyDescription(AGTypeID typeID) { } #endif -AGTypeKind AGTypeGetKind(AGTypeID typeID) { - auto type = reinterpret_cast(typeID); +IAGTypeKind IAGTypeGetKind(IAGTypeID typeID) { + auto type = reinterpret_cast(typeID); switch (type->getKind()) { case swift::MetadataKind::Class: - return AGTypeKindClass; + return IAGTypeKindClass; case swift::MetadataKind::Struct: - return AGTypeKindStruct; + return IAGTypeKindStruct; case swift::MetadataKind::Enum: - return AGTypeKindEnum; + return IAGTypeKindEnum; case swift::MetadataKind::Optional: - return AGTypeKindOptional; + return IAGTypeKindOptional; case swift::MetadataKind::Tuple: - return AGTypeKindTuple; + return IAGTypeKindTuple; case swift::MetadataKind::Function: - return AGTypeKindFunction; + return IAGTypeKindFunction; case swift::MetadataKind::Existential: - return AGTypeKindExistential; + return IAGTypeKindExistential; case swift::MetadataKind::Metatype: - return AGTypeKindMetatype; + return IAGTypeKindMetatype; default: - return AGTypeKindNone; + return IAGTypeKindNone; } } -const AGTypeSignature AGTypeGetSignature(AGTypeID typeID) { - auto type = reinterpret_cast(typeID); +const IAGTypeSignature IAGTypeGetSignature(IAGTypeID typeID) { + auto type = reinterpret_cast(typeID); const uint8_t *data = static_cast(type->signature()); if (!data) { - return AGTypeSignature(); + return IAGTypeSignature(); } - AGTypeSignature signature = {}; + IAGTypeSignature signature = {}; for (size_t i = 0; i < 20; ++i) { signature.bytes[i] = data[i]; } return signature; } -const void *AGTypeGetDescriptor(AGTypeID typeID) { - auto type = reinterpret_cast(typeID); +const void *IAGTypeGetDescriptor(IAGTypeID typeID) { + auto type = reinterpret_cast(typeID); return type->descriptor(); } -const void *AGTypeNominalDescriptor(AGTypeID typeID) { - auto type = reinterpret_cast(typeID); +const void *IAGTypeNominalDescriptor(IAGTypeID typeID) { + auto type = reinterpret_cast(typeID); return type->nominal_descriptor(); } -const char *AGTypeNominalDescriptorName(AGTypeID typeID) { - auto type = reinterpret_cast(typeID); +const char *IAGTypeNominalDescriptorName(IAGTypeID typeID) { + auto type = reinterpret_cast(typeID); auto nominal_descriptor = type->nominal_descriptor(); if (!nominal_descriptor) { return nullptr; @@ -86,40 +86,40 @@ const char *AGTypeNominalDescriptorName(AGTypeID typeID) { return nominal_descriptor->name(); } -void AGTypeApplyFields(AGTypeID typeID, +void IAGTypeApplyFields(IAGTypeID typeID, void (*apply)(const char *field_name, size_t field_offset, - AGTypeID field_type, - const void *context AG_SWIFT_CONTEXT) - AG_SWIFT_CC(swift), + IAGTypeID field_type, + const void *context IAG_SWIFT_CONTEXT) + IAG_SWIFT_CC(swift), const void *apply_context) { - class Visitor : public AG::swift::metadata_visitor { + class Visitor : public IAG::swift::metadata_visitor { private: void (*_body)(const char *field_name, size_t field_offset, - AGTypeID field_type, - const void *context AG_SWIFT_CONTEXT) - AG_SWIFT_CC(swift); + IAGTypeID field_type, + const void *context IAG_SWIFT_CONTEXT) + IAG_SWIFT_CC(swift); const void *_body_context; public: Visitor(void (*body)(const char *field_name, size_t field_offset, - AGTypeID field_type, - const void *context AG_SWIFT_CONTEXT) AG_SWIFT_CC(swift), + IAGTypeID field_type, + const void *context IAG_SWIFT_CONTEXT) IAG_SWIFT_CC(swift), const void *body_context) : _body(body), _body_context(body_context) {} bool unknown_result() override { return true; } - bool visit_field(const AG::swift::metadata &type, - const AG::swift::field_record &field, + bool visit_field(const IAG::swift::metadata &type, + const IAG::swift::field_record &field, size_t field_offset, size_t field_size) override { auto mangled_name = field.MangledTypeName.get(); auto field_type = type.mangled_type_name_ref(mangled_name, true, nullptr); if (field_type) { auto field_name = field.FieldName.get(); - _body(field_name, field_offset, AGTypeID(field_type), _body_context); + _body(field_name, field_offset, IAGTypeID(field_type), _body_context); } return true; } @@ -127,32 +127,32 @@ void AGTypeApplyFields(AGTypeID typeID, Visitor visitor = Visitor(apply, apply_context); - auto type = reinterpret_cast(typeID); + auto type = reinterpret_cast(typeID); type->visit(visitor); } -bool AGTypeApplyFields2(AGTypeID typeID, AGTypeApplyOptions options, +bool IAGTypeApplyFields2(IAGTypeID typeID, IAGTypeApplyOptions options, bool (*apply)(const char *field_name, size_t field_offset, - AGTypeID field_type, - const void *context AG_SWIFT_CONTEXT) - AG_SWIFT_CC(swift), + IAGTypeID field_type, + const void *context IAG_SWIFT_CONTEXT) + IAG_SWIFT_CC(swift), const void *apply_context) { - class Visitor : public AG::swift::metadata_visitor { + class Visitor : public IAG::swift::metadata_visitor { private: - AGTypeApplyOptions _options; - AG::ClosureFunction *_body; + IAGTypeApplyOptions _options; + IAG::ClosureFunction *_body; public: - Visitor(AGTypeApplyOptions options, - AG::ClosureFunction *body) + Visitor(IAGTypeApplyOptions options, + IAG::ClosureFunction *body) : _options(options), _body(body) {} bool unknown_result() override { - return _options & AGTypeApplyOptionsContinueAfterUnknownField; + return _options & IAGTypeApplyOptionsContinueAfterUnknownField; } - bool visit_field(const AG::swift::metadata &type, - const AG::swift::field_record &field, + bool visit_field(const IAG::swift::metadata &type, + const IAG::swift::field_record &field, size_t field_offset, size_t field_size) override { auto mangled_name = field.MangledTypeName.get(); auto field_type = @@ -162,11 +162,11 @@ bool AGTypeApplyFields2(AGTypeID typeID, AGTypeApplyOptions options, } auto field_name = field.FieldName.get(); bool result = - (*_body)(field_name, field_offset, AGTypeID(field_type)); + (*_body)(field_name, field_offset, IAGTypeID(field_type)); return result != 0; } - bool visit_case(const AG::swift::metadata &type, - const AG::swift::field_record &field, + bool visit_case(const IAG::swift::metadata &type, + const IAG::swift::field_record &field, uint32_t index) override { auto mangled_name = field.MangledTypeName.get(); auto field_type = type.mangled_type_name_ref( @@ -175,39 +175,39 @@ bool AGTypeApplyFields2(AGTypeID typeID, AGTypeApplyOptions options, return unknown_result(); } auto field_name = field.FieldName.get(); - bool result = (*_body)(field_name, index, AGTypeID(field_type)); + bool result = (*_body)(field_name, index, IAGTypeID(field_type)); return result != 0; } }; auto closure_function = - AG::ClosureFunction( + IAG::ClosureFunction( apply, apply_context); Visitor visitor = Visitor(options, &closure_function); - auto type = reinterpret_cast(typeID); + auto type = reinterpret_cast(typeID); switch (type->getKind()) { case ::swift::MetadataKind::Class: - if (options & AGTypeApplyOptionsEnumerateClassFields) { + if (options & IAGTypeApplyOptionsEnumerateClassFields) { return type->visit_heap(visitor, - AG::LayoutDescriptor::HeapMode::Class); + IAG::LayoutDescriptor::HeapMode::Class); } return false; case ::swift::MetadataKind::Struct: - if (!(options & AGTypeApplyOptionsEnumerateClassFields) && - !(options & AGTypeApplyOptionsEnumerateEnumCases)) { + if (!(options & IAGTypeApplyOptionsEnumerateClassFields) && + !(options & IAGTypeApplyOptionsEnumerateEnumCases)) { return type->visit(visitor); } return false; case ::swift::MetadataKind::Enum: case ::swift::MetadataKind::Optional: - if (options & AGTypeApplyOptionsEnumerateEnumCases) { + if (options & IAGTypeApplyOptionsEnumerateEnumCases) { return type->visit(visitor); } return false; case ::swift::MetadataKind::Tuple: - if (!(options & AGTypeApplyOptionsEnumerateClassFields) && - !(options & AGTypeApplyOptionsEnumerateEnumCases)) { + if (!(options & IAGTypeApplyOptionsEnumerateClassFields) && + !(options & IAGTypeApplyOptionsEnumerateEnumCases)) { return type->visit(visitor); } return false; @@ -216,22 +216,22 @@ bool AGTypeApplyFields2(AGTypeID typeID, AGTypeApplyOptions options, } } -bool AGTypeApplyEnumData(AGTypeID typeID, void *value, +bool IAGTypeApplyEnumData(IAGTypeID typeID, void *value, void (*body)(uint32_t tag, - AGTypeID field_type, + IAGTypeID field_type, const void *field_value, - void *context AG_SWIFT_CONTEXT) - AG_SWIFT_CC(swift), + void *context IAG_SWIFT_CONTEXT) + IAG_SWIFT_CC(swift), void *context) { - auto type = reinterpret_cast(typeID); + auto type = reinterpret_cast(typeID); auto value_witness = type->getValueWitnesses(); if (!value_witness || !value_witness->flags.hasEnumWitnesses()) { - AG::precondition_failure("not an enum type: %s", type->name(false)); + IAG::precondition_failure("not an enum type: %s", type->name(false)); } auto enum_value_witness = value_witness->_asEVWT(); uint32_t tag = enum_value_witness->getEnumTag( - reinterpret_cast(value), type); + reinterpret_cast(value), type); if (auto descriptor = type->nominal_descriptor()) { auto enum_descriptor = @@ -245,7 +245,7 @@ bool AGTypeApplyEnumData(AGTypeID typeID, void *value, mangled_name, nullptr); if (field_type) { enum_value_witness->destructiveProjectEnumData( - reinterpret_cast(value), + reinterpret_cast(value), type); void *field_value = value; @@ -258,10 +258,10 @@ bool AGTypeApplyEnumData(AGTypeID typeID, void *value, ~alignment_mask; field_value = *(char **)value + offset; } - body(tag, AGTypeID(field_type), field_value, context); + body(tag, IAGTypeID(field_type), field_value, context); enum_value_witness->destructiveInjectEnumTag( - reinterpret_cast(value), + reinterpret_cast(value), tag, type); return true; } @@ -272,22 +272,22 @@ bool AGTypeApplyEnumData(AGTypeID typeID, void *value, return false; } -bool AGTypeApplyMutableEnumData(AGTypeID typeID, void *value, +bool IAGTypeApplyMutableEnumData(IAGTypeID typeID, void *value, void (*body)(uint32_t tag, - AGTypeID field_type, + IAGTypeID field_type, void *field_value, - void *context AG_SWIFT_CONTEXT) - AG_SWIFT_CC(swift), + void *context IAG_SWIFT_CONTEXT) + IAG_SWIFT_CC(swift), void *context) { - auto type = reinterpret_cast(typeID); + auto type = reinterpret_cast(typeID); auto value_witness = type->getValueWitnesses(); if (!value_witness || !value_witness->flags.hasEnumWitnesses()) { - AG::precondition_failure("not an enum type: %s", type->name(false)); + IAG::precondition_failure("not an enum type: %s", type->name(false)); } auto enum_value_witness = value_witness->_asEVWT(); uint32_t tag = enum_value_witness->getEnumTag( - reinterpret_cast(value), type); + reinterpret_cast(value), type); if (auto descriptor = type->nominal_descriptor()) { auto enum_descriptor = @@ -301,7 +301,7 @@ bool AGTypeApplyMutableEnumData(AGTypeID typeID, void *value, mangled_name, nullptr); if (field_type) { enum_value_witness->destructiveProjectEnumData( - reinterpret_cast(value), + reinterpret_cast(value), type); void *field_value = value; @@ -316,10 +316,10 @@ bool AGTypeApplyMutableEnumData(AGTypeID typeID, void *value, ~alignment_mask; field_value = *(char **)value + offset; } - body(tag, AGTypeID(field_type), field_value, context); + body(tag, IAGTypeID(field_type), field_value, context); enum_value_witness->destructiveInjectEnumTag( - reinterpret_cast(value), + reinterpret_cast(value), tag, type); return true; } @@ -330,38 +330,38 @@ bool AGTypeApplyMutableEnumData(AGTypeID typeID, void *value, return false; } -uint64_t AGTypeGetEnumTag(AGTypeID typeID, const void *value) { - auto type = reinterpret_cast(typeID); +uint64_t IAGTypeGetEnumTag(IAGTypeID typeID, const void *value) { + auto type = reinterpret_cast(typeID); auto value_witness = type->getValueWitnesses(); if (!value_witness || !value_witness->flags.hasEnumWitnesses()) { - AG::precondition_failure("not an enum type: %s", type->name(false)); + IAG::precondition_failure("not an enum type: %s", type->name(false)); } auto enum_value_witness = value_witness->_asEVWT(); return enum_value_witness->getEnumTag( - reinterpret_cast(value), type); + reinterpret_cast(value), type); } -void AGTypeProjectEnumData(AGTypeID typeID, void *value) { - auto type = reinterpret_cast(typeID); +void IAGTypeProjectEnumData(IAGTypeID typeID, void *value) { + auto type = reinterpret_cast(typeID); auto value_witness = type->getValueWitnesses(); if (!value_witness || !value_witness->flags.hasEnumWitnesses()) { - AG::precondition_failure("not an enum type: %s", type->name(false)); + IAG::precondition_failure("not an enum type: %s", type->name(false)); } auto enum_value_witness = value_witness->_asEVWT(); enum_value_witness->destructiveProjectEnumData( - reinterpret_cast(value), type); + reinterpret_cast(value), type); } -void AGTypeInjectEnumTag(AGTypeID typeID, uint32_t tag, void *value) { - auto type = reinterpret_cast(typeID); +void IAGTypeInjectEnumTag(IAGTypeID typeID, uint32_t tag, void *value) { + auto type = reinterpret_cast(typeID); auto value_witness = type->getValueWitnesses(); if (!value_witness || !value_witness->flags.hasEnumWitnesses()) { - AG::precondition_failure("not an enum type: %s", type->name(false)); + IAG::precondition_failure("not an enum type: %s", type->name(false)); } auto enum_value_witness = value_witness->_asEVWT(); enum_value_witness->destructiveInjectEnumTag( - reinterpret_cast(value), tag, type); + reinterpret_cast(value), tag, type); } diff --git a/Sources/ComputeCxx/Swift/Metadata.cpp b/Sources/ComputeCxx/Swift/Metadata.cpp index d5022a6e..6b9ae203 100644 --- a/Sources/ComputeCxx/Swift/Metadata.cpp +++ b/Sources/ComputeCxx/Swift/Metadata.cpp @@ -20,7 +20,7 @@ #include "MetadataVisitor.h" #include "_SwiftStdlibCxxOverlay.h" -namespace AG { +namespace IAG { namespace swift { #pragma mark - Metadata @@ -235,7 +235,7 @@ const void *metadata::signature() const { for (int i = 0; i < generic_arg.num_types; i++) { if (generic_arg.is_pack) { // types points to an array of metadata pointers - auto pack_types = reinterpret_cast(generic_arg.types); + auto pack_types = reinterpret_cast(generic_arg.types); for (int j = 0; j < generic_arg.num_types; j++) { metadata_queue.push_back(pack_types[j]); } @@ -250,7 +250,7 @@ const void *metadata::signature() const { auto context = PLATFORM_SHA1_CTX(); PLATFORM_SHA1_Init(&context); - const char prefix[] = "AGTypeSignature"; + const char prefix[] = "IAGTypeSignature"; PLATFORM_SHA1_Update(&context, prefix, sizeof(prefix)); auto infos = vector(); @@ -852,4 +852,4 @@ const metadata *existential_type_metadata::dynamic_type(void *container) const { } } // namespace swift -} // namespace AG +} // namespace IAG diff --git a/Sources/ComputeCxx/Swift/Metadata.h b/Sources/ComputeCxx/Swift/Metadata.h index 93574630..7c09708c 100644 --- a/Sources/ComputeCxx/Swift/Metadata.h +++ b/Sources/ComputeCxx/Swift/Metadata.h @@ -3,15 +3,15 @@ #include #include -#include "ComputeCxx/AGBase.h" +#include "ComputeCxx/IAGBase.h" #include "Comparison/LayoutDescriptor.h" -AG_ASSUME_NONNULL_BEGIN +IAG_ASSUME_NONNULL_BEGIN CF_EXPORT const void *PROTOCOL_DESCR_SYM(SQ); -namespace AG { +namespace IAG { namespace swift { static constexpr auto &EquatableProtocolDescriptor = PROTOCOL_DESCR_SYM(SQ); @@ -95,6 +95,6 @@ class existential_type_metadata : public ::swift::ExistentialTypeMetadata { }; } // namespace swift -} // namespace AG +} // namespace IAG -AG_ASSUME_NONNULL_END +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/Swift/MetadataVisitor.cpp b/Sources/ComputeCxx/Swift/MetadataVisitor.cpp index 8f769189..e8c31da6 100644 --- a/Sources/ComputeCxx/Swift/MetadataVisitor.cpp +++ b/Sources/ComputeCxx/Swift/MetadataVisitor.cpp @@ -2,7 +2,7 @@ #include -namespace AG { +namespace IAG { namespace swift { bool metadata_visitor::unknown_result() { return false; } @@ -42,4 +42,4 @@ bool metadata_visitor::visit_function(const function_type_metadata &type) { retu bool metadata_visitor::visit_native_object(const metadata &type) { return unknown_result(); } } // namespace swift -} // namespace AG +} // namespace IAG diff --git a/Sources/ComputeCxx/Swift/MetadataVisitor.h b/Sources/ComputeCxx/Swift/MetadataVisitor.h index 4d58ff8e..9fc46c7b 100644 --- a/Sources/ComputeCxx/Swift/MetadataVisitor.h +++ b/Sources/ComputeCxx/Swift/MetadataVisitor.h @@ -6,12 +6,12 @@ #include -#include "ComputeCxx/AGBase.h" +#include "ComputeCxx/IAGBase.h" #include "Metadata.h" -AG_ASSUME_NONNULL_BEGIN +IAG_ASSUME_NONNULL_BEGIN -namespace AG { +namespace IAG { namespace swift { using field_record = ::swift::reflection::FieldRecord; @@ -33,6 +33,6 @@ class metadata_visitor { }; } // namespace swift -} // namespace AG +} // namespace IAG -AG_ASSUME_NONNULL_END +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/Swift/SwiftShims.h b/Sources/ComputeCxx/Swift/SwiftShims.h index c4df267d..6ce76343 100644 --- a/Sources/ComputeCxx/Swift/SwiftShims.h +++ b/Sources/ComputeCxx/Swift/SwiftShims.h @@ -1,6 +1,6 @@ #pragma once -#include "ComputeCxx/AGBase.h" +#include "ComputeCxx/IAGBase.h" #if TARGET_OS_MAC #include @@ -10,19 +10,19 @@ #include #endif -AG_ASSUME_NONNULL_BEGIN +IAG_ASSUME_NONNULL_BEGIN -AG_EXTERN_C_BEGIN +IAG_EXTERN_C_BEGIN -AG_SWIFT_CC(swift) -bool AGDispatchEquatable(const void *lhs_value, const void *rhs_value, const ::swift::Metadata *type, - const AG::swift::equatable_witness_table *wt); +IAG_SWIFT_CC(swift) +bool IAGDispatchEquatable(const void *lhs_value, const void *rhs_value, const ::swift::Metadata *type, + const IAG::swift::equatable_witness_table *wt); #ifdef __OBJC__ -AG_SWIFT_CC(swift) -bool AGSetTypeForKey(NSMutableDictionary *dict, NSString *key, const ::swift::Metadata *type); +IAG_SWIFT_CC(swift) +bool IAGSetTypeForKey(NSMutableDictionary *dict, NSString *key, const ::swift::Metadata *type); #endif -AG_EXTERN_C_END +IAG_EXTERN_C_END -AG_ASSUME_NONNULL_END +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/Swift/_SwiftStdlibCxxOverlay.h b/Sources/ComputeCxx/Swift/_SwiftStdlibCxxOverlay.h index dccf70e1..837e32ca 100644 --- a/Sources/ComputeCxx/Swift/_SwiftStdlibCxxOverlay.h +++ b/Sources/ComputeCxx/Swift/_SwiftStdlibCxxOverlay.h @@ -1,7 +1,7 @@ #pragma once -#include "ComputeCxx/AGBase.h" +#include "ComputeCxx/IAGBase.h" extern "C" const ::swift::Metadata *_Nullable swift_getTypeByMangledNameInContext( const char *_Nullable typeNameStart, size_t typeNameLength, const void *_Nullable context, - const void *_Nullable const *_Nullable genericArgs) AG_SWIFT_CC(swift); + const void *_Nullable const *_Nullable genericArgs) IAG_SWIFT_CC(swift); diff --git a/Sources/ComputeCxx/Time/Time.cpp b/Sources/ComputeCxx/Time/Time.cpp index 164c5c17..c24d023b 100644 --- a/Sources/ComputeCxx/Time/Time.cpp +++ b/Sources/ComputeCxx/Time/Time.cpp @@ -7,7 +7,7 @@ #endif #include -namespace AG { +namespace IAG { double current_time() { #if TARGET_OS_MAC @@ -41,4 +41,4 @@ double absolute_time_to_seconds(uint64_t ticks) { return static_cast(ticks) * time_scale; } -} // namespace AG +} // namespace IAG diff --git a/Sources/ComputeCxx/Time/Time.h b/Sources/ComputeCxx/Time/Time.h index 875ec459..4d675674 100644 --- a/Sources/ComputeCxx/Time/Time.h +++ b/Sources/ComputeCxx/Time/Time.h @@ -1,14 +1,14 @@ #include -#include "ComputeCxx/AGBase.h" +#include "ComputeCxx/IAGBase.h" -AG_ASSUME_NONNULL_BEGIN +IAG_ASSUME_NONNULL_BEGIN -namespace AG { +namespace IAG { double current_time(void); double absolute_time_to_seconds(uint64_t ticks); } -AG_ASSUME_NONNULL_END +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/Trace/ExternalTrace.cpp b/Sources/ComputeCxx/Trace/ExternalTrace.cpp index 8f9ea223..167a856a 100644 --- a/Sources/ComputeCxx/Trace/ExternalTrace.cpp +++ b/Sources/ComputeCxx/Trace/ExternalTrace.cpp @@ -1,7 +1,7 @@ #include "ExternalTrace.h" -#include "Comparison/AGComparison-Private.h" -#include "ComputeCxx/AGGraph.h" +#include "Comparison/IAGComparison-Private.h" +#include "ComputeCxx/IAGGraph.h" #include "Graph/Context.h" #include "Graph/Graph.h" @@ -9,156 +9,156 @@ void ExternalTrace::graph_destroyed() { delete this; }; void ExternalTrace::trace_removed() { delete this; }; -void ExternalTrace::begin_trace(const AG::Graph &graph) { +void ExternalTrace::begin_trace(const IAG::Graph &graph) { auto cf_graph = graph.primary_context()->to_cf(); if (auto callback = _trace->begin_trace) { callback(_context, cf_graph); } } -void ExternalTrace::end_trace(const AG::Graph &graph) { +void ExternalTrace::end_trace(const IAG::Graph &graph) { auto cf_graph = graph.primary_context()->to_cf(); if (auto callback = _trace->end_trace) { callback(_context, cf_graph); } } -void ExternalTrace::begin_update(const AG::Subgraph &subgraph, uint32_t options) { +void ExternalTrace::begin_update(const IAG::Subgraph &subgraph, uint32_t options) { auto cf_subgraph = subgraph.to_cf(); if (auto callback = _trace->begin_subgraph_update) { callback(_context, cf_subgraph, options); } } -void ExternalTrace::end_update(const AG::Subgraph &subgraph) { +void ExternalTrace::end_update(const IAG::Subgraph &subgraph) { auto cf_subgraph = subgraph.to_cf(); if (auto callback = _trace->end_subgraph_update) { callback(_context, cf_subgraph); } } -void ExternalTrace::begin_update(const AG::Graph::UpdateStack &update_stack, AG::data::ptr node, +void ExternalTrace::begin_update(const IAG::Graph::UpdateStack &update_stack, IAG::data::ptr node, uint32_t options) { if (auto callback = _trace->begin_node_update) { - callback(_context, AGAttribute(AG::AttributeID(node))); + callback(_context, IAGAttribute(IAG::AttributeID(node))); } } -void ExternalTrace::end_update(const AG::Graph::UpdateStack &update_stack, AG::data::ptr node, - AGGraphUpdateStatus update_status) { +void ExternalTrace::end_update(const IAG::Graph::UpdateStack &update_stack, IAG::data::ptr node, + IAGGraphUpdateStatus update_status) { if (auto callback = _trace->end_node_update) { - callback(_context, update_status == AGGraphUpdateStatusChanged); + callback(_context, update_status == IAGGraphUpdateStatusChanged); } } -void ExternalTrace::begin_update(AG::data::ptr node) { +void ExternalTrace::begin_update(IAG::data::ptr node) { if (auto callback = _trace->begin_value_update) { - callback(_context, AGAttribute(AG::AttributeID(node))); + callback(_context, IAGAttribute(IAG::AttributeID(node))); } } -void ExternalTrace::end_update(AG::data::ptr node, bool changed) { +void ExternalTrace::end_update(IAG::data::ptr node, bool changed) { if (auto callback = _trace->end_value_update) { - callback(_context, AGAttribute(AG::AttributeID(node)), changed); + callback(_context, IAGAttribute(IAG::AttributeID(node)), changed); } } -void ExternalTrace::begin_update(const AG::Graph::Context &context) { +void ExternalTrace::begin_update(const IAG::Graph::Context &context) { auto cf_context = context.to_cf(); if (auto callback = _trace->begin_graph_update) { callback(_context, cf_context); } } -void ExternalTrace::end_update(const AG::Graph::Context &context) { +void ExternalTrace::end_update(const IAG::Graph::Context &context) { auto cf_context = context.to_cf(); if (auto callback = _trace->end_graph_update) { callback(_context, cf_context); } } -void ExternalTrace::begin_invalidation(const AG::Graph::Context &context, AG::AttributeID attribute) { +void ExternalTrace::begin_invalidation(const IAG::Graph::Context &context, IAG::AttributeID attribute) { auto cf_context = context.to_cf(); if (auto callback = _trace->begin_graph_invalidation) { - callback(_context, cf_context, AGAttribute(attribute)); + callback(_context, cf_context, IAGAttribute(attribute)); } } -void ExternalTrace::end_invalidation(const AG::Graph::Context &context, AG::AttributeID attribute) { +void ExternalTrace::end_invalidation(const IAG::Graph::Context &context, IAG::AttributeID attribute) { auto cf_context = context.to_cf(); if (auto callback = _trace->end_graph_invalidation) { - callback(_context, cf_context, AGAttribute(attribute)); + callback(_context, cf_context, IAGAttribute(attribute)); } } -void ExternalTrace::begin_modify(AG::data::ptr node) { +void ExternalTrace::begin_modify(IAG::data::ptr node) { if (auto callback = _trace->begin_modify_node) { - callback(_context, AGAttribute(AG::AttributeID(node))); + callback(_context, IAGAttribute(IAG::AttributeID(node))); } } -void ExternalTrace::end_modify(AG::data::ptr node) { +void ExternalTrace::end_modify(IAG::data::ptr node) { if (auto callback = _trace->end_modify_node) { - callback(_context, AGAttribute(AG::AttributeID(node))); + callback(_context, IAGAttribute(IAG::AttributeID(node))); } } -void ExternalTrace::begin_event(AG::data::ptr node, uint32_t event_id) { +void ExternalTrace::begin_event(IAG::data::ptr node, uint32_t event_id) { if (auto callback = _trace->begin_event) { - if (auto subgraph = AG::AttributeID(node).subgraph()) { + if (auto subgraph = IAG::AttributeID(node).subgraph()) { const char *event_name = subgraph->graph()->key_name(event_id); - callback(_context, AGAttribute(AG::AttributeID(node)), event_name); + callback(_context, IAGAttribute(IAG::AttributeID(node)), event_name); } } } -void ExternalTrace::end_event(AG::data::ptr node, uint32_t event_id) { +void ExternalTrace::end_event(IAG::data::ptr node, uint32_t event_id) { if (auto callback = _trace->end_event) { - if (auto subgraph = AG::AttributeID(node).subgraph()) { + if (auto subgraph = IAG::AttributeID(node).subgraph()) { const char *event_name = subgraph->graph()->key_name(event_id); - callback(_context, AGAttribute(AG::AttributeID(node)), event_name); + callback(_context, IAGAttribute(IAG::AttributeID(node)), event_name); } } } -void ExternalTrace::created(const AG::Graph::Context &context) { +void ExternalTrace::created(const IAG::Graph::Context &context) { auto cf_context = context.to_cf(); if (auto callback = _trace->graph_created) { callback(_context, cf_context); } } -void ExternalTrace::destroy(const AG::Graph::Context &context) { +void ExternalTrace::destroy(const IAG::Graph::Context &context) { auto cf_context = context.to_cf(); if (auto callback = _trace->graph_destroy) { callback(_context, cf_context); } } -void ExternalTrace::needs_update(const AG::Graph::Context &context) { +void ExternalTrace::needs_update(const IAG::Graph::Context &context) { auto cf_context = context.to_cf(); if (auto callback = _trace->graph_needs_update) { callback(_context, cf_context); } } -void ExternalTrace::created(const AG::Subgraph &subgraph) { +void ExternalTrace::created(const IAG::Subgraph &subgraph) { auto cf_subgraph = subgraph.to_cf(); if (auto callback = _trace->subgraph_created) { callback(_context, cf_subgraph); } } -void ExternalTrace::invalidate(const AG::Subgraph &subgraph) { +void ExternalTrace::invalidate(const IAG::Subgraph &subgraph) { auto cf_subgraph = subgraph.to_cf(); if (auto callback = _trace->subgraph_destroy) { callback(_context, cf_subgraph); } } -void ExternalTrace::destroy(const AG::Subgraph &subgraph) {} +void ExternalTrace::destroy(const IAG::Subgraph &subgraph) {} -void ExternalTrace::add_child(const AG::Subgraph &subgraph, const AG::Subgraph &child) { +void ExternalTrace::add_child(const IAG::Subgraph &subgraph, const IAG::Subgraph &child) { auto cf_subgraph = subgraph.to_cf(); auto cf_child = subgraph.to_cf(); if (auto callback = _trace->subgraph_add_child) { @@ -166,7 +166,7 @@ void ExternalTrace::add_child(const AG::Subgraph &subgraph, const AG::Subgraph & } } -void ExternalTrace::remove_child(const AG::Subgraph &subgraph, const AG::Subgraph &child) { +void ExternalTrace::remove_child(const IAG::Subgraph &subgraph, const IAG::Subgraph &child) { auto cf_subgraph = subgraph.to_cf(); auto cf_child = subgraph.to_cf(); if (auto callback = _trace->subgraph_remove_child) { @@ -174,98 +174,98 @@ void ExternalTrace::remove_child(const AG::Subgraph &subgraph, const AG::Subgrap } } -void ExternalTrace::added(AG::data::ptr node) { +void ExternalTrace::added(IAG::data::ptr node) { if (auto callback = _trace->node_added) { - callback(_context, AGAttribute(AG::AttributeID(node))); + callback(_context, IAGAttribute(IAG::AttributeID(node))); } } -void ExternalTrace::add_edge(AG::data::ptr node, AG::AttributeID input, AGInputOptions input_options) { +void ExternalTrace::add_edge(IAG::data::ptr node, IAG::AttributeID input, IAGInputOptions input_options) { if (auto callback = _trace->node_add_edge) { - callback(_context, AGAttribute(AG::AttributeID(node)), AGAttribute(AG::AttributeID(input)), input_options); + callback(_context, IAGAttribute(IAG::AttributeID(node)), IAGAttribute(IAG::AttributeID(input)), input_options); } } -void ExternalTrace::remove_edge(AG::data::ptr node, uint32_t input_index) { +void ExternalTrace::remove_edge(IAG::data::ptr node, uint32_t input_index) { if (auto callback = _trace->node_remove_edge) { - if (AG::AttributeID(node).subgraph()) { - callback(_context, AGAttribute(AG::AttributeID(node)), input_index); + if (IAG::AttributeID(node).subgraph()) { + callback(_context, IAGAttribute(IAG::AttributeID(node)), input_index); } } } -void ExternalTrace::set_edge_pending(AG::data::ptr node, AG::AttributeID input, bool pending) { +void ExternalTrace::set_edge_pending(IAG::data::ptr node, IAG::AttributeID input, bool pending) { if (auto callback = _trace->node_set_edge_pending) { - if (AG::AttributeID(node).subgraph()) { - callback(_context, AGAttribute(AG::AttributeID(node)), AGAttribute(input), pending); + if (IAG::AttributeID(node).subgraph()) { + callback(_context, IAGAttribute(IAG::AttributeID(node)), IAGAttribute(input), pending); } } } -void ExternalTrace::set_dirty(AG::data::ptr node, bool dirty) { +void ExternalTrace::set_dirty(IAG::data::ptr node, bool dirty) { if (auto callback = _trace->node_set_dirty) { - callback(_context, AGAttribute(AG::AttributeID(node)), dirty); + callback(_context, IAGAttribute(IAG::AttributeID(node)), dirty); } } -void ExternalTrace::set_pending(AG::data::ptr node, bool pending) { +void ExternalTrace::set_pending(IAG::data::ptr node, bool pending) { if (auto callback = _trace->node_set_pending) { - callback(_context, AGAttribute(AG::AttributeID(node)), pending); + callback(_context, IAGAttribute(IAG::AttributeID(node)), pending); } } -void ExternalTrace::set_value(AG::data::ptr node, const void *value) { +void ExternalTrace::set_value(IAG::data::ptr node, const void *value) { if (auto callback = _trace->node_set_value) { - callback(_context, AGAttribute(AG::AttributeID(node))); + callback(_context, IAGAttribute(IAG::AttributeID(node))); } } -void ExternalTrace::mark_value(AG::data::ptr node) { +void ExternalTrace::mark_value(IAG::data::ptr node) { if (auto callback = _trace->node_mark_value) { - callback(_context, AGAttribute(AG::AttributeID(node))); + callback(_context, IAGAttribute(IAG::AttributeID(node))); } } -void ExternalTrace::added(AG::data::ptr indirect_node) { +void ExternalTrace::added(IAG::data::ptr indirect_node) { if (auto callback = _trace->indirect_node_added) { - callback(_context, AGAttribute(AG::AttributeID(indirect_node))); // TODO: check sets kind + callback(_context, IAGAttribute(IAG::AttributeID(indirect_node))); // TODO: check sets kind } } -void ExternalTrace::set_source(AG::data::ptr indirect_node, AG::AttributeID source) { +void ExternalTrace::set_source(IAG::data::ptr indirect_node, IAG::AttributeID source) { if (auto callback = _trace->indirect_node_set_source) { - callback(_context, AGAttribute(AG::AttributeID(indirect_node)), AGAttribute(source)); // TODO: check sets kind + callback(_context, IAGAttribute(IAG::AttributeID(indirect_node)), IAGAttribute(source)); // TODO: check sets kind } } -void ExternalTrace::set_dependency(AG::data::ptr indirect_node, AG::AttributeID dependency) { +void ExternalTrace::set_dependency(IAG::data::ptr indirect_node, IAG::AttributeID dependency) { if (auto callback = _trace->indirect_node_set_dependency) { - callback(_context, AGAttribute(AG::AttributeID(indirect_node)), - AGAttribute(dependency)); // TODO: check sets kind + callback(_context, IAGAttribute(IAG::AttributeID(indirect_node)), + IAGAttribute(dependency)); // TODO: check sets kind } } -void ExternalTrace::mark_profile(const AG::Graph &graph, uint32_t event_id) { +void ExternalTrace::mark_profile(const IAG::Graph &graph, uint32_t event_id) { if (auto callback = _trace->profile_mark) { const char *event_name = graph.key_name(event_id); callback(_context, event_name); } } -void ExternalTrace::custom_event(const AG::Graph::Context &context, const char *event_name, const void *value, - const AG::swift::metadata &type) { - if (_trace->version < AGTraceTypeVersionCustom) { +void ExternalTrace::custom_event(const IAG::Graph::Context &context, const char *event_name, const void *value, + const IAG::swift::metadata &type) { + if (_trace->version < IAGTraceTypeVersionCustom) { return; } auto cf_context = context.to_cf(); if (auto callback = _trace->custom_event) { - callback(_context, cf_context, event_name, value, AGTypeID(&type)); + callback(_context, cf_context, event_name, value, IAGTypeID(&type)); } } -void ExternalTrace::named_event(const AG::Graph::Context &context, uint32_t event_id, uint32_t event_arg_count, +void ExternalTrace::named_event(const IAG::Graph::Context &context, uint32_t event_id, uint32_t event_arg_count, const void *event_args, CFDataRef data, uint32_t arg6) { - if (_trace->version < AGTraceTypeVersionNamed) { + if (_trace->version < IAGTraceTypeVersionNamed) { return; } auto cf_context = context.to_cf(); @@ -275,7 +275,7 @@ void ExternalTrace::named_event(const AG::Graph::Context &context, uint32_t even } bool ExternalTrace::named_event_enabled(uint32_t event_id) { - if (_trace->version < AGTraceTypeVersionNamed) { + if (_trace->version < IAGTraceTypeVersionNamed) { return false; } if (auto callback = _trace->named_event_enabled) { @@ -285,7 +285,7 @@ bool ExternalTrace::named_event_enabled(uint32_t event_id) { } void ExternalTrace::set_deadline(uint64_t deadline) { - if (_trace->version < AGTraceTypeVersionDeadline) { + if (_trace->version < IAGTraceTypeVersionDeadline) { return; } if (auto callback = _trace->set_deadline) { @@ -294,7 +294,7 @@ void ExternalTrace::set_deadline(uint64_t deadline) { } void ExternalTrace::passed_deadline() { - if (_trace->version < AGTraceTypeVersionDeadline) { + if (_trace->version < IAGTraceTypeVersionDeadline) { return; } if (auto callback = _trace->passed_deadline) { @@ -302,13 +302,13 @@ void ExternalTrace::passed_deadline() { } } -void ExternalTrace::compare_failed(AG::data::ptr node, const void *lhs, const void *rhs, size_t range_offset, - size_t range_size, const AG::swift::metadata *_Nullable type) { - if (_trace->version < AGTraceTypeVersionCompareFailed) { +void ExternalTrace::compare_failed(IAG::data::ptr node, const void *lhs, const void *rhs, size_t range_offset, + size_t range_size, const IAG::swift::metadata *_Nullable type) { + if (_trace->version < IAGTraceTypeVersionCompareFailed) { return; } - AGComparisonStateStorage storage = {lhs, rhs, range_offset, range_size, AGTypeID(&type)}; + IAGComparisonStateStorage storage = {lhs, rhs, range_offset, range_size, IAGTypeID(&type)}; if (auto callback = _trace->compare_failed) { - callback(_context, AGAttribute(AG::AttributeID(node)), &storage); + callback(_context, IAGAttribute(IAG::AttributeID(node)), &storage); } } diff --git a/Sources/ComputeCxx/Trace/ExternalTrace.h b/Sources/ComputeCxx/Trace/ExternalTrace.h index 9e6bd056..5d9c5ae9 100644 --- a/Sources/ComputeCxx/Trace/ExternalTrace.h +++ b/Sources/ComputeCxx/Trace/ExternalTrace.h @@ -1,95 +1,95 @@ #pragma once -#include "ComputeCxx/AGAttribute.h" -#include "ComputeCxx/AGBase.h" -#include "ComputeCxx/AGComparison.h" -#include "ComputeCxx/AGGraph.h" -#include "ComputeCxx/AGTraceType.h" -#include "ComputeCxx/AGType.h" +#include "ComputeCxx/IAGAttribute.h" +#include "ComputeCxx/IAGBase.h" +#include "ComputeCxx/IAGComparison.h" +#include "ComputeCxx/IAGGraph.h" +#include "ComputeCxx/IAGTraceType.h" +#include "ComputeCxx/IAGType.h" #include "Graph/Context.h" #include "Subgraph/Subgraph.h" #include "Trace/Trace.h" -AG_ASSUME_NONNULL_BEGIN +IAG_ASSUME_NONNULL_BEGIN -class ExternalTrace : public AG::Trace { +class ExternalTrace : public IAG::Trace { public: private: - const AGTraceTypeRef _trace; + const IAGTraceTypeRef _trace; void *_Nullable _context; public: - ExternalTrace(AGTraceTypeRef trace, void *context) : _trace(trace), _context(context) {}; - ExternalTrace(uint64_t id, const AGTraceTypeRef trace, void *context) - : AG::Trace(id), _trace(trace), _context(context) {}; + ExternalTrace(IAGTraceTypeRef trace, void *context) : _trace(trace), _context(context) {}; + ExternalTrace(uint64_t id, const IAGTraceTypeRef trace, void *context) + : IAG::Trace(id), _trace(trace), _context(context) {}; void graph_destroyed() override; void trace_removed() override; - void begin_trace(const AG::Graph &graph) override; - void end_trace(const AG::Graph &graph) override; + void begin_trace(const IAG::Graph &graph) override; + void end_trace(const IAG::Graph &graph) override; - void begin_update(const AG::Subgraph &subgraph, uint32_t options) override; - void end_update(const AG::Subgraph &subgraph) override; + void begin_update(const IAG::Subgraph &subgraph, uint32_t options) override; + void end_update(const IAG::Subgraph &subgraph) override; - void begin_update(const AG::Graph::UpdateStack &update_stack, AG::data::ptr node, + void begin_update(const IAG::Graph::UpdateStack &update_stack, IAG::data::ptr node, uint32_t options) override; - void end_update(const AG::Graph::UpdateStack &update_stack, AG::data::ptr node, - AGGraphUpdateStatus update_status) override; - void begin_update(AG::data::ptr node) override; - void end_update(AG::data::ptr node, bool changed) override; - void begin_update(const AG::Graph::Context &context) override; - void end_update(const AG::Graph::Context &context) override; + void end_update(const IAG::Graph::UpdateStack &update_stack, IAG::data::ptr node, + IAGGraphUpdateStatus update_status) override; + void begin_update(IAG::data::ptr node) override; + void end_update(IAG::data::ptr node, bool changed) override; + void begin_update(const IAG::Graph::Context &context) override; + void end_update(const IAG::Graph::Context &context) override; - void begin_invalidation(const AG::Graph::Context &context, AG::AttributeID attribute) override; - void end_invalidation(const AG::Graph::Context &context, AG::AttributeID attribute) override; + void begin_invalidation(const IAG::Graph::Context &context, IAG::AttributeID attribute) override; + void end_invalidation(const IAG::Graph::Context &context, IAG::AttributeID attribute) override; - void begin_modify(AG::data::ptr node) override; - void end_modify(AG::data::ptr node) override; + void begin_modify(IAG::data::ptr node) override; + void end_modify(IAG::data::ptr node) override; - void begin_event(AG::data::ptr node, uint32_t event_id) override; - void end_event(AG::data::ptr node, uint32_t event_id) override; + void begin_event(IAG::data::ptr node, uint32_t event_id) override; + void end_event(IAG::data::ptr node, uint32_t event_id) override; - void created(const AG::Graph::Context &context) override; - void destroy(const AG::Graph::Context &context) override; - void needs_update(const AG::Graph::Context &context) override; + void created(const IAG::Graph::Context &context) override; + void destroy(const IAG::Graph::Context &context) override; + void needs_update(const IAG::Graph::Context &context) override; - void created(const AG::Subgraph &subgraph) override; - void invalidate(const AG::Subgraph &subgraph) override; - void destroy(const AG::Subgraph &subgraph) override; + void created(const IAG::Subgraph &subgraph) override; + void invalidate(const IAG::Subgraph &subgraph) override; + void destroy(const IAG::Subgraph &subgraph) override; - void add_child(const AG::Subgraph &subgraph, const AG::Subgraph &child) override; - void remove_child(const AG::Subgraph &subgraph, const AG::Subgraph &child) override; + void add_child(const IAG::Subgraph &subgraph, const IAG::Subgraph &child) override; + void remove_child(const IAG::Subgraph &subgraph, const IAG::Subgraph &child) override; - void added(AG::data::ptr node) override; + void added(IAG::data::ptr node) override; - void add_edge(AG::data::ptr node, AG::AttributeID input, AGInputOptions input_options) override; - void remove_edge(AG::data::ptr node, uint32_t input_index) override; - void set_edge_pending(AG::data::ptr node, AG::AttributeID input, bool pending) override; + void add_edge(IAG::data::ptr node, IAG::AttributeID input, IAGInputOptions input_options) override; + void remove_edge(IAG::data::ptr node, uint32_t input_index) override; + void set_edge_pending(IAG::data::ptr node, IAG::AttributeID input, bool pending) override; - void set_dirty(AG::data::ptr node, bool dirty) override; - void set_pending(AG::data::ptr node, bool pending) override; - void set_value(AG::data::ptr node, const void *value) override; - void mark_value(AG::data::ptr node) override; + void set_dirty(IAG::data::ptr node, bool dirty) override; + void set_pending(IAG::data::ptr node, bool pending) override; + void set_value(IAG::data::ptr node, const void *value) override; + void mark_value(IAG::data::ptr node) override; - void added(AG::data::ptr indirect_node) override; + void added(IAG::data::ptr indirect_node) override; - void set_source(AG::data::ptr indirect_node, AG::AttributeID source) override; - void set_dependency(AG::data::ptr indirect_node, AG::AttributeID dependency) override; + void set_source(IAG::data::ptr indirect_node, IAG::AttributeID source) override; + void set_dependency(IAG::data::ptr indirect_node, IAG::AttributeID dependency) override; - void mark_profile(const AG::Graph &graph, uint32_t event_id) override; + void mark_profile(const IAG::Graph &graph, uint32_t event_id) override; - void custom_event(const AG::Graph::Context &context, const char *event_name, const void *value, - const AG::swift::metadata &type) override; - void named_event(const AG::Graph::Context &context, uint32_t event_id, uint32_t event_arg_count, + void custom_event(const IAG::Graph::Context &context, const char *event_name, const void *value, + const IAG::swift::metadata &type) override; + void named_event(const IAG::Graph::Context &context, uint32_t event_id, uint32_t event_arg_count, const void *event_args, CFDataRef data, uint32_t arg6) override; bool named_event_enabled(uint32_t event_id) override; void set_deadline(uint64_t deadline) override; void passed_deadline() override; - void compare_failed(AG::data::ptr node, const void *lhs, const void *rhs, size_t range_offset, - size_t range_size, const AG::swift::metadata *_Nullable type) override; + void compare_failed(IAG::data::ptr node, const void *lhs, const void *rhs, size_t range_offset, + size_t range_size, const IAG::swift::metadata *_Nullable type) override; }; -AG_ASSUME_NONNULL_END +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/Trace/Trace.cpp b/Sources/ComputeCxx/Trace/Trace.cpp index 69dc13f4..362e8e12 100644 --- a/Sources/ComputeCxx/Trace/Trace.cpp +++ b/Sources/ComputeCxx/Trace/Trace.cpp @@ -1,6 +1,6 @@ #include "Trace.h" -namespace AG { +namespace IAG { void Trace::log_message(const char *format, ...) { va_list args; @@ -9,4 +9,4 @@ void Trace::log_message(const char *format, ...) { va_end(args); } -} // namespace AG +} // namespace IAG diff --git a/Sources/ComputeCxx/Trace/Trace.h b/Sources/ComputeCxx/Trace/Trace.h index c4f6cf4f..4525d0ef 100644 --- a/Sources/ComputeCxx/Trace/Trace.h +++ b/Sources/ComputeCxx/Trace/Trace.h @@ -1,6 +1,6 @@ #pragma once -#include "ComputeCxx/AGBase.h" +#include "ComputeCxx/IAGBase.h" #if TARGET_OS_MAC #include @@ -8,13 +8,13 @@ #include #endif -#include "ComputeCxx/AGGraph.h" -#include "ComputeCxx/AGUniqueID.h" +#include "ComputeCxx/IAGGraph.h" +#include "ComputeCxx/IAGUniqueID.h" #include "Graph/Graph.h" -AG_ASSUME_NONNULL_BEGIN +IAG_ASSUME_NONNULL_BEGIN -namespace AG { +namespace IAG { class Node; class Subgraph; @@ -26,7 +26,7 @@ class Trace { public: uint64_t id() { return _id; } - Trace() : _id(AGMakeUniqueID()) {}; + Trace() : _id(IAGMakeUniqueID()) {}; Trace(uint64_t id) : _id(id) {}; virtual void graph_destroyed() {}; @@ -46,7 +46,7 @@ class Trace { virtual void end_update(const Subgraph &subgraph) {}; virtual void begin_update(const Graph::UpdateStack &update_stack, data::ptr node, uint32_t options) {}; virtual void end_update(const Graph::UpdateStack &update_stack, data::ptr node, - AGGraphUpdateStatus update_status) {}; + IAGGraphUpdateStatus update_status) {}; virtual void begin_update(data::ptr node) {}; virtual void end_update(data::ptr node, bool changed) {}; virtual void begin_update(const Graph::Context &context) {}; @@ -74,7 +74,7 @@ class Trace { virtual void added(data::ptr node) {}; - virtual void add_edge(data::ptr node, AttributeID input, AGInputOptions input_options) {}; + virtual void add_edge(data::ptr node, AttributeID input, IAGInputOptions input_options) {}; virtual void remove_edge(data::ptr node, uint32_t input_index) {}; virtual void set_edge_pending(data::ptr node, AttributeID input, bool pending) {}; @@ -104,6 +104,6 @@ class Trace { size_t range_size, const swift::metadata *_Nullable type) {}; }; -} // namespace AG +} // namespace IAG -AG_ASSUME_NONNULL_END +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/UniqueID/AGUniqueID.cpp b/Sources/ComputeCxx/UniqueID/IAGUniqueID.cpp similarity index 66% rename from Sources/ComputeCxx/UniqueID/AGUniqueID.cpp rename to Sources/ComputeCxx/UniqueID/IAGUniqueID.cpp index 90c780ee..43104558 100644 --- a/Sources/ComputeCxx/UniqueID/AGUniqueID.cpp +++ b/Sources/ComputeCxx/UniqueID/IAGUniqueID.cpp @@ -1,8 +1,8 @@ #include -#include +#include -AGUniqueID AGMakeUniqueID() { +IAGUniqueID IAGMakeUniqueID() { static atomic_ulong counter = 1; return atomic_fetch_add_explicit(&counter, 1, memory_order_relaxed); } diff --git a/Sources/ComputeCxx/Vector/IndirectPointerVector.h b/Sources/ComputeCxx/Vector/IndirectPointerVector.h index e2890905..821c731d 100644 --- a/Sources/ComputeCxx/Vector/IndirectPointerVector.h +++ b/Sources/ComputeCxx/Vector/IndirectPointerVector.h @@ -2,12 +2,12 @@ #include -#include "ComputeCxx/AGBase.h" +#include "ComputeCxx/IAGBase.h" #include "Vector.h" -AG_ASSUME_NONNULL_BEGIN +IAG_ASSUME_NONNULL_BEGIN -namespace AG { +namespace IAG { /// A vector that efficiently stores a single element as a pointer /// or stores multiple elements as a vector. @@ -277,6 +277,6 @@ void indirect_pointer_vector::resize(size_type count) { _data = (uintptr_t)vector | TagMask; } -} // namespace AG +} // namespace IAG -AG_ASSUME_NONNULL_END +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/Vector/Vector.h b/Sources/ComputeCxx/Vector/Vector.h index 911a506b..64012e6a 100644 --- a/Sources/ComputeCxx/Vector/Vector.h +++ b/Sources/ComputeCxx/Vector/Vector.h @@ -10,12 +10,12 @@ #include -#include "ComputeCxx/AGBase.h" +#include "ComputeCxx/IAGBase.h" #include "Errors/Errors.h" -AG_ASSUME_NONNULL_BEGIN +IAG_ASSUME_NONNULL_BEGIN -namespace AG { +namespace IAG { template requires std::unsigned_integral<_size_type> @@ -851,6 +851,6 @@ void vector, 0, size_type>::push_back(std::uniq _size += 1; } -} // namespace AG +} // namespace IAG -AG_ASSUME_NONNULL_END +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/AGAttribute.h b/Sources/ComputeCxx/include/ComputeCxx/AGAttribute.h deleted file mode 100644 index e4aeccea..00000000 --- a/Sources/ComputeCxx/include/ComputeCxx/AGAttribute.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -#include - -AG_ASSUME_NONNULL_BEGIN - -AG_EXTERN_C_BEGIN - -typedef uint32_t AGAttribute AG_SWIFT_STRUCT AG_SWIFT_NAME(AnyAttribute); - -AG_EXPORT -const AGAttribute AGAttributeNil; - -typedef AG_OPTIONS(uint8_t, AGAttributeFlags) { - AGAttributeFlagsNone = 0, - AGAttributeFlagsAll = 0xFF, -} AG_SWIFT_NAME(AGSubgraphRef.Flags); - -AG_EXTERN_C_END - -AG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/AGAttributeInfo.h b/Sources/ComputeCxx/include/ComputeCxx/AGAttributeInfo.h deleted file mode 100644 index 926d04ed..00000000 --- a/Sources/ComputeCxx/include/ComputeCxx/AGAttributeInfo.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include -#include - -AG_ASSUME_NONNULL_BEGIN - -AG_EXTERN_C_BEGIN - -typedef struct AGAttributeInfo { - const AGAttributeType *type; - const void *body; -} AGAttributeInfo; - -AG_EXTERN_C_END - -AG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/AGAttributeType.h b/Sources/ComputeCxx/include/ComputeCxx/AGAttributeType.h deleted file mode 100644 index 8aa81c93..00000000 --- a/Sources/ComputeCxx/include/ComputeCxx/AGAttributeType.h +++ /dev/null @@ -1,67 +0,0 @@ -#pragma once - -#include - -#if TARGET_OS_MAC -#include -#else -#include -#endif - -#include -#include - -AG_ASSUME_NONNULL_BEGIN -AG_IMPLICIT_BRIDGING_ENABLED - -AG_EXTERN_C_BEGIN - -typedef struct AGAttributeType AGAttributeType; - -typedef struct AG_SWIFT_NAME(_AttributeVTable) AGAttributeVTable { - unsigned long version; - void (*_Nullable type_destroy)(AGAttributeType *); - void (*_Nullable self_destroy)(const AGAttributeType *, void *); -#if TARGET_OS_MAC - CFStringRef _Nullable (*_Nullable self_description)(const AGAttributeType *, const void *); - CFStringRef _Nullable (*_Nullable value_description)(const AGAttributeType *, const void *); -#else - CFStringRef _Nullable (*_Nullable copy_self_description)(const AGAttributeType *, const void *); - CFStringRef _Nullable (*_Nullable copy_value_description)(const AGAttributeType *, const void *); -#endif - void (*_Nullable update_default)(const AGAttributeType *, void *); -} AGAttributeVTable; - -typedef AG_OPTIONS(uint32_t, AGAttributeTypeFlags) { - AGAttributeTypeFlagsComparisonModeBitwise = 0, - AGAttributeTypeFlagsComparisonModeIndirect = 1, - AGAttributeTypeFlagsComparisonModeEquatableUnlessPOD = 2, - AGAttributeTypeFlagsComparisonModeEquatableAlways = 3, - AGAttributeTypeFlagsComparisonModeMask = 0x03, - - AGAttributeTypeFlagsHasDestroySelf = 1 << 2, - AGAttributeTypeFlagsMainThread = 1 << 3, - AGAttributeTypeFlagsExternal = 1 << 4, - AGAttributeTypeFlagsAsyncThread = 1 << 5, -} AG_SWIFT_NAME(_AttributeType.Flags); - -typedef struct AG_SWIFT_NAME(_AttributeType) AGAttributeType { - AGTypeID self_id; - AGTypeID value_id; - AGClosureStorage update; - const AGAttributeVTable *vtable; - AGAttributeTypeFlags flags; - - uint32_t internal_offset; - const unsigned char *_Nullable value_layout; - - struct { - AGTypeID type_id; - const void *witness_table; - } body_conformance; -} AGAttributeType; - -AG_EXTERN_C_END - -AG_IMPLICIT_BRIDGING_DISABLED -AG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/AGBase.h b/Sources/ComputeCxx/include/ComputeCxx/AGBase.h deleted file mode 100644 index b5578d8c..00000000 --- a/Sources/ComputeCxx/include/ComputeCxx/AGBase.h +++ /dev/null @@ -1,215 +0,0 @@ -#pragma once - -#include -#include -#include - -#include - -#ifndef __has_include -#define __has_include(x) 0 -#endif -#ifndef __has_feature -#define __has_feature(x) 0 -#endif -#ifndef __has_attribute -#define __has_attribute(x) 0 -#endif -#ifndef __has_extension -#define __has_extension(x) 0 -#endif - -#define _AG_STRINGIFY(_x) #_x - -#if !defined(AG_EXTERN_C_BEGIN) -#if defined(__cplusplus) -#define AG_EXTERN_C_BEGIN extern "C" { -#define AG_EXTERN_C_END } -#else -#define AG_EXTERN_C_BEGIN -#define AG_EXTERN_C_END -#endif -#endif - -#if __GNUC__ -#define AG_EXPORT extern __attribute__((__visibility__("default"))) -#else -#define AG_EXPORT extern -#endif - -#if __GNUC__ -#define AG_INLINE static __inline__ -#else -#define AG_INLINE static inline -#endif - -#ifndef AG_RETURNS_RETAINED -#if __has_feature(attribute_cf_returns_retained) -#define AG_RETURNS_RETAINED __attribute__((cf_returns_retained)) -#else -#define AG_RETURNS_RETAINED -#endif -#endif - -#ifndef AG_IMPLICIT_BRIDGING_ENABLED -#if __has_feature(arc_cf_code_audited) -#define AG_IMPLICIT_BRIDGING_ENABLED _Pragma("clang arc_cf_code_audited begin") -#else -#define AG_IMPLICIT_BRIDGING_ENABLED -#endif -#endif - -#ifndef AG_IMPLICIT_BRIDGING_DISABLED -#if __has_feature(arc_cf_code_audited) -#define AG_IMPLICIT_BRIDGING_DISABLED _Pragma("clang arc_cf_code_audited end") -#else -#define AG_IMPLICIT_BRIDGING_DISABLED -#endif -#endif - -#if __has_attribute(objc_bridge) && __has_feature(objc_bridge_id) && __has_feature(objc_bridge_id_on_typedefs) - -#ifdef __OBJC__ -@class NSArray; -@class NSAttributedString; -@class NSString; -@class NSNull; -@class NSCharacterSet; -@class NSData; -@class NSDate; -@class NSTimeZone; -@class NSDictionary; -@class NSError; -@class NSLocale; -@class NSNumber; -@class NSSet; -@class NSURL; -#endif - -#define AG_BRIDGED_TYPE(T) __attribute__((objc_bridge(T))) -#define AG_BRIDGED_MUTABLE_TYPE(T) __attribute__((objc_bridge_mutable(T))) -#define AG_RELATED_TYPE(T,C,I) __attribute__((objc_bridge_related(T,C,I))) -#else -#define AG_BRIDGED_TYPE(T) -#define AG_BRIDGED_MUTABLE_TYPE(T) -#define AG_RELATED_TYPE(T,C,I) -#endif - -#if __has_feature(assume_nonnull) -#define AG_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin") -#define AG_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end") -#else -#define AG_ASSUME_NONNULL_BEGIN -#define AG_ASSUME_NONNULL_END -#endif - -#if !__has_feature(nullability) -#ifndef _Nullable -#define _Nullable -#endif -#ifndef _Nonnull -#define _Nonnull -#endif -#ifndef _Null_unspecified -#define _Null_unspecified -#endif -#endif - -#if __has_attribute(enum_extensibility) -#define __AG_ENUM_ATTRIBUTES __attribute__((enum_extensibility(open))) -#define __AG_CLOSED_ENUM_ATTRIBUTES __attribute__((enum_extensibility(closed))) -#define __AG_OPTIONS_ATTRIBUTES __attribute__((flag_enum,enum_extensibility(open))) -#else -#define __AG_ENUM_ATTRIBUTES -#define __AG_CLOSED_ENUM_ATTRIBUTES -#define __AG_OPTIONS_ATTRIBUTES -#endif - -#define __AG_ENUM_FIXED_IS_AVAILABLE (__cplusplus && __cplusplus >= 201103L && (__has_extension(cxx_strong_enums) || __has_feature(objc_fixed_enum))) || (!__cplusplus && (__has_feature(objc_fixed_enum) || __has_extension(cxx_fixed_enum))) - -#if __AG_ENUM_FIXED_IS_AVAILABLE -#define AG_ENUM(_type, _name) \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Welaborated-enum-base\"") \ - enum __AG_ENUM_ATTRIBUTES _name : _type _name; \ - enum _name : _type \ - _Pragma("clang diagnostic pop") -#define AG_CLOSED_ENUM(_type, _name) \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Welaborated-enum-base\"") \ - enum __AG_CLOSED_ENUM_ATTRIBUTES _name : _type _name; \ - enum _name : _type \ - _Pragma("clang diagnostic pop") -#if (__cplusplus) -#define AG_OPTIONS(_type, _name) __attribute__((availability(swift,unavailable))) _type _name; enum __AG_OPTIONS_ATTRIBUTES : _name -#else -#define AG_OPTIONS(_type, _name) \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Welaborated-enum-base\"") \ - enum __AG_OPTIONS_ATTRIBUTES _name : _type _name; \ - enum _name : _type \ - _Pragma("clang diagnostic pop") -#endif -#else -#define AG_ENUM(_type, _name) _type _name; enum -#define AG_CLOSED_ENUM(_type, _name) _type _name; enum -#define AG_OPTIONS(_type, _name) _type _name; enum -#endif - -#if __has_attribute(swift_private) -#define AG_REFINED_FOR_SWIFT __attribute__((swift_private)) -#else -#define AG_REFINED_FOR_SWIFT -#endif - -#if __has_attribute(swift_name) -#define AG_SWIFT_NAME(_name) __attribute__((swift_name(#_name))) -#else -#define AG_SWIFT_NAME(_name) -#endif - -#if __has_attribute(swift_wrapper) -#define AG_SWIFT_STRUCT __attribute__((swift_wrapper(struct))) -#else -#define AG_SWIFT_STRUCT -#endif - -// Define mappings for calling conventions. - -// Annotation for specifying a calling convention of -// a runtime function. It should be used with declarations -// of runtime functions like this: -// void runtime_function_name() AG_SWIFT_CC(swift) -#define AG_SWIFT_CC(CC) AG_SWIFT_CC_##CC - -// AG_SWIFT_CC(c) is the C calling convention. -#define AG_SWIFT_CC_c - -// AG_SWIFT_CC(swift) is the Swift calling convention. -#if __has_attribute(swiftcall) -#define AG_SWIFT_CC_swift __attribute__((swiftcall)) -#define AG_SWIFT_CONTEXT __attribute__((swift_context)) -#define AG_SWIFT_ERROR_RESULT __attribute__((swift_error_result)) -#define AG_SWIFT_INDIRECT_RESULT __attribute__((swift_indirect_result)) -#else -#define AG_SWIFT_CC_swift -#define AG_SWIFT_CONTEXT -#define AG_SWIFT_ERROR_RESULT -#define AG_SWIFT_INDIRECT_RESULT -#endif - -#if __has_attribute(swift_attr) -#define AG_SWIFT_SHARED_REFERENCE(_retain, _release) \ - __attribute__((swift_attr("import_reference"))) \ - __attribute__((swift_attr(_AG_STRINGIFY(retain:_retain)))) \ - __attribute__((swift_attr(_AG_STRINGIFY(release:_release)))) -#else -#define AG_SWIFT_SHARED_REFERENCE(_retain, _release) -#endif - -#if __has_include() -#include -#define AG_COUNTED_BY(N) __counted_by(N) -#else -#define AG_COUNTED_BY(N) -#endif diff --git a/Sources/ComputeCxx/include/ComputeCxx/AGCachedValueOptions.h b/Sources/ComputeCxx/include/ComputeCxx/AGCachedValueOptions.h deleted file mode 100644 index 4795e0ce..00000000 --- a/Sources/ComputeCxx/include/ComputeCxx/AGCachedValueOptions.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include - -AG_ASSUME_NONNULL_BEGIN - -AG_EXTERN_C_BEGIN - -typedef AG_OPTIONS(uint32_t, AGCachedValueOptions) { - AGCachedValueOptionsNone = 0, - AGCachedValueOptionsUnprefetched = 1, -} AG_SWIFT_NAME(CachedValueOptions); - -AG_EXTERN_C_END - -AG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/AGChangedValue.h b/Sources/ComputeCxx/include/ComputeCxx/AGChangedValue.h deleted file mode 100644 index f754bf21..00000000 --- a/Sources/ComputeCxx/include/ComputeCxx/AGChangedValue.h +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once - -#include - -AG_ASSUME_NONNULL_BEGIN - -AG_EXTERN_C_BEGIN - -typedef AG_OPTIONS(uint8_t, AGChangedValueFlags) { - AGChangedValueFlagsChanged = 1 << 0, - AGChangedValueFlagsRequiresMainThread = 1 << 1, -}; - -typedef struct AGChangedValue { - const void *value; - AGChangedValueFlags flags; -} AGChangedValue; - -typedef struct AGWeakChangedValue { - const void *_Nullable value; - AGChangedValueFlags flags; -} AGWeakChangedValue; - -AG_EXTERN_C_END - -AG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/AGClosure.h b/Sources/ComputeCxx/include/ComputeCxx/AGClosure.h deleted file mode 100644 index 2c4edfa9..00000000 --- a/Sources/ComputeCxx/include/ComputeCxx/AGClosure.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once - -#include - -AG_ASSUME_NONNULL_BEGIN - -AG_EXTERN_C_BEGIN - -typedef struct AG_SWIFT_NAME(_AGClosureStorage) AGClosureStorage { - const void *thunk; - const void *_Nullable context; -} AGClosureStorage; - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGClosureStorage AGRetainClosure(const void *thunk, const void *_Nullable context); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGReleaseClosure(AGClosureStorage closure); - -AG_EXTERN_C_END - -AG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/AGComparison.h b/Sources/ComputeCxx/include/ComputeCxx/AGComparison.h deleted file mode 100644 index 88ddadad..00000000 --- a/Sources/ComputeCxx/include/ComputeCxx/AGComparison.h +++ /dev/null @@ -1,70 +0,0 @@ -#pragma once - -#include -#include - -AG_ASSUME_NONNULL_BEGIN -AG_IMPLICIT_BRIDGING_ENABLED - -AG_EXTERN_C_BEGIN - -typedef struct AGFieldRange { - size_t offset; - size_t size; -} AGFieldRange AG_SWIFT_STRUCT AG_SWIFT_NAME(FieldRange); - -typedef struct AGComparisonStateStorage *AGComparisonState AG_SWIFT_STRUCT AG_SWIFT_NAME(ComparisonState); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -const void *AGComparisonStateGetDestination(AGComparisonState state); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -const void *AGComparisonStateGetSource(AGComparisonState state); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGFieldRange AGComparisonStateGetFieldRange(AGComparisonState state); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGTypeID AGComparisonStateGetFieldType(AGComparisonState state); - -typedef AG_ENUM(uint8_t, AGComparisonMode) { - AGComparisonModeBitwise = 0, - AGComparisonModeIndirect = 1, - AGComparisonModeEquatableUnlessPOD = 2, - AGComparisonModeEquatableAlways = 3, -} AG_SWIFT_NAME(ComparisonMode); - -typedef AG_OPTIONS(uint32_t, AGComparisonOptions) { - AGComparisonOptionsComparisonModeBitwise = 0, - AGComparisonOptionsComparisonModeIndirect = 1, - AGComparisonOptionsComparisonModeEquatableUnlessPOD = 2, - AGComparisonOptionsComparisonModeEquatableAlways = 3, - AGComparisonOptionsComparisonModeMask = 0xff, - - AGComparisonOptionsCopyOnWrite = 1 << 8, - AGComparisonOptionsFetchLayoutsSynchronously = 1 << 9, - AGComparisonOptionsTraceCompareFailed = 1ul << 31, // -1 signed int -} AG_SWIFT_NAME(ComparisonOptions); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -bool AGCompareValues(const void *_Nonnull destination, const void *_Nonnull source, AGTypeID type_id, - AGComparisonOptions options); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -const unsigned char *_Nullable AGPrefetchCompareValues(AGTypeID type_id, AGComparisonOptions options, - uint32_t priority); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGOverrideComparisonForTypeDescriptor(void *descriptor, AGComparisonMode mode); - -AG_EXTERN_C_END - -AG_IMPLICIT_BRIDGING_DISABLED -AG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/AGDescription.h b/Sources/ComputeCxx/include/ComputeCxx/AGDescription.h deleted file mode 100644 index d9a844b2..00000000 --- a/Sources/ComputeCxx/include/ComputeCxx/AGDescription.h +++ /dev/null @@ -1,37 +0,0 @@ -#pragma once - -#include - -#if TARGET_OS_MAC -#include -#else -#include -#endif - -#include - -AG_ASSUME_NONNULL_BEGIN - -AG_EXTERN_C_BEGIN - -#if TARGET_OS_MAC - -typedef CFStringRef AGDescriptionOption AG_SWIFT_STRUCT AG_SWIFT_NAME(DescriptionOption); - -AG_EXPORT -const AGDescriptionOption AGDescriptionFormat AG_SWIFT_NAME(AGDescriptionOption.format); - -AG_EXPORT -const AGDescriptionOption AGDescriptionMaxFrames AG_SWIFT_NAME(AGDescriptionOption.maxFrames); - -AG_EXPORT -const AGDescriptionOption AGDescriptionIncludeValues AG_SWIFT_NAME(AGDescriptionOption.includeValues); - -AG_EXPORT -const AGDescriptionOption AGDescriptionTruncationLimit AG_SWIFT_NAME(AGDescriptionOption.truncationLimit); - -#endif - -AG_EXTERN_C_END - -AG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/AGGraph.h b/Sources/ComputeCxx/include/ComputeCxx/AGGraph.h deleted file mode 100644 index e1a80896..00000000 --- a/Sources/ComputeCxx/include/ComputeCxx/AGGraph.h +++ /dev/null @@ -1,382 +0,0 @@ -#pragma once - -#include - -#if TARGET_OS_MAC -#include -#include -#include -#else -#include -#include -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -AG_ASSUME_NONNULL_BEGIN -AG_IMPLICIT_BRIDGING_ENABLED - -AG_EXTERN_C_BEGIN - -// MARK: CFType - -typedef struct AG_BRIDGED_TYPE(id) AGGraphStorage *AGGraphRef AG_SWIFT_NAME(Graph); -typedef void *AGUnownedGraphContextRef AG_SWIFT_STRUCT; - -AG_EXPORT -AG_REFINED_FOR_SWIFT -CFTypeID AGGraphGetTypeID(void) AG_SWIFT_NAME(getter:AGGraphRef.typeID()); - -// MARK: Graph Context - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGGraphRef AGGraphCreate(void) AG_SWIFT_NAME(AGGraphRef.init()); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGGraphRef AGGraphCreateShared(AGGraphRef _Nullable graph) AG_SWIFT_NAME(AGGraphRef.init(shared:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGUnownedGraphContextRef AGGraphGetGraphContext(AGGraphRef graph) - AG_SWIFT_NAME(getter:AGGraphRef.graphContext(self:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGGraphRef AGGraphContextGetGraph(void *context); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGGraphInvalidate(AGGraphRef graph) AG_SWIFT_NAME(AGGraphRef.invalidate(self:)); - -// MARK: User context - -AG_EXPORT -AG_REFINED_FOR_SWIFT -const void *_Nullable AGGraphGetContext(AGGraphRef graph) AG_SWIFT_NAME(getter:AGGraphRef.context(self:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGGraphSetContext(AGGraphRef graph, const void *_Nullable context) - AG_SWIFT_NAME(setter:AGGraphRef.context(self:_:)); - -// MARK: Counter - -AG_EXPORT -AG_REFINED_FOR_SWIFT -uint64_t AGGraphGetCounter(AGGraphRef graph, AGGraphCounterQueryType query) - AG_SWIFT_NAME(AGGraphRef.counter(self:for:)); - -// MARK: Main handler - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGGraphWithMainThreadHandler(AGGraphRef graph, - void (*body)(const void *context AG_SWIFT_CONTEXT) AG_SWIFT_CC(swift), - const void *body_context, - void (*main_thread_handler)(void (*trampoline_thunk)(const void *), - const void *trampoline, - const void *context AG_SWIFT_CONTEXT) AG_SWIFT_CC(swift), - const void *main_thread_handler_context); - -// MARK: Subgraphs - -AG_EXPORT -AG_REFINED_FOR_SWIFT -bool AGGraphBeginDeferringSubgraphInvalidation(AGGraphRef graph) - AG_SWIFT_NAME(AGGraphRef.beginDeferringSubgraphInvalidation(self:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGGraphEndDeferringSubgraphInvalidation(AGGraphRef graph, bool was_deferring) - AG_SWIFT_NAME(AGGraphRef.endDeferringSubgraphInvalidation(self:wasDeferring:)); - -// MARK: Attribute types - -AG_EXPORT -AG_REFINED_FOR_SWIFT -uint32_t AGGraphInternAttributeType(AGUnownedGraphContextRef graph, AGTypeID type, - const AGAttributeType *_Nonnull (*_Nonnull make_attribute_type)( - const void *_Nullable context AG_SWIFT_CONTEXT) AG_SWIFT_CC(swift), - const void *_Nullable make_attribute_type_context); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGGraphVerifyType(AGAttribute attribute, AGTypeID type) AG_SWIFT_NAME(AGAttribute.verifyType(self:type:)); - -// MARK: Attributes - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGAttribute AGGraphCreateAttribute(uint32_t type_id, const void *body, const void *_Nullable value) - AG_SWIFT_NAME(AGAttribute.init(type:body:value:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGGraphRef AGGraphGetAttributeGraph(AGAttribute attribute) AG_SWIFT_NAME(getter:AGAttribute.graph(self:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGAttributeInfo AGGraphGetAttributeInfo(AGAttribute attribute) AG_SWIFT_NAME(getter:AGAttribute.info(self:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGAttributeFlags AGGraphGetFlags(AGAttribute attribute) AG_SWIFT_NAME(getter:AGAttribute.flags(self:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGGraphSetFlags(AGAttribute attribute, AGAttributeFlags flags) AG_SWIFT_NAME(setter:AGAttribute.flags(self:_:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -uint32_t AGGraphAddInput(AGAttribute attribute, AGAttribute input, AGInputOptions options) - AG_SWIFT_NAME(AGAttribute.addInput(self:_:options:)); - -// MARK: Offset attributes - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGAttribute AGGraphCreateOffsetAttribute(AGAttribute attribute, uint32_t offset); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGAttribute AGGraphCreateOffsetAttribute2(AGAttribute attribute, uint32_t offset, size_t size); - -// MARK: Indirect attributes - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGAttribute AGGraphCreateIndirectAttribute(AGAttribute attribute) AG_SWIFT_NAME(AGAttribute.createIndirect(self:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGAttribute AGGraphCreateIndirectAttribute2(AGAttribute attribute, size_t size); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGAttribute AGGraphGetIndirectAttribute(AGAttribute attribute) AG_SWIFT_NAME(getter:AGAttribute.source(self:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGGraphSetIndirectAttribute(AGAttribute attribute, AGAttribute source) - AG_SWIFT_NAME(setter:AGAttribute.source(self:_:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGGraphResetIndirectAttribute(AGAttribute attribute, bool non_nil); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGAttribute AGGraphGetIndirectDependency(AGAttribute attribute); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGGraphSetIndirectDependency(AGAttribute attribute, AGAttribute dependency); - -// MARK: Search - -AG_EXPORT -AG_REFINED_FOR_SWIFT -bool AGGraphSearch(AGAttribute attribute, AGSearchOptions options, - bool (*predicate)(AGAttribute attribute, const void *context AG_SWIFT_CONTEXT) AG_SWIFT_CC(swift), - const void *predicate_context); - -// MARK: Body - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGGraphMutateAttribute(AGAttribute attribute, AGTypeID type, bool invalidating, - void (*modify)(void *body, const void *context AG_SWIFT_CONTEXT) AG_SWIFT_CC(swift), - const void *modify_context); - -// MARK: Value - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGChangedValue AGGraphGetValue(AGAttribute attribute, AGValueOptions options, AGTypeID type); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGWeakChangedValue AGGraphGetWeakValue(AGWeakAttribute attribute, AGValueOptions options, AGTypeID type); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGChangedValue AGGraphGetInputValue(AGAttribute attribute, AGAttribute input, AGValueOptions options, AGTypeID type); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -bool AGGraphSetValue(AGAttribute attribute, const void *value, AGTypeID type); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -bool AGGraphHasValue(AGAttribute attribute) AG_SWIFT_NAME(getter:AGAttribute.hasValue(self:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGValueState AGGraphGetValueState(AGAttribute attribute) AG_SWIFT_NAME(getter:AGAttribute.valueState(self:)); - -typedef AG_OPTIONS(uint32_t, AGGraphUpdateOptions) { - AGGraphUpdateOptionsNone = 0, - AGGraphUpdateOptionsInTransaction = 1 << 0, - AGGraphUpdateOptionsAbortIfCancelled = 1 << 1, - AGGraphUpdateOptionsCancelIfPassedDeadline = 1 << 2, - AGGraphUpdateOptionsInitializeCleared = 1 << 3, - AGGraphUpdateOptionsEndDeferringSubgraphInvalidationOnExit = 1 << 4, -}; - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGGraphUpdateValue(AGAttribute attribute, AGGraphUpdateOptions options) - AG_SWIFT_NAME(AGAttribute.updateValue(self:options:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -uint32_t AGGraphPrefetchValue(AGAttribute attribute) AG_SWIFT_NAME(AGAttribute.prefetchValue(self:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGGraphInvalidateValue(AGAttribute attribute) AG_SWIFT_NAME(AGAttribute.invalidateValue(self:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGGraphInvalidateAllValues(AGGraphRef graph) AG_SWIFT_NAME(AGGraphRef.invalidateAllValues(self:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGGraphSetInvalidationCallback(AGGraphRef graph, - void (*callback)(AGAttribute, const void *context AG_SWIFT_CONTEXT) - AG_SWIFT_CC(swift), - const void *callback_context); - -// MARK: Cached value - -CF_EXPORT -CF_REFINED_FOR_SWIFT -void *AGGraphReadCachedAttribute(size_t hash, AGTypeID type, const void *body, AGTypeID value_type, - AGCachedValueOptions options, AGAttribute owner, bool *_Nullable changed_out, - uint32_t (*closure)(AGUnownedGraphContextRef graph_context, - const void *context AG_SWIFT_CONTEXT) AG_SWIFT_CC(swift), - const void *closure_context); - -CF_EXPORT -CF_REFINED_FOR_SWIFT -void *_Nullable AGGraphReadCachedAttributeIfExists(size_t hash, AGTypeID type, const void *body, AGTypeID value_type, - AGCachedValueOptions options, AGAttribute owner, - bool *_Nullable changed_out); - -// MARK: Update - -typedef AG_ENUM(uint32_t, AGGraphUpdateStatus) { - AGGraphUpdateStatusNoChange = 0, - AGGraphUpdateStatusChanged = 1, - AGGraphUpdateStatusAborted = 2, - AGGraphUpdateStatusNeedsCallMainHandler = 3, -}; - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGGraphSetUpdate(const void *update) AG_SWIFT_NAME(AGGraphRef.setUpdate(_:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -const void *AGGraphClearUpdate(void) AG_SWIFT_NAME(AGGraphRef.clearUpdate()); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGGraphCancelUpdate(void) AG_SWIFT_NAME(AGGraphRef.cancelUpdate()); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -bool AGGraphCancelUpdateIfNeeded(void) AG_SWIFT_NAME(AGGraphRef.cancelUpdateIfNeeded()); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -bool AGGraphUpdateWasCancelled(void) AG_SWIFT_NAME(getter:AGGraphRef.updateWasCancelled()); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -uint64_t AGGraphGetDeadline(AGGraphRef graph) AG_SWIFT_NAME(getter:AGGraphRef.deadline(self:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGGraphSetDeadline(AGGraphRef graph, uint64_t deadline) AG_SWIFT_NAME(setter:AGGraphRef.deadline(self:_:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -bool AGGraphHasDeadlinePassed(void) AG_SWIFT_NAME(getter:AGGraphRef.hasDeadlinePassed()); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGGraphSetNeedsUpdate(AGGraphRef graph) AG_SWIFT_NAME(AGGraphRef.setNeedsUpdate(self:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGGraphWithUpdate(AGAttribute attribute, void (*body)(const void *context AG_SWIFT_CONTEXT) AG_SWIFT_CC(swift), - const void *body_context); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGGraphWithoutUpdate(void (*body)(const void *context AG_SWIFT_CONTEXT) AG_SWIFT_CC(swift), - const void *body_context); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGGraphSetUpdateCallback(AGGraphRef graph, - void (*callback)(const void *context AG_SWIFT_CONTEXT) AG_SWIFT_CC(swift), - const void *callback_context); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGAttribute AGGraphGetCurrentAttribute(void); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -bool AGGraphCurrentAttributeWasModified(void) AG_SWIFT_NAME(getter:AGAttribute.currentWasModified()); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -bool AGGraphAnyInputsChanged(const AGAttribute *AG_COUNTED_BY(count) exclude_attributes, size_t count); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void *_Nullable AGGraphGetOutputValue(AGTypeID type); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGGraphSetOutputValue(const void *value, AGTypeID type); - -// MARK: Description - -#if TARGET_OS_MAC -AG_EXPORT -AG_REFINED_FOR_SWIFT -CFTypeRef _Nullable AGGraphDescription(AGGraphRef _Nullable graph, CFDictionaryRef options) - AG_SWIFT_NAME(AGGraphRef.description(_:options:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGGraphArchiveJSON(const char *_Nullable filename) AG_SWIFT_NAME(AGGraphRef.archiveJSON(name:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGGraphArchiveJSON2(const char *filename, bool exclude_values) - AG_SWIFT_NAME(AGGraphRef.archiveJSON(name:excludeValues:)); -#endif - -AG_EXTERN_C_END - -AG_IMPLICIT_BRIDGING_DISABLED -AG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/AGGraphCounterQueryType.h b/Sources/ComputeCxx/include/ComputeCxx/AGGraphCounterQueryType.h deleted file mode 100644 index a23da427..00000000 --- a/Sources/ComputeCxx/include/ComputeCxx/AGGraphCounterQueryType.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include - -typedef AG_ENUM(uint32_t, AGGraphCounterQueryType) { - AGGraphCounterQueryTypeNodes, - AGGraphCounterQueryTypeTransactions, - AGGraphCounterQueryTypeUpdates, - AGGraphCounterQueryTypeChanges, - AGGraphCounterQueryTypeContextID, - AGGraphCounterQueryTypeGraphID, - AGGraphCounterQueryTypeContextThreadUpdating, - AGGraphCounterQueryTypeThreadUpdating, - AGGraphCounterQueryTypeContextNeedsUpdate, - AGGraphCounterQueryTypeNeedsUpdate, - AGGraphCounterQueryTypeMainThreadUpdates, - AGGraphCounterQueryTypeCreatedNodes, - AGGraphCounterQueryTypeSubgraphs, - AGGraphCounterQueryTypeCreatedSubgraphs, -} AG_SWIFT_NAME(AGGraphRef.CounterQueryType); diff --git a/Sources/ComputeCxx/include/ComputeCxx/AGGraphTracing.h b/Sources/ComputeCxx/include/ComputeCxx/AGGraphTracing.h deleted file mode 100644 index efa4009d..00000000 --- a/Sources/ComputeCxx/include/ComputeCxx/AGGraphTracing.h +++ /dev/null @@ -1,102 +0,0 @@ -#pragma once - -#include -#include - -typedef AG_OPTIONS(uint32_t, AGGraphTraceOptions) { - AGGraphTraceOptionsEnabled = 1 << 0, - AGGraphTraceOptionsFull = 1 << 1, - AGGraphTraceOptionsBacktrace = 1 << 2, - AGGraphTraceOptionsPrepare = 1 << 3, - AGGraphTraceOptionsCustom = 1 << 4, - AGGraphTraceOptionsAll = 1 << 5, -} AG_SWIFT_NAME(AGGraphRef.TraceOptions); - -typedef struct AGTraceType *AGTraceTypeRef; - -AG_ASSUME_NONNULL_BEGIN - -AG_EXTERN_C_BEGIN - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGGraphStartTracing(AGGraphRef _Nullable graph, AGGraphTraceOptions trace_options) - AG_SWIFT_NAME(AGGraphRef.startTracing(_:options:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGGraphStartTracing2(AGGraphRef _Nullable graph, AGGraphTraceOptions trace_options, - CFArrayRef _Nullable subsystems) - AG_SWIFT_NAME(AGGraphRef.startTracing(_:options:subsystems:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGGraphStopTracing(AGGraphRef _Nullable graph) AG_SWIFT_NAME(AGGraphRef.stopTracing(_:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGGraphSyncTracing(AGGraphRef graph) AG_SWIFT_NAME(AGGraphRef.syncTracing(self:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -CFStringRef AGGraphCopyTracePath(AGGraphRef graph) AG_SWIFT_NAME(getter:AGGraphRef.tracePath(self:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -uint64_t AGGraphAddTrace(AGGraphRef graph, const AGTraceTypeRef trace, void *_Nullable context) - AG_SWIFT_NAME(AGGraphRef.addTrace(self:_:context:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGGraphRemoveTrace(AGGraphRef graph, uint64_t trace_id) AG_SWIFT_NAME(AGGraphRef.removeTrace(self:traceID:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGGraphSetTrace(AGGraphRef graph, const AGTraceTypeRef trace, void *_Nullable context) - AG_SWIFT_NAME(AGGraphRef.setTrace(self:_:context:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGGraphResetTrace(AGGraphRef graph) AG_SWIFT_NAME(AGGraphRef.resetTrace(self:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -bool AGGraphIsTracingActive(AGGraphRef graph) AG_SWIFT_NAME(getter:AGGraphRef.isTracingActive(self:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGGraphPrepareTrace(AGGraphRef graph, const AGTraceTypeRef trace, void *_Nullable context); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -bool AGGraphTraceEventEnabled(AGGraphRef graph, uint32_t event_id) - AG_SWIFT_NAME(AGGraphRef.traceEventEnabled(self:for:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGGraphAddTraceEvent(AGGraphRef graph, const char *event_name, const void *value, AGTypeID type) - AG_SWIFT_NAME(AGGraphRef.addTraceEvent(self:name:value:type:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGGraphAddNamedTraceEvent(AGGraphRef graph, uint32_t event_id, uint32_t event_arg_count, const void *event_args, - CFDataRef data, uint32_t arg6) - AG_SWIFT_NAME(AGGraphRef.addNamedTraceEvent(self:eventID:eventArgCount:eventArgs:data:arg6:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -const char *_Nullable AGGraphGetTraceEventName(uint32_t event_id) AG_SWIFT_NAME(AGGraphRef.traceEventName(for:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -const char *_Nullable AGGraphGetTraceEventSubsystem(uint32_t event_id) - AG_SWIFT_NAME(AGGraphRef.traceEventSubsystem(for:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -uint32_t AGGraphRegisterNamedTraceEvent(const char *event_name, const char *event_subsystem) - AG_SWIFT_NAME(AGGraphRef.registerNamedTraceEvent(name:subsystem:)); - -AG_EXTERN_C_END - -AG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/AGInputOptions.h b/Sources/ComputeCxx/include/ComputeCxx/AGInputOptions.h deleted file mode 100644 index 09224ad4..00000000 --- a/Sources/ComputeCxx/include/ComputeCxx/AGInputOptions.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include - -AG_ASSUME_NONNULL_BEGIN - -AG_EXTERN_C_BEGIN - -typedef AG_OPTIONS(uint8_t, AGInputOptions) { - AGInputOptionsNone = 0, - AGInputOptionsUnprefetched = 1 << 0, - AGInputOptionsSyncMainRef = 1 << 1, - AGInputOptionsAlwaysEnabled = 1 << 2, - AGInputOptionsChanged = 1 << 3, - AGInputOptionsEnabled = 1 << 4, -}; - -AG_EXTERN_C_END - -AG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/AGSearchOptions.h b/Sources/ComputeCxx/include/ComputeCxx/AGSearchOptions.h deleted file mode 100644 index 50933360..00000000 --- a/Sources/ComputeCxx/include/ComputeCxx/AGSearchOptions.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include - -AG_ASSUME_NONNULL_BEGIN - -AG_EXTERN_C_BEGIN - -typedef AG_OPTIONS(uint32_t, AGSearchOptions) { - AGSearchOptionsSearchInputs = 1 << 0, - AGSearchOptionsSearchOutputs = 1 << 1, - AGSearchOptionsTraverseGraphContexts = 1 << 2, -} AG_SWIFT_NAME(SearchOptions); - -AG_EXTERN_C_END - -AG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/AGSubgraph.h b/Sources/ComputeCxx/include/ComputeCxx/AGSubgraph.h deleted file mode 100644 index ae861448..00000000 --- a/Sources/ComputeCxx/include/ComputeCxx/AGSubgraph.h +++ /dev/null @@ -1,186 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -AG_ASSUME_NONNULL_BEGIN -AG_IMPLICIT_BRIDGING_ENABLED - -AG_EXTERN_C_BEGIN - -// MARK: CFType - -typedef struct AG_BRIDGED_TYPE(id) AGSubgraphStorage *AGSubgraphRef AG_SWIFT_NAME(Subgraph); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -CFTypeID AGSubgraphGetTypeID(void) AG_SWIFT_NAME(getter:AGSubgraphRef.typeID()); - -// MARK: Current subgraph - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGSubgraphRef _Nullable AGSubgraphGetCurrent(void) AG_SWIFT_NAME(getter:AGSubgraphRef.current()); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGSubgraphSetCurrent(AGSubgraphRef _Nullable subgraph) AG_SWIFT_NAME(setter:AGSubgraphRef.current(_:)); - -// MARK: Graph Context - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGSubgraphRef AGSubgraphCreate(AGGraphRef graph) AG_SWIFT_NAME(AGSubgraphRef.init(graph:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGSubgraphRef AGSubgraphCreate2(AGGraphRef graph, AGAttribute attribute) - AG_SWIFT_NAME(AGSubgraphRef.init(graph:attribute:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGUnownedGraphContextRef _Nullable AGSubgraphGetCurrentGraphContext(void) - AG_SWIFT_NAME(getter:AGSubgraphRef.currentGraphContext()); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGGraphRef AGSubgraphGetGraph(AGSubgraphRef subgraph) AG_SWIFT_NAME(getter:AGSubgraphRef.graph(self:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -bool AGSubgraphIsValid(AGSubgraphRef subgraph) AG_SWIFT_NAME(getter:AGSubgraphRef.isValid(self:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGSubgraphInvalidate(AGSubgraphRef subgraph) AG_SWIFT_NAME(AGSubgraphRef.invalidate(self:)); - -// MARK: Index - -AG_EXPORT -AG_REFINED_FOR_SWIFT -uint32_t AGSubgraphGetIndex(AGSubgraphRef subgraph) AG_SWIFT_NAME(getter:AGSubgraphRef.index(self:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGSubgraphSetIndex(AGSubgraphRef subgraph, uint32_t index) AG_SWIFT_NAME(setter:AGSubgraphRef.index(self:_:)); - -// MARK: Observers - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGUniqueID AGSubgraphAddObserver(AGSubgraphRef subgraph, - void (*observer)(const void *_Nullable context AG_SWIFT_CONTEXT) AG_SWIFT_CC(swift), - const void *_Nullable observer_context); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGSubgraphRemoveObserver(AGSubgraphRef subgraph, AGUniqueID observer_id) - AG_SWIFT_NAME(AGSubgraphRef.removeObserver(self:_:)); - -// MARK: Children - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGSubgraphAddChild(AGSubgraphRef subgraph, AGSubgraphRef child) AG_SWIFT_NAME(AGSubgraphRef.addChild(self:_:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGSubgraphAddChild2(AGSubgraphRef subgraph, AGSubgraphRef child, uint8_t tag) - AG_SWIFT_NAME(AGSubgraphRef.addChild(self:_:tag:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGSubgraphRemoveChild(AGSubgraphRef subgraph, AGSubgraphRef child) - AG_SWIFT_NAME(AGSubgraphRef.removeChild(self:_:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGSubgraphRef AGSubgraphGetChild(AGSubgraphRef subgraph, uint32_t index, uint8_t *_Nullable tag_out) - AG_SWIFT_NAME(AGSubgraphRef.child(self:at:tag:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -uint32_t AGSubgraphGetChildCount(AGSubgraphRef subgraph) AG_SWIFT_NAME(getter:AGSubgraphRef.childCount(self:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGSubgraphRef AGSubgraphGetParent(AGSubgraphRef subgraph, int64_t index) AG_SWIFT_NAME(AGSubgraphRef.parent(self:at:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -uint64_t AGSubgraphGetParentCount(AGSubgraphRef subgraph) AG_SWIFT_NAME(getter:AGSubgraphRef.parentCount(self:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -bool AGSubgraphIsAncestor(AGSubgraphRef subgraph, AGSubgraphRef other) - AG_SWIFT_NAME(AGSubgraphRef.isAncestor(self:of:)); - -// MARK: Flags - -AG_EXPORT -AG_REFINED_FOR_SWIFT -bool AGSubgraphIntersects(AGSubgraphRef subgraph, AGAttributeFlags flags) - AG_SWIFT_NAME(AGSubgraphRef.intersects(self:flags:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -bool AGSubgraphIsDirty(AGSubgraphRef subgraph, AGAttributeFlags flags) AG_SWIFT_NAME(AGSubgraphRef.isDirty(self:flags:)); - -// MARK: Attributes - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGSubgraphRef AGGraphGetAttributeSubgraph(AGAttribute attribute) AG_SWIFT_NAME(getter:AGAttribute.subgraph(self:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGSubgraphRef _Nullable AGGraphGetAttributeSubgraph2(AGAttribute attribute) - AG_SWIFT_NAME(getter:AGAttribute.subgraphOrNil(self:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGSubgraphApply(AGSubgraphRef subgraph, uint32_t options, - void (*body)(AGAttribute, const void *context AG_SWIFT_CONTEXT) AG_SWIFT_CC(swift), - const void *body_context); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGSubgraphUpdate(AGSubgraphRef subgraph, AGAttributeFlags flags) AG_SWIFT_NAME(AGSubgraphRef.update(self:flags:)); - -// MARK: Tree - -AG_EXPORT -AG_REFINED_FOR_SWIFT -_Nullable AGTreeElement AGSubgraphGetTreeRoot(AGSubgraphRef subgraph) AG_SWIFT_NAME(getter:AGSubgraphRef.treeRoot(self:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGSubgraphBeginTreeElement(AGAttribute value, AGTypeID type, uint32_t flags); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGSubgraphEndTreeElement(AGAttribute value); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGSubgraphSetTreeOwner(AGSubgraphRef subgraph, AGAttribute owner) - AG_SWIFT_NAME(AGSubgraphRef.setTreeOwner(self:_:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGSubgraphAddTreeValue(AGAttribute value, AGTypeID type, const char *key, uint32_t flags); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -bool AGSubgraphShouldRecordTree(void) AG_SWIFT_NAME(getter:AGSubgraphRef.shouldRecordTree()); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGSubgraphSetShouldRecordTree(void) AG_SWIFT_NAME(AGSubgraphRef.setShouldRecordTree()); - -AG_EXTERN_C_END - -AG_IMPLICIT_BRIDGING_DISABLED -AG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/AGTraceType.h b/Sources/ComputeCxx/include/ComputeCxx/AGTraceType.h deleted file mode 100644 index 2f9bb90e..00000000 --- a/Sources/ComputeCxx/include/ComputeCxx/AGTraceType.h +++ /dev/null @@ -1,82 +0,0 @@ -#pragma once - -#include -#include -#include - -AG_ASSUME_NONNULL_BEGIN - -AG_EXTERN_C_BEGIN - -typedef AG_ENUM(uint64_t, AGTraceTypeVersion) { - AGTraceTypeVersionInitial = 0, - AGTraceTypeVersionCustom = 1, - AGTraceTypeVersionNamed = 2, - AGTraceTypeVersionDeadline = 3, - AGTraceTypeVersionCompareFailed = 4, -}; - -typedef struct AGTraceType { - AGTraceTypeVersion version; - - void (*_Nullable begin_trace)(void *_Nullable context, AGGraphRef graph); - void (*_Nullable end_trace)(void *_Nullable context, AGGraphRef graph); - - void (*_Nullable begin_subgraph_update)(void *_Nullable context, AGSubgraphRef subgraph, uint32_t options); - void (*_Nullable end_subgraph_update)(void *_Nullable context, AGSubgraphRef subgraph); - void (*_Nullable begin_node_update)(void *_Nullable context, AGAttribute attribute); - void (*_Nullable end_node_update)(void *_Nullable context, bool changed); - void (*_Nullable begin_value_update)(void *_Nullable context, AGAttribute attribute); - void (*_Nullable end_value_update)(void *_Nullable context, AGAttribute attribute, bool changed); - void (*_Nullable begin_graph_update)(void *_Nullable context, AGGraphRef graph); - void (*_Nullable end_graph_update)(void *_Nullable context, AGGraphRef graph); - - void (*_Nullable begin_graph_invalidation)(void *_Nullable context, AGGraphRef graph, AGAttribute attribute); - void (*_Nullable end_graph_invalidation)(void *_Nullable context, AGGraphRef graph, AGAttribute attribute); - - void (*_Nullable begin_modify_node)(void *_Nullable context, AGAttribute attribute); - void (*_Nullable end_modify_node)(void *_Nullable context, AGAttribute attribute); - - void (*_Nullable begin_event)(void *_Nullable context, AGAttribute attribute, const char *event_name); - void (*_Nullable end_event)(void *_Nullable context, AGAttribute attribute, const char *event_name); - - void (*_Nullable graph_created)(void *_Nullable context, AGGraphRef graph); - void (*_Nullable graph_destroy)(void *_Nullable context, AGGraphRef graph); - void (*_Nullable graph_needs_update)(void *_Nullable context, AGGraphRef graph); - - void (*_Nullable subgraph_created)(void *_Nullable context, AGSubgraphRef subgraph); - void (*_Nullable subgraph_destroy)(void *_Nullable context, AGSubgraphRef subgraph); - void (*_Nullable subgraph_add_child)(void *_Nullable context, AGSubgraphRef subgraph, AGSubgraphRef child); - void (*_Nullable subgraph_remove_child)(void *_Nullable context, AGSubgraphRef subgraph, AGSubgraphRef child); - - void (*_Nullable node_added)(void *_Nullable context, AGAttribute attribute); - void (*_Nullable node_add_edge)(void *_Nullable context, AGAttribute attribute, AGAttribute input, AGInputOptions input_options); - void (*_Nullable node_remove_edge)(void *_Nullable context, AGAttribute attribute, uint32_t index); - void (*_Nullable node_set_edge_pending)(void *_Nullable context, AGAttribute attribute, AGAttribute input, bool pending); - - void (*_Nullable node_set_dirty)(void *_Nullable context, AGAttribute attribute, bool dirty); - void (*_Nullable node_set_pending)(void *_Nullable context, AGAttribute attribute, bool pending); - void (*_Nullable node_set_value)(void *_Nullable context, AGAttribute attribute); - void (*_Nullable node_mark_value)(void *_Nullable context, AGAttribute attribute); - - void (*_Nullable indirect_node_added)(void *_Nullable context, AGAttribute attribute); - void (*_Nullable indirect_node_set_source)(void *_Nullable context, AGAttribute attribute, AGAttribute source); - void (*_Nullable indirect_node_set_dependency)(void *_Nullable context, AGAttribute attribute, AGAttribute dependency); - - void (*_Nullable profile_mark)(void *_Nullable context, const char *event_name); - - void (*_Nullable custom_event)(void *_Nullable context, AGGraphRef graph, const char *event_name, const void *value, - AGTypeID type); - void (*_Nullable named_event)(void *_Nullable context, AGGraphRef graph, uint32_t eventID, uint32_t eventArgCount, - const void *eventArgs, CFDataRef data, uint32_t arg6); - bool (*_Nullable named_event_enabled)(void *_Nullable context); - - void (*_Nullable set_deadline)(void *_Nullable context); - void (*_Nullable passed_deadline)(void *_Nullable context); - - void (*_Nullable compare_failed)(void *_Nullable context, AGAttribute attribute, AGComparisonState comparisonState); -} AGTraceType; - -AG_EXTERN_C_END - -AG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/AGTreeElement.h b/Sources/ComputeCxx/include/ComputeCxx/AGTreeElement.h deleted file mode 100644 index 731fe1e4..00000000 --- a/Sources/ComputeCxx/include/ComputeCxx/AGTreeElement.h +++ /dev/null @@ -1,81 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -AG_ASSUME_NONNULL_BEGIN - -AG_EXTERN_C_BEGIN - -typedef struct _AGTreeElement *AGTreeElement AG_SWIFT_STRUCT AG_SWIFT_NAME(TreeElement); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGTypeID AGTreeElementGetType(AGTreeElement tree_element) AG_SWIFT_NAME(getter:AGTreeElement.type(self:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGAttribute AGTreeElementGetValue(AGTreeElement tree_element); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -uint32_t AGTreeElementGetFlags(AGTreeElement tree_element) AG_SWIFT_NAME(getter:AGTreeElement.flags(self:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGTreeElement _Nullable AGTreeElementGetParent(AGTreeElement tree_element) AG_SWIFT_NAME(getter:AGTreeElement.parent(self:)); - -// MARK: Iterating values - -typedef struct AGTreeElementValueIterator { - uintptr_t parent_elt; - uintptr_t next_elt; -} AG_SWIFT_NAME(Values) AGTreeElementValueIterator; - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGTreeElementValueIterator AGTreeElementMakeValueIterator(AGTreeElement tree_element) - AG_SWIFT_NAME(getter:AGTreeElement.values(self:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGTreeValue _Nullable AGTreeElementGetNextValue(AGTreeElementValueIterator *iter) AG_SWIFT_NAME(AGTreeElementValueIterator.next(self:)); - -// MARK: Iterating nodes - -typedef struct AGTreeElementNodeIterator { - uintptr_t elt; - unsigned long node_index; -} AG_SWIFT_NAME(Nodes) AGTreeElementNodeIterator; - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGTreeElementNodeIterator AGTreeElementMakeNodeIterator(AGTreeElement tree_element) - AG_SWIFT_NAME(getter:AGTreeElement.nodes(self:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGAttribute AGTreeElementGetNextNode(AGTreeElementNodeIterator *iter); - -// MARK: Iterating children - -typedef struct AGTreeElementChildIterator { - uintptr_t parent_elt; - uintptr_t next_elt; - size_t subgraph_index; -} AG_SWIFT_NAME(Children) AGTreeElementChildIterator; - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGTreeElementChildIterator AGTreeElementMakeChildIterator(AGTreeElement tree_element) - AG_SWIFT_NAME(getter:AGTreeElement.children(self:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGTreeElement _Nullable AGTreeElementGetNextChild(AGTreeElementChildIterator *iter) AG_SWIFT_NAME(AGTreeElementChildIterator.next(self:)); - -AG_EXTERN_C_END - -AG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/AGTreeValue.h b/Sources/ComputeCxx/include/ComputeCxx/AGTreeValue.h deleted file mode 100644 index 25615c82..00000000 --- a/Sources/ComputeCxx/include/ComputeCxx/AGTreeValue.h +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once - -#include -#include -#include - -AG_ASSUME_NONNULL_BEGIN - -AG_EXTERN_C_BEGIN - -typedef struct _AGTreeValue *AGTreeValue AG_SWIFT_STRUCT AG_SWIFT_NAME(TreeValue); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGTypeID AGTreeValueGetType(AGTreeValue tree_value) AG_SWIFT_NAME(getter:AGTreeValue.type(self:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGAttribute AGTreeValueGetValue(AGTreeValue tree_value) AG_SWIFT_NAME(getter:AGTreeValue.value(self:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -const char *AGTreeValueGetKey(AGTreeValue tree_value) AG_SWIFT_NAME(getter:AGTreeValue.key(self:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -uint32_t AGTreeValueGetFlags(AGTreeValue tree_value) AG_SWIFT_NAME(getter:AGTreeValue.flags(self:)); - -AG_EXTERN_C_END - -AG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/AGTuple.h b/Sources/ComputeCxx/include/ComputeCxx/AGTuple.h deleted file mode 100644 index a6487d26..00000000 --- a/Sources/ComputeCxx/include/ComputeCxx/AGTuple.h +++ /dev/null @@ -1,89 +0,0 @@ -#pragma once - -#include -#include - -AG_ASSUME_NONNULL_BEGIN -AG_IMPLICIT_BRIDGING_ENABLED - -AG_EXTERN_C_BEGIN - -typedef AG_ENUM(uint32_t, AGTupleCopyOptions) { - AGTupleCopyOptionsAssignCopy = 0, - AGTupleCopyOptionsInitCopy = 1, - AGTupleCopyOptionsAssignTake = 2, - AGTupleCopyOptionsInitTake = 3, -} AG_SWIFT_NAME(TupleType.CopyOptions); - -typedef const struct AGSwiftMetadata *AGTupleType AG_SWIFT_STRUCT AG_SWIFT_NAME(TupleType); - -typedef struct AGUnsafeTuple { - AGTupleType type; - const void *value; -} AG_SWIFT_NAME(UnsafeTuple) AGUnsafeTuple; - -typedef struct AGUnsafeMutableTuple { - AGTupleType type; - void *value; -} AG_SWIFT_NAME(UnsafeMutableTuple) AGUnsafeMutableTuple; - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGTupleType AGNewTupleType(size_t count, const AGTypeID _Nonnull *_Nonnull elements) - AG_SWIFT_NAME(TupleType.init(count:elements:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -size_t AGTupleCount(AGTupleType tuple_type) AG_SWIFT_NAME(getter:AGTupleType.count(self:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -size_t AGTupleSize(AGTupleType tuple_type) AG_SWIFT_NAME(getter:AGTupleType.size(self:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGTypeID AGTupleElementType(AGTupleType tuple_type, size_t index) AG_SWIFT_NAME(TupleType.elementType(self:at:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -size_t AGTupleElementSize(AGTupleType tuple_type, size_t index) AG_SWIFT_NAME(TupleType.elementSize(self:at:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -size_t AGTupleElementOffset(AGTupleType tuple_type, size_t index) AG_SWIFT_NAME(TupleType.elementOffset(self:at:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -size_t AGTupleElementOffsetChecked(AGTupleType tuple_type, size_t index, AGTypeID element_type) - AG_SWIFT_NAME(TupleType.elementOffset(self:at:type:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void *AGTupleGetElement(AGTupleType tuple_type, void *tuple_value, size_t index, void *element_value, - AGTypeID element_type, AGTupleCopyOptions options); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void *AGTupleSetElement(AGTupleType tuple_type, void *tuple_value, size_t index, const void *element_value, - AGTypeID element_type, AGTupleCopyOptions options); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGTupleDestroy(AGTupleType tuple_type, void *tuple_value) AG_SWIFT_NAME(TupleType.destroy(self:_:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGTupleDestroyElement(AGTupleType tuple_type, void *tuple_value, size_t index) - AG_SWIFT_NAME(TupleType.destroy(self:_:at:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGTupleWithBuffer(AGTupleType tuple_type, size_t count, - void (*function)(const AGUnsafeMutableTuple mutable_tuple, void *context AG_SWIFT_CONTEXT) - AG_SWIFT_CC(swift), - void *context); - -AG_EXTERN_C_END - -AG_IMPLICIT_BRIDGING_DISABLED -AG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/AGType.h b/Sources/ComputeCxx/include/ComputeCxx/AGType.h deleted file mode 100644 index d3f35bdc..00000000 --- a/Sources/ComputeCxx/include/ComputeCxx/AGType.h +++ /dev/null @@ -1,129 +0,0 @@ -#pragma once - -#include - -#if TARGET_OS_MAC -#include -#else -#include -#endif - -AG_ASSUME_NONNULL_BEGIN -AG_IMPLICIT_BRIDGING_ENABLED - -AG_EXTERN_C_BEGIN - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wextern-c-compat" -typedef struct AG_SWIFT_NAME(_Metadata) AGSwiftMetadata { -} AGSwiftMetadata; -#pragma GCC diagnostic pop - -typedef const AGSwiftMetadata *AGTypeID AG_SWIFT_STRUCT AG_SWIFT_NAME(Metadata); - -typedef struct AGTypeSignature { - uint8_t bytes[20]; -} AG_SWIFT_NAME(Signature) AGTypeSignature; - -typedef AG_CLOSED_ENUM(uint32_t, AGTypeKind) { - AGTypeKindNone, - AGTypeKindClass, - AGTypeKindStruct, - AGTypeKindEnum, - AGTypeKindOptional, - AGTypeKindTuple, - AGTypeKindFunction, - AGTypeKindExistential, - AGTypeKindMetatype, -} AG_SWIFT_NAME(Metadata.Kind); - -#if TARGET_OS_MAC -AG_EXPORT -AG_REFINED_FOR_SWIFT -CFStringRef AGTypeDescription(AGTypeID typeID); -#else -AG_EXPORT -AG_REFINED_FOR_SWIFT -CFStringRef AGTypeCopyDescription(AGTypeID typeID); -#endif - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGTypeKind AGTypeGetKind(AGTypeID typeID) AG_SWIFT_NAME(getter:Metadata.kind(self:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -const AGTypeSignature AGTypeGetSignature(AGTypeID typeID) AG_SWIFT_NAME(getter:Metadata.signature(self:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -const void *_Nullable AGTypeGetDescriptor(AGTypeID typeID) AG_SWIFT_NAME(getter:Metadata.descriptor(self:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -const void *_Nullable AGTypeNominalDescriptor(AGTypeID typeID) AG_SWIFT_NAME(getter:Metadata.nominalDescriptor(self:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -const char *_Nullable AGTypeNominalDescriptorName(AGTypeID typeID) - AG_SWIFT_NAME(getter:Metadata.nominalDescriptorName(self:)); - -typedef AG_OPTIONS(uint32_t, AGTypeApplyOptions) { - AGTypeApplyOptionsEnumerateStructFields = 0, - AGTypeApplyOptionsEnumerateClassFields = 1 << 0, - AGTypeApplyOptionsContinueAfterUnknownField = 1 << 1, - AGTypeApplyOptionsEnumerateEnumCases = 1 << 2, -} AG_SWIFT_NAME(Metadata.ApplyOptions); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGTypeApplyFields(AGTypeID typeID, - void (*apply)(const char *field_name, - size_t field_offset, - AGTypeID field_type, - const void *_Nullable context AG_SWIFT_CONTEXT) AG_SWIFT_CC(swift), - const void *apply_context); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -bool AGTypeApplyFields2(AGTypeID typeID, AGTypeApplyOptions options, - bool (*_Nonnull apply)(const char *field_name, - size_t field_offset, - AGTypeID field_type, - const void *context AG_SWIFT_CONTEXT) AG_SWIFT_CC(swift), - const void *apply_context); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -bool AGTypeApplyEnumData(AGTypeID typeID, void *value, - void (*body)(uint32_t tag, - AGTypeID field_type, - const void *field_value, - void *context AG_SWIFT_CONTEXT) AG_SWIFT_CC(swift), - void *context); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -bool AGTypeApplyMutableEnumData(AGTypeID typeID, void *value, - void (*body)(uint32_t tag, - AGTypeID field_type, - void *field_value, - void *context AG_SWIFT_CONTEXT) AG_SWIFT_CC(swift), - void *context); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -uint64_t AGTypeGetEnumTag(AGTypeID typeID, const void *value) AG_SWIFT_NAME(AGTypeID.enumTag(self:_:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGTypeProjectEnumData(AGTypeID typeID, void *value) AG_SWIFT_NAME(AGTypeID.projectEnumData(self:_:)); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -void AGTypeInjectEnumTag(AGTypeID typeID, uint32_t tag, void *value) AG_SWIFT_NAME(AGTypeID.injectEnumTag(self:tag:_:)); - -AG_EXTERN_C_END - -AG_IMPLICIT_BRIDGING_DISABLED -AG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/AGUniqueID.h b/Sources/ComputeCxx/include/ComputeCxx/AGUniqueID.h deleted file mode 100644 index 6cd0c88e..00000000 --- a/Sources/ComputeCxx/include/ComputeCxx/AGUniqueID.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include - -AG_ASSUME_NONNULL_BEGIN - -AG_EXTERN_C_BEGIN - -typedef long AGUniqueID; - -AGUniqueID AGMakeUniqueID(void) AG_SWIFT_NAME(makeUniqueID()); - -AG_EXTERN_C_END - -AG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/AGValue.h b/Sources/ComputeCxx/include/ComputeCxx/AGValue.h deleted file mode 100644 index 79cd5271..00000000 --- a/Sources/ComputeCxx/include/ComputeCxx/AGValue.h +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once - -#include - -AG_ASSUME_NONNULL_BEGIN - -AG_EXTERN_C_BEGIN - -typedef AG_OPTIONS(uint32_t, AGValueOptions) { - AGValueOptionsNone = 0, - AGValueOptionsInputOptionsUnprefetched = 1 << 0, - AGValueOptionsInputOptionsSyncMainRef = 1 << 1, - AGValueOptionsInputOptionsMask = 3, - - AGValueOptionsIncrementGraphVersion = 1 << 2, // AsTopLevelOutput -}; - -typedef AG_OPTIONS(uint8_t, AGValueState) { - AGValueStateNone = 0, - AGValueStateDirty = 1 << 0, - AGValueStatePending = 1 << 1, - AGValueStateUpdating = 1 << 2, - AGValueStateValueExists = 1 << 3, - AGValueStateMainThread = 1 << 4, - AGValueStateMainRef = 1 << 5, - AGValueStateRequiresMainThread = 1 << 6, - AGValueStateSelfModified = 1 << 7, -}; - -AG_EXTERN_C_END - -AG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/AGWeakAttribute.h b/Sources/ComputeCxx/include/ComputeCxx/AGWeakAttribute.h deleted file mode 100644 index 9e6c01c9..00000000 --- a/Sources/ComputeCxx/include/ComputeCxx/AGWeakAttribute.h +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once - -#include -#include - -AG_ASSUME_NONNULL_BEGIN - -AG_EXTERN_C_BEGIN - -typedef struct AGWeakAttribute { - struct { - AGAttribute identifier; - uint32_t seed; - } _details; -} AG_SWIFT_NAME(AnyWeakAttribute) AGWeakAttribute; - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGWeakAttribute AGCreateWeakAttribute(AGAttribute attribute); - -AG_EXPORT -AG_REFINED_FOR_SWIFT -AGAttribute AGWeakAttributeGetAttribute(AGWeakAttribute attribute); - -AG_EXTERN_C_END - -AG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/ComputeCxx.h b/Sources/ComputeCxx/include/ComputeCxx/ComputeCxx.h index 6abc3b9e..8e463ac7 100644 --- a/Sources/ComputeCxx/include/ComputeCxx/ComputeCxx.h +++ b/Sources/ComputeCxx/include/ComputeCxx/ComputeCxx.h @@ -1,26 +1,26 @@ #pragma once -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/Sources/ComputeCxx/include/ComputeCxx/IAGAttribute.h b/Sources/ComputeCxx/include/ComputeCxx/IAGAttribute.h new file mode 100644 index 00000000..8db7cdc7 --- /dev/null +++ b/Sources/ComputeCxx/include/ComputeCxx/IAGAttribute.h @@ -0,0 +1,21 @@ +#pragma once + +#include + +IAG_ASSUME_NONNULL_BEGIN + +IAG_EXTERN_C_BEGIN + +typedef uint32_t IAGAttribute IAG_SWIFT_STRUCT IAG_SWIFT_NAME(AnyAttribute); + +IAG_EXPORT +const IAGAttribute IAGAttributeNil; + +typedef IAG_OPTIONS(uint8_t, IAGAttributeFlags) { + IAGAttributeFlagsNone = 0, + IAGAttributeFlagsAll = 0xFF, +} IAG_SWIFT_NAME(IAGSubgraphRef.Flags); + +IAG_EXTERN_C_END + +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/IAGAttributeInfo.h b/Sources/ComputeCxx/include/ComputeCxx/IAGAttributeInfo.h new file mode 100644 index 00000000..dca465c7 --- /dev/null +++ b/Sources/ComputeCxx/include/ComputeCxx/IAGAttributeInfo.h @@ -0,0 +1,17 @@ +#pragma once + +#include +#include + +IAG_ASSUME_NONNULL_BEGIN + +IAG_EXTERN_C_BEGIN + +typedef struct IAGAttributeInfo { + const IAGAttributeType *type; + const void *body; +} IAGAttributeInfo; + +IAG_EXTERN_C_END + +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/IAGAttributeType.h b/Sources/ComputeCxx/include/ComputeCxx/IAGAttributeType.h new file mode 100644 index 00000000..8870657f --- /dev/null +++ b/Sources/ComputeCxx/include/ComputeCxx/IAGAttributeType.h @@ -0,0 +1,67 @@ +#pragma once + +#include + +#if TARGET_OS_MAC +#include +#else +#include +#endif + +#include +#include + +IAG_ASSUME_NONNULL_BEGIN +IAG_IMPLICIT_BRIDGING_ENABLED + +IAG_EXTERN_C_BEGIN + +typedef struct IAGAttributeType IAGAttributeType; + +typedef struct IAG_SWIFT_NAME(_AttributeVTable) IAGAttributeVTable { + unsigned long version; + void (*_Nullable type_destroy)(IAGAttributeType *); + void (*_Nullable self_destroy)(const IAGAttributeType *, void *); +#if TARGET_OS_MAC + CFStringRef _Nullable (*_Nullable self_description)(const IAGAttributeType *, const void *); + CFStringRef _Nullable (*_Nullable value_description)(const IAGAttributeType *, const void *); +#else + CFStringRef _Nullable (*_Nullable copy_self_description)(const IAGAttributeType *, const void *); + CFStringRef _Nullable (*_Nullable copy_value_description)(const IAGAttributeType *, const void *); +#endif + void (*_Nullable update_default)(const IAGAttributeType *, void *); +} IAGAttributeVTable; + +typedef IAG_OPTIONS(uint32_t, IAGAttributeTypeFlags) { + IAGAttributeTypeFlagsComparisonModeBitwise = 0, + IAGAttributeTypeFlagsComparisonModeIndirect = 1, + IAGAttributeTypeFlagsComparisonModeEquatableUnlessPOD = 2, + IAGAttributeTypeFlagsComparisonModeEquatableAlways = 3, + IAGAttributeTypeFlagsComparisonModeMask = 0x03, + + IAGAttributeTypeFlagsHasDestroySelf = 1 << 2, + IAGAttributeTypeFlagsMainThread = 1 << 3, + IAGAttributeTypeFlagsExternal = 1 << 4, + IAGAttributeTypeFlagsAsyncThread = 1 << 5, +} IAG_SWIFT_NAME(_AttributeType.Flags); + +typedef struct IAG_SWIFT_NAME(_AttributeType) IAGAttributeType { + IAGTypeID self_id; + IAGTypeID value_id; + IAGClosureStorage update; + const IAGAttributeVTable *vtable; + IAGAttributeTypeFlags flags; + + uint32_t internal_offset; + const unsigned char *_Nullable value_layout; + + struct { + IAGTypeID type_id; + const void *witness_table; + } body_conformance; +} IAGAttributeType; + +IAG_EXTERN_C_END + +IAG_IMPLICIT_BRIDGING_DISABLED +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/IAGBase.h b/Sources/ComputeCxx/include/ComputeCxx/IAGBase.h new file mode 100644 index 00000000..eec69d36 --- /dev/null +++ b/Sources/ComputeCxx/include/ComputeCxx/IAGBase.h @@ -0,0 +1,215 @@ +#pragma once + +#include +#include +#include + +#include + +#ifndef __has_include +#define __has_include(x) 0 +#endif +#ifndef __has_feature +#define __has_feature(x) 0 +#endif +#ifndef __has_attribute +#define __has_attribute(x) 0 +#endif +#ifndef __has_extension +#define __has_extension(x) 0 +#endif + +#define _IAG_STRINGIFY(_x) #_x + +#if !defined(IAG_EXTERN_C_BEGIN) +#if defined(__cplusplus) +#define IAG_EXTERN_C_BEGIN extern "C" { +#define IAG_EXTERN_C_END } +#else +#define IAG_EXTERN_C_BEGIN +#define IAG_EXTERN_C_END +#endif +#endif + +#if __GNUC__ +#define IAG_EXPORT extern __attribute__((__visibility__("default"))) +#else +#define IAG_EXPORT extern +#endif + +#if __GNUC__ +#define IAG_INLINE static __inline__ +#else +#define IAG_INLINE static inline +#endif + +#ifndef IAG_RETURNS_RETAINED +#if __has_feature(attribute_cf_returns_retained) +#define IAG_RETURNS_RETAINED __attribute__((cf_returns_retained)) +#else +#define IAG_RETURNS_RETAINED +#endif +#endif + +#ifndef IAG_IMPLICIT_BRIDGING_ENABLED +#if __has_feature(arc_cf_code_audited) +#define IAG_IMPLICIT_BRIDGING_ENABLED _Pragma("clang arc_cf_code_audited begin") +#else +#define IAG_IMPLICIT_BRIDGING_ENABLED +#endif +#endif + +#ifndef IAG_IMPLICIT_BRIDGING_DISABLED +#if __has_feature(arc_cf_code_audited) +#define IAG_IMPLICIT_BRIDGING_DISABLED _Pragma("clang arc_cf_code_audited end") +#else +#define IAG_IMPLICIT_BRIDGING_DISABLED +#endif +#endif + +#if __has_attribute(objc_bridge) && __has_feature(objc_bridge_id) && __has_feature(objc_bridge_id_on_typedefs) + +#ifdef __OBJC__ +@class NSArray; +@class NSAttributedString; +@class NSString; +@class NSNull; +@class NSCharacterSet; +@class NSData; +@class NSDate; +@class NSTimeZone; +@class NSDictionary; +@class NSError; +@class NSLocale; +@class NSNumber; +@class NSSet; +@class NSURL; +#endif + +#define IAG_BRIDGED_TYPE(T) __attribute__((objc_bridge(T))) +#define IAG_BRIDGED_MUTABLE_TYPE(T) __attribute__((objc_bridge_mutable(T))) +#define IAG_RELATED_TYPE(T,C,I) __attribute__((objc_bridge_related(T,C,I))) +#else +#define IAG_BRIDGED_TYPE(T) +#define IAG_BRIDGED_MUTABLE_TYPE(T) +#define IAG_RELATED_TYPE(T,C,I) +#endif + +#if __has_feature(assume_nonnull) +#define IAG_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin") +#define IAG_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end") +#else +#define IAG_ASSUME_NONNULL_BEGIN +#define IAG_ASSUME_NONNULL_END +#endif + +#if !__has_feature(nullability) +#ifndef _Nullable +#define _Nullable +#endif +#ifndef _Nonnull +#define _Nonnull +#endif +#ifndef _Null_unspecified +#define _Null_unspecified +#endif +#endif + +#if __has_attribute(enum_extensibility) +#define __IAG_ENUM_ATTRIBUTES __attribute__((enum_extensibility(open))) +#define __IAG_CLOSED_ENUM_ATTRIBUTES __attribute__((enum_extensibility(closed))) +#define __IAG_OPTIONS_ATTRIBUTES __attribute__((flag_enum,enum_extensibility(open))) +#else +#define __IAG_ENUM_ATTRIBUTES +#define __IAG_CLOSED_ENUM_ATTRIBUTES +#define __IAG_OPTIONS_ATTRIBUTES +#endif + +#define __IAG_ENUM_FIXED_IS_AVAILABLE (__cplusplus && __cplusplus >= 201103L && (__has_extension(cxx_strong_enums) || __has_feature(objc_fixed_enum))) || (!__cplusplus && (__has_feature(objc_fixed_enum) || __has_extension(cxx_fixed_enum))) + +#if __IAG_ENUM_FIXED_IS_AVAILABLE +#define IAG_ENUM(_type, _name) \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Welaborated-enum-base\"") \ + enum __IAG_ENUM_ATTRIBUTES _name : _type _name; \ + enum _name : _type \ + _Pragma("clang diagnostic pop") +#define IAG_CLOSED_ENUM(_type, _name) \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Welaborated-enum-base\"") \ + enum __IAG_CLOSED_ENUM_ATTRIBUTES _name : _type _name; \ + enum _name : _type \ + _Pragma("clang diagnostic pop") +#if (__cplusplus) +#define IAG_OPTIONS(_type, _name) __attribute__((availability(swift,unavailable))) _type _name; enum __IAG_OPTIONS_ATTRIBUTES : _name +#else +#define IAG_OPTIONS(_type, _name) \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Welaborated-enum-base\"") \ + enum __IAG_OPTIONS_ATTRIBUTES _name : _type _name; \ + enum _name : _type \ + _Pragma("clang diagnostic pop") +#endif +#else +#define IAG_ENUM(_type, _name) _type _name; enum +#define IAG_CLOSED_ENUM(_type, _name) _type _name; enum +#define IAG_OPTIONS(_type, _name) _type _name; enum +#endif + +#if __has_attribute(swift_private) +#define IAG_REFINED_FOR_SWIFT __attribute__((swift_private)) +#else +#define IAG_REFINED_FOR_SWIFT +#endif + +#if __has_attribute(swift_name) +#define IAG_SWIFT_NAME(_name) __attribute__((swift_name(#_name))) +#else +#define IAG_SWIFT_NAME(_name) +#endif + +#if __has_attribute(swift_wrapper) +#define IAG_SWIFT_STRUCT __attribute__((swift_wrapper(struct))) +#else +#define IAG_SWIFT_STRUCT +#endif + +// Define mappings for calling conventions. + +// Annotation for specifying a calling convention of +// a runtime function. It should be used with declarations +// of runtime functions like this: +// void runtime_function_name() IAG_SWIFT_CC(swift) +#define IAG_SWIFT_CC(CC) IAG_SWIFT_CC_##CC + +// IAG_SWIFT_CC(c) is the C calling convention. +#define IAG_SWIFT_CC_c + +// IAG_SWIFT_CC(swift) is the Swift calling convention. +#if __has_attribute(swiftcall) +#define IAG_SWIFT_CC_swift __attribute__((swiftcall)) +#define IAG_SWIFT_CONTEXT __attribute__((swift_context)) +#define IAG_SWIFT_ERROR_RESULT __attribute__((swift_error_result)) +#define IAG_SWIFT_INDIRECT_RESULT __attribute__((swift_indirect_result)) +#else +#define IAG_SWIFT_CC_swift +#define IAG_SWIFT_CONTEXT +#define IAG_SWIFT_ERROR_RESULT +#define IAG_SWIFT_INDIRECT_RESULT +#endif + +#if __has_attribute(swift_attr) +#define IAG_SWIFT_SHARED_REFERENCE(_retain, _release) \ + __attribute__((swift_attr("import_reference"))) \ + __attribute__((swift_attr(_IAG_STRINGIFY(retain:_retain)))) \ + __attribute__((swift_attr(_IAG_STRINGIFY(release:_release)))) +#else +#define IAG_SWIFT_SHARED_REFERENCE(_retain, _release) +#endif + +#if __has_include() +#include +#define IAG_COUNTED_BY(N) __counted_by(N) +#else +#define IAG_COUNTED_BY(N) +#endif diff --git a/Sources/ComputeCxx/include/ComputeCxx/IAGCachedValueOptions.h b/Sources/ComputeCxx/include/ComputeCxx/IAGCachedValueOptions.h new file mode 100644 index 00000000..9974c40b --- /dev/null +++ b/Sources/ComputeCxx/include/ComputeCxx/IAGCachedValueOptions.h @@ -0,0 +1,16 @@ +#pragma once + +#include + +IAG_ASSUME_NONNULL_BEGIN + +IAG_EXTERN_C_BEGIN + +typedef IAG_OPTIONS(uint32_t, IAGCachedValueOptions) { + IAGCachedValueOptionsNone = 0, + IAGCachedValueOptionsUnprefetched = 1, +} IAG_SWIFT_NAME(CachedValueOptions); + +IAG_EXTERN_C_END + +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/IAGChangedValue.h b/Sources/ComputeCxx/include/ComputeCxx/IAGChangedValue.h new file mode 100644 index 00000000..efd245cb --- /dev/null +++ b/Sources/ComputeCxx/include/ComputeCxx/IAGChangedValue.h @@ -0,0 +1,26 @@ +#pragma once + +#include + +IAG_ASSUME_NONNULL_BEGIN + +IAG_EXTERN_C_BEGIN + +typedef IAG_OPTIONS(uint8_t, IAGChangedValueFlags) { + IAGChangedValueFlagsChanged = 1 << 0, + IAGChangedValueFlagsRequiresMainThread = 1 << 1, +}; + +typedef struct IAGChangedValue { + const void *value; + IAGChangedValueFlags flags; +} IAGChangedValue; + +typedef struct IAGWeakChangedValue { + const void *_Nullable value; + IAGChangedValueFlags flags; +} IAGWeakChangedValue; + +IAG_EXTERN_C_END + +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/IAGClosure.h b/Sources/ComputeCxx/include/ComputeCxx/IAGClosure.h new file mode 100644 index 00000000..adf8d041 --- /dev/null +++ b/Sources/ComputeCxx/include/ComputeCxx/IAGClosure.h @@ -0,0 +1,24 @@ +#pragma once + +#include + +IAG_ASSUME_NONNULL_BEGIN + +IAG_EXTERN_C_BEGIN + +typedef struct IAG_SWIFT_NAME(_IAGClosureStorage) IAGClosureStorage { + const void *thunk; + const void *_Nullable context; +} IAGClosureStorage; + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGClosureStorage IAGRetainClosure(const void *thunk, const void *_Nullable context); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGReleaseClosure(IAGClosureStorage closure); + +IAG_EXTERN_C_END + +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/IAGComparison.h b/Sources/ComputeCxx/include/ComputeCxx/IAGComparison.h new file mode 100644 index 00000000..21c2a760 --- /dev/null +++ b/Sources/ComputeCxx/include/ComputeCxx/IAGComparison.h @@ -0,0 +1,70 @@ +#pragma once + +#include +#include + +IAG_ASSUME_NONNULL_BEGIN +IAG_IMPLICIT_BRIDGING_ENABLED + +IAG_EXTERN_C_BEGIN + +typedef struct IAGFieldRange { + size_t offset; + size_t size; +} IAGFieldRange IAG_SWIFT_STRUCT IAG_SWIFT_NAME(FieldRange); + +typedef struct IAGComparisonStateStorage *IAGComparisonState IAG_SWIFT_STRUCT IAG_SWIFT_NAME(ComparisonState); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +const void *IAGComparisonStateGetDestination(IAGComparisonState state); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +const void *IAGComparisonStateGetSource(IAGComparisonState state); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGFieldRange IAGComparisonStateGetFieldRange(IAGComparisonState state); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGTypeID IAGComparisonStateGetFieldType(IAGComparisonState state); + +typedef IAG_ENUM(uint8_t, IAGComparisonMode) { + IAGComparisonModeBitwise = 0, + IAGComparisonModeIndirect = 1, + IAGComparisonModeEquatableUnlessPOD = 2, + IAGComparisonModeEquatableAlways = 3, +} IAG_SWIFT_NAME(ComparisonMode); + +typedef IAG_OPTIONS(uint32_t, IAGComparisonOptions) { + IAGComparisonOptionsComparisonModeBitwise = 0, + IAGComparisonOptionsComparisonModeIndirect = 1, + IAGComparisonOptionsComparisonModeEquatableUnlessPOD = 2, + IAGComparisonOptionsComparisonModeEquatableAlways = 3, + IAGComparisonOptionsComparisonModeMask = 0xff, + + IAGComparisonOptionsCopyOnWrite = 1 << 8, + IAGComparisonOptionsFetchLayoutsSynchronously = 1 << 9, + IAGComparisonOptionsTraceCompareFailed = 1ul << 31, // -1 signed int +} IAG_SWIFT_NAME(ComparisonOptions); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +bool IAGCompareValues(const void *_Nonnull destination, const void *_Nonnull source, IAGTypeID type_id, + IAGComparisonOptions options); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +const unsigned char *_Nullable IAGPrefetchCompareValues(IAGTypeID type_id, IAGComparisonOptions options, + uint32_t priority); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGOverrideComparisonForTypeDescriptor(void *descriptor, IAGComparisonMode mode); + +IAG_EXTERN_C_END + +IAG_IMPLICIT_BRIDGING_DISABLED +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/IAGDescription.h b/Sources/ComputeCxx/include/ComputeCxx/IAGDescription.h new file mode 100644 index 00000000..9a9b00b0 --- /dev/null +++ b/Sources/ComputeCxx/include/ComputeCxx/IAGDescription.h @@ -0,0 +1,37 @@ +#pragma once + +#include + +#if TARGET_OS_MAC +#include +#else +#include +#endif + +#include + +IAG_ASSUME_NONNULL_BEGIN + +IAG_EXTERN_C_BEGIN + +#if TARGET_OS_MAC + +typedef CFStringRef IAGDescriptionOption IAG_SWIFT_STRUCT IAG_SWIFT_NAME(DescriptionOption); + +IAG_EXPORT +const IAGDescriptionOption IAGDescriptionFormat IAG_SWIFT_NAME(IAGDescriptionOption.format); + +IAG_EXPORT +const IAGDescriptionOption IAGDescriptionMaxFrames IAG_SWIFT_NAME(IAGDescriptionOption.maxFrames); + +IAG_EXPORT +const IAGDescriptionOption IAGDescriptionIncludeValues IAG_SWIFT_NAME(IAGDescriptionOption.includeValues); + +IAG_EXPORT +const IAGDescriptionOption IAGDescriptionTruncationLimit IAG_SWIFT_NAME(IAGDescriptionOption.truncationLimit); + +#endif + +IAG_EXTERN_C_END + +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/IAGGraph.h b/Sources/ComputeCxx/include/ComputeCxx/IAGGraph.h new file mode 100644 index 00000000..6879d305 --- /dev/null +++ b/Sources/ComputeCxx/include/ComputeCxx/IAGGraph.h @@ -0,0 +1,382 @@ +#pragma once + +#include + +#if TARGET_OS_MAC +#include +#include +#include +#else +#include +#include +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +IAG_ASSUME_NONNULL_BEGIN +IAG_IMPLICIT_BRIDGING_ENABLED + +IAG_EXTERN_C_BEGIN + +// MARK: CFType + +typedef struct IAG_BRIDGED_TYPE(id) IAGGraphStorage *IAGGraphRef IAG_SWIFT_NAME(Graph); +typedef void *IAGUnownedGraphContextRef IAG_SWIFT_STRUCT; + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +CFTypeID IAGGraphGetTypeID(void) IAG_SWIFT_NAME(getter:IAGGraphRef.typeID()); + +// MARK: Graph Context + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGGraphRef IAGGraphCreate(void) IAG_SWIFT_NAME(IAGGraphRef.init()); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGGraphRef IAGGraphCreateShared(IAGGraphRef _Nullable graph) IAG_SWIFT_NAME(IAGGraphRef.init(shared:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGUnownedGraphContextRef IAGGraphGetGraphContext(IAGGraphRef graph) + IAG_SWIFT_NAME(getter:IAGGraphRef.graphContext(self:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGGraphRef IAGGraphContextGetGraph(void *context); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGGraphInvalidate(IAGGraphRef graph) IAG_SWIFT_NAME(IAGGraphRef.invalidate(self:)); + +// MARK: User context + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +const void *_Nullable IAGGraphGetContext(IAGGraphRef graph) IAG_SWIFT_NAME(getter:IAGGraphRef.context(self:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGGraphSetContext(IAGGraphRef graph, const void *_Nullable context) + IAG_SWIFT_NAME(setter:IAGGraphRef.context(self:_:)); + +// MARK: Counter + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +uint64_t IAGGraphGetCounter(IAGGraphRef graph, IAGGraphCounterQueryType query) + IAG_SWIFT_NAME(IAGGraphRef.counter(self:for:)); + +// MARK: Main handler + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGGraphWithMainThreadHandler(IAGGraphRef graph, + void (*body)(const void *context IAG_SWIFT_CONTEXT) IAG_SWIFT_CC(swift), + const void *body_context, + void (*main_thread_handler)(void (*trampoline_thunk)(const void *), + const void *trampoline, + const void *context IAG_SWIFT_CONTEXT) IAG_SWIFT_CC(swift), + const void *main_thread_handler_context); + +// MARK: Subgraphs + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +bool IAGGraphBeginDeferringSubgraphInvalidation(IAGGraphRef graph) + IAG_SWIFT_NAME(IAGGraphRef.beginDeferringSubgraphInvalidation(self:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGGraphEndDeferringSubgraphInvalidation(IAGGraphRef graph, bool was_deferring) + IAG_SWIFT_NAME(IAGGraphRef.endDeferringSubgraphInvalidation(self:wasDeferring:)); + +// MARK: Attribute types + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +uint32_t IAGGraphInternAttributeType(IAGUnownedGraphContextRef graph, IAGTypeID type, + const IAGAttributeType *_Nonnull (*_Nonnull make_attribute_type)( + const void *_Nullable context IAG_SWIFT_CONTEXT) IAG_SWIFT_CC(swift), + const void *_Nullable make_attribute_type_context); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGGraphVerifyType(IAGAttribute attribute, IAGTypeID type) IAG_SWIFT_NAME(IAGAttribute.verifyType(self:type:)); + +// MARK: Attributes + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGAttribute IAGGraphCreateAttribute(uint32_t type_id, const void *body, const void *_Nullable value) + IAG_SWIFT_NAME(IAGAttribute.init(type:body:value:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGGraphRef IAGGraphGetAttributeGraph(IAGAttribute attribute) IAG_SWIFT_NAME(getter:IAGAttribute.graph(self:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGAttributeInfo IAGGraphGetAttributeInfo(IAGAttribute attribute) IAG_SWIFT_NAME(getter:IAGAttribute.info(self:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGAttributeFlags IAGGraphGetFlags(IAGAttribute attribute) IAG_SWIFT_NAME(getter:IAGAttribute.flags(self:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGGraphSetFlags(IAGAttribute attribute, IAGAttributeFlags flags) IAG_SWIFT_NAME(setter:IAGAttribute.flags(self:_:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +uint32_t IAGGraphAddInput(IAGAttribute attribute, IAGAttribute input, IAGInputOptions options) + IAG_SWIFT_NAME(IAGAttribute.addInput(self:_:options:)); + +// MARK: Offset attributes + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGAttribute IAGGraphCreateOffsetAttribute(IAGAttribute attribute, uint32_t offset); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGAttribute IAGGraphCreateOffsetAttribute2(IAGAttribute attribute, uint32_t offset, size_t size); + +// MARK: Indirect attributes + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGAttribute IAGGraphCreateIndirectAttribute(IAGAttribute attribute) IAG_SWIFT_NAME(IAGAttribute.createIndirect(self:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGAttribute IAGGraphCreateIndirectAttribute2(IAGAttribute attribute, size_t size); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGAttribute IAGGraphGetIndirectAttribute(IAGAttribute attribute) IAG_SWIFT_NAME(getter:IAGAttribute.source(self:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGGraphSetIndirectAttribute(IAGAttribute attribute, IAGAttribute source) + IAG_SWIFT_NAME(setter:IAGAttribute.source(self:_:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGGraphResetIndirectAttribute(IAGAttribute attribute, bool non_nil); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGAttribute IAGGraphGetIndirectDependency(IAGAttribute attribute); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGGraphSetIndirectDependency(IAGAttribute attribute, IAGAttribute dependency); + +// MARK: Search + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +bool IAGGraphSearch(IAGAttribute attribute, IAGSearchOptions options, + bool (*predicate)(IAGAttribute attribute, const void *context IAG_SWIFT_CONTEXT) IAG_SWIFT_CC(swift), + const void *predicate_context); + +// MARK: Body + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGGraphMutateAttribute(IAGAttribute attribute, IAGTypeID type, bool invalidating, + void (*modify)(void *body, const void *context IAG_SWIFT_CONTEXT) IAG_SWIFT_CC(swift), + const void *modify_context); + +// MARK: Value + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGChangedValue IAGGraphGetValue(IAGAttribute attribute, IAGValueOptions options, IAGTypeID type); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGWeakChangedValue IAGGraphGetWeakValue(IAGWeakAttribute attribute, IAGValueOptions options, IAGTypeID type); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGChangedValue IAGGraphGetInputValue(IAGAttribute attribute, IAGAttribute input, IAGValueOptions options, IAGTypeID type); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +bool IAGGraphSetValue(IAGAttribute attribute, const void *value, IAGTypeID type); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +bool IAGGraphHasValue(IAGAttribute attribute) IAG_SWIFT_NAME(getter:IAGAttribute.hasValue(self:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGValueState IAGGraphGetValueState(IAGAttribute attribute) IAG_SWIFT_NAME(getter:IAGAttribute.valueState(self:)); + +typedef IAG_OPTIONS(uint32_t, IAGGraphUpdateOptions) { + IAGGraphUpdateOptionsNone = 0, + IAGGraphUpdateOptionsInTransaction = 1 << 0, + IAGGraphUpdateOptionsAbortIfCancelled = 1 << 1, + IAGGraphUpdateOptionsCancelIfPassedDeadline = 1 << 2, + IAGGraphUpdateOptionsInitializeCleared = 1 << 3, + IAGGraphUpdateOptionsEndDeferringSubgraphInvalidationOnExit = 1 << 4, +}; + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGGraphUpdateValue(IAGAttribute attribute, IAGGraphUpdateOptions options) + IAG_SWIFT_NAME(IAGAttribute.updateValue(self:options:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +uint32_t IAGGraphPrefetchValue(IAGAttribute attribute) IAG_SWIFT_NAME(IAGAttribute.prefetchValue(self:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGGraphInvalidateValue(IAGAttribute attribute) IAG_SWIFT_NAME(IAGAttribute.invalidateValue(self:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGGraphInvalidateAllValues(IAGGraphRef graph) IAG_SWIFT_NAME(IAGGraphRef.invalidateAllValues(self:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGGraphSetInvalidationCallback(IAGGraphRef graph, + void (*callback)(IAGAttribute, const void *context IAG_SWIFT_CONTEXT) + IAG_SWIFT_CC(swift), + const void *callback_context); + +// MARK: Cached value + +CF_EXPORT +CF_REFINED_FOR_SWIFT +void *IAGGraphReadCachedAttribute(size_t hash, IAGTypeID type, const void *body, IAGTypeID value_type, + IAGCachedValueOptions options, IAGAttribute owner, bool *_Nullable changed_out, + uint32_t (*closure)(IAGUnownedGraphContextRef graph_context, + const void *context IAG_SWIFT_CONTEXT) IAG_SWIFT_CC(swift), + const void *closure_context); + +CF_EXPORT +CF_REFINED_FOR_SWIFT +void *_Nullable IAGGraphReadCachedAttributeIfExists(size_t hash, IAGTypeID type, const void *body, IAGTypeID value_type, + IAGCachedValueOptions options, IAGAttribute owner, + bool *_Nullable changed_out); + +// MARK: Update + +typedef IAG_ENUM(uint32_t, IAGGraphUpdateStatus) { + IAGGraphUpdateStatusNoChange = 0, + IAGGraphUpdateStatusChanged = 1, + IAGGraphUpdateStatusAborted = 2, + IAGGraphUpdateStatusNeedsCallMainHandler = 3, +}; + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGGraphSetUpdate(const void *update) IAG_SWIFT_NAME(IAGGraphRef.setUpdate(_:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +const void *IAGGraphClearUpdate(void) IAG_SWIFT_NAME(IAGGraphRef.clearUpdate()); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGGraphCancelUpdate(void) IAG_SWIFT_NAME(IAGGraphRef.cancelUpdate()); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +bool IAGGraphCancelUpdateIfNeeded(void) IAG_SWIFT_NAME(IAGGraphRef.cancelUpdateIfNeeded()); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +bool IAGGraphUpdateWasCancelled(void) IAG_SWIFT_NAME(getter:IAGGraphRef.updateWasCancelled()); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +uint64_t IAGGraphGetDeadline(IAGGraphRef graph) IAG_SWIFT_NAME(getter:IAGGraphRef.deadline(self:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGGraphSetDeadline(IAGGraphRef graph, uint64_t deadline) IAG_SWIFT_NAME(setter:IAGGraphRef.deadline(self:_:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +bool IAGGraphHasDeadlinePassed(void) IAG_SWIFT_NAME(getter:IAGGraphRef.hasDeadlinePassed()); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGGraphSetNeedsUpdate(IAGGraphRef graph) IAG_SWIFT_NAME(IAGGraphRef.setNeedsUpdate(self:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGGraphWithUpdate(IAGAttribute attribute, void (*body)(const void *context IAG_SWIFT_CONTEXT) IAG_SWIFT_CC(swift), + const void *body_context); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGGraphWithoutUpdate(void (*body)(const void *context IAG_SWIFT_CONTEXT) IAG_SWIFT_CC(swift), + const void *body_context); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGGraphSetUpdateCallback(IAGGraphRef graph, + void (*callback)(const void *context IAG_SWIFT_CONTEXT) IAG_SWIFT_CC(swift), + const void *callback_context); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGAttribute IAGGraphGetCurrentAttribute(void); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +bool IAGGraphCurrentAttributeWasModified(void) IAG_SWIFT_NAME(getter:IAGAttribute.currentWasModified()); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +bool IAGGraphAnyInputsChanged(const IAGAttribute *IAG_COUNTED_BY(count) exclude_attributes, size_t count); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void *_Nullable IAGGraphGetOutputValue(IAGTypeID type); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGGraphSetOutputValue(const void *value, IAGTypeID type); + +// MARK: Description + +#if TARGET_OS_MAC +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +CFTypeRef _Nullable IAGGraphDescription(IAGGraphRef _Nullable graph, CFDictionaryRef options) + IAG_SWIFT_NAME(IAGGraphRef.description(_:options:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGGraphArchiveJSON(const char *_Nullable filename) IAG_SWIFT_NAME(IAGGraphRef.archiveJSON(name:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGGraphArchiveJSON2(const char *filename, bool exclude_values) + IAG_SWIFT_NAME(IAGGraphRef.archiveJSON(name:excludeValues:)); +#endif + +IAG_EXTERN_C_END + +IAG_IMPLICIT_BRIDGING_DISABLED +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/IAGGraphCounterQueryType.h b/Sources/ComputeCxx/include/ComputeCxx/IAGGraphCounterQueryType.h new file mode 100644 index 00000000..762bfca5 --- /dev/null +++ b/Sources/ComputeCxx/include/ComputeCxx/IAGGraphCounterQueryType.h @@ -0,0 +1,20 @@ +#pragma once + +#include + +typedef IAG_ENUM(uint32_t, IAGGraphCounterQueryType) { + IAGGraphCounterQueryTypeNodes, + IAGGraphCounterQueryTypeTransactions, + IAGGraphCounterQueryTypeUpdates, + IAGGraphCounterQueryTypeChanges, + IAGGraphCounterQueryTypeContextID, + IAGGraphCounterQueryTypeGraphID, + IAGGraphCounterQueryTypeContextThreadUpdating, + IAGGraphCounterQueryTypeThreadUpdating, + IAGGraphCounterQueryTypeContextNeedsUpdate, + IAGGraphCounterQueryTypeNeedsUpdate, + IAGGraphCounterQueryTypeMainThreadUpdates, + IAGGraphCounterQueryTypeCreatedNodes, + IAGGraphCounterQueryTypeSubgraphs, + IAGGraphCounterQueryTypeCreatedSubgraphs, +} IAG_SWIFT_NAME(IAGGraphRef.CounterQueryType); diff --git a/Sources/ComputeCxx/include/ComputeCxx/IAGGraphTracing.h b/Sources/ComputeCxx/include/ComputeCxx/IAGGraphTracing.h new file mode 100644 index 00000000..b1db4401 --- /dev/null +++ b/Sources/ComputeCxx/include/ComputeCxx/IAGGraphTracing.h @@ -0,0 +1,102 @@ +#pragma once + +#include +#include + +typedef IAG_OPTIONS(uint32_t, IAGGraphTraceOptions) { + IAGGraphTraceOptionsEnabled = 1 << 0, + IAGGraphTraceOptionsFull = 1 << 1, + IAGGraphTraceOptionsBacktrace = 1 << 2, + IAGGraphTraceOptionsPrepare = 1 << 3, + IAGGraphTraceOptionsCustom = 1 << 4, + IAGGraphTraceOptionsAll = 1 << 5, +} IAG_SWIFT_NAME(IAGGraphRef.TraceOptions); + +typedef struct IAGTraceType *IAGTraceTypeRef; + +IAG_ASSUME_NONNULL_BEGIN + +IAG_EXTERN_C_BEGIN + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGGraphStartTracing(IAGGraphRef _Nullable graph, IAGGraphTraceOptions trace_options) + IAG_SWIFT_NAME(IAGGraphRef.startTracing(_:options:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGGraphStartTracing2(IAGGraphRef _Nullable graph, IAGGraphTraceOptions trace_options, + CFArrayRef _Nullable subsystems) + IAG_SWIFT_NAME(IAGGraphRef.startTracing(_:options:subsystems:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGGraphStopTracing(IAGGraphRef _Nullable graph) IAG_SWIFT_NAME(IAGGraphRef.stopTracing(_:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGGraphSyncTracing(IAGGraphRef graph) IAG_SWIFT_NAME(IAGGraphRef.syncTracing(self:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +CFStringRef IAGGraphCopyTracePath(IAGGraphRef graph) IAG_SWIFT_NAME(getter:IAGGraphRef.tracePath(self:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +uint64_t IAGGraphAddTrace(IAGGraphRef graph, const IAGTraceTypeRef trace, void *_Nullable context) + IAG_SWIFT_NAME(IAGGraphRef.addTrace(self:_:context:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGGraphRemoveTrace(IAGGraphRef graph, uint64_t trace_id) IAG_SWIFT_NAME(IAGGraphRef.removeTrace(self:traceID:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGGraphSetTrace(IAGGraphRef graph, const IAGTraceTypeRef trace, void *_Nullable context) + IAG_SWIFT_NAME(IAGGraphRef.setTrace(self:_:context:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGGraphResetTrace(IAGGraphRef graph) IAG_SWIFT_NAME(IAGGraphRef.resetTrace(self:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +bool IAGGraphIsTracingActive(IAGGraphRef graph) IAG_SWIFT_NAME(getter:IAGGraphRef.isTracingActive(self:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGGraphPrepareTrace(IAGGraphRef graph, const IAGTraceTypeRef trace, void *_Nullable context); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +bool IAGGraphTraceEventEnabled(IAGGraphRef graph, uint32_t event_id) + IAG_SWIFT_NAME(IAGGraphRef.traceEventEnabled(self:for:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGGraphAddTraceEvent(IAGGraphRef graph, const char *event_name, const void *value, IAGTypeID type) + IAG_SWIFT_NAME(IAGGraphRef.addTraceEvent(self:name:value:type:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGGraphAddNamedTraceEvent(IAGGraphRef graph, uint32_t event_id, uint32_t event_arg_count, const void *event_args, + CFDataRef data, uint32_t arg6) + IAG_SWIFT_NAME(IAGGraphRef.addNamedTraceEvent(self:eventID:eventArgCount:eventArgs:data:arg6:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +const char *_Nullable IAGGraphGetTraceEventName(uint32_t event_id) IAG_SWIFT_NAME(IAGGraphRef.traceEventName(for:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +const char *_Nullable IAGGraphGetTraceEventSubsystem(uint32_t event_id) + IAG_SWIFT_NAME(IAGGraphRef.traceEventSubsystem(for:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +uint32_t IAGGraphRegisterNamedTraceEvent(const char *event_name, const char *event_subsystem) + IAG_SWIFT_NAME(IAGGraphRef.registerNamedTraceEvent(name:subsystem:)); + +IAG_EXTERN_C_END + +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/IAGInputOptions.h b/Sources/ComputeCxx/include/ComputeCxx/IAGInputOptions.h new file mode 100644 index 00000000..87d893ce --- /dev/null +++ b/Sources/ComputeCxx/include/ComputeCxx/IAGInputOptions.h @@ -0,0 +1,20 @@ +#pragma once + +#include + +IAG_ASSUME_NONNULL_BEGIN + +IAG_EXTERN_C_BEGIN + +typedef IAG_OPTIONS(uint8_t, IAGInputOptions) { + IAGInputOptionsNone = 0, + IAGInputOptionsUnprefetched = 1 << 0, + IAGInputOptionsSyncMainRef = 1 << 1, + IAGInputOptionsAlwaysEnabled = 1 << 2, + IAGInputOptionsChanged = 1 << 3, + IAGInputOptionsEnabled = 1 << 4, +}; + +IAG_EXTERN_C_END + +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/IAGSearchOptions.h b/Sources/ComputeCxx/include/ComputeCxx/IAGSearchOptions.h new file mode 100644 index 00000000..d33bb2ed --- /dev/null +++ b/Sources/ComputeCxx/include/ComputeCxx/IAGSearchOptions.h @@ -0,0 +1,17 @@ +#pragma once + +#include + +IAG_ASSUME_NONNULL_BEGIN + +IAG_EXTERN_C_BEGIN + +typedef IAG_OPTIONS(uint32_t, IAGSearchOptions) { + IAGSearchOptionsSearchInputs = 1 << 0, + IAGSearchOptionsSearchOutputs = 1 << 1, + IAGSearchOptionsTraverseGraphContexts = 1 << 2, +} IAG_SWIFT_NAME(SearchOptions); + +IAG_EXTERN_C_END + +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/IAGSubgraph.h b/Sources/ComputeCxx/include/ComputeCxx/IAGSubgraph.h new file mode 100644 index 00000000..700a47d4 --- /dev/null +++ b/Sources/ComputeCxx/include/ComputeCxx/IAGSubgraph.h @@ -0,0 +1,186 @@ +#pragma once + +#include +#include +#include +#include + +IAG_ASSUME_NONNULL_BEGIN +IAG_IMPLICIT_BRIDGING_ENABLED + +IAG_EXTERN_C_BEGIN + +// MARK: CFType + +typedef struct IAG_BRIDGED_TYPE(id) IAGSubgraphStorage *IAGSubgraphRef IAG_SWIFT_NAME(Subgraph); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +CFTypeID IAGSubgraphGetTypeID(void) IAG_SWIFT_NAME(getter:IAGSubgraphRef.typeID()); + +// MARK: Current subgraph + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGSubgraphRef _Nullable IAGSubgraphGetCurrent(void) IAG_SWIFT_NAME(getter:IAGSubgraphRef.current()); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGSubgraphSetCurrent(IAGSubgraphRef _Nullable subgraph) IAG_SWIFT_NAME(setter:IAGSubgraphRef.current(_:)); + +// MARK: Graph Context + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGSubgraphRef IAGSubgraphCreate(IAGGraphRef graph) IAG_SWIFT_NAME(IAGSubgraphRef.init(graph:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGSubgraphRef IAGSubgraphCreate2(IAGGraphRef graph, IAGAttribute attribute) + IAG_SWIFT_NAME(IAGSubgraphRef.init(graph:attribute:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGUnownedGraphContextRef _Nullable IAGSubgraphGetCurrentGraphContext(void) + IAG_SWIFT_NAME(getter:IAGSubgraphRef.currentGraphContext()); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGGraphRef IAGSubgraphGetGraph(IAGSubgraphRef subgraph) IAG_SWIFT_NAME(getter:IAGSubgraphRef.graph(self:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +bool IAGSubgraphIsValid(IAGSubgraphRef subgraph) IAG_SWIFT_NAME(getter:IAGSubgraphRef.isValid(self:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGSubgraphInvalidate(IAGSubgraphRef subgraph) IAG_SWIFT_NAME(IAGSubgraphRef.invalidate(self:)); + +// MARK: Index + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +uint32_t IAGSubgraphGetIndex(IAGSubgraphRef subgraph) IAG_SWIFT_NAME(getter:IAGSubgraphRef.index(self:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGSubgraphSetIndex(IAGSubgraphRef subgraph, uint32_t index) IAG_SWIFT_NAME(setter:IAGSubgraphRef.index(self:_:)); + +// MARK: Observers + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGUniqueID IAGSubgraphAddObserver(IAGSubgraphRef subgraph, + void (*observer)(const void *_Nullable context IAG_SWIFT_CONTEXT) IAG_SWIFT_CC(swift), + const void *_Nullable observer_context); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGSubgraphRemoveObserver(IAGSubgraphRef subgraph, IAGUniqueID observer_id) + IAG_SWIFT_NAME(IAGSubgraphRef.removeObserver(self:_:)); + +// MARK: Children + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGSubgraphAddChild(IAGSubgraphRef subgraph, IAGSubgraphRef child) IAG_SWIFT_NAME(IAGSubgraphRef.addChild(self:_:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGSubgraphAddChild2(IAGSubgraphRef subgraph, IAGSubgraphRef child, uint8_t tag) + IAG_SWIFT_NAME(IAGSubgraphRef.addChild(self:_:tag:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGSubgraphRemoveChild(IAGSubgraphRef subgraph, IAGSubgraphRef child) + IAG_SWIFT_NAME(IAGSubgraphRef.removeChild(self:_:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGSubgraphRef IAGSubgraphGetChild(IAGSubgraphRef subgraph, uint32_t index, uint8_t *_Nullable tag_out) + IAG_SWIFT_NAME(IAGSubgraphRef.child(self:at:tag:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +uint32_t IAGSubgraphGetChildCount(IAGSubgraphRef subgraph) IAG_SWIFT_NAME(getter:IAGSubgraphRef.childCount(self:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGSubgraphRef IAGSubgraphGetParent(IAGSubgraphRef subgraph, int64_t index) IAG_SWIFT_NAME(IAGSubgraphRef.parent(self:at:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +uint64_t IAGSubgraphGetParentCount(IAGSubgraphRef subgraph) IAG_SWIFT_NAME(getter:IAGSubgraphRef.parentCount(self:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +bool IAGSubgraphIsAncestor(IAGSubgraphRef subgraph, IAGSubgraphRef other) + IAG_SWIFT_NAME(IAGSubgraphRef.isAncestor(self:of:)); + +// MARK: Flags + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +bool IAGSubgraphIntersects(IAGSubgraphRef subgraph, IAGAttributeFlags flags) + IAG_SWIFT_NAME(IAGSubgraphRef.intersects(self:flags:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +bool IAGSubgraphIsDirty(IAGSubgraphRef subgraph, IAGAttributeFlags flags) IAG_SWIFT_NAME(IAGSubgraphRef.isDirty(self:flags:)); + +// MARK: Attributes + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGSubgraphRef IAGGraphGetAttributeSubgraph(IAGAttribute attribute) IAG_SWIFT_NAME(getter:IAGAttribute.subgraph(self:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGSubgraphRef _Nullable IAGGraphGetAttributeSubgraph2(IAGAttribute attribute) + IAG_SWIFT_NAME(getter:IAGAttribute.subgraphOrNil(self:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGSubgraphApply(IAGSubgraphRef subgraph, uint32_t options, + void (*body)(IAGAttribute, const void *context IAG_SWIFT_CONTEXT) IAG_SWIFT_CC(swift), + const void *body_context); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGSubgraphUpdate(IAGSubgraphRef subgraph, IAGAttributeFlags flags) IAG_SWIFT_NAME(IAGSubgraphRef.update(self:flags:)); + +// MARK: Tree + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +_Nullable IAGTreeElement IAGSubgraphGetTreeRoot(IAGSubgraphRef subgraph) IAG_SWIFT_NAME(getter:IAGSubgraphRef.treeRoot(self:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGSubgraphBeginTreeElement(IAGAttribute value, IAGTypeID type, uint32_t flags); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGSubgraphEndTreeElement(IAGAttribute value); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGSubgraphSetTreeOwner(IAGSubgraphRef subgraph, IAGAttribute owner) + IAG_SWIFT_NAME(IAGSubgraphRef.setTreeOwner(self:_:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGSubgraphAddTreeValue(IAGAttribute value, IAGTypeID type, const char *key, uint32_t flags); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +bool IAGSubgraphShouldRecordTree(void) IAG_SWIFT_NAME(getter:IAGSubgraphRef.shouldRecordTree()); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGSubgraphSetShouldRecordTree(void) IAG_SWIFT_NAME(IAGSubgraphRef.setShouldRecordTree()); + +IAG_EXTERN_C_END + +IAG_IMPLICIT_BRIDGING_DISABLED +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/AGTargetConditionals.h b/Sources/ComputeCxx/include/ComputeCxx/IAGTargetConditionals.h similarity index 100% rename from Sources/ComputeCxx/include/ComputeCxx/AGTargetConditionals.h rename to Sources/ComputeCxx/include/ComputeCxx/IAGTargetConditionals.h diff --git a/Sources/ComputeCxx/include/ComputeCxx/IAGTraceType.h b/Sources/ComputeCxx/include/ComputeCxx/IAGTraceType.h new file mode 100644 index 00000000..d4c38a2d --- /dev/null +++ b/Sources/ComputeCxx/include/ComputeCxx/IAGTraceType.h @@ -0,0 +1,82 @@ +#pragma once + +#include +#include +#include + +IAG_ASSUME_NONNULL_BEGIN + +IAG_EXTERN_C_BEGIN + +typedef IAG_ENUM(uint64_t, IAGTraceTypeVersion) { + IAGTraceTypeVersionInitial = 0, + IAGTraceTypeVersionCustom = 1, + IAGTraceTypeVersionNamed = 2, + IAGTraceTypeVersionDeadline = 3, + IAGTraceTypeVersionCompareFailed = 4, +}; + +typedef struct IAGTraceType { + IAGTraceTypeVersion version; + + void (*_Nullable begin_trace)(void *_Nullable context, IAGGraphRef graph); + void (*_Nullable end_trace)(void *_Nullable context, IAGGraphRef graph); + + void (*_Nullable begin_subgraph_update)(void *_Nullable context, IAGSubgraphRef subgraph, uint32_t options); + void (*_Nullable end_subgraph_update)(void *_Nullable context, IAGSubgraphRef subgraph); + void (*_Nullable begin_node_update)(void *_Nullable context, IAGAttribute attribute); + void (*_Nullable end_node_update)(void *_Nullable context, bool changed); + void (*_Nullable begin_value_update)(void *_Nullable context, IAGAttribute attribute); + void (*_Nullable end_value_update)(void *_Nullable context, IAGAttribute attribute, bool changed); + void (*_Nullable begin_graph_update)(void *_Nullable context, IAGGraphRef graph); + void (*_Nullable end_graph_update)(void *_Nullable context, IAGGraphRef graph); + + void (*_Nullable begin_graph_invalidation)(void *_Nullable context, IAGGraphRef graph, IAGAttribute attribute); + void (*_Nullable end_graph_invalidation)(void *_Nullable context, IAGGraphRef graph, IAGAttribute attribute); + + void (*_Nullable begin_modify_node)(void *_Nullable context, IAGAttribute attribute); + void (*_Nullable end_modify_node)(void *_Nullable context, IAGAttribute attribute); + + void (*_Nullable begin_event)(void *_Nullable context, IAGAttribute attribute, const char *event_name); + void (*_Nullable end_event)(void *_Nullable context, IAGAttribute attribute, const char *event_name); + + void (*_Nullable graph_created)(void *_Nullable context, IAGGraphRef graph); + void (*_Nullable graph_destroy)(void *_Nullable context, IAGGraphRef graph); + void (*_Nullable graph_needs_update)(void *_Nullable context, IAGGraphRef graph); + + void (*_Nullable subgraph_created)(void *_Nullable context, IAGSubgraphRef subgraph); + void (*_Nullable subgraph_destroy)(void *_Nullable context, IAGSubgraphRef subgraph); + void (*_Nullable subgraph_add_child)(void *_Nullable context, IAGSubgraphRef subgraph, IAGSubgraphRef child); + void (*_Nullable subgraph_remove_child)(void *_Nullable context, IAGSubgraphRef subgraph, IAGSubgraphRef child); + + void (*_Nullable node_added)(void *_Nullable context, IAGAttribute attribute); + void (*_Nullable node_add_edge)(void *_Nullable context, IAGAttribute attribute, IAGAttribute input, IAGInputOptions input_options); + void (*_Nullable node_remove_edge)(void *_Nullable context, IAGAttribute attribute, uint32_t index); + void (*_Nullable node_set_edge_pending)(void *_Nullable context, IAGAttribute attribute, IAGAttribute input, bool pending); + + void (*_Nullable node_set_dirty)(void *_Nullable context, IAGAttribute attribute, bool dirty); + void (*_Nullable node_set_pending)(void *_Nullable context, IAGAttribute attribute, bool pending); + void (*_Nullable node_set_value)(void *_Nullable context, IAGAttribute attribute); + void (*_Nullable node_mark_value)(void *_Nullable context, IAGAttribute attribute); + + void (*_Nullable indirect_node_added)(void *_Nullable context, IAGAttribute attribute); + void (*_Nullable indirect_node_set_source)(void *_Nullable context, IAGAttribute attribute, IAGAttribute source); + void (*_Nullable indirect_node_set_dependency)(void *_Nullable context, IAGAttribute attribute, IAGAttribute dependency); + + void (*_Nullable profile_mark)(void *_Nullable context, const char *event_name); + + void (*_Nullable custom_event)(void *_Nullable context, IAGGraphRef graph, const char *event_name, const void *value, + IAGTypeID type); + void (*_Nullable named_event)(void *_Nullable context, IAGGraphRef graph, uint32_t eventID, uint32_t eventArgCount, + const void *eventArgs, CFDataRef data, uint32_t arg6); + bool (*_Nullable named_event_enabled)(void *_Nullable context); + + void (*_Nullable set_deadline)(void *_Nullable context); + void (*_Nullable passed_deadline)(void *_Nullable context); + + void (*_Nullable compare_failed)(void *_Nullable context, IAGAttribute attribute, IAGComparisonState comparisonState); +} IAGTraceType; + +IAG_EXTERN_C_END + +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/IAGTreeElement.h b/Sources/ComputeCxx/include/ComputeCxx/IAGTreeElement.h new file mode 100644 index 00000000..e0d1dbfd --- /dev/null +++ b/Sources/ComputeCxx/include/ComputeCxx/IAGTreeElement.h @@ -0,0 +1,81 @@ +#pragma once + +#include +#include +#include +#include + +IAG_ASSUME_NONNULL_BEGIN + +IAG_EXTERN_C_BEGIN + +typedef struct _IAGTreeElement *IAGTreeElement IAG_SWIFT_STRUCT IAG_SWIFT_NAME(TreeElement); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGTypeID IAGTreeElementGetType(IAGTreeElement tree_element) IAG_SWIFT_NAME(getter:IAGTreeElement.type(self:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGAttribute IAGTreeElementGetValue(IAGTreeElement tree_element); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +uint32_t IAGTreeElementGetFlags(IAGTreeElement tree_element) IAG_SWIFT_NAME(getter:IAGTreeElement.flags(self:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGTreeElement _Nullable IAGTreeElementGetParent(IAGTreeElement tree_element) IAG_SWIFT_NAME(getter:IAGTreeElement.parent(self:)); + +// MARK: Iterating values + +typedef struct IAGTreeElementValueIterator { + uintptr_t parent_elt; + uintptr_t next_elt; +} IAG_SWIFT_NAME(Values) IAGTreeElementValueIterator; + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGTreeElementValueIterator IAGTreeElementMakeValueIterator(IAGTreeElement tree_element) + IAG_SWIFT_NAME(getter:IAGTreeElement.values(self:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGTreeValue _Nullable IAGTreeElementGetNextValue(IAGTreeElementValueIterator *iter) IAG_SWIFT_NAME(IAGTreeElementValueIterator.next(self:)); + +// MARK: Iterating nodes + +typedef struct IAGTreeElementNodeIterator { + uintptr_t elt; + unsigned long node_index; +} IAG_SWIFT_NAME(Nodes) IAGTreeElementNodeIterator; + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGTreeElementNodeIterator IAGTreeElementMakeNodeIterator(IAGTreeElement tree_element) + IAG_SWIFT_NAME(getter:IAGTreeElement.nodes(self:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGAttribute IAGTreeElementGetNextNode(IAGTreeElementNodeIterator *iter); + +// MARK: Iterating children + +typedef struct IAGTreeElementChildIterator { + uintptr_t parent_elt; + uintptr_t next_elt; + size_t subgraph_index; +} IAG_SWIFT_NAME(Children) IAGTreeElementChildIterator; + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGTreeElementChildIterator IAGTreeElementMakeChildIterator(IAGTreeElement tree_element) + IAG_SWIFT_NAME(getter:IAGTreeElement.children(self:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGTreeElement _Nullable IAGTreeElementGetNextChild(IAGTreeElementChildIterator *iter) IAG_SWIFT_NAME(IAGTreeElementChildIterator.next(self:)); + +IAG_EXTERN_C_END + +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/IAGTreeValue.h b/Sources/ComputeCxx/include/ComputeCxx/IAGTreeValue.h new file mode 100644 index 00000000..9f634496 --- /dev/null +++ b/Sources/ComputeCxx/include/ComputeCxx/IAGTreeValue.h @@ -0,0 +1,31 @@ +#pragma once + +#include +#include +#include + +IAG_ASSUME_NONNULL_BEGIN + +IAG_EXTERN_C_BEGIN + +typedef struct _IAGTreeValue *IAGTreeValue IAG_SWIFT_STRUCT IAG_SWIFT_NAME(TreeValue); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGTypeID IAGTreeValueGetType(IAGTreeValue tree_value) IAG_SWIFT_NAME(getter:IAGTreeValue.type(self:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGAttribute IAGTreeValueGetValue(IAGTreeValue tree_value) IAG_SWIFT_NAME(getter:IAGTreeValue.value(self:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +const char *IAGTreeValueGetKey(IAGTreeValue tree_value) IAG_SWIFT_NAME(getter:IAGTreeValue.key(self:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +uint32_t IAGTreeValueGetFlags(IAGTreeValue tree_value) IAG_SWIFT_NAME(getter:IAGTreeValue.flags(self:)); + +IAG_EXTERN_C_END + +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/IAGTuple.h b/Sources/ComputeCxx/include/ComputeCxx/IAGTuple.h new file mode 100644 index 00000000..21966220 --- /dev/null +++ b/Sources/ComputeCxx/include/ComputeCxx/IAGTuple.h @@ -0,0 +1,89 @@ +#pragma once + +#include +#include + +IAG_ASSUME_NONNULL_BEGIN +IAG_IMPLICIT_BRIDGING_ENABLED + +IAG_EXTERN_C_BEGIN + +typedef IAG_ENUM(uint32_t, IAGTupleCopyOptions) { + IAGTupleCopyOptionsAssignCopy = 0, + IAGTupleCopyOptionsInitCopy = 1, + IAGTupleCopyOptionsAssignTake = 2, + IAGTupleCopyOptionsInitTake = 3, +} IAG_SWIFT_NAME(TupleType.CopyOptions); + +typedef const struct IAGSwiftMetadata *IAGTupleType IAG_SWIFT_STRUCT IAG_SWIFT_NAME(TupleType); + +typedef struct IAGUnsafeTuple { + IAGTupleType type; + const void *value; +} IAG_SWIFT_NAME(UnsafeTuple) IAGUnsafeTuple; + +typedef struct IAGUnsafeMutableTuple { + IAGTupleType type; + void *value; +} IAG_SWIFT_NAME(UnsafeMutableTuple) IAGUnsafeMutableTuple; + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGTupleType IAGNewTupleType(size_t count, const IAGTypeID _Nonnull *_Nonnull elements) + IAG_SWIFT_NAME(TupleType.init(count:elements:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +size_t IAGTupleCount(IAGTupleType tuple_type) IAG_SWIFT_NAME(getter:IAGTupleType.count(self:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +size_t IAGTupleSize(IAGTupleType tuple_type) IAG_SWIFT_NAME(getter:IAGTupleType.size(self:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGTypeID IAGTupleElementType(IAGTupleType tuple_type, size_t index) IAG_SWIFT_NAME(TupleType.elementType(self:at:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +size_t IAGTupleElementSize(IAGTupleType tuple_type, size_t index) IAG_SWIFT_NAME(TupleType.elementSize(self:at:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +size_t IAGTupleElementOffset(IAGTupleType tuple_type, size_t index) IAG_SWIFT_NAME(TupleType.elementOffset(self:at:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +size_t IAGTupleElementOffsetChecked(IAGTupleType tuple_type, size_t index, IAGTypeID element_type) + IAG_SWIFT_NAME(TupleType.elementOffset(self:at:type:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void *IAGTupleGetElement(IAGTupleType tuple_type, void *tuple_value, size_t index, void *element_value, + IAGTypeID element_type, IAGTupleCopyOptions options); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void *IAGTupleSetElement(IAGTupleType tuple_type, void *tuple_value, size_t index, const void *element_value, + IAGTypeID element_type, IAGTupleCopyOptions options); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGTupleDestroy(IAGTupleType tuple_type, void *tuple_value) IAG_SWIFT_NAME(TupleType.destroy(self:_:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGTupleDestroyElement(IAGTupleType tuple_type, void *tuple_value, size_t index) + IAG_SWIFT_NAME(TupleType.destroy(self:_:at:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGTupleWithBuffer(IAGTupleType tuple_type, size_t count, + void (*function)(const IAGUnsafeMutableTuple mutable_tuple, void *context IAG_SWIFT_CONTEXT) + IAG_SWIFT_CC(swift), + void *context); + +IAG_EXTERN_C_END + +IAG_IMPLICIT_BRIDGING_DISABLED +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/IAGType.h b/Sources/ComputeCxx/include/ComputeCxx/IAGType.h new file mode 100644 index 00000000..182a3241 --- /dev/null +++ b/Sources/ComputeCxx/include/ComputeCxx/IAGType.h @@ -0,0 +1,129 @@ +#pragma once + +#include + +#if TARGET_OS_MAC +#include +#else +#include +#endif + +IAG_ASSUME_NONNULL_BEGIN +IAG_IMPLICIT_BRIDGING_ENABLED + +IAG_EXTERN_C_BEGIN + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wextern-c-compat" +typedef struct IAG_SWIFT_NAME(_Metadata) IAGSwiftMetadata { +} IAGSwiftMetadata; +#pragma GCC diagnostic pop + +typedef const IAGSwiftMetadata *IAGTypeID IAG_SWIFT_STRUCT IAG_SWIFT_NAME(Metadata); + +typedef struct IAGTypeSignature { + uint8_t bytes[20]; +} IAG_SWIFT_NAME(Signature) IAGTypeSignature; + +typedef IAG_CLOSED_ENUM(uint32_t, IAGTypeKind) { + IAGTypeKindNone, + IAGTypeKindClass, + IAGTypeKindStruct, + IAGTypeKindEnum, + IAGTypeKindOptional, + IAGTypeKindTuple, + IAGTypeKindFunction, + IAGTypeKindExistential, + IAGTypeKindMetatype, +} IAG_SWIFT_NAME(Metadata.Kind); + +#if TARGET_OS_MAC +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +CFStringRef IAGTypeDescription(IAGTypeID typeID); +#else +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +CFStringRef IAGTypeCopyDescription(IAGTypeID typeID); +#endif + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGTypeKind IAGTypeGetKind(IAGTypeID typeID) IAG_SWIFT_NAME(getter:Metadata.kind(self:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +const IAGTypeSignature IAGTypeGetSignature(IAGTypeID typeID) IAG_SWIFT_NAME(getter:Metadata.signature(self:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +const void *_Nullable IAGTypeGetDescriptor(IAGTypeID typeID) IAG_SWIFT_NAME(getter:Metadata.descriptor(self:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +const void *_Nullable IAGTypeNominalDescriptor(IAGTypeID typeID) IAG_SWIFT_NAME(getter:Metadata.nominalDescriptor(self:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +const char *_Nullable IAGTypeNominalDescriptorName(IAGTypeID typeID) + IAG_SWIFT_NAME(getter:Metadata.nominalDescriptorName(self:)); + +typedef IAG_OPTIONS(uint32_t, IAGTypeApplyOptions) { + IAGTypeApplyOptionsEnumerateStructFields = 0, + IAGTypeApplyOptionsEnumerateClassFields = 1 << 0, + IAGTypeApplyOptionsContinueAfterUnknownField = 1 << 1, + IAGTypeApplyOptionsEnumerateEnumCases = 1 << 2, +} IAG_SWIFT_NAME(Metadata.ApplyOptions); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGTypeApplyFields(IAGTypeID typeID, + void (*apply)(const char *field_name, + size_t field_offset, + IAGTypeID field_type, + const void *_Nullable context IAG_SWIFT_CONTEXT) IAG_SWIFT_CC(swift), + const void *apply_context); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +bool IAGTypeApplyFields2(IAGTypeID typeID, IAGTypeApplyOptions options, + bool (*_Nonnull apply)(const char *field_name, + size_t field_offset, + IAGTypeID field_type, + const void *context IAG_SWIFT_CONTEXT) IAG_SWIFT_CC(swift), + const void *apply_context); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +bool IAGTypeApplyEnumData(IAGTypeID typeID, void *value, + void (*body)(uint32_t tag, + IAGTypeID field_type, + const void *field_value, + void *context IAG_SWIFT_CONTEXT) IAG_SWIFT_CC(swift), + void *context); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +bool IAGTypeApplyMutableEnumData(IAGTypeID typeID, void *value, + void (*body)(uint32_t tag, + IAGTypeID field_type, + void *field_value, + void *context IAG_SWIFT_CONTEXT) IAG_SWIFT_CC(swift), + void *context); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +uint64_t IAGTypeGetEnumTag(IAGTypeID typeID, const void *value) IAG_SWIFT_NAME(IAGTypeID.enumTag(self:_:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGTypeProjectEnumData(IAGTypeID typeID, void *value) IAG_SWIFT_NAME(IAGTypeID.projectEnumData(self:_:)); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +void IAGTypeInjectEnumTag(IAGTypeID typeID, uint32_t tag, void *value) IAG_SWIFT_NAME(IAGTypeID.injectEnumTag(self:tag:_:)); + +IAG_EXTERN_C_END + +IAG_IMPLICIT_BRIDGING_DISABLED +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/IAGUniqueID.h b/Sources/ComputeCxx/include/ComputeCxx/IAGUniqueID.h new file mode 100644 index 00000000..6e62a2f5 --- /dev/null +++ b/Sources/ComputeCxx/include/ComputeCxx/IAGUniqueID.h @@ -0,0 +1,15 @@ +#pragma once + +#include + +IAG_ASSUME_NONNULL_BEGIN + +IAG_EXTERN_C_BEGIN + +typedef long IAGUniqueID; + +IAGUniqueID IAGMakeUniqueID(void) IAG_SWIFT_NAME(makeUniqueID()); + +IAG_EXTERN_C_END + +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/IAGValue.h b/Sources/ComputeCxx/include/ComputeCxx/IAGValue.h new file mode 100644 index 00000000..bc3fbb2a --- /dev/null +++ b/Sources/ComputeCxx/include/ComputeCxx/IAGValue.h @@ -0,0 +1,32 @@ +#pragma once + +#include + +IAG_ASSUME_NONNULL_BEGIN + +IAG_EXTERN_C_BEGIN + +typedef IAG_OPTIONS(uint32_t, IAGValueOptions) { + IAGValueOptionsNone = 0, + IAGValueOptionsInputOptionsUnprefetched = 1 << 0, + IAGValueOptionsInputOptionsSyncMainRef = 1 << 1, + IAGValueOptionsInputOptionsMask = 3, + + IAGValueOptionsIncrementGraphVersion = 1 << 2, // AsTopLevelOutput +}; + +typedef IAG_OPTIONS(uint8_t, IAGValueState) { + IAGValueStateNone = 0, + IAGValueStateDirty = 1 << 0, + IAGValueStatePending = 1 << 1, + IAGValueStateUpdating = 1 << 2, + IAGValueStateValueExists = 1 << 3, + IAGValueStateMainThread = 1 << 4, + IAGValueStateMainRef = 1 << 5, + IAGValueStateRequiresMainThread = 1 << 6, + IAGValueStateSelfModified = 1 << 7, +}; + +IAG_EXTERN_C_END + +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/include/ComputeCxx/IAGWeakAttribute.h b/Sources/ComputeCxx/include/ComputeCxx/IAGWeakAttribute.h new file mode 100644 index 00000000..b9f2f1f3 --- /dev/null +++ b/Sources/ComputeCxx/include/ComputeCxx/IAGWeakAttribute.h @@ -0,0 +1,27 @@ +#pragma once + +#include +#include + +IAG_ASSUME_NONNULL_BEGIN + +IAG_EXTERN_C_BEGIN + +typedef struct IAGWeakAttribute { + struct { + IAGAttribute identifier; + uint32_t seed; + } _details; +} IAG_SWIFT_NAME(AnyWeakAttribute) IAGWeakAttribute; + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGWeakAttribute IAGCreateWeakAttribute(IAGAttribute attribute); + +IAG_EXPORT +IAG_REFINED_FOR_SWIFT +IAGAttribute IAGWeakAttributeGetAttribute(IAGWeakAttribute attribute); + +IAG_EXTERN_C_END + +IAG_ASSUME_NONNULL_END diff --git a/Sources/ComputeCxx/internalInclude/CoreFoundationPrivate/CFRuntime.h b/Sources/ComputeCxx/internalInclude/CoreFoundationPrivate/CFRuntime.h index adace9ee..ff265e8f 100644 --- a/Sources/ComputeCxx/internalInclude/CoreFoundationPrivate/CFRuntime.h +++ b/Sources/ComputeCxx/internalInclude/CoreFoundationPrivate/CFRuntime.h @@ -1,4 +1,4 @@ -#include "ComputeCxx/AGTargetConditionals.h" +#include "ComputeCxx/IAGTargetConditionals.h" #if TARGET_OS_MAC diff --git a/Sources/ComputeCxxSwiftSupport/ComputeCxxSwiftSupport.swift b/Sources/ComputeCxxSwiftSupport/ComputeCxxSwiftSupport.swift index 71153738..96d93f00 100644 --- a/Sources/ComputeCxxSwiftSupport/ComputeCxxSwiftSupport.swift +++ b/Sources/ComputeCxxSwiftSupport/ComputeCxxSwiftSupport.swift @@ -1,6 +1,6 @@ import Foundation -@_silgen_name("AGDispatchEquatable") +@_silgen_name("IAGDispatchEquatable") public func Equatable_isEqual_indirect( _ lhs: UnsafePointer, _ rhs: UnsafePointer @@ -8,7 +8,7 @@ public func Equatable_isEqual_indirect( return lhs.pointee == rhs.pointee } -@_silgen_name("AGSetTypeForKey") +@_silgen_name("IAGSetTypeForKey") public func setTypeForKey( _ dict: NSMutableDictionary, _ key: NSString, diff --git a/Tests/ComputeLayoutDescriptorTests/Shared/CompareValuesTests.swift b/Tests/ComputeLayoutDescriptorTests/Shared/CompareValuesTests.swift index 6248eaea..932a6ab8 100644 --- a/Tests/ComputeLayoutDescriptorTests/Shared/CompareValuesTests.swift +++ b/Tests/ComputeLayoutDescriptorTests/Shared/CompareValuesTests.swift @@ -60,7 +60,7 @@ struct CompareValuesTests { @Test func compareInlineEnumValues() async { await #expect(processExitsWith: .success) { - setenv("AG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) #expect( compareValues( @@ -135,7 +135,7 @@ struct CompareValuesTests { @Test func compareRecursiveEnumValues() async { await #expect(processExitsWith: .success) { - setenv("AG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) #expect( compareValues( @@ -210,7 +210,7 @@ struct CompareValuesTests { @Test func compareRecursiveEnumNonEquatableValues() async { await #expect(processExitsWith: .success) { - setenv("AG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) #expect( compareValues( diff --git a/Tests/ComputeLayoutDescriptorTests/Shared/PrefetchCompareValuesTests.swift b/Tests/ComputeLayoutDescriptorTests/Shared/PrefetchCompareValuesTests.swift index 64ebc1b1..098dc1f8 100644 --- a/Tests/ComputeLayoutDescriptorTests/Shared/PrefetchCompareValuesTests.swift +++ b/Tests/ComputeLayoutDescriptorTests/Shared/PrefetchCompareValuesTests.swift @@ -36,7 +36,7 @@ func prefetchCompareValues( { guard - let layout = __AGPrefetchCompareValues( + let layout = __IAGPrefetchCompareValues( Metadata(type), options, UInt32(priority) @@ -61,8 +61,8 @@ struct PrefetchCompareValuesTests { @Test func layoutForNever() async { - setenv("AG_ASYNC_LAYOUTS", "0", 1) - setenv("AG_PRINT_LAYOUTS", "1", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_PRINT_LAYOUTS", "1", 1) let layout0 = prefetchCompareValues( of: Never.self, @@ -109,7 +109,7 @@ struct PrefetchCompareValuesTests { @Test func layoutForVoid() async { await #expect(processExitsWith: .success) { - setenv("AG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) for options in allOptions { let layout = prefetchCompareValues(of: Void.self, options: options, priority: 0) @@ -121,8 +121,8 @@ struct PrefetchCompareValuesTests { @Test func layoutForBool() async { await #expect(processExitsWith: .success) { - setenv("AG_ASYNC_LAYOUTS", "0", 1) - setenv("AG_PRINT_LAYOUTS", "1", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_PRINT_LAYOUTS", "1", 1) let layout0 = prefetchCompareValues( of: Bool.self, @@ -168,8 +168,8 @@ struct PrefetchCompareValuesTests { @Test func layoutForNumericNonEquatable() async { await #expect(processExitsWith: .success) { - setenv("AG_ASYNC_LAYOUTS", "0", 1) - setenv("AG_PRINT_LAYOUTS", "1", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_PRINT_LAYOUTS", "1", 1) let types: [Any.Type] = [Int.self, Double.self, Float.self] for type in types { @@ -199,8 +199,8 @@ struct PrefetchCompareValuesTests { @Test func layoutForIntEquatable() async { - setenv("AG_ASYNC_LAYOUTS", "0", 1) - setenv("AG_PRINT_LAYOUTS", "1", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_PRINT_LAYOUTS", "1", 1) await #expect(processExitsWith: .success) { var output = "" @@ -221,8 +221,8 @@ struct PrefetchCompareValuesTests { @Test func layoutForDoubleEquatable() async { - setenv("AG_ASYNC_LAYOUTS", "0", 1) - setenv("AG_PRINT_LAYOUTS", "1", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_PRINT_LAYOUTS", "1", 1) await #expect(processExitsWith: .success) { var output = "" @@ -247,8 +247,8 @@ struct PrefetchCompareValuesTests { @Test func layoutForFloatEquatable() async { - setenv("AG_ASYNC_LAYOUTS", "0", 1) - setenv("AG_PRINT_LAYOUTS", "1", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_PRINT_LAYOUTS", "1", 1) await #expect(processExitsWith: .success) { var output = "" @@ -274,8 +274,8 @@ struct PrefetchCompareValuesTests { @Test func layoutForString() async { await #expect(processExitsWith: .success) { - setenv("AG_ASYNC_LAYOUTS", "0", 1) - setenv("AG_PRINT_LAYOUTS", "1", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_PRINT_LAYOUTS", "1", 1) let layout0 = prefetchCompareValues( of: String.self, @@ -332,7 +332,7 @@ struct PrefetchCompareValuesTests { @Test func layoutForStaticString() async { await #expect(processExitsWith: .success) { - setenv("AG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) for options in allOptions { let layout = prefetchCompareValues(of: StaticString.self, options: options, priority: 0) @@ -357,7 +357,7 @@ struct PrefetchCompareValuesTests { @Test("Layout for struct enclosing single element equals the layout of the enclosed element") func layoutForStructEnclosingSingleElement() async { await #expect(processExitsWith: .success) { - setenv("AG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) struct StructEnclosingSingleElement { var property: Int @@ -405,8 +405,8 @@ struct PrefetchCompareValuesTests { @Test func layoutForTrivialStruct() async { await #expect(processExitsWith: .success) { - setenv("AG_ASYNC_LAYOUTS", "0", 1) - setenv("AG_PRINT_LAYOUTS", "1", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_PRINT_LAYOUTS", "1", 1) struct TrivialStruct { var first: Int @@ -463,8 +463,8 @@ struct PrefetchCompareValuesTests { @Test func layoutForStructWithAlignedElement() async { - setenv("AG_ASYNC_LAYOUTS", "0", 1) - setenv("AG_PRINT_LAYOUTS", "1", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_PRINT_LAYOUTS", "1", 1) struct StructWithAlignedElement { var int8: Int8 @@ -573,8 +573,8 @@ struct PrefetchCompareValuesTests { @Test func layoutForStructWithComplexProperty() async { - setenv("AG_ASYNC_LAYOUTS", "0", 1) - setenv("AG_PRINT_LAYOUTS", "1", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_PRINT_LAYOUTS", "1", 1) typealias ComplexType = Int64??? struct StructWithComplexProperty { @@ -707,7 +707,7 @@ struct PrefetchCompareValuesTests { @Test(arguments: allOptions) func layoutForEmptyClass(with options: ComparisonOptions) { - setenv("AG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) class EmptyClass {} @@ -717,7 +717,7 @@ struct PrefetchCompareValuesTests { @Test(arguments: allOptions) func layoutForTrivialClass(with options: ComparisonOptions) { - setenv("AG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) class TrivialClass { var property: Int = 0 @@ -730,7 +730,7 @@ struct PrefetchCompareValuesTests { @Test func layoutForStructWithWeakVar() async { await #expect(processExitsWith: .success) { - setenv("AG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) class EmptyClass {} struct StructWithWeakVar { @@ -751,7 +751,7 @@ struct PrefetchCompareValuesTests { @Test(arguments: allOptions) func layoutForEmptyEnum(with options: ComparisonOptions) { - setenv("AG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) enum EmptyEnum {} @@ -761,8 +761,8 @@ struct PrefetchCompareValuesTests { @Test func layoutForBasicEnum() async { - setenv("AG_ASYNC_LAYOUTS", "0", 1) - setenv("AG_PRINT_LAYOUTS", "1", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_PRINT_LAYOUTS", "1", 1) enum BasicEnum { case first @@ -813,8 +813,8 @@ struct PrefetchCompareValuesTests { @Test func layoutForIntEnum() async { - setenv("AG_ASYNC_LAYOUTS", "0", 1) - setenv("AG_PRINT_LAYOUTS", "1", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_PRINT_LAYOUTS", "1", 1) enum IntEnum: Int { case first = 1 @@ -865,8 +865,8 @@ struct PrefetchCompareValuesTests { @Test func layoutForTaggedUnionEnum() async { - setenv("AG_ASYNC_LAYOUTS", "0", 1) - setenv("AG_PRINT_LAYOUTS", "1", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_PRINT_LAYOUTS", "1", 1) enum TaggedUnionEnum { case first @@ -990,8 +990,8 @@ struct PrefetchCompareValuesTests { @Test func layoutForIndirectEnum() async { - setenv("AG_ASYNC_LAYOUTS", "0", 1) - setenv("AG_PRINT_LAYOUTS", "1", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_PRINT_LAYOUTS", "1", 1) indirect enum IndirectEnum { case string(String) @@ -1097,8 +1097,8 @@ struct PrefetchCompareValuesTests { @Test func layoutForIndirectEnumCase() async { - setenv("AG_ASYNC_LAYOUTS", "0", 1) - setenv("AG_PRINT_LAYOUTS", "1", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_PRINT_LAYOUTS", "1", 1) protocol NodeProtocol { @@ -1210,8 +1210,8 @@ struct PrefetchCompareValuesTests { @Test func layoutForTuple() async { await #expect(processExitsWith: .success) { - setenv("AG_ASYNC_LAYOUTS", "0", 1) - setenv("AG_PRINT_LAYOUTS", "1", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_PRINT_LAYOUTS", "1", 1) let layout0 = prefetchCompareValues( of: (Int, String).self, @@ -1286,8 +1286,8 @@ struct PrefetchCompareValuesTests { @Test func layoutForTupleWithAlignedElement() async { - setenv("AG_ASYNC_LAYOUTS", "0", 1) - setenv("AG_PRINT_LAYOUTS", "1", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_PRINT_LAYOUTS", "1", 1) await #expect(processExitsWith: .success) { var output0 = "" @@ -1397,8 +1397,8 @@ struct PrefetchCompareValuesTests { @Test func layoutForArray() async { await #expect(processExitsWith: .success) { - setenv("AG_ASYNC_LAYOUTS", "0", 1) - setenv("AG_PRINT_LAYOUTS", "1", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_PRINT_LAYOUTS", "1", 1) let layout0 = prefetchCompareValues( of: Array.self, @@ -1455,7 +1455,7 @@ struct PrefetchCompareValuesTests { @Test func layoutForArrayOfNotEquatable() async { await #expect(processExitsWith: .success) { - setenv("AG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) class NotEquatable {} @@ -1469,8 +1469,8 @@ struct PrefetchCompareValuesTests { @Test func layoutForDictionary() async { await #expect(processExitsWith: .success) { - setenv("AG_ASYNC_LAYOUTS", "0", 1) - setenv("AG_PRINT_LAYOUTS", "1", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_PRINT_LAYOUTS", "1", 1) let layout0 = prefetchCompareValues( of: Dictionary.self, @@ -1527,7 +1527,7 @@ struct PrefetchCompareValuesTests { @Test func layoutForDictionaryOfNotEquatable() async { await #expect(processExitsWith: .success) { - setenv("AG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) class NotEquatable {} @@ -1545,8 +1545,8 @@ struct PrefetchCompareValuesTests { @Test func layoutForSet() async { await #expect(processExitsWith: .success) { - setenv("AG_ASYNC_LAYOUTS", "0", 1) - setenv("AG_PRINT_LAYOUTS", "1", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_PRINT_LAYOUTS", "1", 1) let layout0 = prefetchCompareValues( of: Set.self, @@ -1608,8 +1608,8 @@ struct PrefetchCompareValuesTests { @Test func layoutForEquatableStruct() async { await #expect(processExitsWith: .success) { - setenv("AG_ASYNC_LAYOUTS", "0", 1) - setenv("AG_PRINT_LAYOUTS", "1", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_PRINT_LAYOUTS", "1", 1) struct EquatableStruct: Equatable { var property: Int = 0 @@ -1661,8 +1661,8 @@ struct PrefetchCompareValuesTests { @Test func layoutForEquatableClass() async { - setenv("AG_ASYNC_LAYOUTS", "0", 1) - setenv("AG_PRINT_LAYOUTS", "1", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_PRINT_LAYOUTS", "1", 1) class EquatableClass: Equatable { var property: Int = 0 @@ -1733,8 +1733,8 @@ struct PrefetchCompareValuesTests { @Test func layoutForAny() async { - setenv("AG_ASYNC_LAYOUTS", "0", 1) - setenv("AG_PRINT_LAYOUTS", "1", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_PRINT_LAYOUTS", "1", 1) let layout0 = prefetchCompareValues(of: Any.self, options: ComparisonOptions(mode: .bitwise), priority: 0) #expect(layout0 == nil) @@ -1794,8 +1794,8 @@ struct PrefetchCompareValuesTests { @Test func layoutForAnyError() async { - setenv("AG_ASYNC_LAYOUTS", "0", 1) - setenv("AG_PRINT_LAYOUTS", "1", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_PRINT_LAYOUTS", "1", 1) let layout0 = prefetchCompareValues( of: (any Error).self, @@ -1872,8 +1872,8 @@ struct PrefetchCompareValuesTests { @Test func layoutForFunction() async { - setenv("AG_ASYNC_LAYOUTS", "0", 1) - setenv("AG_PRINT_LAYOUTS", "1", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_PRINT_LAYOUTS", "1", 1) typealias Function = () -> Void diff --git a/Tests/ComputeTests/Shared/Attribute/AttributeTests.swift b/Tests/ComputeTests/Shared/Attribute/AttributeTests.swift index 84117893..ee0dcc07 100644 --- a/Tests/ComputeTests/Shared/Attribute/AttributeTests.swift +++ b/Tests/ComputeTests/Shared/Attribute/AttributeTests.swift @@ -17,8 +17,8 @@ struct AttributeTests { @Test func initWithValue() async throws { try await #require(processExitsWith: .success) { - setenv("AG_PREFETCH_LAYOUTS", "1", 1) - setenv("AG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_PREFETCH_LAYOUTS", "1", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) let graph = Graph() let subgraph = Subgraph(graph: graph) @@ -27,7 +27,7 @@ struct AttributeTests { let attribute = Attribute(value: 1) #expect(attribute.value == 1) - let expectedlayout = __AGPrefetchCompareValues( + let expectedlayout = __IAGPrefetchCompareValues( Metadata(Int.self), [.comparisonModeEquatableAlways, .fetchLayoutsSynchronously], 0 @@ -64,8 +64,8 @@ struct AttributeTests { @Test func initWithType() async throws { try await #require(processExitsWith: .success) { - setenv("AG_PREFETCH_LAYOUTS", "1", 1) - setenv("AG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_PREFETCH_LAYOUTS", "1", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) let graph = Graph() let subgraph = Subgraph(graph: graph) @@ -73,7 +73,7 @@ struct AttributeTests { let attribute = Attribute(type: Int.self) - let expectedlayout = __AGPrefetchCompareValues( + let expectedlayout = __IAGPrefetchCompareValues( Metadata(Int.self), [.comparisonModeEquatableAlways, .fetchLayoutsSynchronously], 0 @@ -110,8 +110,8 @@ struct AttributeTests { @Test func initWithBody() async throws { try await #require(processExitsWith: .success) { - setenv("AG_PREFETCH_LAYOUTS", "1", 1) - setenv("AG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_PREFETCH_LAYOUTS", "1", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) let graph = Graph() let subgraph = Subgraph(graph: graph) @@ -132,7 +132,7 @@ struct AttributeTests { } #expect(attribute.value == "test value") - let expectedlayout = __AGPrefetchCompareValues( + let expectedlayout = __IAGPrefetchCompareValues( Metadata(String.self), [.comparisonModeEquatableUnlessPOD, .fetchLayoutsSynchronously], 0 diff --git a/Tests/ComputeTests/Shared/Graph/GraphTests.swift b/Tests/ComputeTests/Shared/Graph/GraphTests.swift index 13d4ae12..11c07ad2 100644 --- a/Tests/ComputeTests/Shared/Graph/GraphTests.swift +++ b/Tests/ComputeTests/Shared/Graph/GraphTests.swift @@ -11,7 +11,7 @@ struct GraphTests { @Test func typeID() { let description = CFCopyTypeIDDescription(Graph.typeID) as String? - #expect(description == "AGGraphStorage") + #expect(description == "IAGGraphStorage") } @Test @@ -81,7 +81,7 @@ struct GraphTests { let graph = Graph() // First type index is not 0 - let intTypeIndex = __AGGraphInternAttributeType( + let intTypeIndex = __IAGGraphInternAttributeType( graph.graphContext, Metadata(External.self), { _ in @@ -98,7 +98,7 @@ struct GraphTests { #expect(intTypeIndex == 1) // A new type is assigned a new index - let stringTypeIndex = __AGGraphInternAttributeType( + let stringTypeIndex = __IAGGraphInternAttributeType( graph.graphContext, Metadata(External.self), { _ in @@ -115,7 +115,7 @@ struct GraphTests { #expect(stringTypeIndex == 2) // Interning the same type reuses the same index - let cachedIntTypeIndex = __AGGraphInternAttributeType( + let cachedIntTypeIndex = __IAGGraphInternAttributeType( graph.graphContext, Metadata(External.self), { _ in @@ -137,12 +137,12 @@ struct GraphTests { @Test func internAttributeTypeInitializesSelfOffsetAndLayout() async throws { try await #require(processExitsWith: .success) { - setenv("AG_PREFETCH_LAYOUTS", "1", 1) - setenv("AG_ASYNC_LAYOUTS", "0", 1) + setenv("IAG_PREFETCH_LAYOUTS", "1", 1) + setenv("IAG_ASYNC_LAYOUTS", "0", 1) let graph = Graph() - let _ = __AGGraphInternAttributeType( + let _ = __IAGGraphInternAttributeType( graph.graphContext, Metadata(External.self), { _ in @@ -181,7 +181,7 @@ struct GraphTests { var traceCalls: [(name: String, graph: Graph)] = [] } - var trace = AGTraceType() + var trace = IAGTraceType() trace.begin_trace = { contextPointer, graph in if let context = contextPointer?.assumingMemoryBound(to: Context.self).pointee { context.traceCalls.append((name: "beginTrace", graph: graph)) @@ -225,7 +225,7 @@ struct GraphTests { var traceCalls: [(name: String, graph: Graph)] = [] } - var trace = AGTraceType() + var trace = IAGTraceType() trace.begin_trace = { contextPointer, graph in if let context = contextPointer?.assumingMemoryBound(to: Context.self).pointee { context.traceCalls.append((name: "beginTrace", graph: graph)) diff --git a/Tests/ComputeTests/Shared/Subgraph/SubgraphTests.swift b/Tests/ComputeTests/Shared/Subgraph/SubgraphTests.swift index cb5a4133..1f77d7c7 100644 --- a/Tests/ComputeTests/Shared/Subgraph/SubgraphTests.swift +++ b/Tests/ComputeTests/Shared/Subgraph/SubgraphTests.swift @@ -10,7 +10,7 @@ struct SubgraphTests { @Test func typeID() { let description = CFCopyTypeIDDescription(Subgraph.typeID) as String? - #expect(description == "AGSubgraph") + #expect(description == "IAGSubgraph") } @Test @@ -190,7 +190,7 @@ struct SubgraphTests { @Test func invalidateSubgraph() async throws { - var trace = AGTraceType() + var trace = IAGTraceType() trace.subgraph_created = { context, graph in guard let reporter = context?.assumingMemoryBound(to: TraceReporter.self).pointee else { return diff --git a/Xcode/Scripts/process_headers_inputs.xcfilelist b/Xcode/Scripts/process_headers_inputs.xcfilelist index a02f627c..75d81de5 100644 --- a/Xcode/Scripts/process_headers_inputs.xcfilelist +++ b/Xcode/Scripts/process_headers_inputs.xcfilelist @@ -1,25 +1,25 @@ -$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/AGAttribute.h -$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/AGAttributeInfo.h -$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/AGAttributeType.h -$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/AGBase.h -$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/AGCachedValueOptions.h -$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/AGChangedValue.h -$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/AGClosure.h -$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/AGComparison.h -$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/AGDescription.h -$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/AGGraph.h -$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/AGGraphCounterQueryType.h -$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/AGGraphTracing.h -$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/AGInputOptions.h -$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/AGSearchOptions.h -$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/AGSubgraph.h -$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/AGTargetConditionals.h -$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/AGTraceType.h -$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/AGTreeElement.h -$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/AGTreeValue.h -$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/AGTuple.h -$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/AGType.h -$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/AGUniqueID.h -$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/AGValue.h -$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/AGWeakAttribute.h +$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/IAGAttribute.h +$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/IAGAttributeInfo.h +$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/IAGAttributeType.h +$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/IAGBase.h +$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/IAGCachedValueOptions.h +$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/IAGChangedValue.h +$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/IAGClosure.h +$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/IAGComparison.h +$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/IAGDescription.h +$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/IAGGraph.h +$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/IAGGraphCounterQueryType.h +$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/IAGGraphTracing.h +$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/IAGInputOptions.h +$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/IAGSearchOptions.h +$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/IAGSubgraph.h +$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/IAGTargetConditionals.h +$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/IAGTraceType.h +$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/IAGTreeElement.h +$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/IAGTreeValue.h +$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/IAGTuple.h +$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/IAGType.h +$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/IAGUniqueID.h +$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/IAGValue.h +$(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/IAGWeakAttribute.h $(SRCROOT)/../Sources/ComputeCxx/include/ComputeCxx/ComputeCxx.h diff --git a/Xcode/Scripts/process_headers_outputs.xcfilelist b/Xcode/Scripts/process_headers_outputs.xcfilelist index 49457672..00539816 100644 --- a/Xcode/Scripts/process_headers_outputs.xcfilelist +++ b/Xcode/Scripts/process_headers_outputs.xcfilelist @@ -1,25 +1,25 @@ -$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/AGAttribute.h -$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/AGAttributeInfo.h -$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/AGAttributeType.h -$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/AGBase.h -$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/AGCachedValueOptions.h -$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/AGChangedValue.h -$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/AGClosure.h -$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/AGComparison.h -$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/AGDescription.h -$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/AGGraph.h -$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/AGGraphCounterQueryType.h -$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/AGGraphTracing.h -$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/AGInputOptions.h -$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/AGSearchOptions.h -$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/AGSubgraph.h -$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/AGTargetConditionals.h -$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/AGTraceType.h -$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/AGTreeElement.h -$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/AGTreeValue.h -$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/AGTuple.h -$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/AGType.h -$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/AGUniqueID.h -$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/AGValue.h -$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/AGWeakAttribute.h +$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/IAGAttribute.h +$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/IAGAttributeInfo.h +$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/IAGAttributeType.h +$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/IAGBase.h +$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/IAGCachedValueOptions.h +$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/IAGChangedValue.h +$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/IAGClosure.h +$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/IAGComparison.h +$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/IAGDescription.h +$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/IAGGraph.h +$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/IAGGraphCounterQueryType.h +$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/IAGGraphTracing.h +$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/IAGInputOptions.h +$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/IAGSearchOptions.h +$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/IAGSubgraph.h +$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/IAGTargetConditionals.h +$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/IAGTraceType.h +$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/IAGTreeElement.h +$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/IAGTreeValue.h +$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/IAGTuple.h +$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/IAGType.h +$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/IAGUniqueID.h +$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/IAGValue.h +$(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/IAGWeakAttribute.h $(BUILT_PRODUCTS_DIR)/$(PUBLIC_HEADERS_FOLDER_PATH)/Compute.h