Commit 2323ef91 authored by Damien George's avatar Damien George
Browse files

py: Rename globally-accessible tuple functions, prefix with mp_obj_.

Likely there are other functions that should be renamed, but this is a
start.
parent c59af52e
......@@ -492,7 +492,6 @@ mp_obj_t mp_obj_complex_binary_op(int op, mp_float_t lhs_real, mp_float_t lhs_im
void mp_obj_tuple_get(mp_obj_t self_in, uint *len, mp_obj_t **items);
void mp_obj_tuple_del(mp_obj_t self_in);
machine_int_t mp_obj_tuple_hash(mp_obj_t self_in);
mp_obj_t mp_obj_tuple_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args);
// list
struct _mp_obj_list_t;
......
......@@ -76,7 +76,7 @@ STATIC void mp_obj_exception_print(void (*print)(void *env, const char *fmt, ...
return;
}
}
tuple_print(print, env, o->args, kind);
mp_obj_tuple_print(print, env, o->args, kind);
}
mp_obj_t mp_obj_exception_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
......
......@@ -155,12 +155,12 @@ mp_obj_t mp_obj_new_namedtuple_type(qstr name, const char *fields) {
o->base.name = name;
o->base.print = namedtuple_print;
o->base.make_new = namedtuple_make_new;
o->base.unary_op = tuple_unary_op;
o->base.binary_op = tuple_binary_op;
o->base.unary_op = mp_obj_tuple_unary_op;
o->base.binary_op = mp_obj_tuple_binary_op;
o->base.load_attr = namedtuple_load_attr;
o->base.store_attr = namedtuple_store_attr;
o->base.subscr = tuple_subscr;
o->base.getiter = tuple_getiter;
o->base.subscr = mp_obj_tuple_subscr;
o->base.getiter = mp_obj_tuple_getiter;
o->base.bases_tuple = (mp_obj_t)&namedtuple_base_tuple;
o->fields = fields;
return o;
......
......@@ -41,7 +41,7 @@ STATIC mp_obj_t mp_obj_new_tuple_iterator(mp_obj_tuple_t *tuple, int cur);
/******************************************************************************/
/* tuple */
void tuple_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind) {
void mp_obj_tuple_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind) {
mp_obj_tuple_t *o = o_in;
print(env, "(");
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
print(env, ")");
}
mp_obj_t mp_obj_tuple_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
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) {
// TODO check n_kw == 0
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
// Don't pass MP_BINARY_OP_NOT_EQUAL here
STATIC bool tuple_cmp_helper(int op, mp_obj_t self_in, mp_obj_t another_in) {
mp_obj_type_t *self_type = mp_obj_get_type(self_in);
if (self_type->getiter != tuple_getiter) {
if (self_type->getiter != mp_obj_tuple_getiter) {
assert(0);
}
mp_obj_type_t *another_type = mp_obj_get_type(another_in);
mp_obj_tuple_t *self = self_in;
mp_obj_tuple_t *another = another_in;
if (another_type->getiter != tuple_getiter) {
if (another_type->getiter != mp_obj_tuple_getiter) {
// Slow path for user subclasses
another = mp_instance_cast_to_native_base(another, &mp_type_tuple);
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) {
return mp_seq_cmp_objs(op, self->items, self->len, another->items, another->len);
}
mp_obj_t tuple_unary_op(int op, mp_obj_t self_in) {
mp_obj_t mp_obj_tuple_unary_op(int op, mp_obj_t self_in) {
mp_obj_tuple_t *self = self_in;
switch (op) {
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) {
}
}
mp_obj_t tuple_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
mp_obj_t mp_obj_tuple_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
mp_obj_tuple_t *o = lhs;
switch (op) {
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) {
}
}
mp_obj_t tuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
mp_obj_t mp_obj_tuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
if (value == MP_OBJ_SENTINEL) {
// load
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) {
}
}
mp_obj_t tuple_getiter(mp_obj_t o_in) {
mp_obj_t mp_obj_tuple_getiter(mp_obj_t o_in) {
return mp_obj_new_tuple_iterator(o_in, 0);
}
......@@ -210,12 +210,12 @@ STATIC MP_DEFINE_CONST_DICT(tuple_locals_dict, tuple_locals_dict_table);
const mp_obj_type_t mp_type_tuple = {
{ &mp_type_type },
.name = MP_QSTR_tuple,
.print = tuple_print,
.print = mp_obj_tuple_print,
.make_new = mp_obj_tuple_make_new,
.unary_op = tuple_unary_op,
.binary_op = tuple_binary_op,
.subscr = tuple_subscr,
.getiter = tuple_getiter,
.unary_op = mp_obj_tuple_unary_op,
.binary_op = mp_obj_tuple_binary_op,
.subscr = mp_obj_tuple_subscr,
.getiter = mp_obj_tuple_getiter,
.locals_dict = (mp_obj_t)&tuple_locals_dict,
};
......
......@@ -30,8 +30,8 @@ typedef struct _mp_obj_tuple_t {
mp_obj_t items[];
} mp_obj_tuple_t;
void tuple_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind);
mp_obj_t tuple_unary_op(int op, mp_obj_t self_in);
mp_obj_t tuple_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs);
mp_obj_t tuple_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value);
mp_obj_t tuple_getiter(mp_obj_t o_in);
void mp_obj_tuple_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind);
mp_obj_t mp_obj_tuple_unary_op(int op, mp_obj_t self_in);
mp_obj_t mp_obj_tuple_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs);
mp_obj_t mp_obj_tuple_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value);
mp_obj_t mp_obj_tuple_getiter(mp_obj_t o_in);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment