diff --git a/esp8266/modpyb.c b/esp8266/modpyb.c index 49df418a2c..d40745b8fc 100644 --- a/esp8266/modpyb.c +++ b/esp8266/modpyb.c @@ -155,16 +155,7 @@ STATIC const mp_map_elem_t pyb_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_sync), (mp_obj_t)&pyb_sync_obj }, }; -STATIC const mp_obj_dict_t pyb_module_globals = { - .base = {&mp_type_dict}, - .map = { - .all_keys_are_qstrs = 1, - .table_is_fixed_array = 1, - .used = MP_ARRAY_SIZE(pyb_module_globals_table), - .alloc = MP_ARRAY_SIZE(pyb_module_globals_table), - .table = (mp_map_elem_t*)pyb_module_globals_table, - }, -}; +STATIC MP_DEFINE_CONST_DICT(pyb_module_globals, pyb_module_globals_table); const mp_obj_module_t pyb_module = { .base = { &mp_type_module }, diff --git a/extmod/modubinascii.c b/extmod/modubinascii.c index 8cab7d6781..262d99bc31 100644 --- a/extmod/modubinascii.c +++ b/extmod/modubinascii.c @@ -68,16 +68,7 @@ STATIC const mp_map_elem_t mp_module_binascii_globals_table[] = { // { MP_OBJ_NEW_QSTR(MP_QSTR_b2a_base64), (mp_obj_t)&mod_binascii_b2a_base64_obj }, }; -STATIC const mp_obj_dict_t mp_module_binascii_globals = { - .base = {&mp_type_dict}, - .map = { - .all_keys_are_qstrs = 1, - .table_is_fixed_array = 1, - .used = MP_ARRAY_SIZE(mp_module_binascii_globals_table), - .alloc = MP_ARRAY_SIZE(mp_module_binascii_globals_table), - .table = (mp_map_elem_t*)mp_module_binascii_globals_table, - }, -}; +STATIC MP_DEFINE_CONST_DICT(mp_module_binascii_globals, mp_module_binascii_globals_table); const mp_obj_module_t mp_module_ubinascii = { .base = { &mp_type_module }, diff --git a/extmod/moductypes.c b/extmod/moductypes.c index dc3776f9a6..83cfbbcc57 100644 --- a/extmod/moductypes.c +++ b/extmod/moductypes.c @@ -649,16 +649,7 @@ STATIC const mp_map_elem_t mp_module_uctypes_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_ARRAY), MP_OBJ_NEW_SMALL_INT(TYPE2SMALLINT(ARRAY, AGG_TYPE_BITS)) }, }; -STATIC const mp_obj_dict_t mp_module_uctypes_globals = { - .base = {&mp_type_dict}, - .map = { - .all_keys_are_qstrs = 1, - .table_is_fixed_array = 1, - .used = MP_ARRAY_SIZE(mp_module_uctypes_globals_table), - .alloc = MP_ARRAY_SIZE(mp_module_uctypes_globals_table), - .table = (mp_map_elem_t*)mp_module_uctypes_globals_table, - }, -}; +STATIC MP_DEFINE_CONST_DICT(mp_module_uctypes_globals, mp_module_uctypes_globals_table); const mp_obj_module_t mp_module_uctypes = { .base = { &mp_type_module }, diff --git a/extmod/moduhashlib.c b/extmod/moduhashlib.c index 8c6b34a4ca..1c2e76b042 100644 --- a/extmod/moduhashlib.c +++ b/extmod/moduhashlib.c @@ -105,16 +105,7 @@ STATIC const mp_map_elem_t mp_module_hashlib_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_sha256), (mp_obj_t)&sha256_type }, }; -STATIC const mp_obj_dict_t mp_module_hashlib_globals = { - .base = {&mp_type_dict}, - .map = { - .all_keys_are_qstrs = 1, - .table_is_fixed_array = 1, - .used = MP_ARRAY_SIZE(mp_module_hashlib_globals_table), - .alloc = MP_ARRAY_SIZE(mp_module_hashlib_globals_table), - .table = (mp_map_elem_t*)mp_module_hashlib_globals_table, - }, -}; +STATIC MP_DEFINE_CONST_DICT(mp_module_hashlib_globals, mp_module_hashlib_globals_table); const mp_obj_module_t mp_module_uhashlib = { .base = { &mp_type_module }, diff --git a/extmod/moduheapq.c b/extmod/moduheapq.c index c2db3b6211..8c8cd8345f 100644 --- a/extmod/moduheapq.c +++ b/extmod/moduheapq.c @@ -118,16 +118,7 @@ STATIC const mp_map_elem_t mp_module_uheapq_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_heapify), (mp_obj_t)&mod_uheapq_heapify_obj }, }; -STATIC const mp_obj_dict_t mp_module_uheapq_globals = { - .base = {&mp_type_dict}, - .map = { - .all_keys_are_qstrs = 1, - .table_is_fixed_array = 1, - .used = MP_ARRAY_SIZE(mp_module_uheapq_globals_table), - .alloc = MP_ARRAY_SIZE(mp_module_uheapq_globals_table), - .table = (mp_map_elem_t*)mp_module_uheapq_globals_table, - }, -}; +STATIC MP_DEFINE_CONST_DICT(mp_module_uheapq_globals, mp_module_uheapq_globals_table); const mp_obj_module_t mp_module_uheapq = { .base = { &mp_type_module }, diff --git a/extmod/modujson.c b/extmod/modujson.c index 4bfadf193e..f1a5eda629 100644 --- a/extmod/modujson.c +++ b/extmod/modujson.c @@ -259,16 +259,7 @@ STATIC const mp_map_elem_t mp_module_ujson_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_loads), (mp_obj_t)&mod_ujson_loads_obj }, }; -STATIC const mp_obj_dict_t mp_module_ujson_globals = { - .base = {&mp_type_dict}, - .map = { - .all_keys_are_qstrs = 1, - .table_is_fixed_array = 1, - .used = MP_ARRAY_SIZE(mp_module_ujson_globals_table), - .alloc = MP_ARRAY_SIZE(mp_module_ujson_globals_table), - .table = (mp_map_elem_t*)mp_module_ujson_globals_table, - }, -}; +STATIC MP_DEFINE_CONST_DICT(mp_module_ujson_globals, mp_module_ujson_globals_table); const mp_obj_module_t mp_module_ujson = { .base = { &mp_type_module }, diff --git a/extmod/modure.c b/extmod/modure.c index deb3679475..eb010faf90 100644 --- a/extmod/modure.c +++ b/extmod/modure.c @@ -221,16 +221,7 @@ STATIC const mp_map_elem_t mp_module_re_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_DEBUG), MP_OBJ_NEW_SMALL_INT(FLAG_DEBUG) }, }; -STATIC const mp_obj_dict_t mp_module_re_globals = { - .base = {&mp_type_dict}, - .map = { - .all_keys_are_qstrs = 1, - .table_is_fixed_array = 1, - .used = MP_ARRAY_SIZE(mp_module_re_globals_table), - .alloc = MP_ARRAY_SIZE(mp_module_re_globals_table), - .table = (mp_map_elem_t*)mp_module_re_globals_table, - }, -}; +STATIC MP_DEFINE_CONST_DICT(mp_module_re_globals, mp_module_re_globals_table); const mp_obj_module_t mp_module_ure = { .base = { &mp_type_module }, diff --git a/extmod/moduzlib.c b/extmod/moduzlib.c index 3659d518c9..751b064d37 100644 --- a/extmod/moduzlib.c +++ b/extmod/moduzlib.c @@ -87,16 +87,7 @@ STATIC const mp_map_elem_t mp_module_uzlib_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_decompress), (mp_obj_t)&mod_uzlib_decompress_obj }, }; -STATIC const mp_obj_dict_t mp_module_uzlib_globals = { - .base = {&mp_type_dict}, - .map = { - .all_keys_are_qstrs = 1, - .table_is_fixed_array = 1, - .used = MP_ARRAY_SIZE(mp_module_uzlib_globals_table), - .alloc = MP_ARRAY_SIZE(mp_module_uzlib_globals_table), - .table = (mp_map_elem_t*)mp_module_uzlib_globals_table, - }, -}; +STATIC MP_DEFINE_CONST_DICT(mp_module_uzlib_globals, mp_module_uzlib_globals_table); const mp_obj_module_t mp_module_uzlib = { .base = { &mp_type_module }, diff --git a/py/modarray.c b/py/modarray.c index c0fe331643..360fe8a5f1 100644 --- a/py/modarray.c +++ b/py/modarray.c @@ -37,16 +37,7 @@ STATIC const mp_map_elem_t mp_module_array_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_array), (mp_obj_t)&mp_type_array }, }; -STATIC const mp_obj_dict_t mp_module_array_globals = { - .base = {&mp_type_dict}, - .map = { - .all_keys_are_qstrs = 1, - .table_is_fixed_array = 1, - .used = MP_ARRAY_SIZE(mp_module_array_globals_table), - .alloc = MP_ARRAY_SIZE(mp_module_array_globals_table), - .table = (mp_map_elem_t*)mp_module_array_globals_table, - }, -}; +STATIC MP_DEFINE_CONST_DICT(mp_module_array_globals, mp_module_array_globals_table); const mp_obj_module_t mp_module_array = { .base = { &mp_type_module }, diff --git a/py/modcmath.c b/py/modcmath.c index a147a754b8..4cd3a82359 100644 --- a/py/modcmath.c +++ b/py/modcmath.c @@ -162,16 +162,7 @@ STATIC const mp_map_elem_t mp_module_cmath_globals_table[] = { //{ MP_OBJ_NEW_QSTR(MP_QSTR_isnan), (mp_obj_t)&mp_cmath_isnan_obj }, }; -STATIC const mp_obj_dict_t mp_module_cmath_globals = { - .base = {&mp_type_dict}, - .map = { - .all_keys_are_qstrs = 1, - .table_is_fixed_array = 1, - .used = MP_ARRAY_SIZE(mp_module_cmath_globals_table), - .alloc = MP_ARRAY_SIZE(mp_module_cmath_globals_table), - .table = (mp_map_elem_t*)mp_module_cmath_globals_table, - }, -}; +STATIC MP_DEFINE_CONST_DICT(mp_module_cmath_globals, mp_module_cmath_globals_table); const mp_obj_module_t mp_module_cmath = { .base = { &mp_type_module }, diff --git a/py/modcollections.c b/py/modcollections.c index 5cd0b317a1..8035b72d59 100644 --- a/py/modcollections.c +++ b/py/modcollections.c @@ -37,16 +37,7 @@ STATIC const mp_map_elem_t mp_module_collections_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_namedtuple), (mp_obj_t)&mp_namedtuple_obj }, }; -STATIC const mp_obj_dict_t mp_module_collections_globals = { - .base = {&mp_type_dict}, - .map = { - .all_keys_are_qstrs = 1, - .table_is_fixed_array = 1, - .used = MP_ARRAY_SIZE(mp_module_collections_globals_table), - .alloc = MP_ARRAY_SIZE(mp_module_collections_globals_table), - .table = (mp_map_elem_t*)mp_module_collections_globals_table, - }, -}; +STATIC MP_DEFINE_CONST_DICT(mp_module_collections_globals, mp_module_collections_globals_table); const mp_obj_module_t mp_module_collections = { .base = { &mp_type_module }, diff --git a/py/modgc.c b/py/modgc.c index a27ef7eed9..8c9be70688 100644 --- a/py/modgc.c +++ b/py/modgc.c @@ -100,16 +100,7 @@ STATIC const mp_map_elem_t mp_module_gc_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_mem_alloc), (mp_obj_t)&gc_mem_alloc_obj }, }; -STATIC const mp_obj_dict_t mp_module_gc_globals = { - .base = {&mp_type_dict}, - .map = { - .all_keys_are_qstrs = 1, - .table_is_fixed_array = 1, - .used = MP_ARRAY_SIZE(mp_module_gc_globals_table), - .alloc = MP_ARRAY_SIZE(mp_module_gc_globals_table), - .table = (mp_map_elem_t*)mp_module_gc_globals_table, - }, -}; +STATIC MP_DEFINE_CONST_DICT(mp_module_gc_globals, mp_module_gc_globals_table); const mp_obj_module_t mp_module_gc = { .base = { &mp_type_module }, diff --git a/py/modio.c b/py/modio.c index ef3b29b53f..6a273b39b7 100644 --- a/py/modio.c +++ b/py/modio.c @@ -52,16 +52,7 @@ STATIC const mp_map_elem_t mp_module_io_globals_table[] = { #endif }; -STATIC const mp_obj_dict_t mp_module_io_globals = { - .base = {&mp_type_dict}, - .map = { - .all_keys_are_qstrs = 1, - .table_is_fixed_array = 1, - .used = MP_ARRAY_SIZE(mp_module_io_globals_table), - .alloc = MP_ARRAY_SIZE(mp_module_io_globals_table), - .table = (mp_map_elem_t*)mp_module_io_globals_table, - }, -}; +STATIC MP_DEFINE_CONST_DICT(mp_module_io_globals, mp_module_io_globals_table); const mp_obj_module_t mp_module_io = { .base = { &mp_type_module }, diff --git a/py/modmath.c b/py/modmath.c index 7124820041..0111dc5523 100644 --- a/py/modmath.c +++ b/py/modmath.c @@ -221,16 +221,7 @@ STATIC const mp_map_elem_t mp_module_math_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_lgamma), (mp_obj_t)&mp_math_lgamma_obj }, }; -STATIC const mp_obj_dict_t mp_module_math_globals = { - .base = {&mp_type_dict}, - .map = { - .all_keys_are_qstrs = 1, - .table_is_fixed_array = 1, - .used = MP_ARRAY_SIZE(mp_module_math_globals_table), - .alloc = MP_ARRAY_SIZE(mp_module_math_globals_table), - .table = (mp_map_elem_t*)mp_module_math_globals_table, - }, -}; +STATIC MP_DEFINE_CONST_DICT(mp_module_math_globals, mp_module_math_globals_table); const mp_obj_module_t mp_module_math = { .base = { &mp_type_module }, diff --git a/py/modmicropython.c b/py/modmicropython.c index 87bab0a33e..b23758291d 100644 --- a/py/modmicropython.c +++ b/py/modmicropython.c @@ -67,16 +67,7 @@ STATIC const mp_map_elem_t mp_module_micropython_globals_table[] = { #endif }; -STATIC const mp_obj_dict_t mp_module_micropython_globals = { - .base = {&mp_type_dict}, - .map = { - .all_keys_are_qstrs = 1, - .table_is_fixed_array = 1, - .used = MP_ARRAY_SIZE(mp_module_micropython_globals_table), - .alloc = MP_ARRAY_SIZE(mp_module_micropython_globals_table), - .table = (mp_map_elem_t*)mp_module_micropython_globals_table, - }, -}; +STATIC MP_DEFINE_CONST_DICT(mp_module_micropython_globals, mp_module_micropython_globals_table); const mp_obj_module_t mp_module_micropython = { .base = { &mp_type_module }, diff --git a/py/modstruct.c b/py/modstruct.c index 8c0cafda07..f29c8c1f96 100644 --- a/py/modstruct.c +++ b/py/modstruct.c @@ -205,16 +205,7 @@ STATIC const mp_map_elem_t mp_module_struct_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_unpack), (mp_obj_t)&struct_unpack_obj }, }; -STATIC const mp_obj_dict_t mp_module_struct_globals = { - .base = {&mp_type_dict}, - .map = { - .all_keys_are_qstrs = 1, - .table_is_fixed_array = 1, - .used = MP_ARRAY_SIZE(mp_module_struct_globals_table), - .alloc = MP_ARRAY_SIZE(mp_module_struct_globals_table), - .table = (mp_map_elem_t*)mp_module_struct_globals_table, - }, -}; +STATIC MP_DEFINE_CONST_DICT(mp_module_struct_globals, mp_module_struct_globals_table); const mp_obj_module_t mp_module_struct = { .base = { &mp_type_module }, diff --git a/py/modsys.c b/py/modsys.c index 8ef66af052..d9be7d1bc1 100644 --- a/py/modsys.c +++ b/py/modsys.c @@ -120,16 +120,7 @@ STATIC const mp_map_elem_t mp_module_sys_globals_table[] = { #endif }; -STATIC const mp_obj_dict_t mp_module_sys_globals = { - .base = {&mp_type_dict}, - .map = { - .all_keys_are_qstrs = 1, - .table_is_fixed_array = 1, - .used = MP_ARRAY_SIZE(mp_module_sys_globals_table), - .alloc = MP_ARRAY_SIZE(mp_module_sys_globals_table), - .table = (mp_map_elem_t*)mp_module_sys_globals_table, - }, -}; +STATIC MP_DEFINE_CONST_DICT(mp_module_sys_globals, mp_module_sys_globals_table); const mp_obj_module_t mp_module_sys = { .base = { &mp_type_module }, diff --git a/py/obj.h b/py/obj.h index 8a8a1eb211..febff67c29 100644 --- a/py/obj.h +++ b/py/obj.h @@ -106,8 +106,8 @@ typedef struct _mp_obj_base_t mp_obj_base_t; .map = { \ .all_keys_are_qstrs = 1, \ .table_is_fixed_array = 1, \ - .used = sizeof(table_name) / sizeof(mp_map_elem_t), \ - .alloc = sizeof(table_name) / sizeof(mp_map_elem_t), \ + .used = MP_ARRAY_SIZE(table_name), \ + .alloc = MP_ARRAY_SIZE(table_name), \ .table = (mp_map_elem_t*)table_name, \ }, \ } diff --git a/stmhal/make-stmconst.py b/stmhal/make-stmconst.py index ba428395ce..03051c557e 100644 --- a/stmhal/make-stmconst.py +++ b/stmhal/make-stmconst.py @@ -145,23 +145,14 @@ STATIC const mp_map_elem_t stm_%s_globals_table[] = { print("""}; -STATIC const mp_obj_dict_t stm_%s_globals = { - .base = {&mp_type_dict}, - .map = { - .all_keys_are_qstrs = 1, - .table_is_fixed_array = 1, - .used = sizeof(stm_%s_globals_table) / sizeof(mp_map_elem_t), - .alloc = sizeof(stm_%s_globals_table) / sizeof(mp_map_elem_t), - .table = (mp_map_elem_t*)stm_%s_globals_table, - }, -}; +STATIC MP_DEFINE_CONST_DICT(stm_%s_globals, stm_%s_globals_table); const mp_obj_module_t stm_%s_obj = { .base = { &mp_type_module }, .name = MP_QSTR_%s, .globals = (mp_obj_dict_t*)&stm_%s_globals, }; -""" % (mod_name_lower, mod_name_lower, mod_name_lower, mod_name_lower, mod_name_lower, mod_name_upper, mod_name_lower)) +""" % (mod_name_lower, mod_name_lower, mod_name_lower, mod_name_upper, mod_name_lower)) def main(): cmd_parser = argparse.ArgumentParser(description='Extract ST constants from a C header file.') diff --git a/stmhal/modnetwork.c b/stmhal/modnetwork.c index c6723b182e..fd3fee9284 100644 --- a/stmhal/modnetwork.c +++ b/stmhal/modnetwork.c @@ -79,16 +79,7 @@ STATIC const mp_map_elem_t mp_module_network_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_route), (mp_obj_t)&network_route_obj }, }; -STATIC const mp_obj_dict_t mp_module_network_globals = { - .base = {&mp_type_dict}, - .map = { - .all_keys_are_qstrs = 1, - .table_is_fixed_array = 1, - .used = MP_ARRAY_SIZE(mp_module_network_globals_table), - .alloc = MP_ARRAY_SIZE(mp_module_network_globals_table), - .table = (mp_map_elem_t*)mp_module_network_globals_table, - }, -}; +STATIC MP_DEFINE_CONST_DICT(mp_module_network_globals, mp_module_network_globals_table); const mp_obj_module_t mp_module_network = { .base = { &mp_type_module }, diff --git a/stmhal/modpyb.c b/stmhal/modpyb.c index d3ea797976..38c5499b0b 100644 --- a/stmhal/modpyb.c +++ b/stmhal/modpyb.c @@ -574,16 +574,7 @@ STATIC const mp_map_elem_t pyb_module_globals_table[] = { #endif }; -STATIC const mp_obj_dict_t pyb_module_globals = { - .base = {&mp_type_dict}, - .map = { - .all_keys_are_qstrs = 1, - .table_is_fixed_array = 1, - .used = MP_ARRAY_SIZE(pyb_module_globals_table), - .alloc = MP_ARRAY_SIZE(pyb_module_globals_table), - .table = (mp_map_elem_t*)pyb_module_globals_table, - }, -}; +STATIC MP_DEFINE_CONST_DICT(pyb_module_globals, pyb_module_globals_table); const mp_obj_module_t pyb_module = { .base = { &mp_type_module }, diff --git a/stmhal/modstm.c b/stmhal/modstm.c index 1196ff82ff..960476fa95 100644 --- a/stmhal/modstm.c +++ b/stmhal/modstm.c @@ -126,16 +126,7 @@ STATIC const mp_map_elem_t stm_module_globals_table[] = { #include "modstmconst.gen.c" }; -STATIC const mp_obj_dict_t stm_module_globals = { - .base = {&mp_type_dict}, - .map = { - .all_keys_are_qstrs = 1, - .table_is_fixed_array = 1, - .used = MP_ARRAY_SIZE(stm_module_globals_table), - .alloc = MP_ARRAY_SIZE(stm_module_globals_table), - .table = (mp_map_elem_t*)stm_module_globals_table, - }, -}; +STATIC MP_DEFINE_CONST_DICT(stm_module_globals, stm_module_globals_table); const mp_obj_module_t stm_module = { .base = { &mp_type_module }, diff --git a/stmhal/moduos.c b/stmhal/moduos.c index 95446cdb06..ad0913fae4 100644 --- a/stmhal/moduos.c +++ b/stmhal/moduos.c @@ -351,16 +351,7 @@ STATIC const mp_map_elem_t os_module_globals_table[] = { #endif }; -STATIC const mp_obj_dict_t os_module_globals = { - .base = {&mp_type_dict}, - .map = { - .all_keys_are_qstrs = 1, - .table_is_fixed_array = 1, - .used = MP_ARRAY_SIZE(os_module_globals_table), - .alloc = MP_ARRAY_SIZE(os_module_globals_table), - .table = (mp_map_elem_t*)os_module_globals_table, - }, -}; +STATIC MP_DEFINE_CONST_DICT(os_module_globals, os_module_globals_table); const mp_obj_module_t mp_module_uos = { .base = { &mp_type_module }, diff --git a/stmhal/moduselect.c b/stmhal/moduselect.c index ec5910a712..0d5d6dd4ad 100644 --- a/stmhal/moduselect.c +++ b/stmhal/moduselect.c @@ -292,16 +292,7 @@ STATIC const mp_map_elem_t mp_module_select_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_poll), (mp_obj_t)&mp_select_poll_obj }, }; -STATIC const mp_obj_dict_t mp_module_select_globals = { - .base = {&mp_type_dict}, - .map = { - .all_keys_are_qstrs = 1, - .table_is_fixed_array = 1, - .used = MP_ARRAY_SIZE(mp_module_select_globals_table), - .alloc = MP_ARRAY_SIZE(mp_module_select_globals_table), - .table = (mp_map_elem_t*)mp_module_select_globals_table, - }, -}; +STATIC MP_DEFINE_CONST_DICT(mp_module_select_globals, mp_module_select_globals_table); const mp_obj_module_t mp_module_uselect = { .base = { &mp_type_module }, diff --git a/stmhal/modusocket.c b/stmhal/modusocket.c index bab1087037..048f052982 100644 --- a/stmhal/modusocket.c +++ b/stmhal/modusocket.c @@ -133,16 +133,7 @@ STATIC const mp_map_elem_t mp_module_usocket_globals_table[] = { */ }; -STATIC const mp_obj_dict_t mp_module_usocket_globals = { - .base = {&mp_type_dict}, - .map = { - .all_keys_are_qstrs = 1, - .table_is_fixed_array = 1, - .used = MP_ARRAY_SIZE(mp_module_usocket_globals_table), - .alloc = MP_ARRAY_SIZE(mp_module_usocket_globals_table), - .table = (mp_map_elem_t*)mp_module_usocket_globals_table, - }, -}; +STATIC MP_DEFINE_CONST_DICT(mp_module_usocket_globals, mp_module_usocket_globals_table); const mp_obj_module_t mp_module_usocket = { .base = { &mp_type_module }, diff --git a/stmhal/modutime.c b/stmhal/modutime.c index fd8fbb36af..0bc3245c48 100644 --- a/stmhal/modutime.c +++ b/stmhal/modutime.c @@ -344,16 +344,7 @@ STATIC const mp_map_elem_t time_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&time_time_obj }, }; -STATIC const mp_obj_dict_t time_module_globals = { - .base = {&mp_type_dict}, - .map = { - .all_keys_are_qstrs = 1, - .table_is_fixed_array = 1, - .used = MP_ARRAY_SIZE(time_module_globals_table), - .alloc = MP_ARRAY_SIZE(time_module_globals_table), - .table = (mp_map_elem_t*)time_module_globals_table, - }, -}; +STATIC MP_DEFINE_CONST_DICT(time_module_globals, time_module_globals_table); const mp_obj_module_t mp_module_utime = { .base = { &mp_type_module }, diff --git a/teensy/modpyb.c b/teensy/modpyb.c index 18d3809cf3..67c5896a5a 100644 --- a/teensy/modpyb.c +++ b/teensy/modpyb.c @@ -354,16 +354,7 @@ STATIC const mp_map_elem_t pyb_module_globals_table[] = { //#endif }; -STATIC const mp_obj_dict_t pyb_module_globals = { - .base = {&mp_type_dict}, - .map = { - .all_keys_are_qstrs = 1, - .table_is_fixed_array = 1, - .used = MP_ARRAY_SIZE(pyb_module_globals_table), - .alloc = MP_ARRAY_SIZE(pyb_module_globals_table), - .table = (mp_map_elem_t*)pyb_module_globals_table, - }, -}; +STATIC MP_DEFINE_CONST_DICT(pyb_module_globals, pyb_module_globals_table); const mp_obj_module_t pyb_module = { .base = { &mp_type_module }, diff --git a/unix/modffi.c b/unix/modffi.c index 03b76e643b..331219a14b 100644 --- a/unix/modffi.c +++ b/unix/modffi.c @@ -433,16 +433,7 @@ STATIC const mp_map_elem_t mp_module_ffi_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_as_bytearray), (mp_obj_t)&mod_ffi_as_bytearray_obj }, }; -STATIC const mp_obj_dict_t mp_module_ffi_globals = { - .base = {&mp_type_dict}, - .map = { - .all_keys_are_qstrs = 1, - .table_is_fixed_array = 1, - .used = MP_ARRAY_SIZE(mp_module_ffi_globals_table), - .alloc = MP_ARRAY_SIZE(mp_module_ffi_globals_table), - .table = (mp_map_elem_t*)mp_module_ffi_globals_table, - }, -}; +STATIC MP_DEFINE_CONST_DICT(mp_module_ffi_globals, mp_module_ffi_globals_table); const mp_obj_module_t mp_module_ffi = { .base = { &mp_type_module }, diff --git a/unix/modos.c b/unix/modos.c index 90998bcffe..712c528b4d 100644 --- a/unix/modos.c +++ b/unix/modos.c @@ -70,16 +70,7 @@ STATIC const mp_map_elem_t mp_module_os_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_stat), (mp_obj_t)&mod_os_stat_obj }, }; -STATIC const mp_obj_dict_t mp_module_os_globals = { - .base = {&mp_type_dict}, - .map = { - .all_keys_are_qstrs = 1, - .table_is_fixed_array = 1, - .used = MP_ARRAY_SIZE(mp_module_os_globals_table), - .alloc = MP_ARRAY_SIZE(mp_module_os_globals_table), - .table = (mp_map_elem_t*)mp_module_os_globals_table, - }, -}; +STATIC MP_DEFINE_CONST_DICT(mp_module_os_globals, mp_module_os_globals_table); const mp_obj_module_t mp_module_os = { .base = { &mp_type_module }, diff --git a/unix/modsocket.c b/unix/modsocket.c index 82d833653f..749e58328e 100644 --- a/unix/modsocket.c +++ b/unix/modsocket.c @@ -453,16 +453,7 @@ STATIC const mp_map_elem_t mp_module_socket_globals_table[] = { #undef C }; -STATIC const mp_obj_dict_t mp_module_socket_globals = { - .base = {&mp_type_dict}, - .map = { - .all_keys_are_qstrs = 1, - .table_is_fixed_array = 1, - .used = MP_ARRAY_SIZE(mp_module_socket_globals_table), - .alloc = MP_ARRAY_SIZE(mp_module_socket_globals_table), - .table = (mp_map_elem_t*)mp_module_socket_globals_table, - }, -}; +STATIC MP_DEFINE_CONST_DICT(mp_module_socket_globals, mp_module_socket_globals_table); const mp_obj_module_t mp_module_socket = { .base = { &mp_type_module }, diff --git a/unix/modtermios.c b/unix/modtermios.c index f9884da903..0fa0e13947 100644 --- a/unix/modtermios.c +++ b/unix/modtermios.c @@ -137,16 +137,7 @@ STATIC const mp_map_elem_t mp_module_termios_globals_table[] = { #undef C }; -STATIC const mp_obj_dict_t mp_module_termios_globals = { - .base = {&mp_type_dict}, - .map = { - .all_keys_are_qstrs = 1, - .table_is_fixed_array = 1, - .used = MP_ARRAY_SIZE(mp_module_termios_globals_table), - .alloc = MP_ARRAY_SIZE(mp_module_termios_globals_table), - .table = (mp_map_elem_t*)mp_module_termios_globals_table, - }, -}; +STATIC MP_DEFINE_CONST_DICT(mp_module_termios_globals, mp_module_termios_globals_table); const mp_obj_module_t mp_module_termios = { .base = { &mp_type_module }, diff --git a/unix/modtime.c b/unix/modtime.c index 15352735c6..84f041fedf 100644 --- a/unix/modtime.c +++ b/unix/modtime.c @@ -108,16 +108,7 @@ STATIC const mp_map_elem_t mp_module_time_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&mod_time_time_obj }, }; -STATIC const mp_obj_dict_t mp_module_time_globals = { - .base = {&mp_type_dict}, - .map = { - .all_keys_are_qstrs = 1, - .table_is_fixed_array = 1, - .used = MP_ARRAY_SIZE(mp_module_time_globals_table), - .alloc = MP_ARRAY_SIZE(mp_module_time_globals_table), - .table = (mp_map_elem_t*)mp_module_time_globals_table, - }, -}; +STATIC MP_DEFINE_CONST_DICT(mp_module_time_globals, mp_module_time_globals_table); const mp_obj_module_t mp_module_time = { .base = { &mp_type_module },