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
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,18 @@ extension AttributeGraph.AGGraph {
public static func withoutUpdate<Value>(_ body: () -> Value) -> Value
}

extension AttributeGraph.AGGraph {
@_silgen_name("AGGraphGetOutputValue")
@inline(__always)
@inlinable
public static func outputValue<Value>() -> Swift.UnsafePointer<Value>?

@_silgen_name("AGGraphSetOutputValue")
@inline(__always)
@inlinable
public static func setOutputValue<Value>(_ value: Swift.UnsafePointer<Value>)
}

// MARK: - AGSubgraph

extension AttributeGraph.AGSubgraph {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,18 @@ extension AttributeGraph.AGGraph {
public static func withoutUpdate<Value>(_ body: () -> Value) -> Value
}

extension AttributeGraph.AGGraph {
@_silgen_name("AGGraphGetOutputValue")
@inline(__always)
@inlinable
public static func outputValue<Value>() -> Swift.UnsafePointer<Value>?

@_silgen_name("AGGraphSetOutputValue")
@inline(__always)
@inlinable
public static func setOutputValue<Value>(_ value: Swift.UnsafePointer<Value>)
}

// MARK: - AGSubgraph

extension AttributeGraph.AGSubgraph {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,18 @@ extension AttributeGraph.AGGraph {
public static func withoutUpdate<Value>(_ body: () -> Value) -> Value
}

extension AttributeGraph.AGGraph {
@_silgen_name("AGGraphGetOutputValue")
@inline(__always)
@inlinable
public static func outputValue<Value>() -> Swift.UnsafePointer<Value>?

@_silgen_name("AGGraphSetOutputValue")
@inline(__always)
@inlinable
public static func setOutputValue<Value>(_ value: Swift.UnsafePointer<Value>)
}

// MARK: - AGSubgraph

extension AttributeGraph.AGSubgraph {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,18 @@ extension AttributeGraph.AGGraph {
public static func withoutUpdate<Value>(_ body: () -> Value) -> Value
}

extension AttributeGraph.AGGraph {
@_silgen_name("AGGraphGetOutputValue")
@inline(__always)
@inlinable
public static func outputValue<Value>() -> Swift.UnsafePointer<Value>?

@_silgen_name("AGGraphSetOutputValue")
@inline(__always)
@inlinable
public static func setOutputValue<Value>(_ value: Swift.UnsafePointer<Value>)
}

// MARK: - AGSubgraph

extension AttributeGraph.AGSubgraph {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,18 @@ extension AttributeGraph.AGGraph {
public static func withoutUpdate<Value>(_ body: () -> Value) -> Value
}

extension AttributeGraph.AGGraph {
@_silgen_name("AGGraphGetOutputValue")
@inline(__always)
@inlinable
public static func outputValue<Value>() -> Swift.UnsafePointer<Value>?

@_silgen_name("AGGraphSetOutputValue")
@inline(__always)
@inlinable
public static func setOutputValue<Value>(_ value: Swift.UnsafePointer<Value>)
}

// MARK: - AGSubgraph

extension AttributeGraph.AGSubgraph {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,18 @@ extension AttributeGraph.AGGraph {
public static func withoutUpdate<Value>(_ body: () -> Value) -> Value
}

extension AttributeGraph.AGGraph {
@_silgen_name("AGGraphGetOutputValue")
@inline(__always)
@inlinable
public static func outputValue<Value>() -> Swift.UnsafePointer<Value>?

@_silgen_name("AGGraphSetOutputValue")
@inline(__always)
@inlinable
public static func setOutputValue<Value>(_ value: Swift.UnsafePointer<Value>)
}

// MARK: - AGSubgraph

extension AttributeGraph.AGSubgraph {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,18 @@ extension AttributeGraph.AGGraph {
public static func withoutUpdate<Value>(_ body: () -> Value) -> Value
}

extension AttributeGraph.AGGraph {
@_silgen_name("AGGraphGetOutputValue")
@inline(__always)
@inlinable
public static func outputValue<Value>() -> Swift.UnsafePointer<Value>?

@_silgen_name("AGGraphSetOutputValue")
@inline(__always)
@inlinable
public static func setOutputValue<Value>(_ value: Swift.UnsafePointer<Value>)
}

// MARK: - AGSubgraph

extension AttributeGraph.AGSubgraph {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,18 @@ extension AttributeGraph.AGGraph {
public static func withoutUpdate<Value>(_ body: () -> Value) -> Value
}

extension AttributeGraph.AGGraph {
@_silgen_name("AGGraphGetOutputValue")
@inline(__always)
@inlinable
public static func outputValue<Value>() -> Swift.UnsafePointer<Value>?

@_silgen_name("AGGraphSetOutputValue")
@inline(__always)
@inlinable
public static func setOutputValue<Value>(_ value: Swift.UnsafePointer<Value>)
}

// MARK: - AGSubgraph

extension AttributeGraph.AGSubgraph {
Expand Down
18 changes: 4 additions & 14 deletions Sources/OpenGraph/Attribute/Rule/Rule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ extension Rule {
let rule = pointer.assumingMemoryBound(to: Self.self)
let value = rule.pointee.value
// Verified for RELEASE_2023
withUnsafePointer(to: value) { valuePointer in
OGGraphSetOutputValue(valuePointer)
withUnsafePointer(to: value) { value in
OGGraph.setOutputValue(value)
}
}

Expand All @@ -32,8 +32,8 @@ extension Rule {
return
}
// Verified for RELEASE_2023
withUnsafePointer(to: initialValue) { valuePointer in
OGGraphSetOutputValue(valuePointer)
withUnsafePointer(to: initialValue) { value in
OGGraph.setOutputValue(value)
}
}
}
Expand Down Expand Up @@ -91,13 +91,3 @@ extension Rule where Self: Hashable {
.assumingMemoryBound(to: Value.self)
}
}

@_silgen_name("OGGraphGetOutputValue")
@inline(__always)
@inlinable
func OGGraphGetOutputValue<Value>() -> UnsafePointer<Value>?

@_silgen_name("OGGraphSetOutputValue")
@inline(__always)
@inlinable
func OGGraphSetOutputValue<Value>(_ valuePointer: UnsafePointer<Value>)
8 changes: 4 additions & 4 deletions Sources/OpenGraph/Attribute/Rule/RuleContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ public struct RuleContext<Value> {

public var value: Value {
unsafeAddress {
OGGraphGetOutputValue()!
OGGraph.outputValue()!
}
nonmutating set {
withUnsafePointer(to: newValue) { valuePointer in
OGGraphSetOutputValue(valuePointer)
withUnsafePointer(to: newValue) { value in
OGGraph.setOutputValue(value)
}
}
}

public var hasValue: Bool {
let valuePointer: UnsafePointer<Value>? = OGGraphGetOutputValue()
let valuePointer: UnsafePointer<Value>? = OGGraph.outputValue()
return valuePointer != nil
}

Expand Down
6 changes: 3 additions & 3 deletions Sources/OpenGraph/Attribute/Rule/StatefulRule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ extension StatefulRule {
guard let initialValue else {
return
}
withUnsafePointer(to: initialValue) { valuePointer in
OGGraphSetOutputValue(valuePointer)
withUnsafePointer(to: initialValue) { value in
OGGraph.setOutputValue(value)
}
}
}
Expand All @@ -46,7 +46,7 @@ extension StatefulRule {
}

public var value: Value {
unsafeAddress { OGGraphGetOutputValue()! }
unsafeAddress { OGGraph.outputValue()! }
nonmutating set { context.value = newValue }
}

Expand Down
13 changes: 13 additions & 0 deletions Sources/OpenGraph/Graph/OGGraph.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,16 @@ extension OGGraph {
return body()
}
}

extension OGGraph {
// NOTE: Currently Swift does not support generic computed variable
@_silgen_name("OGGraphGetOutputValue")
@inline(__always)
@inlinable
public static func outputValue<Value>() -> UnsafePointer<Value>?

@_silgen_name("OGGraphSetOutputValue")
@inline(__always)
@inlinable
public static func setOutputValue<Value>(_ value: UnsafePointer<Value>)
}