Repository navigation
CPython binds struct methods that take the struct by value - #49
Merged
Merged
Conversation
A struct method was bound only when its first argument was a pointer to the struct. So lv_color_brightness(lv_color_t c) and the other by-value methods were generated but never added to a method table, and weren't module functions either. They're now methods, as on MicroPython.
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 #46. #48 has merged, so this is based on main.
On CPython, a struct method is now bound when its first argument is the struct by value, as on MicroPython. Before, it was bound only when that argument was a pointer to the struct. So
lv_color_brightness(lv_color_t c)and the rest were generated but never reachable, as methods or as module functions.All 21 methods listed in #46 are now bound on CPython. A by-value method gets a copy of its struct, so calling it never changes the struct.
area_t.diffwas the other case: its first parameter is an array (lv_area_t res_p[]). It's now bound the way MicroPython binds it, as a static method that takes all three arguments.The MicroPython and CircuitPython outputs are unchanged.
The new smoke test
test_struct_methods_by_valuecallsto_u32,eq,brightness,lightenandto_32, and checks that the other methods exist. Before this change, CPython failed it with'lvgl.lv_color_t' object has no attribute 'to_u32', and MicroPython passed it. With this change it passes on both locally, along with the rest of the smoke test and lvgl-python's unittests. pytest (109) passes andregenerate_all.sh --checkmatches.