Skip to content

Commit cd0d207

Browse files
committed
Update struct definitions
1 parent b6259dc commit cd0d207

24 files changed

+157
-71
lines changed

Sources/OpenGraph/Attribute/Attribute/AnyAttribute.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ extension AnyAttribute {
4141

4242
// FIXME: Use AttributeType instead
4343
public func visitBody<Body: AttributeBodyVisitor>(_ visitor: inout Body) {
44-
let bodyType = info.type.advanced(by: 1).pointee.typeID.type as! _AttributeBody.Type
44+
let bodyType = info.type.advanced(by: 1).pointee.self_id.type as! _AttributeBody.Type
4545
bodyType._visitBody(&visitor, info.body)
4646
}
4747

@@ -56,15 +56,15 @@ extension AnyAttribute {
5656
}
5757

5858
public var _bodyType: Any.Type {
59-
info.type.pointee.typeID.type
59+
info.type.pointee.self_id.type
6060
}
6161

6262
public var _bodyPointer: UnsafeRawPointer {
6363
info.body
6464
}
6565

6666
public var valueType: Any.Type {
67-
info.type.pointee.valueTypeID.type
67+
info.type.pointee.value_id.type
6868
}
6969

7070
public var indirectDependency: AnyAttribute? {

Sources/OpenGraph/Attribute/Attribute/Attribute.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public struct Attribute<Value> {
1919
public init(value: Value) {
2020
self = withUnsafePointer(to: value) { valuePointer in
2121
withUnsafePointer(to: External<Value>()) { bodyPointer in
22-
Attribute(body: bodyPointer, value: valuePointer, flags: ._16) {
22+
Attribute(body: bodyPointer, value: valuePointer, flags: .external) {
2323
External<Value>._update
2424
}
2525
}
@@ -28,7 +28,7 @@ public struct Attribute<Value> {
2828

2929
public init(type _: Value.Type) {
3030
self = withUnsafePointer(to: External<Value>()) { bodyPointer in
31-
Attribute(body: bodyPointer, value: nil, flags: ._16) {
31+
Attribute(body: bodyPointer, value: nil, flags: .external) {
3232
External<Value>._update
3333
}
3434
}
@@ -158,15 +158,15 @@ public struct Attribute<Value> {
158158
let value = OGGraphGetValue(identifier, options: options, type: Value.self)
159159
return (
160160
value.value.assumingMemoryBound(to: Value.self).pointee,
161-
value.changed ? ._1 : []
161+
value.flags
162162
)
163163
}
164164

165165
public func changedValue(options: OGValueOptions = []) -> (value: Value, changed: Bool) {
166166
let value = OGGraphGetValue(identifier, options: options, type: Value.self)
167167
return (
168168
value.value.assumingMemoryBound(to: Value.self).pointee,
169-
value.changed
169+
value.flags.contains(.changed)
170170
)
171171
}
172172

Sources/OpenGraph/Attribute/RuleContext/AnyRuleContext.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ public struct AnyRuleContext: Equatable {
4949
let value = OGGraphGetInputValue(attribute, input: input.identifier, options: options, type: V.self)
5050
return (
5151
value.value.assumingMemoryBound(to: V.self).pointee,
52-
value.changed ? ._1 : []
52+
value.flags
5353
)
5454
}
5555

5656
public func changedValue<V>(of input: Attribute<V>, options: OGValueOptions = []) -> (value: V, changed: Bool) {
5757
let value = OGGraphGetInputValue(attribute, input: input.identifier, options: options, type: V.self)
5858
return (
5959
value.value.assumingMemoryBound(to: V.self).pointee,
60-
value.changed
60+
value.flags.contains(.changed)
6161
)
6262
}
6363

Sources/OpenGraph/Attribute/RuleContext/RuleContext.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ public struct RuleContext<Value>: Equatable {
6161
let value = OGGraphGetInputValue(attribute.identifier, input: input.identifier, options: options, type: V.self)
6262
return (
6363
value.value.assumingMemoryBound(to: V.self).pointee,
64-
value.changed ? ._1 : []
64+
value.flags
6565
)
6666
}
6767

6868
public func changedValue<V>(of input: Attribute<V>, options: OGValueOptions = []) -> (value: V, changed: Bool) {
6969
let value = OGGraphGetInputValue(attribute.identifier, input: input.identifier, options: options, type: V.self)
7070
return (
7171
value.value.assumingMemoryBound(to: V.self).pointee,
72-
value.changed
72+
value.flags.contains(.changed)
7373
)
7474
}
7575

Sources/OpenGraph/Attribute/Weak/AnyWeakAttribute.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extension AnyWeakAttribute {
1414
public init(_ attribute: AnyAttribute?) {
1515
self = __OGCreateWeakAttribute(attribute ?? .nil)
1616
}
17-
17+
1818
@_alwaysEmitIntoClient
1919
public init<Value>(_ weakAttribute: WeakAttribute<Value>) {
2020
self = weakAttribute.base
@@ -40,13 +40,13 @@ extension AnyWeakAttribute {
4040
extension AnyWeakAttribute: Swift.Hashable {
4141
@_alwaysEmitIntoClient
4242
public static func == (lhs: AnyWeakAttribute, rhs: AnyWeakAttribute) -> Bool {
43-
lhs.raw_attribute == rhs.raw_attribute && lhs.subgraph_id == rhs.subgraph_id
43+
lhs._details.identifier == rhs._details.identifier && lhs._details.seed == rhs._details.seed
4444
}
4545

4646
@_alwaysEmitIntoClient
4747
public func hash(into hasher: inout Hasher) {
48-
hasher.combine(raw_attribute)
49-
hasher.combine(subgraph_id)
48+
hasher.combine(_details.identifier)
49+
hasher.combine(_details.seed)
5050
}
5151

5252
@_alwaysEmitIntoClient

Sources/OpenGraph/Attribute/Weak/WeakAttribute.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public struct WeakAttribute<Value> {
2020
}
2121

2222
public init() {
23-
base = AnyWeakAttribute(raw_attribute: AnyAttribute(rawValue: 0), subgraph_id: 0)
23+
base = AnyWeakAttribute(_details: AnyWeakAttribute.__Unnamed_struct__details(identifier: AnyAttribute(rawValue: 0), seed: 0))
2424
}
2525

2626
public init(_ attribute: Attribute<Value>) {

Sources/OpenGraph/Graph/Graph.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ extension Graph {
4848
extension Graph {
4949
@_transparent
5050
@inline(__always)
51-
public var mainUpdates: Int { numericCast(counter(for: ._10)) }
51+
public var mainUpdates: Int { numericCast(counter(for: .mainThreadUpdateCount)) }
5252
}
5353
5454
extension Graph {

Sources/OpenGraph_SPI/Graph/GraphDescription.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
#if OG_OBJC_FOUNDATION
1414
#include <Foundation/Foundation.h>
15-
CFStringRef OGDescriptionFormat = CFSTR("format");
15+
const CFStringRef OGDescriptionFormat = CFSTR("format");
1616

1717
CFTypeRef OG::Graph::description(const Graph * _Nullable graph, NSDictionary* dic) {
1818
// TODO

Sources/OpenGraph_SPI/Graph/OGGraph.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -161,27 +161,27 @@ uint64_t OGGraphGetCounter(OGGraphRef graph, OGCounterQueryType query) {
161161
}
162162
OG::Graph::Context& context = graph->context;
163163
switch (query) {
164-
case OGCounterQueryType_0:
164+
case OGCounterQueryTypeNodeCount:
165165
return context.get_graph().get_counter_0();
166-
case OGCounterQueryType_1:
166+
case OGCounterQueryTypeTransactionCount:
167167
return context.get_graph().get_counter_1();
168-
case OGCounterQueryType_2:
168+
case OGCounterQueryTypeUpdateCount:
169169
return context.get_graph().get_counter_2();
170-
case OGCounterQueryType_3:
170+
case OGCounterQueryTypeChangeCount:
171171
return context.get_graph().get_counter_3();
172-
case OGCounterQueryType_4:
172+
case OGCounterQueryTypeContextID:
173173
return context.get_graph().get_counter_4();
174-
case OGCounterQueryType_5:
174+
case OGCounterQueryTypeGraphID:
175175
return context.get_graph().get_counter_5();
176-
case OGCounterQueryType_6:
176+
case OGCounterQueryTypeContextThreadUpdating:
177177
return context.thread_is_updating();
178-
case OGCounterQueryType_7:
178+
case OGCounterQueryTypeThreadUpdating:
179179
return context.get_graph().thread_is_updating();
180-
case OGCounterQueryType_8:
180+
case OGCounterQueryTypeContextNeedsUpdate:
181181
return context.get_graph().get_counter_8();
182-
case OGCounterQueryType_9:
182+
case OGCounterQueryTypeNeedsUpdate:
183183
return context.get_graph().get_counter_9();
184-
case OGCounterQueryType_10:
184+
case OGCounterQueryTypeMainThreadUpdateCount:
185185
return context.get_graph().get_counter_10();
186186
default:
187187
return 0;

Sources/OpenGraph_SPI/include/OGAttributeFlags.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#include "OGBase.h"
1212

13-
typedef OG_OPTIONS(uint32_t, OGAttributeFlags) {
13+
typedef OG_OPTIONS(uint8_t, OGAttributeFlags) {
1414
OGAttributeFlagsDefault = 0,
1515
OGAttributeFlagsActive = 1 << 0,
1616
OGAttributeFlagsRemovable = 1 << 1,

0 commit comments

Comments
 (0)