diff options
author | Damien George <damien.p.george@gmail.com> | 2015-10-17 22:57:34 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-10-20 12:35:40 +0100 |
commit | aedb8591778a8dc4097eb4ffd2891dd5730efdde (patch) | |
tree | 2f4f88fba8a3af7504f66abac0bd7f2d111bf7be /py/obj.h | |
parent | 7e359c648b1f92e709c5ff4b7089011967ebb9f5 (diff) | |
download | micropython-aedb8591778a8dc4097eb4ffd2891dd5730efdde.tar.gz micropython-aedb8591778a8dc4097eb4ffd2891dd5730efdde.zip |
py: Make float representation configurable with object representation.
Diffstat (limited to 'py/obj.h')
-rw-r--r-- | py/obj.h | 30 |
1 files changed, 22 insertions, 8 deletions
@@ -83,6 +83,17 @@ static inline bool MP_OBJ_IS_QSTR(mp_const_obj_t o) #define MP_OBJ_QSTR_VALUE(o) (((mp_uint_t)(o)) >> 2) #define MP_OBJ_NEW_QSTR(qst) ((mp_obj_t)((((mp_uint_t)(qst)) << 2) | 2)) +#if MICROPY_PY_BUILTINS_FLOAT +#define mp_const_float_e ((mp_obj_t)&mp_const_float_e_obj) +#define mp_const_float_pi ((mp_obj_t)&mp_const_float_pi_obj) +extern const struct _mp_obj_float_t mp_const_float_e_obj; +extern const struct _mp_obj_float_t mp_const_float_pi_obj; + +#define mp_obj_is_float(o) MP_OBJ_IS_TYPE((o), &mp_type_float) +mp_float_t mp_obj_float_get(mp_obj_t self_in); +mp_obj_t mp_obj_new_float(mp_float_t value); +#endif + static inline bool MP_OBJ_IS_OBJ(mp_const_obj_t o) { return ((((mp_int_t)(o)) & 3) == 0); } @@ -98,6 +109,17 @@ static inline bool MP_OBJ_IS_QSTR(mp_const_obj_t o) #define MP_OBJ_QSTR_VALUE(o) (((mp_uint_t)(o)) >> 2) #define MP_OBJ_NEW_QSTR(qst) ((mp_obj_t)((((mp_uint_t)(qst)) << 2) | 3)) +#if MICROPY_PY_BUILTINS_FLOAT +#define mp_const_float_e ((mp_obj_t)&mp_const_float_e_obj) +#define mp_const_float_pi ((mp_obj_t)&mp_const_float_pi_obj) +extern const struct _mp_obj_float_t mp_const_float_e_obj; +extern const struct _mp_obj_float_t mp_const_float_pi_obj; + +#define mp_obj_is_float(o) MP_OBJ_IS_TYPE((o), &mp_type_float) +mp_float_t mp_obj_float_get(mp_obj_t self_in); +mp_obj_t mp_obj_new_float(mp_float_t value); +#endif + static inline bool MP_OBJ_IS_OBJ(mp_const_obj_t o) { return ((((mp_int_t)(o)) & 1) == 0); } @@ -473,7 +495,6 @@ mp_obj_t mp_obj_new_bytearray(mp_uint_t n, void *items); mp_obj_t mp_obj_new_bytearray_by_ref(mp_uint_t n, void *items); #if MICROPY_PY_BUILTINS_FLOAT mp_obj_t mp_obj_new_int_from_float(mp_float_t val); -mp_obj_t mp_obj_new_float(mp_float_t val); mp_obj_t mp_obj_new_complex(mp_float_t real, mp_float_t imag); #endif mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); @@ -564,13 +585,6 @@ void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, mp_uint_ #if MICROPY_PY_BUILTINS_FLOAT // float -#define mp_const_float_e ((mp_obj_t)&mp_const_float_e_obj) -#define mp_const_float_pi ((mp_obj_t)&mp_const_float_pi_obj) -extern const struct _mp_obj_float_t mp_const_float_e_obj; -extern const struct _mp_obj_float_t mp_const_float_pi_obj; - -#define mp_obj_is_float(o) MP_OBJ_IS_TYPE((o), &mp_type_float) -mp_float_t mp_obj_float_get(mp_obj_t self_in); mp_obj_t mp_obj_float_binary_op(mp_uint_t op, mp_float_t lhs_val, mp_obj_t rhs); // can return MP_OBJ_NULL if op not supported // complex |