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
2 changes: 1 addition & 1 deletion Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Sources/OpenGraph/Attribute/Attribute/External.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public struct External<Value> {
extension External: _AttributeBody {
public static var comparisonMode: ComparisonMode { .equatableAlways }

public static var flags: _AttributeType.Flags { [] }
public static var flags: Flags { [] }

public static func _update(_: UnsafeMutableRawPointer, attribute _: AnyAttribute) {}
}
Expand Down
5 changes: 3 additions & 2 deletions Sources/OpenGraph/Attribute/Body/AttributeBody.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ public protocol _AttributeBody {
static var _hasDestroySelf: Bool { get }
static func _updateDefault(_ pointer: UnsafeMutableRawPointer)
static var comparisonMode: ComparisonMode { get }
static var flags: _AttributeType.Flags { get }
typealias Flags = _AttributeType.Flags
static var flags: Flags { get }
}

// MARK: - Protocol Default implementation
Expand All @@ -22,7 +23,7 @@ extension _AttributeBody {
public static var _hasDestroySelf: Bool { false }
public static func _updateDefault(_ pointer: UnsafeMutableRawPointer) {}
public static var comparisonMode: ComparisonMode { .equatableUnlessPOD }
public static var flags: _AttributeType.Flags { .mainThread }
public static var flags: Flags { .mainThread }
}

extension _AttributeBody {
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenGraph/Attribute/Rule/Focus.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public struct Focus<Root, Value>: Rule, CustomStringConvertible {

public var value: Value { root.value[keyPath: keyPath] }

public static var flags: _AttributeType.Flags { [] }
public static var flags: Flags { [] }

public var description: String { "• \(Metadata(Value.self).description)" }
}
2 changes: 1 addition & 1 deletion Sources/OpenGraph/Attribute/Rule/Map.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public struct Map<Source, Value>: Rule, CustomStringConvertible {

public var value: Value { body(arg.value) }

public static var flags: _AttributeType.Flags { [] }
public static var flags: Flags { [] }

public var description: String { "λ \(Value.self)" }
}
16 changes: 15 additions & 1 deletion Sources/OpenGraph/Graph/Graph.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,21 @@ extension Graph {
}

extension Graph {
@_transparent
public func startProfiling() {
__OGGraphStartProfiling(self)
}

@_transparent
public func stopProfiling() {
__OGGraphStopProfiling(self)
}

@_transparent
public func resetProfile() {
__OGGraphResetProfile(self)
}

public static func startProfiling() {
__OGGraphStartProfiling(nil)
}
Expand All @@ -80,7 +95,6 @@ extension Graph {

extension Graph {
@_transparent
@inline(__always)
public var mainUpdates: Int { numericCast(counter(for: .mainThreadUpdates)) }
}

Expand Down
7 changes: 7 additions & 0 deletions Sources/OpenGraph/Graph/Subgraph.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@

public import OpenGraphCxx

extension Subgraph {
public typealias Flags = AnyAttribute.Flags

// FIXME
public typealias ChildFlags = AnyAttribute.Flags
}

extension Subgraph {
public func addObserver(_ observer: () -> Void) -> Int {
Subgraph.addObserver(self, observer: observer)
Expand Down
4 changes: 2 additions & 2 deletions Sources/OpenGraphCxx/Graph/OGGraphTracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

#include <OpenGraph/OGGraphTracing.h>

void OGGraphStartTracing(_Nullable OGGraphRef graph, OGGraphTraceFlags options) {
void OGGraphStartTracing(_Nullable OGGraphRef graph, OGGraphTraceOptions options) {
OGGraphStartTracing2(graph, options, NULL);
}

void OGGraphStartTracing2(_Nullable OGGraphRef graph, OGGraphTraceFlags options, _Nullable CFArrayRef array) {
void OGGraphStartTracing2(_Nullable OGGraphRef graph, OGGraphTraceOptions options, _Nullable CFArrayRef array) {
// TODO
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenGraphCxx/Graph/OGSubgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ void OGSubgraphUpdate(OGSubgraphRef cf_subgraph, OGAttributeFlags flags) {
// subgraph->update(flags);
}

bool OGSubgraphIsDirty(OGSubgraphRef cf_subgraph, uint32_t unknown) {
bool OGSubgraphIsDirty(OGSubgraphRef cf_subgraph, OGAttributeFlags flags) {
OG::Subgraph *subgraph = cf_subgraph->subgraph;
if (subgraph == nullptr) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenGraphCxx/include/OpenGraph/OGAttributeFlags.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
typedef OG_OPTIONS(uint8_t, OGAttributeFlags) {
OGAttributeFlagsNone = 0,
OGAttributeFlagsAll = 0xFF,
} OG_SWIFT_NAME(OGSubgraphRef.Flags);
} OG_SWIFT_NAME(OGAttribute.Flags);

#endif /* OGAttributeFlags_h */
20 changes: 10 additions & 10 deletions Sources/OpenGraphCxx/include/OpenGraph/OGGraphTracing.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
#include <OpenGraph/OGGraph.h>
#include <OpenGraph/OGUniqueID.h>

typedef OG_OPTIONS(uint32_t, OGGraphTraceFlags) {
OGGraphTraceFlagsEnabled = 1 << 0,
OGGraphTraceFlagsFull = 1 << 1,
OGGraphTraceFlagsBacktrace = 1 << 2,
OGGraphTraceFlagsPrepare = 1 << 3,
OGGraphTraceFlagsCustom = 1 << 4,
OGGraphTraceFlagsAll = 1 << 5,
} OG_SWIFT_NAME(OGGraphRef.TraceFlags);
typedef OG_OPTIONS(uint32_t, OGGraphTraceOptions) {
OGGraphTraceOptionsEnabled = 1 << 0,
OGGraphTraceOptionsFull = 1 << 1,
OGGraphTraceOptionsBacktrace = 1 << 2,
OGGraphTraceOptionsPrepare = 1 << 3,
OGGraphTraceOptionsCustom = 1 << 4,
OGGraphTraceOptionsAll = 1 << 5,
} OG_SWIFT_NAME(OGGraphRef.TraceOptions);

typedef struct OGTrace *OGTraceRef;

Expand All @@ -28,11 +28,11 @@ OG_EXTERN_C_BEGIN

OG_EXPORT
OG_REFINED_FOR_SWIFT
void OGGraphStartTracing(_Nullable OGGraphRef graph, OGGraphTraceFlags flags) OG_SWIFT_NAME(OGGraphRef.startTracing(_:flags:));
void OGGraphStartTracing(_Nullable OGGraphRef graph, OGGraphTraceOptions options) OG_SWIFT_NAME(OGGraphRef.startTracing(_:options:));

OG_EXPORT
OG_REFINED_FOR_SWIFT
void OGGraphStartTracing2(_Nullable OGGraphRef graph, OGGraphTraceFlags flags, _Nullable CFArrayRef subsystems) OG_SWIFT_NAME(OGGraphRef.startTracing(_:flags:subsystems:));
void OGGraphStartTracing2(_Nullable OGGraphRef graph, OGGraphTraceOptions options, _Nullable CFArrayRef subsystems) OG_SWIFT_NAME(OGGraphRef.startTracing(_:flags:subsystems:));

OG_EXPORT
OG_REFINED_FOR_SWIFT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ struct GraphTracingCompatibilityTests {
@Test
func tracing() {
let graph = Graph()
Graph.startTracing(graph, flags: [])
Graph.startTracing(graph, options: [])
Graph.stopTracing(graph)
}

@Test
func tracingAll() {
Graph.startTracing(nil, flags: [])
Graph.startTracing(nil, options: [])
Graph.stopTracing(nil)
}

@Test
func options() {
let option = Graph.TraceFlags(rawValue: 1)
let option = Graph.TraceOptions(rawValue: 1)
#expect(option == .enabled)
}
}