Files
lightgui_rust/tools
cnmcdee 8178513e4e Extract indicator catalog (250) from src/indicators.h
data/indicators.json: the catalog only - name, formula family (the
defs_* group), plot kind, style, kPalette colour index, default
parameters, and the C++ compute-function name. Formulas are NOT
ported here; the function name lets the later pure-function port
find each formula in the header.

Groups: averages 32, bands 28, momentum 52, volume 20, volatility
43, patterns 66, final 9 = 250. Every referenced function verified
defined in the header (246 distinct fns; 4 shared), all names unique,
all defaults numeric-or-empty, all colour indices inside the
14-entry kPalette. The 3 extra v.push_back hits a naive grep finds
are pivot-point code inside a formula body, not registry entries.
2026-11-29 05:46:20 +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.