Skip to content

Commit d69dcc6

Browse files
authored
Update Graph and Subgraph name (#125)
1 parent ae33121 commit d69dcc6

File tree

16 files changed

+73
-89
lines changed

16 files changed

+73
-89
lines changed

Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Sources/OpenGraph/Attribute/Attribute/Attribute.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ public struct Attribute<Value> {
4545
// See https://github.com/swiftwasm/swift/issues/5569
4646
fatalError("Swift 5.9.1 Compiler issue - type mismatch of Unmanaged<OGGraphContext> and OGGraphContext")
4747
#else
48-
guard let context = OGSubgraph.currentGraphContext else {
48+
guard let context = Subgraph.currentGraphContext else {
4949
fatalError("attempting to create attribute with no subgraph: \(Value.self)")
5050
}
51-
let index = OGGraph.typeIndex(
51+
let index = Graph.typeIndex(
5252
ctx: context,
5353
body: Body.self,
5454
valueType: Metadata(Value.self),
@@ -126,14 +126,14 @@ public struct Attribute<Value> {
126126

127127
// MARK: - Graph
128128

129-
public var graph: OGGraph {
129+
public var graph: Graph {
130130
#if os(WASI)
131131
fatalError("Compiler Bug")
132132
#else
133133
identifier.graph
134134
#endif
135135
}
136-
public var subgraph: OGSubgraph {
136+
public var subgraph: Subgraph {
137137
#if os(WASI)
138138
fatalError("Compiler Bug")
139139
#else

Sources/OpenGraph/Attribute/Rule/Rule.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ extension Rule {
2323
let value = rule.pointee.value
2424
// Verified for RELEASE_2023
2525
withUnsafePointer(to: value) { value in
26-
OGGraph.setOutputValue(value)
26+
Graph.setOutputValue(value)
2727
}
2828
}
2929

@@ -33,7 +33,7 @@ extension Rule {
3333
}
3434
// Verified for RELEASE_2023
3535
withUnsafePointer(to: initialValue) { value in
36-
OGGraph.setOutputValue(value)
36+
Graph.setOutputValue(value)
3737
}
3838
}
3939
}

Sources/OpenGraph/Attribute/Rule/StatefulRule.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ extension StatefulRule {
2929
return
3030
}
3131
withUnsafePointer(to: initialValue) { value in
32-
OGGraph.setOutputValue(value)
32+
Graph.setOutputValue(value)
3333
}
3434
}
3535
}
@@ -46,7 +46,7 @@ extension StatefulRule {
4646
}
4747

4848
public var value: Value {
49-
unsafeAddress { OGGraph.outputValue()! }
49+
unsafeAddress { Graph.outputValue()! }
5050
nonmutating set { context.value = newValue }
5151
}
5252

Sources/OpenGraph/Attribute/RuleContext/RuleContext.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,17 @@ public struct RuleContext<Value>: Equatable {
4343

4444
public var value: Value {
4545
unsafeAddress {
46-
OGGraph.outputValue()!
46+
Graph.outputValue()!
4747
}
4848
nonmutating set {
4949
withUnsafePointer(to: newValue) { value in
50-
OGGraph.setOutputValue(value)
50+
Graph.setOutputValue(value)
5151
}
5252
}
5353
}
5454

5555
public var hasValue: Bool {
56-
let valuePointer: UnsafePointer<Value>? = OGGraph.outputValue()
56+
let valuePointer: UnsafePointer<Value>? = Graph.outputValue()
5757
return valuePointer != nil
5858
}
5959

Sources/OpenGraph/Graph/OGGraph.swift renamed to Sources/OpenGraph/Graph/Graph.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
//
2-
// OGGraph.swift
2+
// Graph.swift
33
// OpenGraph
44
//
55
// Audited for RELEASE_2021
66
// Status: WIP
77

88
public import OpenGraph_SPI
99

10-
extension OGGraph {
10+
extension Graph {
1111
public static func typeIndex(
12-
ctx: OGGraphContext,
12+
ctx: GraphContext,
1313
body: _AttributeBody.Type,
1414
valueType: Metadata,
1515
flags: OGAttributeTypeFlags,
@@ -20,12 +20,12 @@ extension OGGraph {
2020
}
2121
}
2222

23-
extension OGGraph {
23+
extension Graph {
2424
@_silgen_name("OGGraphStartProfiling")
25-
public static func startProfiling(_ graph: OGGraph? = nil)
25+
public static func startProfiling(_ graph: Graph? = nil)
2626

2727
@_silgen_name("OGGraphStopProfiling")
28-
public static func stopProfiling(_ graph: OGGraph? = nil)
28+
public static func stopProfiling(_ graph: Graph? = nil)
2929
}
3030

3131
// FIXME: migrate to use @_extern(c, "xx") in Swift 6
@@ -37,29 +37,29 @@ extension OGGraph {
3737
// @_silgen_name("OGGGraphSetUpdateCallback")
3838
// public func setUpdateCallback(_ callback: (() -> Void)?)
3939
//}
40-
extension OGGraph {
40+
extension Graph {
4141
@_silgen_name("OGGraphSetInvalidationCallback")
42-
public static func setInvalidationCallback(_ graph: OGGraph, callback: ((AnyAttribute) -> Void)?)
42+
public static func setInvalidationCallback(_ graph: Graph, callback: ((AnyAttribute) -> Void)?)
4343

4444
@_silgen_name("OGGraphSetUpdateCallback")
45-
public static func setUpdateCallback(_ graph: OGGraph, callback: (() -> Void)?)
45+
public static func setUpdateCallback(_ graph: Graph, callback: (() -> Void)?)
4646
}
4747
48-
extension OGGraph {
48+
extension Graph {
4949
@_transparent
5050
@inline(__always)
5151
public var mainUpdates: Int { numericCast(counter(for: ._10)) }
5252
}
5353
54-
extension OGGraph {
54+
extension Graph {
5555
public static func withoutUpdate<Value>(_ body: () -> Value) -> Value {
5656
let update = clearUpdate()
5757
defer { setUpdate(update) }
5858
return body()
5959
}
6060
}
6161
62-
extension OGGraph {
62+
extension Graph {
6363
// NOTE: Currently Swift does not support generic computed variable
6464
@_silgen_name("OGGraphGetOutputValue")
6565
@inline(__always)
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
//
2-
// OGSubgraph.swift
2+
// Subgraph.swift
33
// OpenGraph
44
//
55
// Audited for RELEASE_2021
66
// Status: WIP
77

88
public import OpenGraph_SPI
99

10-
extension OGSubgraph {
10+
extension Subgraph {
1111
public func addObserver(_ observer: () -> Void) -> Int {
12-
OGSubgraph.addObserver(self, observer: observer)
12+
Subgraph.addObserver(self, observer: observer)
1313
}
1414

1515
public func apply<Value>(_ body: () -> Value) -> Value {
1616
#if !os(WASI)
17-
let update = OGGraph.clearUpdate()
18-
let current = OGSubgraph.current
17+
let update = Graph.clearUpdate()
18+
let current = Subgraph.current
1919
defer {
20-
OGSubgraph.current = current
21-
OGGraph.setUpdate(update)
20+
Subgraph.current = current
21+
Graph.setUpdate(update)
2222
}
23-
OGSubgraph.current = self
23+
Subgraph.current = self
2424
return body()
2525
#else
2626
fatalError("upstream SIL Compiler assert issue")
2727
#endif
2828
}
2929

3030
public func forEach(_ flags: OGAttributeFlags, _ callback: (AnyAttribute) -> Void) {
31-
OGSubgraph.apply(self, flags: flags, callback: callback)
31+
Subgraph.apply(self, flags: flags, callback: callback)
3232
}
3333
}
3434

35-
extension OGSubgraph {
35+
extension Subgraph {
3636
public static func beginTreeElement<Value>(value: Attribute<Value>, flags: UInt32) {
3737
if shouldRecordTree {
3838
__OGSubgraphBeginTreeElement(value.identifier, Metadata(Value.self), flags)
@@ -53,10 +53,10 @@ extension OGSubgraph {
5353
}
5454

5555
// FIXME: migrate to use @_extern(c, "xx") in Swift 6
56-
extension OGSubgraph {
56+
extension Subgraph {
5757
@_silgen_name("OGSubgraphApply")
58-
private static func apply(_ graph: OGSubgraph, flags: OGAttributeFlags, callback: (AnyAttribute) -> Void)
58+
private static func apply(_ graph: Subgraph, flags: OGAttributeFlags, callback: (AnyAttribute) -> Void)
5959

6060
@_silgen_name("OGSubgraphAddObserver")
61-
private static func addObserver(_ graph: OGSubgraph, observer: () -> Void) -> Int
61+
private static func addObserver(_ graph: Subgraph, observer: () -> Void) -> Int
6262
}

Sources/OpenGraphShims/Graph+Debug.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
// Graph+Debug.swift
33
// OpenGraphShims
44

5-
// FIXME: Update name in OpenGraph
6-
public typealias Graph = OGGraph
7-
public typealias Subgraph = OGSubgraph
8-
95
#if canImport(Darwin)
106

117
import Foundation

Sources/OpenGraphShims/GraphShims.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@ public typealias OGComparisonMode = AGComparisonMode
1414
public typealias OGComparisonOptions = AGComparisonOptions
1515
public typealias OGCounterQueryType = AGCounterQueryType
1616
public typealias OGDebugServer = AGDebugServer
17-
public typealias OGGraph = AGGraph
18-
public typealias OGGraphContext = AGGraphContext
1917
public typealias OGInputOptions = AGInputOptions
2018
public typealias OGSearchOptions = AGSearchOptions
21-
public typealias OGSubgraph = AGSubgraph
2219
public typealias OGTypeApplyOptions = AGTypeApplyOptions
2320
public typealias OGUniqueID = AGUniqueID
2421
public typealias OGValue = AGValue

Sources/OpenGraph_SPI/Graph/OGGraph.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
//
22
// OGGraph.h
3-
//
4-
//
5-
// Created by Kyle on 2024/2/5.
6-
//
3+
// OpenGraph_SPI
74

85
#ifndef OGGraph_h
96
#define OGGraph_h
@@ -14,9 +11,9 @@
1411

1512
// Note: Place all structure declaration in a single place to avoid header cycle dependency
1613

17-
typedef struct OG_BRIDGED_TYPE(id) OGGraphStorage * OGGraphRef;
18-
typedef struct OG_BRIDGED_TYPE(id) OGGraphContextStorage * OGGraphContextRef;
19-
typedef struct OG_BRIDGED_TYPE(id) OGSubgraphStorage * OGSubgraphRef;
14+
typedef struct OG_BRIDGED_TYPE(id) OGGraphStorage * OGGraphRef OG_SWIFT_NAME(Graph);
15+
typedef struct OG_BRIDGED_TYPE(id) OGSubgraphStorage * OGSubgraphRef OG_SWIFT_NAME(Subgraph);
16+
typedef struct OG_BRIDGED_TYPE(id) OGGraphContextStorage * OGGraphContextRef OG_SWIFT_NAME(GraphContext);
2017

2118
struct OGGraphStorage;
2219
struct OGGraphContextStorage;

0 commit comments

Comments
 (0)