@@ -47,11 +47,12 @@ def eprint(*args, **kwargs):
47
47
argParser .add_argument ('-I' , '--include' , dest = 'include' , help = 'Preprocesor include path' , metavar = '<Include Path>' , action = 'append' )
48
48
argParser .add_argument ('-D' , '--define' , dest = 'define' , help = 'Define preprocessor macro' , metavar = '<Macro Name>' , action = 'append' )
49
49
argParser .add_argument ('-E' , '--external-preprocessing' , dest = 'ep' , help = 'Prevent preprocessing. Assume input file is already preprocessed' , metavar = '<Preprocessed File>' , action = 'store' )
50
+ argParser .add_argument ('-J' , '--lvgl-json' , dest = 'json' , help = 'Provde a JSON from the LVGL JSON generator for missing information' , metavar = '<JSON file>' , action = 'store' )
50
51
argParser .add_argument ('-M' , '--module_name' , dest = 'module_name' , help = 'Module name' , metavar = '<Module name string>' , action = 'store' )
51
52
argParser .add_argument ('-MP' , '--module_prefix' , dest = 'module_prefix' , help = 'Module prefix that starts every function name' , metavar = '<Prefix string>' , action = 'store' )
52
53
argParser .add_argument ('-MD' , '--metadata' , dest = 'metadata' , help = 'Optional file to emit metadata (introspection)' , metavar = '<MetaData File Name>' , action = 'store' )
53
54
argParser .add_argument ('input' , nargs = '+' )
54
- argParser .set_defaults (include = [], define = [], ep = None , input = [])
55
+ argParser .set_defaults (include = [], define = [], ep = None , json = None , input = [])
55
56
args = argParser .parse_args ()
56
57
57
58
module_name = args .module_name
@@ -210,7 +211,7 @@ def function_prototype(func):
210
211
create_obj_pattern = re .compile ('^{prefix}_(.+)_create$' .format (prefix = module_prefix ))
211
212
lv_method_pattern = re .compile ('^{prefix}_[^_]+_(.+)' .format (prefix = module_prefix ), re .IGNORECASE )
212
213
lv_base_obj_pattern = re .compile ('^(struct _){{0,1}}{prefix}_{base_name}_t( [*]){{0,1}}' .format (prefix = module_prefix , base_name = base_obj_name ))
213
- lv_str_enum_pattern = re .compile ('^_{prefix}_STR_(.+)' .format (prefix = module_prefix .upper ()))
214
+ lv_str_enum_pattern = re .compile ('^_? {prefix}_STR_(.+)' .format (prefix = module_prefix .upper ()))
214
215
lv_callback_type_pattern = re .compile ('({prefix}_){{0,1}}(.+)_cb(_t){{0,1}}' .format (prefix = module_prefix ))
215
216
lv_global_callback_pattern = re .compile ('.*g_cb_t' )
216
217
lv_func_returns_array = re .compile ('.*_array$' )
@@ -294,6 +295,14 @@ def is_struct(type):
294
295
gen = c_generator .CGenerator ()
295
296
ast = parser .parse (s , filename = '<none>' )
296
297
298
+ if args .json is not None :
299
+ with open (args .json , "r" ) as f :
300
+ lvgl_json = json .load (f )
301
+ if not lvgl_json :
302
+ # if the json is an empty dictionary
303
+ lvgl_json = None
304
+ else :
305
+ lvgl_json = None
297
306
298
307
# *************** Fix ***********************************
299
308
# this is a fix for structures not getting populated properly from
@@ -1860,6 +1869,10 @@ def get_user_data(func, func_name = None, containing_struct = None, containing_s
1860
1869
user_data = 'user_data'
1861
1870
user_data_found = user_data in [decl .name for decl in flatten_struct_decls ]
1862
1871
# print('/* --> callback: user_data=%s user_data_found=%s containing_struct=%s */' % (user_data, user_data_found, containing_struct))
1872
+ if not user_data_found and lvgl_json is not None :
1873
+ containing_struct_j = next ((struct for struct in lvgl_json ["structures" ] if struct ["name" ] == struct_arg_type_name ), None )
1874
+ if containing_struct_j is not None :
1875
+ user_data_found = any (user_data == field ["name" ] for field in containing_struct_j ["fields" ])
1863
1876
return (user_data if user_data_found else None ), * get_user_data_accessors (containing_struct , containing_struct_name )
1864
1877
1865
1878
#
0 commit comments