Skip to content

Commit f6932d6

Browse files
committed
Prefix ARRAY_SIZE with micropython prefix MP_
1 parent bf3366a commit f6932d6

32 files changed

Lines changed: 67 additions & 67 deletions

py/builtin.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_any_obj, mp_builtin_any);
154154

155155
STATIC mp_obj_t mp_builtin_bin(mp_obj_t o_in) {
156156
mp_obj_t args[] = { MP_OBJ_NEW_QSTR(MP_QSTR__brace_open__colon__hash_b_brace_close_), o_in };
157-
return mp_obj_str_format(ARRAY_SIZE(args), args);
157+
return mp_obj_str_format(MP_ARRAY_SIZE(args), args);
158158
}
159159

160160
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_bin_obj, mp_builtin_bin);

py/builtintables.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ const mp_obj_dict_t mp_builtin_object_dict_obj = {
150150
.map = {
151151
.all_keys_are_qstrs = 1,
152152
.table_is_fixed_array = 1,
153-
.used = ARRAY_SIZE(mp_builtin_object_table),
154-
.alloc = ARRAY_SIZE(mp_builtin_object_table),
153+
.used = MP_ARRAY_SIZE(mp_builtin_object_table),
154+
.alloc = MP_ARRAY_SIZE(mp_builtin_object_table),
155155
.table = (mp_map_elem_t*)mp_builtin_object_table,
156156
},
157157
};
@@ -195,8 +195,8 @@ const mp_obj_dict_t mp_builtin_module_dict_obj = {
195195
.map = {
196196
.all_keys_are_qstrs = 1,
197197
.table_is_fixed_array = 1,
198-
.used = ARRAY_SIZE(mp_builtin_module_table),
199-
.alloc = ARRAY_SIZE(mp_builtin_module_table),
198+
.used = MP_ARRAY_SIZE(mp_builtin_module_table),
199+
.alloc = MP_ARRAY_SIZE(mp_builtin_module_table),
200200
.table = (mp_map_elem_t*)mp_builtin_module_table,
201201
},
202202
};

