Skip to content

Commit 3b603f2

Browse files
committed
Use MP_DEFINE_CONST_DICT macro to define module dicts.
This is just a clean-up of the code. Generated code is exactly the same.
1 parent e636279 commit 3b603f2

32 files changed

Lines changed: 34 additions & 313 deletions

esp8266/modpyb.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -155,16 +155,7 @@ STATIC const mp_map_elem_t pyb_module_globals_table[] = {
155155
{ MP_OBJ_NEW_QSTR(MP_QSTR_sync), (mp_obj_t)&pyb_sync_obj },
156156
};
157157

158-
STATIC const mp_obj_dict_t pyb_module_globals = {
159-
.base = {&mp_type_dict},
160-
.map = {
161-
.all_keys_are_qstrs = 1,
162-
.table_is_fixed_array = 1,
163-
.used = MP_ARRAY_SIZE(pyb_module_globals_table),
164-
.alloc = MP_ARRAY_SIZE(pyb_module_globals_table),
165-
.table = (mp_map_elem_t*)pyb_module_globals_table,
166-
},
167-
};
158+
STATIC MP_DEFINE_CONST_DICT(pyb_module_globals, pyb_module_globals_table);
168159

169160
const mp_obj_module_t pyb_module = {
170161
.base = { &mp_type_module },

extmod/modubinascii.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,7 @@ STATIC const mp_map_elem_t mp_module_binascii_globals_table[] = {
6868
// { MP_OBJ_NEW_QSTR(MP_QSTR_b2a_base64), (mp_obj_t)&mod_binascii_b2a_base64_obj },
6969
};
7070

71-
STATIC const mp_obj_dict_t mp_module_binascii_globals = {
72-
.base = {&mp_type_dict},
73-
.map = {
74-
.all_keys_are_qstrs = 1,
75-
.table_is_fixed_array = 1,
76-
.used = MP_ARRAY_SIZE(mp_module_binascii_globals_table),
77-
.alloc = MP_ARRAY_SIZE(mp_module_binascii_globals_table),
78-
.table = (mp_map_elem_t*)mp_module_binascii_globals_table,
79-
},
80-
};
71+
STATIC MP_DEFINE_CONST_DICT(mp_module_binascii_globals, mp_module_binascii_globals_table);
8172

8273
const mp_obj_module_t mp_module_ubinascii = {
8374
.base = { &mp_type_module },

extmod/moductypes.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -649,16 +649,7 @@ STATIC const mp_map_elem_t mp_module_uctypes_globals_table[] = {
649649
{ MP_OBJ_NEW_QSTR(MP_QSTR_ARRAY), MP_OBJ_NEW_SMALL_INT(TYPE2SMALLINT(ARRAY, AGG_TYPE_BITS)) },
650650
};
651651

652-
STATIC const mp_obj_dict_t mp_module_uctypes_globals = {
653-
.base = {&mp_type_dict},
654-
.map = {
655-
.all_keys_are_qstrs = 1,
656-
.table_is_fixed_array = 1,
657-
.used = MP_ARRAY_SIZE(mp_module_uctypes_globals_table),
658-
.alloc = MP_ARRAY_SIZE(mp_module_uctypes_globals_table),
659-
.table = (mp_map_elem_t*)mp_module_uctypes_globals_table,
660-
},
661-
};
652+
STATIC MP_DEFINE_CONST_DICT(mp_module_uctypes_globals, mp_module_uctypes_globals_table);
662653

663654
const mp_obj_module_t mp_module_uctypes = {
664655
.base = { &mp_type_module },

extmod/moduhashlib.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,7 @@ STATIC const mp_map_elem_t mp_module_hashlib_globals_table[] = {
105105
{ MP_OBJ_NEW_QSTR(MP_QSTR_sha256), (mp_obj_t)&sha256_type },
106106
};
107107

108-
STATIC const mp_obj_dict_t mp_module_hashlib_globals = {
109-
.base = {&mp_type_dict},
110-
.map = {
111-
.all_keys_are_qstrs = 1,
112-
.table_is_fixed_array = 1,
113-
.used = MP_ARRAY_SIZE(mp_module_hashlib_globals_table),
114-
.alloc = MP_ARRAY_SIZE(mp_module_hashlib_globals_table),
115-
.table = (mp_map_elem_t*)mp_module_hashlib_globals_table,
116-
},
117-
};
108+
STATIC MP_DEFINE_CONST_DICT(mp_module_hashlib_globals, mp_module_hashlib_globals_table);
118109

119110
const mp_obj_module_t mp_module_uhashlib = {
120111
.base = { &mp_type_module },

extmod/moduheapq.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,7 @@ STATIC const mp_map_elem_t mp_module_uheapq_globals_table[] = {
118118
{ MP_OBJ_NEW_QSTR(MP_QSTR_heapify), (mp_obj_t)&mod_uheapq_heapify_obj },
119119
};
120120

121-
STATIC const mp_obj_dict_t mp_module_uheapq_globals = {
122-
.base = {&mp_type_dict},
123-
.map = {
124-
.all_keys_are_qstrs = 1,
125-
.table_is_fixed_array = 1,
126-
.used = MP_ARRAY_SIZE(mp_module_uheapq_globals_table),
127-
.alloc = MP_ARRAY_SIZE(mp_module_uheapq_globals_table),
128-
.table = (mp_map_elem_t*)mp_module_uheapq_globals_table,
129-
},
130-
};
121+
STATIC MP_DEFINE_CONST_DICT(mp_module_uheapq_globals, mp_module_uheapq_globals_table);
131122

132123
const mp_obj_module_t mp_module_uheapq = {
133124
.base = { &mp_type_module },

extmod/modujson.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -259,16 +259,7 @@ STATIC const mp_map_elem_t mp_module_ujson_globals_table[] = {
259259
{ MP_OBJ_NEW_QSTR(MP_QSTR_loads), (mp_obj_t)&mod_ujson_loads_obj },
260260
};
261261

262-
STATIC const mp_obj_dict_t mp_module_ujson_globals = {
263-
.base = {&mp_type_dict},
264-
.map = {
265-
.all_keys_are_qstrs = 1,
266-
.table_is_fixed_array = 1,
267-
.used = MP_ARRAY_SIZE(mp_module_ujson_globals_table),
268-
.alloc = MP_ARRAY_SIZE(mp_module_ujson_globals_table),
269-
.table = (mp_map_elem_t*)mp_module_ujson_globals_table,
270-
},
271-
};
262+
STATIC MP_DEFINE_CONST_DICT(mp_module_ujson_globals, mp_module_ujson_globals_table);
272263

273264
const mp_obj_module_t mp_module_ujson = {
274265
.base = { &mp_type_module },

extmod/modure.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -221,16 +221,7 @@ STATIC const mp_map_elem_t mp_module_re_globals_table[] = {
221221
{ MP_OBJ_NEW_QSTR(MP_QSTR_DEBUG), MP_OBJ_NEW_SMALL_INT(FLAG_DEBUG) },
222222
};
223223

224-
STATIC const mp_obj_dict_t mp_module_re_globals = {
225-
.base = {&mp_type_dict},
226-
.map = {
227-
.all_keys_are_qstrs = 1,
228-
.table_is_fixed_array = 1,
229-
.used = MP_ARRAY_SIZE(mp_module_re_globals_table),
230-
.alloc = MP_ARRAY_SIZE(mp_module_re_globals_table),
231-
.table = (mp_map_elem_t*)mp_module_re_globals_table,
232-
},
233-
};
224+
STATIC MP_DEFINE_CONST_DICT(mp_module_re_globals, mp_module_re_globals_table);
234225

235226
const mp_obj_module_t mp_module_ure = {
236227
.base = { &mp_type_module },

extmod/moduzlib.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,7 @@ STATIC const mp_map_elem_t mp_module_uzlib_globals_table[] = {
8787
{ MP_OBJ_NEW_QSTR(MP_QSTR_decompress), (mp_obj_t)&mod_uzlib_decompress_obj },
8888
};
8989

90-
STATIC const mp_obj_dict_t mp_module_uzlib_globals = {
91-
.base = {&mp_type_dict},
92-
.map = {
93-
.all_keys_are_qstrs = 1,
94-
.table_is_fixed_array = 1,
95-
.used = MP_ARRAY_SIZE(mp_module_uzlib_globals_table),
96-
.alloc = MP_ARRAY_SIZE(mp_module_uzlib_globals_table),
97-
.table = (mp_map_elem_t*)mp_module_uzlib_globals_table,
98-
},
99-
};
90+
STATIC MP_DEFINE_CONST_DICT(mp_module_uzlib_globals, mp_module_uzlib_globals_table);
10091

10192
const mp_obj_module_t mp_module_uzlib = {
10293
.base = { &mp_type_module },

py/modarray.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,7 @@ STATIC const mp_map_elem_t mp_module_array_globals_table[] = {
3737
{ MP_OBJ_NEW_QSTR(MP_QSTR_array), (mp_obj_t)&mp_type_array },
3838
};
3939

40-
STATIC const mp_obj_dict_t mp_module_array_globals = {
41-
.base = {&mp_type_dict},
42-
.map = {
43-
.all_keys_are_qstrs = 1,
44-
.table_is_fixed_array = 1,
45-
.used = MP_ARRAY_SIZE(mp_module_array_globals_table),
46-
.alloc = MP_ARRAY_SIZE(mp_module_array_globals_table),
47-
.table = (mp_map_elem_t*)mp_module_array_globals_table,
48-
},
49-
};
40+
STATIC MP_DEFINE_CONST_DICT(mp_module_array_globals, mp_module_array_globals_table);
5041

5142
const mp_obj_module_t mp_module_array = {
5243
.base = { &mp_type_module },

py/modcmath.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -162,16 +162,7 @@ STATIC const mp_map_elem_t mp_module_cmath_globals_table[] = {
162162
//{ MP_OBJ_NEW_QSTR(MP_QSTR_isnan), (mp_obj_t)&mp_cmath_isnan_obj },
163163
};
164164

165-
STATIC const mp_obj_dict_t mp_module_cmath_globals = {
166-
.base = {&mp_type_dict},
167-
.map = {
168-
.all_keys_are_qstrs = 1,
169-
.table_is_fixed_array = 1,
170-
.used = MP_ARRAY_SIZE(mp_module_cmath_globals_table),
171-
.alloc = MP_ARRAY_SIZE(mp_module_cmath_globals_table),
172-
.table = (mp_map_elem_t*)mp_module_cmath_globals_table,
173-
},
174-
};
165+
STATIC MP_DEFINE_CONST_DICT(mp_module_cmath_globals, mp_module_cmath_globals_table);
175166

176167
const mp_obj_module_t mp_module_cmath = {
177168
.base = { &mp_type_module },

0 commit comments

Comments
 (0)