Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitec19858

Browse files
Adjust binding code generator to fix UnicodeError
This change addresses a UnicodeError in the MicroPython-LVGL binding generatorby explicitly handling `char *` arguments in `build_callback_func_arg`.Previously, the function relied on the `lv_to_mp` dictionary for all typeconversions, which could lead to incorrect or missing converters for `char *`,causing encoding issues. Now, `char *` arguments are assigned the `ptr_to_mp`converter directly, ensuring proper conversion to MicroPython string objects.Additionally, the initial type extraction preserves qualifiers(`remove_quals=False`) to improve type handling accuracy, while maintainingcompatibility for non-`char *` types by stripping qualifiers in the fallbackpath.
1 parenteda82dd commitec19858

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

‎gen/python_api_gen_mpy.py‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2865,12 +2865,18 @@ def create_helper_struct(struct_str):
28652865

28662866

28672867
defbuild_callback_func_arg(arg,index,func,func_name=None):
2868-
arg_type=get_type(arg.type,remove_quals=True)
2868+
arg_type=get_type(arg.type,remove_quals=False)
28692869
cast='(void*)'ifisinstance(arg.type,c_ast.PtrDecl)else''# needed when field is const. casting to void overrides it
2870-
ifarg_typenotinlv_to_mpornotlv_to_mp[arg_type]:
2871-
try_generate_type(arg.type)
2870+
2871+
ifarg_type=='char *':
2872+
converter='ptr_to_mp'
2873+
else:
2874+
arg_type=get_type(arg.type,remove_quals=True)
28722875
ifarg_typenotinlv_to_mpornotlv_to_mp[arg_type]:
2873-
raiseMissingConversionException("Callback: Missing conversion to %s"%arg_type)
2876+
try_generate_type(arg.type)
2877+
ifarg_typenotinlv_to_mpornotlv_to_mp[arg_type]:
2878+
raiseMissingConversionException("Callback: Missing conversion to %s"%arg_type)
2879+
converter=lv_to_mp[arg_type]
28742880

28752881
arg_metadata= {'c_type':arg_type,'py_type':get_py_type(arg_type)}
28762882

@@ -2880,8 +2886,9 @@ def build_callback_func_arg(arg, index, func, func_name = None):
28802886
arg_metadata['name']=None
28812887

28822888
callback_metadata[func_name]['args'].append(arg_metadata)
2889+
28832890
return'mp_args[{i}] = {convertor}({cast}arg{i});'.format(
2884-
convertor=lv_to_mp[arg_type],
2891+
convertor=converter,
28852892
i=index,cast=cast)
28862893

28872894

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp