Skip to content

Stub struct methods use the runtime names; CPython binds anonymous struct and union fields - #47

Merged
bdbarnett merged 2 commits into
mainfrom
fix/grad-helpers
Oct 27, 2026
Merged

bdbarnett merged 2 commits into
mainfrom
fix/grad-helpers

Conversation

@bdbarnett

@bdbarnett bdbarnett commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #39. #45 has merged, so this is based on main.

The stub named struct methods with their struct's prefix, as in grad_dsc_t.grad_linear_init. Both runtimes bind them without it, as in linear_init. The stub now uses the runtime names. This renames about 75 stub methods, among them cache_t.create, draw_buf_t.align_ex and the grad_dsc_t helpers.

CPython also skipped fields whose type is an anonymous struct or union, so grad_dsc_t.params didn't exist there. It now binds them the way MicroPython does, as nested types such as params.linear, params.radial and params.conical, which you can read and write.

New tests, each failing before this change:

  • pytest test_struct_method_names_match_the_runtime_binding failed with assert 'grad_linear_init' == 'linear_init'.
  • pytest test_generated_struct_method_names_match_the_runtime_binding checks every struct method in api.json against the runtime's naming rule. It failed with a list of mismatches.
  • Smoke test_grad_helpers calls linear_init, radial_init and conical_init, then reads and writes params. On CPython it failed with 'lvgl.lv_grad_dsc_t' object has no attribute 'params'.

With this change, the smoke test passes on MicroPython and CPython locally, and so do lvgl-python's unittests. pytest (109) passes and regenerate_all.sh --check matches.

Some stub methods that take their struct by value are still missing on CPython. That's #46.

…mous struct and union fields

The stub named struct methods with their struct's prefix (grad_dsc_t.grad_linear_init), but both runtimes bind them without it (linear_init). The stub now names them the way the runtimes do.

CPython skipped fields whose type is an anonymous struct or union, so grad_dsc_t.params was missing. It now typedefs them the way MicroPython does.
Base automatically changed from fix/struct-arrays to main October 27, 2026 16:09
@bdbarnett
bdbarnett merged commit b8f7ae0 into main Oct 27, 2026
4 checks passed
@bdbarnett
bdbarnett deleted the fix/grad-helpers branch October 27, 2026 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

grad_dsc_t init helpers and params are in the stub but missing at runtime

1 participant