Files
lightgui_rust/tools
cnmcdee a98d24d495 Phase 4: generator emits Stock/Instrumentation props (lightgui-gen)
Mirrors the C generator: a generic Phase 4 loop driven by PHASE4_CAPS
(caps_rs mode of tools/gen_phase4_props.py) emits one setter call per
Inspector-table prop the widget actually has, with the arg form from
the table kind (set_value(double) for gauges, set_value("...") for Seg
displays). Pairs are emitted together (minimum/maximum -> set_range,
y-min/y-max -> set_y_range, set_anchors3 when all six anchor
components are present, else one set_anchor per complete anchor). The
StockChart branch keeps only the NOTE for data-file/indicators/
drawings/compare-files/scale-mode; its up/down colours now come from
the generic loop. The common background prop falls back to
set_bg_color for Stock/Inst classes that have it (PHASE4_BG_COLOR,
bg_rs mode).
2026-11-30 15:01:38 +00:00
..

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 547 widgets: name, family, section, default size, header path
extract_palette.py src/xframe_palette.h, src/model.h, data/registry.json data/palette.json 583 palette entries: 36 LightGUI + 547 XFrame
extract_props.py src/props.h, src/model.h data/props.json 6 PropKinds, 9 enum tables, 35 per-type tables (99 props), common props
extract_events.py src/events.h, src/model.h data/events.json 10 EventKinds, 27 per-type tables (32 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 36 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 36 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 eb0b5fc)

  • Widgets: 547 — families Gtk 102, Ind 250, Inst 66, Stock 37, T 90, X 2. (The survey's Stock 38 / Inst 67 counted the shared non-widget headers StockData.h / InstData.h; the X family — XGraph, XSpreadsheet — was omitted from its family table.)
  • 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 4, Stock Market 287, Instrumentation 66.
  • Palette: 583 = 36 LightGUI + 547 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.