From 0c36da0b59bd3d5aeb6f7bd7f75913695a1dd366 Mon Sep 17 00:00:00 2001 From: Damien George Date: Sat, 8 Mar 2014 15:24:39 +0000 Subject: Implement ROMable modules. Add math module. mp_module_obj_t can now be put in ROM. Configuration of float type is now similar to longint: can now choose none, float or double as the implementation. math module has basic math functions. For STM port, these are not yet implemented (they are just stub functions). --- py/objcomplex.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'py/objcomplex.c') diff --git a/py/objcomplex.c b/py/objcomplex.c index 188c33413..bba89daf0 100644 --- a/py/objcomplex.c +++ b/py/objcomplex.c @@ -39,7 +39,7 @@ STATIC mp_obj_t complex_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const case 1: // TODO allow string as first arg and parse it - if (MP_OBJ_IS_TYPE(args[0], &complex_type)) { + if (MP_OBJ_IS_TYPE(args[0], &mp_type_complex)) { return args[0]; } else { return mp_obj_new_complex(mp_obj_get_float(args[0]), 0); @@ -48,13 +48,13 @@ STATIC mp_obj_t complex_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const case 2: { mp_float_t real, imag; - if (MP_OBJ_IS_TYPE(args[0], &complex_type)) { + if (MP_OBJ_IS_TYPE(args[0], &mp_type_complex)) { mp_obj_complex_get(args[0], &real, &imag); } else { real = mp_obj_get_float(args[0]); imag = 0; } - if (MP_OBJ_IS_TYPE(args[1], &complex_type)) { + if (MP_OBJ_IS_TYPE(args[1], &mp_type_complex)) { mp_float_t real2, imag2; mp_obj_complex_get(args[1], &real2, &imag2); real -= imag2; @@ -85,7 +85,7 @@ STATIC mp_obj_t complex_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) { return mp_obj_complex_binary_op(op, lhs->real, lhs->imag, rhs_in); } -const mp_obj_type_t complex_type = { +const mp_obj_type_t mp_type_complex = { { &mp_type_type }, .name = MP_QSTR_complex, .print = complex_print, @@ -96,14 +96,14 @@ const mp_obj_type_t complex_type = { mp_obj_t mp_obj_new_complex(mp_float_t real, mp_float_t imag) { mp_obj_complex_t *o = m_new_obj(mp_obj_complex_t); - o->base.type = &complex_type; + o->base.type = &mp_type_complex; o->real = real; o->imag = imag; return o; } void mp_obj_complex_get(mp_obj_t self_in, mp_float_t *real, mp_float_t *imag) { - assert(MP_OBJ_IS_TYPE(self_in, &complex_type)); + assert(MP_OBJ_IS_TYPE(self_in, &mp_type_complex)); mp_obj_complex_t *self = self_in; *real = self->real; *imag = self->imag; -- cgit v1.2.3