py: Add mp_obj_is_float function (macro) and use it where appropriate.

This commit is contained in:
Damien George
2015-08-20 23:30:12 +01:00
parent 60401d461a
commit aaef1851a7
8 changed files with 12 additions and 11 deletions

View File

@@ -268,7 +268,7 @@ mp_float_t mp_obj_get_float(mp_obj_t arg) {
return MP_OBJ_SMALL_INT_VALUE(arg);
} else if (MP_OBJ_IS_TYPE(arg, &mp_type_int)) {
return mp_obj_int_as_float(arg);
} else if (MP_OBJ_IS_TYPE(arg, &mp_type_float)) {
} else if (mp_obj_is_float(arg)) {
return mp_obj_float_get(arg);
} else {
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
@@ -295,7 +295,7 @@ void mp_obj_get_complex(mp_obj_t arg, mp_float_t *real, mp_float_t *imag) {
} else if (MP_OBJ_IS_TYPE(arg, &mp_type_int)) {
*real = mp_obj_int_as_float(arg);
*imag = 0;
} else if (MP_OBJ_IS_TYPE(arg, &mp_type_float)) {
} else if (mp_obj_is_float(arg)) {
*real = mp_obj_float_get(arg);
*imag = 0;
} else if (MP_OBJ_IS_TYPE(arg, &mp_type_complex)) {