Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions gen/lvgl_api_gen_mpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
)
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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!
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Copy link
Author

@carylhubin carylhubin Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that this macro is used at the top of the files (lvgl + python):

#define LV_OBJ_T {obj_type}

typedef struct mp_lv_obj_type_t {
    const lv_obj_class_t *lv_obj_class;
    const mp_obj_type_t *mp_obj_type;
} mp_lv_obj_type_t;

I was wondering if it’s still necessary.

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;
}
Expand All @@ -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
Expand All @@ -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);
Expand Down Expand Up @@ -3603,7 +3606,7 @@ def _iter_metadata(d, indent=0):

import stub_gen

stub_gen.run(args.metadata)
stub_gen.run(args.metadata, '')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inside gen/stub_gen.py, function def run(json_path, lvgl_api_json_path):,
argument lvgl_api_json_path is currently unused.

Is this still a work in progress?


stdout.close()

10 changes: 5 additions & 5 deletions gen/python_api_gen_mpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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
Expand All @@ -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);
Expand Down