Skip to content

Fix Attribute.flags setter issue #72

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 5, 2024
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 @@ -15,6 +15,8 @@ typedef AG_OPTIONS(uint32_t, AGAttributeFlags) {
AGAttributeFlagsActive = 1 << 0,
AGAttributeFlagsRemovable = 1 << 1,
AGAttributeFlagsInvalidatable = 1 << 2,

AGAttributeFlagsMask = 0xFF,
};

#endif /* AGAttributeFlags_h */
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public struct Attribute<Value> {
unsafeAddress
nonmutating set
}
public var projectedValue: AttributeGraph.Attribute<Value> { get _modify }
public var projectedValue: AttributeGraph.Attribute<Value> { get set }

public subscript<Member>(dynamicMember _: Swift.KeyPath<Value, Member>) -> AttributeGraph.Attribute<Member> { get }
public subscript<Member>(keyPath _: Swift.KeyPath<Value, Member>) -> AttributeGraph.Attribute<Member> { get }
Expand Down Expand Up @@ -85,7 +85,10 @@ public struct Attribute<Value> {
public func addInput(_ attribute: AGAttribute, options: AGInputOptions = [], token: Swift.Int)
public func addInput<V>(_ attribute: AttributeGraph.Attribute<V>, options: AGInputOptions = [], token: Int)

public var flags: AGAttributeFlags { get _modify }
public var flags: AGAttributeFlags {
get
nonmutating set
}
public func setFlags(_ newFlags: AGAttributeFlags, mask: AGAttributeFlags)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public struct Attribute<Value> {
unsafeAddress
nonmutating set
}
public var projectedValue: AttributeGraph.Attribute<Value> { get _modify }
public var projectedValue: AttributeGraph.Attribute<Value> { get set }

public subscript<Member>(dynamicMember _: Swift.KeyPath<Value, Member>) -> AttributeGraph.Attribute<Member> { get }
public subscript<Member>(keyPath _: Swift.KeyPath<Value, Member>) -> AttributeGraph.Attribute<Member> { get }
Expand Down Expand Up @@ -85,7 +85,10 @@ public struct Attribute<Value> {
public func addInput(_ attribute: AGAttribute, options: AGInputOptions = [], token: Swift.Int)
public func addInput<V>(_ attribute: AttributeGraph.Attribute<V>, options: AGInputOptions = [], token: Int)

public var flags: AGAttributeFlags { get _modify }
public var flags: AGAttributeFlags {
get
nonmutating set
}
public func setFlags(_ newFlags: AGAttributeFlags, mask: AGAttributeFlags)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ typedef AG_OPTIONS(uint32_t, AGAttributeFlags) {
AGAttributeFlagsActive = 1 << 0,
AGAttributeFlagsRemovable = 1 << 1,
AGAttributeFlagsInvalidatable = 1 << 2,

AGAttributeFlagsMask = 0xFF,
};

#endif /* AGAttributeFlags_h */
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public struct Attribute<Value> {
unsafeAddress
nonmutating set
}
public var projectedValue: AttributeGraph.Attribute<Value> { get _modify }
public var projectedValue: AttributeGraph.Attribute<Value> { get set }

public subscript<Member>(dynamicMember _: Swift.KeyPath<Value, Member>) -> AttributeGraph.Attribute<Member> { get }
public subscript<Member>(keyPath _: Swift.KeyPath<Value, Member>) -> AttributeGraph.Attribute<Member> { get }
Expand Down Expand Up @@ -85,7 +85,10 @@ public struct Attribute<Value> {
public func addInput(_ attribute: AGAttribute, options: AGInputOptions = [], token: Swift.Int)
public func addInput<V>(_ attribute: AttributeGraph.Attribute<V>, options: AGInputOptions = [], token: Int)

public var flags: AGAttributeFlags { get _modify }
public var flags: AGAttributeFlags {
get
nonmutating set
}
public func setFlags(_ newFlags: AGAttributeFlags, mask: AGAttributeFlags)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public struct Attribute<Value> {
unsafeAddress
nonmutating set
}
public var projectedValue: AttributeGraph.Attribute<Value> { get _modify }
public var projectedValue: AttributeGraph.Attribute<Value> { get set }

public subscript<Member>(dynamicMember _: Swift.KeyPath<Value, Member>) -> AttributeGraph.Attribute<Member> { get }
public subscript<Member>(keyPath _: Swift.KeyPath<Value, Member>) -> AttributeGraph.Attribute<Member> { get }
Expand Down Expand Up @@ -85,7 +85,10 @@ public struct Attribute<Value> {
public func addInput(_ attribute: AGAttribute, options: AGInputOptions = [], token: Swift.Int)
public func addInput<V>(_ attribute: AttributeGraph.Attribute<V>, options: AGInputOptions = [], token: Int)

public var flags: AGAttributeFlags { get _modify }
public var flags: AGAttributeFlags {
get
nonmutating set
}
public func setFlags(_ newFlags: AGAttributeFlags, mask: AGAttributeFlags)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ typedef AG_OPTIONS(uint32_t, AGAttributeFlags) {
AGAttributeFlagsActive = 1 << 0,
AGAttributeFlagsRemovable = 1 << 1,
AGAttributeFlagsInvalidatable = 1 << 2,

AGAttributeFlagsMask = 0xFF,
};

#endif /* AGAttributeFlags_h */
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public struct Attribute<Value> {
unsafeAddress
nonmutating set
}
public var projectedValue: AttributeGraph.Attribute<Value> { get _modify }
public var projectedValue: AttributeGraph.Attribute<Value> { get set }

public subscript<Member>(dynamicMember _: Swift.KeyPath<Value, Member>) -> AttributeGraph.Attribute<Member> { get }
public subscript<Member>(keyPath _: Swift.KeyPath<Value, Member>) -> AttributeGraph.Attribute<Member> { get }
Expand Down Expand Up @@ -85,7 +85,10 @@ public struct Attribute<Value> {
public func addInput(_ attribute: AGAttribute, options: AGInputOptions = [], token: Swift.Int)
public func addInput<V>(_ attribute: AttributeGraph.Attribute<V>, options: AGInputOptions = [], token: Int)

public var flags: AGAttributeFlags { get _modify }
public var flags: AGAttributeFlags {
get
nonmutating set
}
public func setFlags(_ newFlags: AGAttributeFlags, mask: AGAttributeFlags)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public struct Attribute<Value> {
unsafeAddress
nonmutating set
}
public var projectedValue: AttributeGraph.Attribute<Value> { get _modify }
public var projectedValue: AttributeGraph.Attribute<Value> { get set }

public subscript<Member>(dynamicMember _: Swift.KeyPath<Value, Member>) -> AttributeGraph.Attribute<Member> { get }
public subscript<Member>(keyPath _: Swift.KeyPath<Value, Member>) -> AttributeGraph.Attribute<Member> { get }
Expand Down Expand Up @@ -85,7 +85,10 @@ public struct Attribute<Value> {
public func addInput(_ attribute: AGAttribute, options: AGInputOptions = [], token: Swift.Int)
public func addInput<V>(_ attribute: AttributeGraph.Attribute<V>, options: AGInputOptions = [], token: Int)

public var flags: AGAttributeFlags { get _modify }
public var flags: AGAttributeFlags {
get
nonmutating set
}
public func setFlags(_ newFlags: AGAttributeFlags, mask: AGAttributeFlags)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public struct Attribute<Value> {
unsafeAddress
nonmutating set
}
public var projectedValue: AttributeGraph.Attribute<Value> { get _modify }
public var projectedValue: AttributeGraph.Attribute<Value> { get set }

public subscript<Member>(dynamicMember _: Swift.KeyPath<Value, Member>) -> AttributeGraph.Attribute<Member> { get }
public subscript<Member>(keyPath _: Swift.KeyPath<Value, Member>) -> AttributeGraph.Attribute<Member> { get }
Expand Down Expand Up @@ -85,7 +85,10 @@ public struct Attribute<Value> {
public func addInput(_ attribute: AGAttribute, options: AGInputOptions = [], token: Swift.Int)
public func addInput<V>(_ attribute: AttributeGraph.Attribute<V>, options: AGInputOptions = [], token: Int)

public var flags: AGAttributeFlags { get _modify }
public var flags: AGAttributeFlags {
get
nonmutating set
}
public func setFlags(_ newFlags: AGAttributeFlags, mask: AGAttributeFlags)
}

Expand Down
2 changes: 2 additions & 0 deletions AG/Sources/Headers/AGAttributeFlags.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ typedef AG_OPTIONS(uint32_t, AGAttributeFlags) {
AGAttributeFlagsActive = 1 << 0,
AGAttributeFlagsRemovable = 1 << 1,
AGAttributeFlagsInvalidatable = 1 << 2,

AGAttributeFlagsMask = 0xFF,
};

#endif /* AGAttributeFlags_h */
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public struct Attribute<Value> {
unsafeAddress
nonmutating set
}
public var projectedValue: AttributeGraph.Attribute<Value> { get _modify }
public var projectedValue: AttributeGraph.Attribute<Value> { get set }

public subscript<Member>(dynamicMember _: Swift.KeyPath<Value, Member>) -> AttributeGraph.Attribute<Member> { get }
public subscript<Member>(keyPath _: Swift.KeyPath<Value, Member>) -> AttributeGraph.Attribute<Member> { get }
Expand Down Expand Up @@ -81,7 +81,10 @@ public struct Attribute<Value> {
public func addInput(_ attribute: AGAttribute, options: AGInputOptions = [], token: Swift.Int)
public func addInput<V>(_ attribute: AttributeGraph.Attribute<V>, options: AGInputOptions = [], token: Int)

public var flags: AGAttributeFlags { get _modify }
public var flags: AGAttributeFlags {
get
nonmutating set
}
public func setFlags(_ newFlags: AGAttributeFlags, mask: AGAttributeFlags)
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/OpenGraph/Attribute/Attribute/Attribute.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public struct Attribute<Value> {

public var projectedValue: Attribute<Value> {
get { self }
_modify { yield &self }
set { self = newValue }
}

// MARK: - dynamicMemberLookup
Expand Down Expand Up @@ -196,7 +196,7 @@ public struct Attribute<Value> {

public var flags: OGAttributeFlags {
get { identifier.flags }
_modify { yield &identifier.flags }
nonmutating set { identifier.flags = newValue }
}

public func setFlags(_ newFlags: OGAttributeFlags, mask: OGAttributeFlags) {
Expand Down
2 changes: 2 additions & 0 deletions Sources/_OpenGraph/Attribute/OGAttributeFlags.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ typedef OG_OPTIONS(uint32_t, OGAttributeFlags) {
OGAttributeFlagsActive = 1 << 0,
OGAttributeFlagsRemovable = 1 << 1,
OGAttributeFlagsInvalidatable = 1 << 2,

OGAttributeFlagsMask = 0xFF,
};

#endif /* OGAttributeFlags_h */
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,12 @@ final class AttributeTests: AttributeTestBase {

}
}

@Test
func flagSetter() {
let attribute = Attribute(value: ())
attribute.flags = .active
#expect(attribute.flags == .active)
}
}
#endif