| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
state/ serves the running sketch's State nested: a directory per struct
and per array, a file per value, state/tracker/songs/3/bpm. A read is
the value as get shows it, and a newline; a write is the console's set
with the file's path (control.zig builds `set tracker.songs[3].bpm 90`
and runs it through runLine, so it stops a replay, logs, marks a jump
and notes the line like any set). Numbers, bools and enums are written;
optionals, unions and the like read as `<N bytes>` and refuse writes.
An array of scalars (a vector's lanes, talk.text) is one file of its
values, blank-separated; an array of arrays is a directory of such rows
(grid/1 for grid[1] of a [2][3]i16). So a file is one value or one row,
the run of values one set names, and stays the size of a row however
large the array; and paths keep the State's own shape. An array of
structs is a directory of indices: drat-meout's patterns, 8x16x16x4 of
{pitch, velocity}, are state/tracker/songs/<n>/patterns/<n>/<n>/<n>/
pitch, reached by walking, listed a dimension at a time.
state_files.zig does the walking from a (Layout, bytes) alone: lookup,
readdir, read, the set path and a README line per file, so the save's
newest State and a sketch's defaults can be served the same way. A node
is the layout's first leaf under it, its depth and the element's offset,
with bit 62 set (bit 63 stays the sketch's). A node a reload made stale
is refused, "StateLayoutChangedWalkAgain". fields.setRow sets a row from
its words, all or none, and the console's set takes it: `set talk.text
104 105 0`. The engine keeps names up to 64 bytes (from 28), for long
field names.
Tests: test-control (now also "the State as files" and "a row of
scalars"): 40/40 steps, 9/9 tests. Live, headless, the replay fixture
over plan9port 9p: ls state, read and write dots/buffer/3/kind and the
position vector, a bad value refused as InvalidValue.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
|