Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions Sources/Compute/Attribute/AnyAttribute.swift
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -18,7 +18,7 @@ func AGGraphSearch(
extension AnyAttribute {

public static var current: AnyAttribute? {
let attribute = __AGGraphGetCurrentAttribute()
let attribute = __IAGGraphGetCurrentAttribute()
return attribute == .nil ? nil : attribute
}

Expand All @@ -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,
Expand All @@ -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<T>(_ input: Attribute<T>, options: AGInputOptions, token: Int) {
public func addInput<T>(_ input: Attribute<T>, 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)
}
}

Expand Down
22 changes: 11 additions & 11 deletions Sources/Compute/Attribute/Attribute.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ public struct Attribute<Value> {
identifier.mutateBody(as: bodyType, invalidating: invalidating, mutator)
}

public func addInput<T>(_ input: Attribute<T>, options: AGInputOptions, token: Int) {
public func addInput<T>(_ input: Attribute<T>, 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)
}

Expand All @@ -120,7 +120,7 @@ public struct Attribute<Value> {

public var value: Value {
unsafeAddress {
return __AGGraphGetValue(identifier, [], Metadata(Value.self))
return __IAGGraphGetValue(identifier, [], Metadata(Value.self))
.value
.assumingMemoryBound(to: Value.self)
}
Expand All @@ -131,15 +131,15 @@ public struct Attribute<Value> {

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))
}
}

public var hasValue: Bool {
return identifier.hasValue
}

public var valueState: AGValueState {
public var valueState: IAGValueState {
return identifier.valueState
}

Expand All @@ -155,16 +155,16 @@ public struct Attribute<Value> {
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
Expand All @@ -173,7 +173,7 @@ public struct Attribute<Value> {

public var wrappedValue: Value {
unsafeAddress {
__AGGraphGetValue(identifier, [], Metadata(Value.self))
__IAGGraphGetValue(identifier, [], Metadata(Value.self))
.value
.assumingMemoryBound(to: Value.self)
}
Expand Down Expand Up @@ -213,7 +213,7 @@ public struct Attribute<Value> {

public func unsafeOffset<Member>(at offset: Int, as type: Member.Type) -> Attribute<Member> {
return Attribute<Member>(
identifier: __AGGraphCreateOffsetAttribute2(identifier, UInt32(offset), MemoryLayout<Member>.size)
identifier: __IAGGraphCreateOffsetAttribute2(identifier, UInt32(offset), MemoryLayout<Member>.size)
)
}

Expand Down
16 changes: 8 additions & 8 deletions Sources/Compute/Attribute/AttributeType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -37,10 +37,10 @@ extension String {

}

@_silgen_name("AGRetainClosure")
func AGRetainClosure(
@_silgen_name("IAGRetainClosure")
func IAGRetainClosure(
_ closure: (UnsafeMutableRawPointer, AnyAttribute) -> Void
) -> _AGClosureStorage
) -> _IAGClosureStorage

extension _AttributeType {

Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions Sources/Compute/Attribute/Indirect/IndirectAttribute.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public struct IndirectAttribute<Value> {
public var identifier: AnyAttribute

public init(source: Attribute<Value>) {
identifier = __AGGraphCreateIndirectAttribute2(source.identifier, MemoryLayout<Value>.size)
identifier = __IAGGraphCreateIndirectAttribute2(source.identifier, MemoryLayout<Value>.size)
}

public var source: Attribute<Value> {
Expand All @@ -24,7 +24,7 @@ public struct IndirectAttribute<Value> {
}

public func resetSource() {
__AGGraphResetIndirectAttribute(identifier, false)
__IAGGraphResetIndirectAttribute(identifier, false)
}

public var dependency: AnyAttribute? {
Expand All @@ -48,7 +48,7 @@ public struct IndirectAttribute<Value> {
}
}

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)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public struct AnyOptionalAttribute {
}

public init(_ weakAttribute: AnyWeakAttribute) {
identifier = __AGWeakAttributeGetAttribute(weakAttribute)
identifier = __IAGWeakAttributeGetAttribute(weakAttribute)
}

public init(_ attribute: AnyAttribute?) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Compute/Attribute/Optional/OptionalAttribute.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public struct OptionalAttribute<Value> {
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)
}

Expand Down
10 changes: 5 additions & 5 deletions Sources/Compute/Attribute/Rule/Rule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ extension Rule {

}

@_silgen_name("AGGraphReadCachedAttribute")
func AGGraphReadCachedAttribute(
@_silgen_name("IAGGraphReadCachedAttribute")
func IAGGraphReadCachedAttribute(
hash: Int,
type: Metadata,
body: UnsafeRawPointer,
valueType: Metadata,
options: CachedValueOptions,
owner: AnyAttribute,
changed: UnsafeMutablePointer<Bool>?,
attributeTypeID: (AGUnownedGraphContextRef) -> UInt32
attributeTypeID: (IAGUnownedGraphContextRef) -> UInt32
) -> UnsafeRawPointer

extension Rule where Self: Hashable {
Expand All @@ -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,
Expand All @@ -101,7 +101,7 @@ extension Rule where Self: Hashable {
bodyPtr: UnsafeRawPointer,
update: () -> (UnsafeMutableRawPointer, AnyAttribute) -> Void
) -> UnsafePointer<Value> {
let value = AGGraphReadCachedAttribute(
let value = IAGGraphReadCachedAttribute(
hash: hashValue,
type: Metadata(Self.self),
body: bodyPtr,
Expand Down
2 changes: 1 addition & 1 deletion Sources/Compute/Attribute/Rule/StatefulRule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 9 additions & 9 deletions Sources/Compute/Attribute/RuleContext/AnyRuleContext.swift
Original file line number Diff line number Diff line change
@@ -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 {

Expand All @@ -20,16 +20,16 @@ public struct AnyRuleContext {
}

public func update(body: () -> Void) {
AGGraphWithUpdate(attribute, body: body)
IAGGraphWithUpdate(attribute, body: body)
}

public func changedValue<Value>(
of input: Attribute<Value>,
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)
Expand All @@ -38,11 +38,11 @@ public struct AnyRuleContext {

public func valueAndFlags<Value>(
of input: Attribute<Value>,
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 : []
Expand All @@ -51,7 +51,7 @@ public struct AnyRuleContext {

public subscript<Value>(_ attribute: Attribute<Value>) -> 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)
}
Expand Down
Loading