Skip to content

Commit

Permalink
Fix Attribute.flags setter issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle-Ye committed May 5, 2024
1 parent 241ff5c commit 3a523c0
Show file tree
Hide file tree
Showing 15 changed files with 59 additions and 18 deletions.
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

0 comments on commit 3a523c0

Please sign in to comment.