Skip to content

Releases: mattrberry/bitfield

v0.1.3

27 Oct 07:05
Compare
Choose a tag to compare

Add the ability to lock fields in the bitfield:

Since I've primarily developed this shard for use in my emulator projects where bitfields are typically used to define IO registers, it's typical to have a register where fields may need to be locked in place in a bitfield. That is achievable by simply providing a lock: true argument with the field you want to lock.

class TestLock < BitField(UInt8)
  num top, 3
  num mid, 2, lock: true
  num bot, 3
end

The effect of locking a field is that it will not change when writing to bitfield's #value method. If it needs to be mutated after initialization, it will need to be through the field's specific setter method.

bf = TestLock.new 0x00
bf.top # => 0x0
bf.mid # => 0x0
bf.bot # => 0x0
bf.value = 0xFF
bf.top # => 0x7
bf.mid # => 0x0
bf.bot # => 0x7
bf.value # => 0xE7
bf.mid = 0x3
bf.value # => 0xFF

v0.1.2

20 Oct 05:32
Compare
Choose a tag to compare

First release.