diff --git a/Package.resolved b/Package.resolved index 95b15ec6..955b52ad 100644 --- a/Package.resolved +++ b/Package.resolved @@ -7,7 +7,7 @@ "location" : "https://github.com/OpenSwiftUIProject/DarwinPrivateFrameworks.git", "state" : { "branch" : "main", - "revision" : "bcef7b5a07311ef13dd47f6960b127d394e6bbff" + "revision" : "09f6bd3d766b0fd99aa67bdcacd3105bf508a7c4" } }, { diff --git a/Sources/OpenGraph/Attribute/Attribute/AnyAttribute.swift b/Sources/OpenGraph/Attribute/Attribute/AnyAttribute.swift index c577545c..08f73f3c 100644 --- a/Sources/OpenGraph/Attribute/Attribute/AnyAttribute.swift +++ b/Sources/OpenGraph/Attribute/Attribute/AnyAttribute.swift @@ -33,7 +33,7 @@ extension AnyAttribute { create(offset: offset) } - public func setFlags(_ newFlags: Subgraph.Flags, mask: Subgraph.Flags) { + public func setFlags(_ newFlags: Flags, mask: Flags) { flags = flags.subtracting(mask).union(newFlags.intersection(mask)) } diff --git a/Sources/OpenGraph/Attribute/Attribute/Attribute.swift b/Sources/OpenGraph/Attribute/Attribute/Attribute.swift index a5f832ed..103d19c1 100644 --- a/Sources/OpenGraph/Attribute/Attribute/Attribute.swift +++ b/Sources/OpenGraph/Attribute/Attribute/Attribute.swift @@ -194,12 +194,14 @@ public struct Attribute { // MARK: - Flags - public var flags: Subgraph.Flags { + public typealias Flags = AnyAttribute.Flags + + public var flags: Flags { get { identifier.flags } nonmutating set { identifier.flags = newValue } } - public func setFlags(_ newFlags: Subgraph.Flags, mask: Subgraph.Flags) { + public func setFlags(_ newFlags: Flags, mask: Flags) { identifier.setFlags(newFlags, mask: mask) } } diff --git a/Sources/OpenGraph/Graph/Subgraph.swift b/Sources/OpenGraph/Graph/Subgraph.swift index 8592b880..1724c63f 100644 --- a/Sources/OpenGraph/Graph/Subgraph.swift +++ b/Sources/OpenGraph/Graph/Subgraph.swift @@ -34,7 +34,7 @@ extension Subgraph { #endif } - public func forEach(_ flags: Subgraph.Flags, _ callback: (AnyAttribute) -> Void) { + public func forEach(_ flags: Flags, _ callback: (AnyAttribute) -> Void) { Subgraph.apply(self, flags: flags, callback: callback) } } @@ -62,7 +62,7 @@ extension Subgraph { // FIXME: migrate to use @_extern(c, "xx") in Swift 6 extension Subgraph { @_silgen_name("OGSubgraphApply") - private static func apply(_ graph: Subgraph, flags: Subgraph.Flags, callback: (AnyAttribute) -> Void) + private static func apply(_ graph: Subgraph, flags: Flags, callback: (AnyAttribute) -> Void) @_silgen_name("OGSubgraphAddObserver") private static func addObserver(_ graph: Subgraph, observer: () -> Void) -> Int diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/AnyAttributeCompatibilityTests.swift b/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/AnyAttributeCompatibilityTests.swift index 347e1dab..757dcc7d 100644 --- a/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/AnyAttributeCompatibilityTests.swift +++ b/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/AnyAttributeCompatibilityTests.swift @@ -46,34 +46,36 @@ final class AnyAttributeCompatibilityTests: AttributeTestBase { @Test func setFlags() throws { + typealias Flags = AnyAttribute.Flags + let attribute = AnyAttribute(Attribute(value: 0)) #expect(attribute.flags == []) // Test mask = [] attribute.flags = [] - attribute.setFlags([Subgraph.Flags(rawValue: 1)], mask: []) + attribute.setFlags([Flags(rawValue: 1)], mask: []) #expect(attribute.flags == []) - attribute.setFlags([Subgraph.Flags(rawValue: 2)], mask: []) + attribute.setFlags([Flags(rawValue: 2)], mask: []) #expect(attribute.flags == []) - attribute.setFlags([Subgraph.Flags(rawValue: 1), Subgraph.Flags(rawValue: 4)], mask: []) + attribute.setFlags([Flags(rawValue: 1), Flags(rawValue: 4)], mask: []) #expect(attribute.flags == []) // Test mask attribute.flags = [] - attribute.setFlags([Subgraph.Flags(rawValue: 1)], mask: [Subgraph.Flags(rawValue: 1)]) - #expect(attribute.flags == [Subgraph.Flags(rawValue: 1)]) + attribute.setFlags([Flags(rawValue: 1)], mask: [Flags(rawValue: 1)]) + #expect(attribute.flags == [Flags(rawValue: 1)]) - attribute.setFlags([Subgraph.Flags(rawValue: 2)], mask: [Subgraph.Flags(rawValue: 2)]) - #expect(attribute.flags == [Subgraph.Flags(rawValue: 1), Subgraph.Flags(rawValue: 2)]) + attribute.setFlags([Flags(rawValue: 2)], mask: [Flags(rawValue: 2)]) + #expect(attribute.flags == [Flags(rawValue: 1), Flags(rawValue: 2)]) - attribute.setFlags([Subgraph.Flags(rawValue: 4)], mask: [Subgraph.Flags(rawValue: 1)]) - #expect(attribute.flags == [Subgraph.Flags(rawValue: 2)]) + attribute.setFlags([Flags(rawValue: 4)], mask: [Flags(rawValue: 1)]) + #expect(attribute.flags == [Flags(rawValue: 2)]) - attribute.setFlags([Subgraph.Flags(rawValue: 1), Subgraph.Flags(rawValue: 4)], mask: [Subgraph.Flags(rawValue: 1), Subgraph.Flags(rawValue: 2), Subgraph.Flags(rawValue: 4)]) - #expect(attribute.flags == [Subgraph.Flags(rawValue: 1), Subgraph.Flags(rawValue: 4)]) + attribute.setFlags([Flags(rawValue: 1), Flags(rawValue: 4)], mask: [Flags(rawValue: 1), Flags(rawValue: 2), Flags(rawValue: 4)]) + #expect(attribute.flags == [Flags(rawValue: 1), Flags(rawValue: 4)]) } @Test diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/AttributeCompatibilityTests.swift b/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/AttributeCompatibilityTests.swift index ff865da5..86eed2f9 100644 --- a/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/AttributeCompatibilityTests.swift +++ b/Tests/OpenGraphCompatibilityTests/Attribute/Attribute/AttributeCompatibilityTests.swift @@ -75,8 +75,8 @@ final class AttributeCompatibilityTests: AttributeTestBase { @Test func flagSetter() { let attribute = Attribute(value: ()) - attribute.flags = Subgraph.Flags(rawValue: 1) - #expect(attribute.flags == Subgraph.Flags(rawValue: 1)) + attribute.flags = .init(rawValue: 1) + #expect(attribute.flags == .init(rawValue: 1)) } } #endif diff --git a/Tests/OpenGraphCompatibilityTests/Graph/GraphCompatibilityTests.swift b/Tests/OpenGraphCompatibilityTests/Graph/GraphCompatibilityTests.swift index cf67bad3..fbb5632f 100644 --- a/Tests/OpenGraphCompatibilityTests/Graph/GraphCompatibilityTests.swift +++ b/Tests/OpenGraphCompatibilityTests/Graph/GraphCompatibilityTests.swift @@ -5,6 +5,7 @@ import Testing import Foundation +@MainActor struct GraphCompatibilityTests { @Test func graphCreate() throws {