Open Seelengrab opened 1 year ago
Currently, const-per-field annotations are not allowed by the interface, but it would be nice to support this.
const
The way this would be implemented is by allowing the annotation through here:
https://github.com/Seelengrab/FieldFlags.jl/blob/6267ca5c18ab98853f57cd1a4d2224923cccb0a3/src/FieldFlags.jl#L154-L165
as well as simply not generating the various setindex! branches here:
setindex!
https://github.com/Seelengrab/FieldFlags.jl/blob/6267ca5c18ab98853f57cd1a4d2224923cccb0a3/src/FieldFlags.jl#L239-L256
Annotating a field with const currently doesn't error, but the field is ignored entirely, so adding this shouldn't break anything:
julia> @bitfield mutable struct Foo const a:2 b:3 end julia> methods(Foo) # 3 methods for type constructor: [1] Foo() @ none:0 [2] Foo(t::Foo_fields) @ none:0 [3] Foo(b::Union{Bool, Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8}) @ none:0
Currently,
const
-per-field annotations are not allowed by the interface, but it would be nice to support this.The way this would be implemented is by allowing the annotation through here:
https://github.com/Seelengrab/FieldFlags.jl/blob/6267ca5c18ab98853f57cd1a4d2224923cccb0a3/src/FieldFlags.jl#L154-L165
as well as simply not generating the various
setindex!
branches here:https://github.com/Seelengrab/FieldFlags.jl/blob/6267ca5c18ab98853f57cd1a4d2224923cccb0a3/src/FieldFlags.jl#L239-L256
Annotating a field with
const
currently doesn't error, but the field is ignored entirely, so adding this shouldn't break anything: