Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance lvgl stubs by reading parameters & typing from lvgl json #124

Closed
Josverl opened this issue Nov 13, 2021 · 1 comment
Closed

Enhance lvgl stubs by reading parameters & typing from lvgl json #124

Josverl opened this issue Nov 13, 2021 · 1 comment
Labels

Comments

@Josverl
Copy link
Owner

Josverl commented Nov 13, 2021

JDSmith discovered something quite interesting: lv_micropython includes a json file with all the calling information, structure members, etc. In my build I found it in mpy-cross/build/lvgl/lv_mpy.json (see comment here).

Seems like an easy target to translate and give type information to parameters, with some type translation (e.g. enum_type -> int, etc.). This could be done either by fully parsing this file, or by adding in parameter information from this file to your generated .pyi's. Here's an example from the json:

                "set_style_text_opa": {
                    "type": "function",
                    "args": [
                        {
                            "type": "lv_obj_t*",
                            "name": "obj"
                        },
                        {
                            "type": "int",
                            "name": "value"
                        },
                        {
                            "type": "int",
                            "name": "selector"
                        }
                    ],
                    "return_type": "NoneType"

vs:

    def set_style_text_opa(self, *args) -> Any: ...

Merging these would end up with something like:

    def set_style_text_opa(self, value: int, selector: int) -> None: ...

Here are the types mentioned (and their frequency), leaving out those ending _t, which are already exposed as classes:

mp_arr_to_lv_calendar_date_t_____: 1
mp_arr_to_lv_img_dsc_t_ptr____: 1
mp_arr_to_lv_btnmatrix_ctrl_t_____: 2
function pointer: 2
mp_arr_to_char_ptr____: 2
mp_arr_to_lv_point_t_____: 5
char*: 69
callback: 110
mp_arr_to_lv_coord_t_____: 138
enum_type: 187
bool: 259
void*: 296
enum_member: 1800
lv_obj_t*: 12191
function: 12476
int: 13429

Copied from : #97

@Josverl Josverl added enhancement New feature or request LVGL labels Nov 13, 2021
@Josverl Josverl changed the title Enhance lvgl stubs by reading parameters from lvgl json Enhance lvgl stubs by reading parameters & typing from lvgl json Nov 13, 2021
@github-actions
Copy link
Contributor

Stale issue message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant