diff options
author | Damien George <damien.p.george@gmail.com> | 2014-03-08 15:24:39 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-03-08 15:24:39 +0000 |
commit | 0c36da0b59bd3d5aeb6f7bd7f75913695a1dd366 (patch) | |
tree | eb1d8e50037139646f935df99da56764fcafb4f1 /py/objcomplex.c | |
parent | 8fd7d7e102372a3fe067030aa0f2049f744b1567 (diff) | |
download | micropython-0c36da0b59bd3d5aeb6f7bd7f75913695a1dd366.tar.gz micropython-0c36da0b59bd3d5aeb6f7bd7f75913695a1dd366.zip |
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).
Diffstat (limited to 'py/objcomplex.c')
-rw-r--r-- | py/objcomplex.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/py/objcomplex.c b/py/objcomplex.c index 188c334132..bba89daf00 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; |