diff --git a/esp8266/modpyb.c b/esp8266/modpyb.c index 49df418a2c657841068c897165e9aa7f88b0e043..d40745b8fc0360e34b9e92f10933c26e49ceb6fe 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 8cab7d6781d528f34dee3eb38d25eebff38a6620..262d99bc311508511507de3e5ac661d0f4818d99 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 dc3776f9a6d72dc97783d50e4c9a1c2ebd01fee9..83cfbbcc57dcd663b413b01142f1acee59d022be 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 8c6b34a4cae02d2a3df7bc608341004a04fc09d2..1c2e76b042973e0369a2235e020c40427121fae2 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 c2db3b621196fda96cb11044767ad12341b9f4fa..8c8cd8345f5bb5307a7ad51fee7c25c7688ed409 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 4bfadf193e33edfe53ae4179b7fbab2501ab2f72..f1a5eda629e022b4b080a9389b5ce5f921fc7745 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 deb367947542f9bcb2b9669ecadb3c39c3c26e88..eb010faf900b965e6840b21d2b6930eefd6b456d 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 3659d518c906510b219396c371959ceab8364351..751b064d372edf124b9155cd565ec8174a85aa88 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 c0fe331643ed257edc4d61bb434272b2127fc273..360fe8a5f162f4cb6c64ab41812d3c61b6c337ff 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 a147a754b8202f759ab863860bb11ccf98865bc9..4cd3a82359398a0c013764ae7c738508e20d27f9 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 5cd0b317a12ea907d8624eb62bfef83dfa11d944..8035b72d594030fa69ab681f52d93406ad969e97 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 a27ef7eed965f4a2076027945a33ff23566e533e..8c9be7068875cd5e253465d5f4a7d638de7fa953 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 ef3b29b53ffe777fbe0571a2fcd8919bed340e27..6a273b39b7e1379309004c6dbe915900730a4a44 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 7124820041fed73d846d70726ce2029d496b17d8..0111dc55232408e3c969f301283835b39b04f5af 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 87bab0a33e980e809fbed2d23780ab1dc1536cdc..b23758291dd03af6c84f09df7ab76e61e40e1fa6 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 8c0cafda07d85eb47c28bce5aed5199f3b16f632..f29c8c1f9690d9ead53797a6f4fea1b3f8006ade 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 8ef66af0524c48e764af9f7b2a5419ef2e629af5..d9be7d1bc11d938b6a994aef479c168537010a14 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 8a8a1eb2111797ba8b02339a245c245fe94f8f68..febff67c29fdc8580bb97e40add82db0d5a7428c 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 ba428395ce91554578bddbf87dd3fd3219795ec4..03051c557e569b47f6272e842bd3780f5efd8257 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 c6723b182e79ec6cf6d6004fde18dd3d1eeabeb2..fd3fee92845a827e8055585b816c44ea44b31033 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 d3ea797976555a4ec8b0e9183b6ce4448a0db758..38c5499b0bda0fa030eda6243dc9b31ad0623151 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 1196ff82ffe13d6e830e6a8574b0e9eaf2773bfd..960476fa95dbd3f4960efbd3342fe07bcc16d730 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 95446cdb061b69f6b2d51dde1e293ba61c72c398..ad0913fae4cbc16aa2744f5dbce5c2b3f6a6137a 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 ec5910a7123be74328c6a991d5f68642e96a161f..0d5d6dd4adc6be3059df0a301f45a91e23c7f8fa 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 bab108703747c3b3aac725cdc212fdfce9856572..048f0529820989d0073d76ffb07b586ab1b8c27d 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 fd8fbb36af6e50a98f93fa0eb85982e928c83b6f..0bc3245c48cd26709f11b7d306053032f9b91b3a 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 18d3809cf38b5595957c8872e93b2ebdbd8bb8b5..67c5896a5afde6d06d3b68721122229d6cd0eee7 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 03b76e643b03b32911a7ace230c0c82def27c874..331219a14b44221e334c81979f02de3164dfa9d8 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 90998bcffe426851c5e20ccf9535d168f3897d86..712c528b4dfdd43a897afbf7fa22eaa0faac9715 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 82d833653f059d6e8e1054aed58a9b6dc28e19b3..749e58328eb0025db32114d7e0b99fb1e744d5cb 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 f9884da90332e70fd7ec9997b2d08fe9f27f0fe0..0fa0e13947dbcb913d226710d2ce8acfffa59f6a 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 15352735c6e1b0328327dac5e81491cf042da7f7..84f041fedf5e0f86bddc01e516db87881da3169f 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 },