Repository navigation
line.set_points takes a list of points or a packed buffer on every interpreter - #44
Merged
Merged
Conversation
CPython lowered a const struct array to a raw pointer, so a list was refused; it now converts a list or tuple of structs or dicts into a C array, retained on the widget because LVGL keeps the pointer. MicroPython iterated a bytearray as ints; bytes, bytearray and memoryview now pass through as the C array. Fixes #37.
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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 #37.
line.set_points(points, n)now takes the same arguments on MicroPython, CircuitPython and CPython: a list or tuple of points (point_precise_tstructs or dicts), or a packed buffer.const T name[]struct-array parameter to a raw pointer, so a list was refused. It now converts a list or tuple into a C array. Because LVGL keeps the pointer (lv_line_set_pointsnever copies), the array, or the buffer you passed, is retained on the widget under a per-function key, the same way string-array arguments already are. A repeat call releases the previous one. This also applies toindev.set_button_pointsand tograd_init_stops's colours.Non-const struct arrays such as
lv_obj_transform_point_array, which LVGL writes into, keep the buffer-only lowering on CPython, because a copied list would silently drop those writes.Test
A new smoke case,
test_line_points_list_and_buffer, draws the same line from a list of dicts, a list of structs, a tuple and a packed buffer. It collects garbage before layout, checks that all four give the same size, and checks that a bad item still raises.Before this change:
line.set_points rejected a list of dicts: TypeError: Cannot convert 'list' to pointerline.set_points rejected a packed buffer: SyntaxError: Can't convert int to lv_point_precise_t!After this change, built locally the way the Linux integration job builds them, the full smoke run passes on:
The generator tests (107) and
regenerate_all.sh --checkpass. CircuitPython is left to the integration job.