Files
Muse 9e6f882575 Regen data tables from lightgui e474894: kTypes 36->38, EventDef lazarus
- tools/extract_palette.py: kTypes expectation 36->38 (ToggleButton and
  CheckListBox added in C); palette total 598->600
- tools/extract_events.py: parse 6th EventDef field `lazarus` (Flag 10
  Lazarus Object Inspector name); scope table/dispatch parsing to
  events_for() (raw_events_for() has its own `raw` table, deliberately
  excluded); dispatch now tests the normalised key `t`, not `type`
- data/*.json regenerated via `make regen`: registry default sizes per
  the C rule (incl. the 15 monitor widgets' hand-written sizes),
  palette Misc/X order per C xframe_palette.h, props 37 types / 270
  props / 25 enum tables / 35 common props, events 29 types with
  lazarus names; indicators provenance head only
- crates/xframe-common: palette asserts 598->600, LightGUI 36->38
- crates/xframe-widgets: *_gen.rs regenerated; gen_data.py opt_f now
  emits float literals for Option<f64> lo/hi (pre-existing latent bug:
  running it on the old data also emitted Some(0)); stale eb0b5fc /
  547 / 9 / 35 / 27 counts updated to e474894 / 562 / 25 / 37 / 29

make check: all 5 tables OK. cargo build warning-free. cargo test
--workspace --no-fail-fast: all suites green except 5 pre-existing
environmental failures, verified identical on HEAD: lightgui-debug
console (37) + gtk (7) need /usr/bin/gdb (not installed on dallas),
lightgui-support font/theme need a display (gtk::init fails), and
lightgui-gen fixtures is stale vs the Task 4 event routing in gen.rs.
2026-12-05 19:20:00 +00:00

3.6 KiB

tools/ — data extraction from the C++ sources

The widget catalog is DATA, not hand-written Rust. These Python scripts read the C++ sources in /opt/lightgui (read-only) and generate the JSON tables under data/ that the Rust port builds from. Python is tooling here, not the product.

Regenerate / verify

make regen   # re-run every extractor, rewriting data/*.json
make check   # re-derive every table from the C++ sources; exit 1 on drift

make check requires all five tables to exist (the full state). While landing the tables one piece at a time, check one table instead:

make check-registry | check-palette | check-props | check-events | check-indicators

LIGHTGUI_SRC overrides the C source location (default /opt/lightgui).

Extractors

Script Source(s) Output Contents
extract_registry.py widgets/common/registry.h, widgets/components/, widgets/tools/sections.py, widgets/tools/gen_registry.py data/registry.json 562 widgets: name, family, section, default size, header path
extract_palette.py src/xframe_palette.h, src/model.h, data/registry.json data/palette.json 600 palette entries: 38 LightGUI + 562 XFrame
extract_props.py src/props.h, src/model.h data/props.json 6 PropKinds, 25 enum tables, 37 per-type tables (270 props), 35 common props
extract_events.py src/events.h, src/model.h data/events.json 10 EventKinds, 29 per-type tables (34 events), 9 no-events notes
extract_indicators.py src/indicators.h data/indicators.json 250 indicator catalog entries (name, group, plot kind, style, colour, defaults, function)

common.py holds the shared C++ parsing helpers (braced-initializer splitting, string literals, provenance stamping) and parse_ktypes() for the 38 LightGUI types in src/model.h. extract_all.py runs the five extractors in dependency order. check.py re-derives each table fresh and deep-compares it against the committed JSON.

Guarantees

  • No hand edits. Every generated file carries a _provenance block (source repo + HEAD, source files, regenerating command). Regeneration is byte-identical unless a source changed (no timestamps).
  • Three-way cross-checks. The registry extractor derives the same numbers from registry.h, the on-disk component directories, sections.py, and the default_size() rule, and fails if they disagree. The palette extractor verifies every entry against the registry (name set, index, section). Props/events verify full coverage of the 38 kTypes keys. Indicators verify every referenced compute function is defined in the header.
  • Counts are derived, never hard-coded. The scripts fail loudly on any mismatch instead of warning.

Re-derived counts (lightgui e474894)

  • Widgets: 562 — families Gtk 102, Ind 250, Inst 66, Stock 37, T 90, X 17. (The survey's Stock 38 / Inst 67 counted the shared non-widget headers StockData.h / InstData.h; the X family was 2 at survey time — XGraph, XSpreadsheet — and is 17 now with the 15 monitor widgets.)
  • Sections: 11 — Windows & Dialogs 28, Containers & Layout 34, Buttons 24, Display 33, Text & Entry 28, Choosers 10, Views & Lists 17, Menus & Toolbars 16, Misc / X 19, Stock Market 287, Instrumentation 66.
  • Palette: 600 = 38 LightGUI + 562 XFrame.
  • PropKinds: 6. EventKinds: 10, not 11 as the survey stated (Simple, SwitchPage, RowActivated, RowSelected, BufferChanged, DeleteEvent, Draw, ItemClicked, ItemActivate, CellChanged).
  • Indicators: 250 — averages 32, bands 28, momentum 52, volume 20, volatility 43, patterns 66, final 9.