The mutable storage that Constructors and Deconstructors read and write: a byte area for primitive values and an object area for references. A value's position is a RegisterOffset: the getters and setters for primitives use its byte part as the index into the byte area, and getObject and setObject use its object part as the index into the object area. Primitives are stored as raw little-endian bytes, without boxing.
Registers(usedRegisters) allocates both areas at the sizes that usedRegisters gives. The setters grow an area when a value does not fit. The getters never grow an area: a position must be inside an area before it is read, and on the JVM reading beyond an area throws an IndexOutOfBoundsException. A position that was allocated but never written reads as 0, false or null.
A Registers is not thread-safe. The JSON reader and writer each keep one as a stack of record frames, so the JSON codec does not allocate registers for each record.
import zio.blocks.schema.binding._
val registers = Registers(RegisterOffset(objects = 1, ints = 1))
registers.setObject(RegisterOffset.Zero, "Zionomicon")
registers.setInt(RegisterOffset(objects = 1), 2021)
val title = registers.getObject(RegisterOffset.Zero) // "Zionomicon"
val year = registers.getInt(RegisterOffset(objects = 1)) // 2021
Attributes
- See also
- Companion
- object
- Source
- Registers.scala
- Graph
-
- Supertypes
Members list
Value members
Concrete methods
Sets the object slots from 0 up to, but not including, the object slot of offset to null, so this instance no longer holds those references. The byte area is not changed.
Sets the object slots from 0 up to, but not including, the object slot of offset to null, so this instance no longer holds those references. The byte area is not changed.
Attributes
- Source
- Registers.scala
Reads the Boolean at the byte position of offset: true for any byte other than 0.
Reads the Boolean at the byte position of offset: true for any byte other than 0.
Attributes
- Source
- Registers.scala
Reads the Byte at the byte position of offset.
Reads the Char at the byte position of offset.
Reads the Double at the byte position of offset.
Reads the Float at the byte position of offset.
Reads the Int at the byte position of offset.
Reads the Long at the byte position of offset.
Reads the reference in the object slot of offset.
Reads the Short at the byte position of offset.
Writes value at the byte position of offset, as 1 for true and 0 for false, and grows the byte area first when it is too small.
Writes value at the byte position of offset, as 1 for true and 0 for false, and grows the byte area first when it is too small.
Attributes
- Source
- Registers.scala
Writes value as a Byte at the byte position of offset, taking 1 byte, and grows the byte area first when it is too small.
Writes value as a Byte at the byte position of offset, taking 1 byte, and grows the byte area first when it is too small.
Attributes
- Source
- Registers.scala
Writes value as a Char at the byte position of offset, taking 2 bytes, and grows the byte area first when it is too small.
Writes value as a Char at the byte position of offset, taking 2 bytes, and grows the byte area first when it is too small.
Attributes
- Source
- Registers.scala
Writes value as a Double at the byte position of offset, taking 8 bytes, and grows the byte area first when it is too small.
Writes value as a Double at the byte position of offset, taking 8 bytes, and grows the byte area first when it is too small.
Attributes
- Source
- Registers.scala
Writes value as a Float at the byte position of offset, taking 4 bytes, and grows the byte area first when it is too small.
Writes value as a Float at the byte position of offset, taking 4 bytes, and grows the byte area first when it is too small.
Attributes
- Source
- Registers.scala
Writes value as an Int at the byte position of offset, taking 4 bytes, and grows the byte area first when it is too small.
Writes value as an Int at the byte position of offset, taking 4 bytes, and grows the byte area first when it is too small.
Attributes
- Source
- Registers.scala
Writes value as a Long at the byte position of offset, taking 8 bytes, and grows the byte area first when it is too small.
Writes value as a Long at the byte position of offset, taking 8 bytes, and grows the byte area first when it is too small.
Attributes
- Source
- Registers.scala
Writes value in the object slot of offset, and grows the object area first when it is too small.
Writes value in the object slot of offset, and grows the object area first when it is too small.
Attributes
- Source
- Registers.scala
Copies all of registers into this instance at offset: its whole byte area to the byte position of offset and its whole object area to the object slot of offset, growing the areas here as needed. The whole areas are copied, including any space they grew to, not only the part that was written.
Copies all of registers into this instance at offset: its whole byte area to the byte position of offset and its whole object area to the object slot of offset, growing the areas here as needed. The whole areas are copied, including any space they grew to, not only the part that was written.
Attributes
- Source
- Registers.scala
Writes value as a Short at the byte position of offset, taking 2 bytes, and grows the byte area first when it is too small.
Writes value as a Short at the byte position of offset, taking 2 bytes, and grows the byte area first when it is too small.
Attributes
- Source
- Registers.scala