Skip to content

Commit 2323ef9

Browse files
committed
py: Rename globally-accessible tuple functions, prefix with mp_obj_.
Likely there are other functions that should be renamed, but this is a start.
1 parent c59af52 commit 2323ef9

File tree

5 files changed

+23
-24
lines changed

5 files changed

+23
-24
lines changed

py/obj.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,6 @@ mp_obj_t mp_obj_complex_binary_op(int op, mp_float_t lhs_real, mp_float_t lhs_im
492492
void mp_obj_tuple_get(mp_obj_t self_in, uint *len, mp_obj_t **items);
493493
void mp_obj_tuple_del(mp_obj_t self_in);
494494
machine_int_t mp_obj_tuple_hash(mp_obj_t self_in);
495-
mp_obj_t mp_obj_tuple_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args);
496495

497496
// list
498497
struct _mp_obj_list_t;

py/objexcept.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ STATIC void mp_obj_exception_print(void (*print)(void *env, const char *fmt, ...
7676
return;
7777
}
7878
}
79-
tuple_print(print, env, o->args, kind);
79+
mp_obj_tuple_print(print, env, o->args, kind);
8080
}
8181

8282
mp_obj_t mp_obj_exception_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {

py/objnamedtuple.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,12 @@ mp_obj_t mp_obj_new_namedtuple_type(qstr name, const char *fields) {
155155
o->base.name = name;
156156
o->base.print = namedtuple_print;
157157
o->base.make_new = namedtuple_make_new;
158-
o->base.unary_op = tuple_unary_op;
159-
o->base.binary_op = tuple_binary_op;
158+
o->base.unary_op = mp_obj_tuple_unary_op;
159+
o->base.binary_op = mp_obj_tuple_binary_op;
160160
o->base.load_attr = namedtuple_load_attr;
161161
o->base.store_attr = namedtuple_store_attr;
162-
o->base.subscr = tuple_subscr;
163-
o->base.getiter = tuple_getiter;
162+
o->base.subscr = mp_obj_tuple_subscr;
163+
o->base.getiter = mp_obj_tuple_getiter;
164164
o->base.bases_tuple = (mp_obj_t)&namedtuple_base_tuple;
165165
o->fields = fields;
166166
return o;

py/objtuple.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ STATIC mp_obj_t mp_obj_new_tuple_iterator(mp_obj_tuple_t *tuple, int cur);
4141
/******************************************************************************/
4242
/* tuple */
4343

44-
void tuple_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind) {
44+
void mp_obj_tuple_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind) {
4545
mp_obj_tuple_t *o = o_in;
4646
print(env, "(");
4747
for (int i = 0; i < o->len; i++) {
@@ -56,7 +56,7 @@ void tuple_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_o
5656
print(env, ")");
5757
}
5858

59-
mp_obj_t mp_obj_tuple_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
59+
STATIC mp_obj_t mp_obj_tuple_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
6060
// TODO check n_kw == 0
6161

6262
switch (n_args) {
@@ -100,13 +100,13 @@ mp_obj_t mp_obj_tuple_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const m
100100
// Don't pass MP_BINARY_OP_NOT_EQUAL here
101101
STATIC bool tuple_cmp_helper(int op, mp_obj_t self_in, mp_obj_t another_in) {
102102
mp_obj_type_t *self_type = mp_obj_get_type(self_in);
103-
if (self_type->getiter != tuple_getiter) {
103+
if (self_type->getiter != mp_obj_tuple_getiter) {
104104
assert(0);
105105
}
106106
mp_obj_type_t *another_type = mp_obj_get_type(another_in);
107107
mp_obj_tuple_t *self = self_in;
108108
mp_obj_tuple_t *another = another_in;
109-
if (another_type->getiter != tuple_getiter) {
109+
if (another_type->getiter != mp_obj_tuple_getiter) {
110110
// Slow path for user subclasses
111111
another = mp_instance_cast_to_native_base(another, &mp_type_tuple);
112112
if (another == MP_OBJ_NULL) {
@@ -117,7 +117,7 @@ STATIC bool tuple_cmp_helper(int op, mp_obj_t self_in, mp_obj_t another_in) {
117117
return mp_seq_cmp_objs(op, self->items, self->len, another->items, another->len);
118118
}
119119

120-
mp_obj_t tuple_unary_op(int op, mp_obj_t self_in) {
120+
mp_obj_t mp_obj_tuple_unary_op(int op, mp_obj_t self_in) {
121121
mp_obj_tuple_t *self = self_in;
122122
switch (op) {
123123
case MP_UNARY_OP_BOOL: return MP_BOOL(self->len != 0);
@@ -126,7 +126,7 @@ mp_obj_t tuple_unary_op(int op, mp_obj_t self_in) {
126126
}
127127
}
128128

129-
mp_obj_t tuple_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
129+
mp_obj_t mp_obj_tuple_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
130130
mp_obj_tuple_t *o = lhs;
131131
switch (op) {
132132
case MP_BINARY_OP_ADD: {
@@ -160,7 +160,7 @@ mp_obj_t tuple_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
160160
}
161161
}
162162

163-
mp_obj_t tuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
163+
mp_obj_t mp_obj_tuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
164164
if (value == MP_OBJ_SENTINEL) {
165165
// load
166166
mp_obj_tuple_t *self = self_in;
@@ -182,7 +182,7 @@ mp_obj_t tuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
182182
}
183183
}
184184

185-
mp_obj_t tuple_getiter(mp_obj_t o_in) {
185+
mp_obj_t mp_obj_tuple_getiter(mp_obj_t o_in) {
186186
return mp_obj_new_tuple_iterator(o_in, 0);
187187
}
188188

@@ -210,12 +210,12 @@ STATIC MP_DEFINE_CONST_DICT(tuple_locals_dict, tuple_locals_dict_table);
210210
const mp_obj_type_t mp_type_tuple = {
211211
{ &mp_type_type },
212212
.name = MP_QSTR_tuple,
213-
.print = tuple_print,
213+
.print = mp_obj_tuple_print,
214214
.make_new = mp_obj_tuple_make_new,
215-
.unary_op = tuple_unary_op,
216-
.binary_op = tuple_binary_op,
217-
.subscr = tuple_subscr,
218-
.getiter = tuple_getiter,
215+
.unary_op = mp_obj_tuple_unary_op,
216+
.binary_op = mp_obj_tuple_binary_op,
217+
.subscr = mp_obj_tuple_subscr,
218+
.getiter = mp_obj_tuple_getiter,
219219
.locals_dict = (mp_obj_t)&tuple_locals_dict,
220220
};
221221

py/objtuple.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ typedef struct _mp_obj_tuple_t {
3030
mp_obj_t items[];
3131
} mp_obj_tuple_t;
3232

33-
void tuple_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind);
34-
mp_obj_t tuple_unary_op(int op, mp_obj_t self_in);
35-
mp_obj_t tuple_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs);
36-
mp_obj_t tuple_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value);
37-
mp_obj_t tuple_getiter(mp_obj_t o_in);
33+
void mp_obj_tuple_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind);
34+
mp_obj_t mp_obj_tuple_unary_op(int op, mp_obj_t self_in);
35+
mp_obj_t mp_obj_tuple_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs);
36+
mp_obj_t mp_obj_tuple_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value);
37+
mp_obj_t mp_obj_tuple_getiter(mp_obj_t o_in);

0 commit comments

Comments
 (0)