py/compile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ STATIC const mp_map_elem_t mp_constants_table[] = {
111111
STATIC const mp_map_t mp_constants_map = {
112112
.all_keys_are_qstrs = 1,
113113
.table_is_fixed_array = 1,
114-
.used = ARRAY_SIZE(mp_constants_table),
115-
.alloc = ARRAY_SIZE(mp_constants_table),
114+
.used = MP_ARRAY_SIZE(mp_constants_table),
115+
.alloc = MP_ARRAY_SIZE(mp_constants_table),
116116
.table = (mp_map_elem_t*)mp_constants_table,
117117
};
118118

py/emitinlinethumb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ STATIC uint get_arg_reg(emit_inline_asm_t *emit, const char *op, mp_parse_node_t
167167
if (MP_PARSE_NODE_IS_ID(pn)) {
168168
qstr reg_qstr = MP_PARSE_NODE_LEAF_ARG(pn);
169169
const char *reg_str = qstr_str(reg_qstr);
170-
for (uint i = 0; i < ARRAY_SIZE(reg_name_table); i++) {
170+
for (uint i = 0; i < MP_ARRAY_SIZE(reg_name_table); i++) {
171171
const reg_name_t *r = &reg_name_table[i];
172172
if (reg_str[0] == r->name[0] && reg_str[1] == r->name[1] && reg_str[2] == r->name[2] && (reg_str[2] == '\0' || reg_str[3] == '\0')) {
173173
if (r->reg > max_reg) {
@@ -286,7 +286,7 @@ STATIC void emit_inline_thumb_op(emit_inline_asm_t *emit, qstr op, int n_args, m
286286
asm_thumb_b_n(emit->as, label_num);
287287
} else if (op_str[0] == 'b' && op_len == 3) {
288288
uint cc = -1;
289-
for (uint i = 0; i < ARRAY_SIZE(cc_name_table); i++) {
289+
for (uint i = 0; i < MP_ARRAY_SIZE(cc_name_table); i++) {
290290
if (op_str[1] == cc_name_table[i].name[0] && op_str[2] == cc_name_table[i].name[1]) {
291291
cc = cc_name_table[i].cc;
292292
}

py/lexer.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -694,10 +694,10 @@ STATIC void mp_lexer_next_token_into(mp_lexer_t *lex, mp_token_t *tok, bool firs
694694
// need to check for this special token in many places in the compiler.
695695
// TODO improve speed of these string comparisons
696696
//for (int i = 0; tok_kw[i] != NULL; i++) {
697-
for (int i = 0; i < ARRAY_SIZE(tok_kw); i++) {
697+
for (int i = 0; i < MP_ARRAY_SIZE(tok_kw); i++) {
698698
if (str_strn_equal(tok_kw[i], tok->str, tok->len)) {
699-
if (i == ARRAY_SIZE(tok_kw) - 1) {
700-
// tok_kw[ARRAY_SIZE(tok_kw) - 1] == "__debug__"
699+
if (i == MP_ARRAY_SIZE(tok_kw) - 1) {
700+
// tok_kw[MP_ARRAY_SIZE(tok_kw) - 1] == "__debug__"
701701
tok->kind = (mp_optimise_value == 0 ? MP_TOKEN_KW_TRUE : MP_TOKEN_KW_FALSE);
702702
} else {
703703
tok->kind = MP_TOKEN_KW_FALSE + i;

py/misc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ int m_get_peak_bytes_allocated(void);
8282
/** array helpers ***********************************************/
8383

8484
// get the number of elements in a fixed-size array
85-
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
85+
#define MP_ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
8686

8787
/** unichar / UTF-8 *********************************************/
8888

py/modarray.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ STATIC const mp_obj_dict_t mp_module_array_globals = {
4040
.map = {
4141
.all_keys_are_qstrs = 1,
4242
.table_is_fixed_array = 1,
43-
.used = ARRAY_SIZE(mp_module_array_globals_table),
44-
.alloc = ARRAY_SIZE(mp_module_array_globals_table),
43+
.used = MP_ARRAY_SIZE(mp_module_array_globals_table),
44+
.alloc = MP_ARRAY_SIZE(mp_module_array_globals_table),
4545
.table = (mp_map_elem_t*)mp_module_array_globals_table,
4646
},
4747
};

py/modcmath.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ STATIC const mp_obj_dict_t mp_module_cmath_globals = {
142142
.map = {
143143
.all_keys_are_qstrs = 1,
144144
.table_is_fixed_array = 1,
145-
.used = ARRAY_SIZE(mp_module_cmath_globals_table),
146-
.alloc = ARRAY_SIZE(mp_module_cmath_globals_table),
145+
.used = MP_ARRAY_SIZE(mp_module_cmath_globals_table),
146+
.alloc = MP_ARRAY_SIZE(mp_module_cmath_globals_table),
147147
.table = (mp_map_elem_t*)mp_module_cmath_globals_table,
148148
},
149149
};

py/modcollections.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ STATIC const mp_obj_dict_t mp_module_collections_globals = {
4242
.map = {
4343
.all_keys_are_qstrs = 1,
4444
.table_is_fixed_array = 1,
45-
.used = ARRAY_SIZE(mp_module_collections_globals_table),
46-
.alloc = ARRAY_SIZE(mp_module_collections_globals_table),
45+
.used = MP_ARRAY_SIZE(mp_module_collections_globals_table),
46+
.alloc = MP_ARRAY_SIZE(mp_module_collections_globals_table),
4747
.table = (mp_map_elem_t*)mp_module_collections_globals_table,
4848
},
4949
};

py/modgc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ STATIC const mp_obj_dict_t mp_module_gc_globals = {
7373
.map = {
7474
.all_keys_are_qstrs = 1,
7575
.table_is_fixed_array = 1,
76-
.used = ARRAY_SIZE(mp_module_gc_globals_table),
77-
.alloc = ARRAY_SIZE(mp_module_gc_globals_table),
76+
.used = MP_ARRAY_SIZE(mp_module_gc_globals_table),
77+
.alloc = MP_ARRAY_SIZE(mp_module_gc_globals_table),
7878
.table = (mp_map_elem_t*)mp_module_gc_globals_table,
7979
},
8080
};

0 commit comments

Comments
 (0)