Advanced Usage Of Blocks
This section describes how Block conversion methods are selected and how they interact with variable metadata and transactions.
Model-Driven Method Dispatch
Variable does not hardcode a single getter/setter implementation. Instead, it binds function
pointers to specific Block methods based on the variable model and size constraints.
Typical mapping:
Model |
C++ path |
Python path |
Notes |
|---|---|---|---|
|
|
|
Raw byte semantics. |
|
|
|
Uses byte-array/PyFunc fallback when >64-bit |
|
|
|
Uses byte-array/PyFunc fallback when >64-bit |
|
|
|
Bit-width usually 1. |
|
|
|
Byte payload interpreted as string. |
|
|
|
32-bit float conversion. |
|
|
|
64-bit float conversion. |
|
|
|
Uses binary-point metadata. |
|
(Python-focused) |
|
Delegates conversion to model hooks. |
Conversion vs Transaction
The Block API has two layers:
Conversion layer:
set*/get*methods convert between native types and staged block bytes.Transaction layer:
write/read/startTransaction/checkTransactionmoves staged bytes to and from hardware.
In the C++ Variable API, a typed set call performs both steps:
Conversion into staged bytes via bound
Blockmethod.Block::write()(write + verify/check sequence).
A typed get call similarly performs:
Block::read().Conversion from staged bytes via bound
Blockmethod.
Packing Rules and Variable Layout
The internal setBytes/getBytes helpers are used by all typed methods and apply variable
layout metadata:
Bit offsets and bit sizes (including disjoint fields)
List semantics (
numValues,valueStride)Fast contiguous byte-copy optimization when possible
Byte reversal and bit-order constraints
Because every typed method funnels through these helpers, custom subclasses can extend behavior while preserving the same packing model.