diff options
author | Damien George <damien.p.george@gmail.com> | 2014-01-04 20:21:15 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-01-04 20:21:15 +0000 |
commit | 71c5181a8dfa69ba9f5ca322a3aba0660be2e166 (patch) | |
tree | 77aae5a9008f269276bda9c433235f7e11b57ed4 /py/obj.c | |
parent | e9906ac3d771a312b05d76e42aee8e806dd0d128 (diff) | |
download | micropython-71c5181a8dfa69ba9f5ca322a3aba0660be2e166.tar.gz micropython-71c5181a8dfa69ba9f5ca322a3aba0660be2e166.zip |
Convert Python types to proper Python type hierarchy.
Now much more inline with how CPython does types.
Diffstat (limited to 'py/obj.c')
-rw-r--r-- | py/obj.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -13,10 +13,6 @@ #include "runtime.h" #include "map.h" -mp_obj_t mp_obj_new_int(machine_int_t value) { - return MP_OBJ_NEW_SMALL_INT(value); -} - const char *mp_obj_get_type_str(mp_obj_t o_in) { if (MP_OBJ_IS_SMALL_INT(o_in)) { return "int"; @@ -128,9 +124,13 @@ machine_int_t mp_obj_get_int(mp_obj_t arg) { return 1; } else if (MP_OBJ_IS_SMALL_INT(arg)) { return MP_OBJ_SMALL_INT_VALUE(arg); +#if MICROPY_ENABLE_FLOAT + } else if (MP_OBJ_IS_TYPE(arg, &float_type)) { + // TODO work out if this should be floor, ceil or trunc + return (machine_int_t)mp_obj_float_get(arg); +#endif } else { - assert(0); - return 0; + nlr_jump(mp_obj_new_exception_msg_1_arg(MP_QSTR_TypeError, "can't convert %s to int", mp_obj_get_type_str(arg))); } } |