From d8e297452d8e0896d4733e09b70fdc3e6ce08a55 Mon Sep 17 00:00:00 2001 From: eunhhu Date: Sun, 18 Oct 2026 17:23:37 +0100 Subject: Module format and executor: 027's stage 3, nested stored state: a stored or a transient list's records may hold lists (a message's rows not, nor as a key); such a list's cell holds the value in its items' stored form (PURE_CELL_LIST, held as bytes are: each item's fields in order, 8 bytes a number, bool or i64, a u32le length and bytes a text or a list, a list's in this form again), read into one of the event's lists by ITEM_GET (counted in the event's room) and written from one by LIST_APPEND, LIST_INSERT and ITEM_SET, APPEND_IN reading, appending and writing back (undone with the event): images, the log, undoing, readers' shares and commits hold it as a text's bytes, so nothing new is stored or recovered; a list image's header names its record graph (a list field's items' record by its number, the graph's other records after the fields: a record holds itself through a list), and starting or replacing moves the items of the lists in fields by field name down the graph (PureLayout, pure_list_migrate); an event's lists keep the event's lists' numbers; a view lets go the lists a view before it read in; no FIND joined to a list field's read; pure-run shows a kept list's lists; unit tests (an event changing a number and a stored item's list, the process dying at the tree's four stages and the log's two, failed commits changing nothing; a replacement moving a stored and a transient list's lists, their items' record gaining a field and the board's fields changing places; under ASan and UBSan too) --- core/module-save.h | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'core/module-save.h') diff --git a/core/module-save.h b/core/module-save.h index 5c81504..281854b 100644 --- a/core/module-save.h +++ b/core/module-save.h @@ -74,12 +74,27 @@ uint32_t pure_fields_lay_out(PureField *fields, uint32_t count); PureResult pure_send_recast(const PureField *from, uint32_t from_count, const PureField *to, uint32_t to_count, PureSpan payload, unsigned char **out, size_t *size); -/* A record field's kind in a list, as a stored list names it too (PURE_CELL_...). */ +/* A record field's kind in a list kept past an event, as a stored list names it too (PURE_CELL_...: a list field's + * PURE_CELL_LIST; an event's list holds one of the event's lists' numbers there instead, an integer). */ uint8_t pure_record_kind(const PureModule *, uint32_t field); -/* A list with record's fields, taking from `from` (its fields' names and - * kinds) each field of the same name and kind, or a number, a bool and an - * i64 from each other when the value fits (pure_cell_as), and giving the - * others their defaults (module.c). */ -PureResult pure_list_migrate(PureList **out, const PureList *from, const char *const *names, - const uint8_t *kinds, unsigned count, const PureModule *m, uint32_t record); +/* A record graph as a list kept past an event names it (027's stage 3): its records, from the list's own (0) on in the + * order its list fields first meet them, each its fields' kinds (PURE_CELL_...) and names, and a list field's items' + * record by its number here. A module's graph knows each record's number in the module too. */ +typedef struct { + unsigned records; + struct { + unsigned count; + uint8_t kinds[PURE_RECORD_FIELDS], items[PURE_RECORD_FIELDS]; + char names[PURE_RECORD_FIELDS][PURE_MODULE_NAME]; + } record[PURE_MODULE_RECORDS]; + uint16_t module_record[PURE_MODULE_RECORDS]; +} PureLayout; +void pure_layout_of(const PureModule *, uint32_t record, PureLayout *out); +bool pure_layout_same(const PureLayout *, const PureLayout *); +/* A list with record's fields, taking from `from` (laid out as from_layout's record 0) each field of the same name and + * kind, or a number, a bool and an i64 from each other when the value fits (pure_cell_as), and giving the others their + * defaults (module.c); a list field's values move so too, item by item (kept: a list kept past an event, holding + * them in their stored form, else an event's, holding none yet). */ +PureResult pure_list_migrate(PureList **out, const PureList *from, const PureLayout *from_layout, const PureModule *m, + uint32_t record, bool kept); #endif -- cgit v1.2.3