This repository was archived by the owner on Oct 30, 2026. It is now read-only.
Repository navigation
Struct array fields read as live views and check assignments - #45
Merged
Merged
Conversation
draw_triangle_dsc_t.p, grad_dsc_t.stops and the other struct-array fields now index, write through and take len() on every interpreter. MicroPython returned a list of copies, so writes were lost; CPython returned a Blob, and assigning a list memcpy'd from NULL. Whole-array assignment takes exactly N structs or dicts, or a buffer of the array's size, and otherwise raises and leaves the field unchanged. Fixes #38.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #38.
Fixed-size struct arrays inside a struct now read as a live view, on both runtimes. Examples are
draw_triangle_dsc_t.p,grad_dsc_t.stops,inv_areasandrecognizers. Before, MicroPython handed back a copy, so item writes were lost. CPython handed back an opaqueBlobwith no length.You can index the view, take its
len(), iterate over it, and write an element by attribute, by struct or by dict. You can also assign the whole field from a list of exactly N items, or from a buffer of exactly the field's size. A wrong length or a bad item raises, and the field is left unchanged. An index past the end raisesIndexError. A view keeps its owner alive acrossgc.collect().The new smoke test
test_struct_array_fieldsfailed on main before this change:struct array item writes were lost: [(0.0,0.0)...]object of type 'lvgl.Blob' has no len()With this change it passes on MicroPython and CPython locally, and lvgl-python's unittests pass. pytest (107) passes and
regenerate_all.sh --checkmatches.