From abb7ea4e2b260054fd6d8dd0a4f1170d7c4361f4 Mon Sep 17 00:00:00 2001 From: Caryl Hubin Date: Mon, 8 Dec 2025 20:40:44 +0100 Subject: [PATCH] Updated LVGL defs from 8.x to LVGL 9.x --- gen/lvgl_api_gen_mpy.py | 25 ++++++++++++++----------- gen/python_api_gen_mpy.py | 10 +++++----- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/gen/lvgl_api_gen_mpy.py b/gen/lvgl_api_gen_mpy.py index 6fb91fe7..c79ee4cb 100644 --- a/gen/lvgl_api_gen_mpy.py +++ b/gen/lvgl_api_gen_mpy.py @@ -239,7 +239,7 @@ def get_path(name: str, p: str) -> str: if args.board == 'win': sdl2_include, _ = get_sdl2() cpp_args.append(f'-I"{sdl2_include}"') - + elif sys.platform.startswith('darwin'): cpp_args = ['-std=c11'] cpp_path = 'clang' @@ -583,8 +583,8 @@ def is_struct(type): gen = c_generator.CGenerator() ast = pycparser.parse_file( - args.input[0], - use_cpp=True, + args.input[0], + use_cpp=True, cpp_path=cpp_path, cpp_args=cpp_args ) @@ -711,7 +711,7 @@ def my_excepthook(exc_type, exc_value, tb): # # check if it's found in `structs_without_typedef`. It actually has the typedef. Replace type with it. # if typedef.type.name in structs_without_typedef: # typedef.type = structs_without_typedef[struct_name] -# +# # structs = collections.OrderedDict((typedef.declname, typedef.type) for typedef in struct_typedefs if typedef.declname and typedef.type.decls) # and not lv_base_obj_pattern.match(typedef.declname)) structs.update(structs_without_typedef) # This is for struct without typedef explicit_structs = collections.OrderedDict((typedef.type.name, typedef.declname) for typedef in struct_typedefs if typedef.type.name) # and not lv_base_obj_pattern.match(typedef.type.name)) @@ -1161,6 +1161,9 @@ def register_int_ptr_type(convertor, *types): # Emit Header # +if 'src/core/lv_global.h' not in args.input: + args.input.append('src/core/lv_global.h') + print (""" /* * Auto-Generated file, DO NOT EDIT! @@ -1236,7 +1239,7 @@ def register_int_ptr_type(convertor, *types): #define GENMPY_UNUSED #endif // __GNUC__ #endif // GENMPY_UNUSED - + // Custom function mp object typedef mp_obj_t (*mp_fun_ptr_var_t)(size_t n, const mp_obj_t *, void *ptr); @@ -1398,9 +1401,9 @@ def register_int_ptr_type(convertor, *types): static void mp_lv_delete_cb(lv_event_t * e) { - LV_OBJ_T *lv_obj = e->current_target; - if (lv_obj){ - mp_lv_obj_t *self = lv_obj->user_data; + lv_obj_t *obj = (lv_obj_t *)lv_event_get_current_target(e); + if (obj){ + mp_lv_obj_t *self = lv_obj_get_user_data(obj); if (self) { self->lv_obj = NULL; } @@ -1410,7 +1413,7 @@ def register_int_ptr_type(convertor, *types): static inline mp_obj_t lv_to_mp(LV_OBJ_T *lv_obj) { if (lv_obj == NULL) return mp_const_none; - mp_lv_obj_t *self = (mp_lv_obj_t*)lv_obj->user_data; + mp_lv_obj_t *self = (mp_lv_obj_t*)lv_obj_get_user_data(lv_obj); if (!self) { // Create the MP object @@ -1421,7 +1424,7 @@ def register_int_ptr_type(convertor, *types): }; // Register the Python object in user_data - lv_obj->user_data = self; + lv_obj_set_user_data(lv_obj, self); // Register a "Delete" event callback lv_obj_add_event_cb(lv_obj, mp_lv_delete_cb, LV_EVENT_DELETE, NULL); @@ -3603,7 +3606,7 @@ def _iter_metadata(d, indent=0): import stub_gen - stub_gen.run(args.metadata) + stub_gen.run(args.metadata, '') stdout.close() diff --git a/gen/python_api_gen_mpy.py b/gen/python_api_gen_mpy.py index a56ab49a..2103fda0 100644 --- a/gen/python_api_gen_mpy.py +++ b/gen/python_api_gen_mpy.py @@ -1513,9 +1513,9 @@ def register_int_ptr_type(convertor, *types): static void mp_lv_delete_cb(lv_event_t * e) { - LV_OBJ_T *lv_obj = e->current_target; - if (lv_obj){ - mp_lv_obj_t *self = lv_obj->user_data; + lv_obj_t *obj = (lv_obj_t *)lv_event_get_current_target(e); + if (obj){ + mp_lv_obj_t *self = lv_obj_get_user_data(obj); if (self) { self->lv_obj = NULL; } @@ -1525,7 +1525,7 @@ def register_int_ptr_type(convertor, *types): static mp_obj_t lv_to_mp(LV_OBJ_T *lv_obj) { if (lv_obj == NULL) return mp_const_none; - mp_lv_obj_t *self = (mp_lv_obj_t*)lv_obj->user_data; + mp_lv_obj_t *self = (mp_lv_obj_t*)lv_obj_get_user_data(lv_obj); if (!self) { // Find the object type @@ -1548,7 +1548,7 @@ def register_int_ptr_type(convertor, *types): }; // Register the Python object in user_data - lv_obj->user_data = self; + lv_obj_set_user_data(lv_obj, self); // Register a "Delete" event callback lv_obj_add_event_cb(lv_obj, mp_lv_delete_cb, LV_EVENT_DELETE, NULL);