From fb510b3bf90eccc8e0d400c6622b2e94c2bfa8e9 Mon Sep 17 00:00:00 2001 From: Damien George Date: Sun, 1 Jun 2014 13:32:54 +0100 Subject: [PATCH] Rename bultins config variables to MICROPY_PY_BUILTINS_*. This renames: MICROPY_PY_FROZENSET -> MICROPY_PY_BUILTINS_FROZENSET MICROPY_PY_PROPERTY -> MICROPY_PY_BUILTINS_PROPERTY MICROPY_PY_SLICE -> MICROPY_PY_BUILTINS_SLICE MICROPY_ENABLE_FLOAT -> MICROPY_PY_BUILTINS_FLOAT See issue #35 for discussion. --- bare-arm/mpconfigport.h | 2 +- py/binary.c | 6 +++--- py/builtin.c | 4 ++-- py/builtintables.c | 10 +++++----- py/modcmath.c | 4 ++-- py/modmath.c | 4 ++-- py/mpconfig.h | 23 +++++++++++------------ py/mpz.c | 2 +- py/mpz.h | 2 +- py/obj.c | 2 +- py/obj.h | 8 ++++---- py/objcomplex.c | 2 +- py/objfloat.c | 4 ++-- py/objfun.c | 2 +- py/objint.c | 6 +++--- py/objint_longlong.c | 2 +- py/objint_mpz.c | 6 +++--- py/objlist.c | 6 +++--- py/objproperty.c | 4 ++-- py/objset.c | 16 ++++++++-------- py/objslice.c | 2 +- py/objstr.c | 12 ++++++------ py/objtuple.c | 2 +- py/objtype.c | 4 ++-- py/parsenum.c | 4 ++-- py/pfenv.c | 4 ++-- py/pfenv.h | 2 +- py/qstrdefs.h | 4 ++-- py/runtime.c | 6 +++--- py/showbc.c | 2 +- py/vm.c | 2 +- stmhal/modtime.c | 4 ++-- stmhal/mpconfigport.h | 2 +- stmhal/printf.c | 4 ++-- stmhal/servo.c | 4 ++-- teensy/mpconfigport.h | 2 +- unix/modtime.c | 6 +++--- unix/mpconfigport.h | 2 +- windows/mpconfigport.h | 2 +- 39 files changed, 92 insertions(+), 93 deletions(-) diff --git a/bare-arm/mpconfigport.h b/bare-arm/mpconfigport.h index 3a3c8615d..19830b454 100644 --- a/bare-arm/mpconfigport.h +++ b/bare-arm/mpconfigport.h @@ -12,13 +12,13 @@ #define MICROPY_HELPER_REPL (0) #define MICROPY_HELPER_LEXER_UNIX (0) #define MICROPY_ENABLE_SOURCE_LINE (0) +#define MICROPY_PY_BUILTINS_PROPERTY (0) #define MICROPY_PY_COLLECTIONS (0) #define MICROPY_PY_MATH (0) #define MICROPY_PY_CMATH (0) #define MICROPY_PY_IO (0) #define MICROPY_PY_STRUCT (0) #define MICROPY_PY_SYS (0) -#define MICROPY_PY_PROPERTY (0) #define MICROPY_CPYTHON_COMPAT (0) #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE) #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE) diff --git a/py/binary.c b/py/binary.c index 7640b7590..cec237446 100644 --- a/py/binary.c +++ b/py/binary.c @@ -114,7 +114,7 @@ mp_obj_t mp_binary_get_val_array(char typecode, void *p, int index) { // TODO: Explode API more to cover signedness return mp_obj_new_int_from_ll(((long long*)p)[index]); #endif -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT case 'f': return mp_obj_new_float(((float*)p)[index]); case 'd': @@ -217,7 +217,7 @@ void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte ** void mp_binary_set_val_array(char typecode, void *p, int index, mp_obj_t val_in) { switch (typecode) { -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT case 'f': ((float*)p)[index] = mp_obj_float_get(val_in); break; @@ -260,7 +260,7 @@ void mp_binary_set_val_array_from_int(char typecode, void *p, int index, machine ((long long*)p)[index] = val; break; #endif -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT case 'f': ((float*)p)[index] = val; break; diff --git a/py/builtin.c b/py/builtin.c index 178a6835a..c33637810 100644 --- a/py/builtin.c +++ b/py/builtin.c @@ -37,7 +37,7 @@ #include "runtime.h" #include "builtin.h" -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT #include #endif @@ -104,7 +104,7 @@ mp_obj_t mp_builtin_abs(mp_obj_t o_in) { val = -val; } return MP_OBJ_NEW_SMALL_INT(val); -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT } else if (MP_OBJ_IS_TYPE(o_in, &mp_type_float)) { mp_float_t value = mp_obj_float_get(o_in); // TODO check for NaN etc diff --git a/py/builtintables.c b/py/builtintables.c index 1d22683d9..05fefb64c 100644 --- a/py/builtintables.c +++ b/py/builtintables.c @@ -44,23 +44,23 @@ STATIC const mp_map_elem_t mp_builtin_object_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_bool), (mp_obj_t)&mp_type_bool }, { MP_OBJ_NEW_QSTR(MP_QSTR_bytes), (mp_obj_t)&mp_type_bytes }, { MP_OBJ_NEW_QSTR(MP_QSTR_bytearray), (mp_obj_t)&mp_type_bytearray }, -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT { MP_OBJ_NEW_QSTR(MP_QSTR_complex), (mp_obj_t)&mp_type_complex }, #endif { MP_OBJ_NEW_QSTR(MP_QSTR_dict), (mp_obj_t)&mp_type_dict }, { MP_OBJ_NEW_QSTR(MP_QSTR_enumerate), (mp_obj_t)&mp_type_enumerate }, { MP_OBJ_NEW_QSTR(MP_QSTR_filter), (mp_obj_t)&mp_type_filter }, -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT { MP_OBJ_NEW_QSTR(MP_QSTR_float), (mp_obj_t)&mp_type_float }, #endif -#if MICROPY_PY_FROZENSET +#if MICROPY_PY_BUILTINS_FROZENSET { MP_OBJ_NEW_QSTR(MP_QSTR_frozenset), (mp_obj_t)&mp_type_frozenset }, #endif { MP_OBJ_NEW_QSTR(MP_QSTR_int), (mp_obj_t)&mp_type_int }, { MP_OBJ_NEW_QSTR(MP_QSTR_list), (mp_obj_t)&mp_type_list }, { MP_OBJ_NEW_QSTR(MP_QSTR_map), (mp_obj_t)&mp_type_map }, { MP_OBJ_NEW_QSTR(MP_QSTR_object), (mp_obj_t)&mp_type_object }, -#if MICROPY_PY_PROPERTY +#if MICROPY_PY_BUILTINS_PROPERTY { MP_OBJ_NEW_QSTR(MP_QSTR_property), (mp_obj_t)&mp_type_property }, #endif { MP_OBJ_NEW_QSTR(MP_QSTR_range), (mp_obj_t)&mp_type_range }, @@ -169,7 +169,7 @@ STATIC const mp_map_elem_t mp_builtin_module_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_struct), (mp_obj_t)&mp_module_struct }, #endif -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT { MP_OBJ_NEW_QSTR(MP_QSTR_math), (mp_obj_t)&mp_module_math }, #if MICROPY_PY_CMATH { MP_OBJ_NEW_QSTR(MP_QSTR_cmath), (mp_obj_t)&mp_module_cmath }, diff --git a/py/modcmath.c b/py/modcmath.c index 9e4de2585..3bc3055dc 100644 --- a/py/modcmath.c +++ b/py/modcmath.c @@ -32,7 +32,7 @@ #include "obj.h" #include "builtin.h" -#if MICROPY_ENABLE_FLOAT && MICROPY_PY_CMATH +#if MICROPY_PY_BUILTINS_FLOAT && MICROPY_PY_CMATH // These are defined in modmath.c extern const mp_obj_float_t mp_math_e_obj; @@ -154,4 +154,4 @@ const mp_obj_module_t mp_module_cmath = { .globals = (mp_obj_dict_t*)&mp_module_cmath_globals, }; -#endif // MICROPY_ENABLE_FLOAT && MICROPY_PY_CMATH +#endif // MICROPY_PY_BUILTINS_FLOAT && MICROPY_PY_CMATH diff --git a/py/modmath.c b/py/modmath.c index e0ff16343..0fd583c2f 100644 --- a/py/modmath.c +++ b/py/modmath.c @@ -32,7 +32,7 @@ #include "obj.h" #include "builtin.h" -#if MICROPY_ENABLE_FLOAT && MICROPY_PY_MATH +#if MICROPY_PY_BUILTINS_FLOAT && MICROPY_PY_MATH //TODO: Change macros to check for overflow and raise OverflowError or RangeError #define MATH_FUN_1(py_name, c_name) \ @@ -184,4 +184,4 @@ const mp_obj_module_t mp_module_math = { .globals = (mp_obj_dict_t*)&mp_module_math_globals, }; -#endif // MICROPY_ENABLE_FLOAT && MICROPY_PY_MATH +#endif // MICROPY_PY_BUILTINS_FLOAT && MICROPY_PY_MATH diff --git a/py/mpconfig.h b/py/mpconfig.h index 1af27f767..a72d5c260 100644 --- a/py/mpconfig.h +++ b/py/mpconfig.h @@ -212,15 +212,15 @@ typedef long long mp_longint_impl_t; #endif #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT -#define MICROPY_ENABLE_FLOAT (1) +#define MICROPY_PY_BUILTINS_FLOAT (1) #define MICROPY_FLOAT_C_FUN(fun) fun##f typedef float mp_float_t; #elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE -#define MICROPY_ENABLE_FLOAT (1) +#define MICROPY_PY_BUILTINS_FLOAT (1) #define MICROPY_FLOAT_C_FUN(fun) fun typedef double mp_float_t; #else -#define MICROPY_ENABLE_FLOAT (0) +#define MICROPY_PY_BUILTINS_FLOAT (0) #endif // Enable features which improve CPython compatibility @@ -239,20 +239,19 @@ typedef double mp_float_t; /*****************************************************************************/ /* Fine control over Python builtins, classes, modules, etc */ -// Whether to support slice object and correspondingly -// slice subscript operators -#ifndef MICROPY_PY_SLICE -#define MICROPY_PY_SLICE (1) +// Whether to support slice subscript operators and slice object +#ifndef MICROPY_PY_BUILTINS_SLICE +#define MICROPY_PY_BUILTINS_SLICE (1) #endif // Whether to support frozenset object -#ifndef MICROPY_PY_FROZENSET -#define MICROPY_PY_FROZENSET (0) +#ifndef MICROPY_PY_BUILTINS_FROZENSET +#define MICROPY_PY_BUILTINS_FROZENSET (0) #endif -// Whether to support the property object -#ifndef MICROPY_PY_PROPERTY -#define MICROPY_PY_PROPERTY (1) +// Whether to support property object +#ifndef MICROPY_PY_BUILTINS_PROPERTY +#define MICROPY_PY_BUILTINS_PROPERTY (1) #endif // Whether to provide "collections" module diff --git a/py/mpz.c b/py/mpz.c index 9c42878ff..ab300b91d 100644 --- a/py/mpz.c +++ b/py/mpz.c @@ -1262,7 +1262,7 @@ bool mpz_as_int_checked(const mpz_t *i, machine_int_t *value) { return true; } -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT mp_float_t mpz_as_float(const mpz_t *i) { mp_float_t val = 0; mpz_dig_t *d = i->dig + i->len; diff --git a/py/mpz.h b/py/mpz.h index 654be21c0..0f962cc02 100644 --- a/py/mpz.h +++ b/py/mpz.h @@ -98,7 +98,7 @@ mpz_t *mpz_mod(const mpz_t *lhs, const mpz_t *rhs); machine_int_t mpz_as_int(const mpz_t *z); bool mpz_as_int_checked(const mpz_t *z, machine_int_t *value); -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT mp_float_t mpz_as_float(const mpz_t *z); #endif uint mpz_as_str_size(const mpz_t *z, uint base); diff --git a/py/obj.c b/py/obj.c index f8b5ee34d..6d0966db2 100644 --- a/py/obj.c +++ b/py/obj.c @@ -257,7 +257,7 @@ bool mp_obj_get_int_maybe(mp_const_obj_t arg, machine_int_t *value) { return true; } -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT mp_float_t mp_obj_get_float(mp_obj_t arg) { if (arg == mp_const_false) { return 0; diff --git a/py/obj.h b/py/obj.h index 185fe14db..e7c044df0 100644 --- a/py/obj.h +++ b/py/obj.h @@ -371,7 +371,7 @@ mp_obj_t mp_obj_new_int_from_str_len(const char **str, uint len, bool neg, uint mp_obj_t mp_obj_new_int_from_ll(long long val); // this must return a multi-precision integer object (or raise an overflow exception) mp_obj_t mp_obj_new_str(const char* data, uint len, bool make_qstr_if_not_already); mp_obj_t mp_obj_new_bytes(const byte* data, uint len); -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT 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 @@ -420,7 +420,7 @@ bool mp_obj_equal(mp_obj_t o1, mp_obj_t o2); machine_int_t mp_obj_get_int(mp_const_obj_t arg); bool mp_obj_get_int_maybe(mp_const_obj_t arg, machine_int_t *value); -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT mp_float_t mp_obj_get_float(mp_obj_t self_in); void mp_obj_get_complex(mp_obj_t self_in, mp_float_t *real, mp_float_t *imag); #endif @@ -442,7 +442,7 @@ void mp_obj_cell_set(mp_obj_t self_in, mp_obj_t obj); // int // For long int, returns value truncated to machine_int_t machine_int_t mp_obj_int_get(mp_const_obj_t self_in); -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT mp_float_t mp_obj_int_as_float(mp_obj_t self_in); #endif // Will raise exception if value doesn't fit into machine_int_t @@ -470,7 +470,7 @@ const char *mp_obj_str_get_str(mp_obj_t self_in); // use this only if you need t const char *mp_obj_str_get_data(mp_obj_t self_in, uint *len); void mp_str_print_quoted(void (*print)(void *env, const char *fmt, ...), void *env, const byte *str_data, uint str_len); -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT // float typedef struct _mp_obj_float_t { mp_obj_base_t base; diff --git a/py/objcomplex.c b/py/objcomplex.c index 80a13c6d8..d58b53463 100644 --- a/py/objcomplex.c +++ b/py/objcomplex.c @@ -36,7 +36,7 @@ #include "runtime0.h" #include "runtime.h" -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT #include diff --git a/py/objfloat.c b/py/objfloat.c index 6732f3121..b608b1a3d 100644 --- a/py/objfloat.c +++ b/py/objfloat.c @@ -39,7 +39,7 @@ #include "runtime0.h" #include "runtime.h" -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT #include "formatfloat.h" @@ -170,4 +170,4 @@ mp_obj_t mp_obj_float_binary_op(int op, mp_float_t lhs_val, mp_obj_t rhs_in) { return mp_obj_new_float(lhs_val); } -#endif // MICROPY_ENABLE_FLOAT +#endif // MICROPY_PY_BUILTINS_FLOAT diff --git a/py/objfun.c b/py/objfun.c index 8ee5365d5..77d57821b 100644 --- a/py/objfun.c +++ b/py/objfun.c @@ -469,7 +469,7 @@ STATIC machine_uint_t convert_obj_for_inline_asm(mp_obj_t obj) { } else { mp_obj_type_t *type = mp_obj_get_type(obj); if (0) { -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT } else if (type == &mp_type_float) { // convert float to int (could also pass in float registers) return (machine_int_t)mp_obj_float_get(obj); diff --git a/py/objint.c b/py/objint.c index f631d698f..74b756455 100644 --- a/py/objint.c +++ b/py/objint.c @@ -41,7 +41,7 @@ #include "runtime0.h" #include "runtime.h" -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT #include #endif @@ -62,7 +62,7 @@ STATIC mp_obj_t mp_obj_int_make_new(mp_obj_t type_in, uint n_args, uint n_kw, co uint l; const char *s = mp_obj_str_get_data(args[0], &l); return mp_parse_num_integer(s, l, 0); -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT } else if (MP_OBJ_IS_TYPE(args[0], &mp_type_float)) { return MP_OBJ_NEW_SMALL_INT((machine_int_t)(MICROPY_FLOAT_C_FUN(trunc)(mp_obj_float_get(args[0])))); #endif @@ -267,7 +267,7 @@ machine_int_t mp_obj_int_get_checked(mp_const_obj_t self_in) { return MP_OBJ_SMALL_INT_VALUE(self_in); } -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT mp_float_t mp_obj_int_as_float(mp_obj_t self_in) { return MP_OBJ_SMALL_INT_VALUE(self_in); } diff --git a/py/objint_longlong.c b/py/objint_longlong.c index 82db9e660..dfe069c08 100644 --- a/py/objint_longlong.c +++ b/py/objint_longlong.c @@ -188,7 +188,7 @@ machine_int_t mp_obj_int_get_checked(mp_const_obj_t self_in) { return mp_obj_int_get(self_in); } -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT mp_float_t mp_obj_int_as_float(mp_obj_t self_in) { if (MP_OBJ_IS_SMALL_INT(self_in)) { return MP_OBJ_SMALL_INT_VALUE(self_in); diff --git a/py/objint_mpz.c b/py/objint_mpz.c index 9cdbb7168..516fb5274 100644 --- a/py/objint_mpz.c +++ b/py/objint_mpz.c @@ -118,7 +118,7 @@ mp_obj_t mp_obj_int_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) { zrhs = &z_int; } else if (MP_OBJ_IS_TYPE(rhs_in, &mp_type_int)) { zrhs = &((mp_obj_int_t*)rhs_in)->mpz; -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT } else if (MP_OBJ_IS_TYPE(rhs_in, &mp_type_float)) { return mp_obj_float_binary_op(op, mpz_as_float(zlhs), rhs_in); } else if (MP_OBJ_IS_TYPE(rhs_in, &mp_type_complex)) { @@ -130,7 +130,7 @@ mp_obj_t mp_obj_int_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) { } if (0) { -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT } else if (op == MP_BINARY_OP_TRUE_DIVIDE || op == MP_BINARY_OP_INPLACE_TRUE_DIVIDE) { mp_float_t flhs = mpz_as_float(zlhs); mp_float_t frhs = mpz_as_float(zrhs); @@ -292,7 +292,7 @@ machine_int_t mp_obj_int_get_checked(mp_const_obj_t self_in) { } } -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT mp_float_t mp_obj_int_as_float(mp_obj_t self_in) { if (MP_OBJ_IS_SMALL_INT(self_in)) { return MP_OBJ_SMALL_INT_VALUE(self_in); diff --git a/py/objlist.c b/py/objlist.c index 647096f0d..6e22169fd 100644 --- a/py/objlist.c +++ b/py/objlist.c @@ -150,7 +150,7 @@ STATIC mp_obj_t list_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) { STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { if (value == MP_OBJ_NULL) { // delete -#if MICROPY_PY_SLICE +#if MICROPY_PY_BUILTINS_SLICE if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { mp_obj_list_t *self = self_in; mp_bound_slice_t slice; @@ -174,7 +174,7 @@ STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { } else if (value == MP_OBJ_SENTINEL) { // load mp_obj_list_t *self = self_in; -#if MICROPY_PY_SLICE +#if MICROPY_PY_BUILTINS_SLICE if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { mp_bound_slice_t slice; if (!mp_seq_get_fast_slice_indexes(self->len, index, &slice)) { @@ -188,7 +188,7 @@ STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { uint index_val = mp_get_index(self->base.type, self->len, index, false); return self->items[index_val]; } else { -#if MICROPY_PY_SLICE +#if MICROPY_PY_BUILTINS_SLICE if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { mp_obj_list_t *self = self_in; assert(MP_OBJ_IS_TYPE(value, &mp_type_list)); diff --git a/py/objproperty.c b/py/objproperty.c index 147a755a4..5a9311ac9 100644 --- a/py/objproperty.c +++ b/py/objproperty.c @@ -34,7 +34,7 @@ #include "obj.h" #include "runtime.h" -#if MICROPY_PY_PROPERTY +#if MICROPY_PY_BUILTINS_PROPERTY typedef struct _mp_obj_property_t { mp_obj_base_t base; @@ -115,4 +115,4 @@ const mp_obj_t *mp_obj_property_get(mp_obj_t self_in) { return self->proxy; } -#endif // MICROPY_PY_PROPERTY +#endif // MICROPY_PY_BUILTINS_PROPERTY diff --git a/py/objset.c b/py/objset.c index 6a6a375fa..5cde71206 100644 --- a/py/objset.c +++ b/py/objset.c @@ -52,13 +52,13 @@ STATIC mp_obj_t set_it_iternext(mp_obj_t self_in); STATIC bool is_set_or_frozenset(mp_obj_t o) { return MP_OBJ_IS_TYPE(o, &mp_type_set) -#if MICROPY_PY_FROZENSET +#if MICROPY_PY_BUILTINS_FROZENSET || MP_OBJ_IS_TYPE(o, &mp_type_frozenset) #endif ; } -#if MICROPY_PY_FROZENSET +#if MICROPY_PY_BUILTINS_FROZENSET STATIC void check_set_or_frozenset(mp_obj_t o) { if (!is_set_or_frozenset(o)) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, "'set' object required")); @@ -72,7 +72,7 @@ STATIC void check_set(mp_obj_t o) { if (!MP_OBJ_IS_TYPE(o, &mp_type_set)) { // Emulate CPython behavior // AttributeError: 'frozenset' object has no attribute 'add' - #if MICROPY_PY_FROZENSET + #if MICROPY_PY_BUILTINS_FROZENSET if (MP_OBJ_IS_TYPE(o, &mp_type_frozenset)) { nlr_raise(mp_obj_new_exception_msg(&mp_type_AttributeError, "'frozenset' has no such attribute")); } @@ -83,11 +83,11 @@ STATIC void check_set(mp_obj_t o) { STATIC void set_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) { mp_obj_set_t *self = self_in; - #if MICROPY_PY_FROZENSET + #if MICROPY_PY_BUILTINS_FROZENSET bool is_frozen = MP_OBJ_IS_TYPE(self_in, &mp_type_frozenset); #endif if (self->set.used == 0) { - #if MICROPY_PY_FROZENSET + #if MICROPY_PY_BUILTINS_FROZENSET if (is_frozen) { print(env, "frozen"); } @@ -96,7 +96,7 @@ STATIC void set_print(void (*print)(void *env, const char *fmt, ...), void *env, return; } bool first = true; - #if MICROPY_PY_FROZENSET + #if MICROPY_PY_BUILTINS_FROZENSET if (is_frozen) { print(env, "frozenset("); } @@ -112,7 +112,7 @@ STATIC void set_print(void (*print)(void *env, const char *fmt, ...), void *env, } } print(env, "}"); - #if MICROPY_PY_FROZENSET + #if MICROPY_PY_BUILTINS_FROZENSET if (is_frozen) { print(env, ")"); } @@ -556,7 +556,7 @@ const mp_obj_type_t mp_type_set = { .locals_dict = (mp_obj_t)&set_locals_dict, }; -#if MICROPY_PY_FROZENSET +#if MICROPY_PY_BUILTINS_FROZENSET const mp_obj_type_t mp_type_frozenset = { { &mp_type_type }, .name = MP_QSTR_frozenset, diff --git a/py/objslice.c b/py/objslice.c index dfd070f8d..6324c0e49 100644 --- a/py/objslice.c +++ b/py/objslice.c @@ -56,7 +56,7 @@ const mp_obj_ellipsis_t mp_const_ellipsis_obj = {{&mp_type_ellipsis}}; /******************************************************************************/ /* slice object */ -#if MICROPY_PY_SLICE +#if MICROPY_PY_BUILTINS_SLICE // TODO: This implements only variant of slice with 2 integer args only. // CPython supports 3rd arg (step), plus args can be arbitrary Python objects. diff --git a/py/objstr.c b/py/objstr.c index 27f6d9cd6..43425f6f7 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -348,7 +348,7 @@ STATIC mp_obj_t str_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { GET_STR_DATA_LEN(self_in, self_data, self_len); if (value == MP_OBJ_SENTINEL) { // load -#if MICROPY_PY_SLICE +#if MICROPY_PY_BUILTINS_SLICE if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { mp_bound_slice_t slice; if (!mp_seq_get_fast_slice_indexes(self_len, index, &slice)) { @@ -741,14 +741,14 @@ static bool arg_looks_integer(mp_obj_t arg) { static bool arg_looks_numeric(mp_obj_t arg) { return arg_looks_integer(arg) -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT || MP_OBJ_IS_TYPE(arg, &mp_type_float) #endif ; } static mp_obj_t arg_as_int(mp_obj_t arg) { -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT if (MP_OBJ_IS_TYPE(arg, &mp_type_float)) { // TODO: Needs a way to construct an mpz integer from a float @@ -1066,7 +1066,7 @@ mp_obj_t mp_obj_str_format(uint n_args, const mp_obj_t *args) { flags |= PF_FLAG_PAD_NAN_INF; // '{:06e}'.format(float('-inf')) should give '-00inf' switch (type) { -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT case 'e': case 'E': case 'f': @@ -1214,7 +1214,7 @@ STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, uint n_args, const mp_obj_t pfenv_print_strn(&pfenv_vstr, &ch, 1, flags, ' ', width); break; } -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT // This is what CPython reports, so we report the same. if (MP_OBJ_IS_TYPE(arg, &mp_type_float)) { nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, "integer argument expected, got float")); @@ -1230,7 +1230,7 @@ STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, uint n_args, const mp_obj_t pfenv_print_mp_int(&pfenv_vstr, arg_as_int(arg), 1, 10, 'a', flags, fill, width); break; -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT case 'e': case 'E': case 'f': diff --git a/py/objtuple.c b/py/objtuple.c index c0a33dad7..fc97f53cf 100644 --- a/py/objtuple.c +++ b/py/objtuple.c @@ -161,7 +161,7 @@ mp_obj_t mp_obj_tuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { if (value == MP_OBJ_SENTINEL) { // load mp_obj_tuple_t *self = self_in; -#if MICROPY_PY_SLICE +#if MICROPY_PY_BUILTINS_SLICE if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { mp_bound_slice_t slice; if (!mp_seq_get_fast_slice_indexes(self->len, index, &slice)) { diff --git a/py/objtype.c b/py/objtype.c index 0561282b8..ebbb6097d 100644 --- a/py/objtype.c +++ b/py/objtype.c @@ -413,7 +413,7 @@ STATIC void instance_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { mp_obj_class_lookup(self, self->base.type, attr, 0, dest); mp_obj_t member = dest[0]; if (member != MP_OBJ_NULL) { -#if MICROPY_PY_PROPERTY +#if MICROPY_PY_BUILTINS_PROPERTY if (MP_OBJ_IS_TYPE(member, &mp_type_property)) { // object member is a property // delegate the store to the property @@ -447,7 +447,7 @@ STATIC void instance_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { STATIC bool instance_store_attr(mp_obj_t self_in, qstr attr, mp_obj_t value) { mp_obj_instance_t *self = self_in; -#if MICROPY_PY_PROPERTY +#if MICROPY_PY_BUILTINS_PROPERTY // for property, we need to do a lookup first in the class dict // this makes all stores slow... how to fix? mp_obj_t member[2] = {MP_OBJ_NULL}; diff --git a/py/parsenum.c b/py/parsenum.c index 9729ffe64..2e513e515 100644 --- a/py/parsenum.c +++ b/py/parsenum.c @@ -36,7 +36,7 @@ #include "parsenum.h" #include "smallint.h" -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT #include #endif @@ -144,7 +144,7 @@ value_error: #define PARSE_DEC_IN_EXP (3) mp_obj_t mp_parse_num_decimal(const char *str, uint len, bool allow_imag, bool force_complex) { -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT const char *top = str + len; mp_float_t dec_val = 0; bool dec_neg = false; diff --git a/py/pfenv.c b/py/pfenv.c index c1a2eee0d..e4db4da04 100644 --- a/py/pfenv.c +++ b/py/pfenv.c @@ -39,7 +39,7 @@ #include #endif -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT #include "formatfloat.h" #endif @@ -266,7 +266,7 @@ int pfenv_print_mp_int(const pfenv_t *pfenv, mp_obj_t x, int sgn, int base, int return len; } -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT int pfenv_print_float(const pfenv_t *pfenv, mp_float_t f, char fmt, int flags, char fill, int width, int prec) { char buf[32]; char sign = '\0'; diff --git a/py/pfenv.h b/py/pfenv.h index 4c902c6bc..2a3de6c32 100644 --- a/py/pfenv.h +++ b/py/pfenv.h @@ -46,6 +46,6 @@ void pfenv_vstr_add_strn(void *data, const char *str, unsigned int len); int pfenv_print_strn(const pfenv_t *pfenv, const char *str, unsigned int len, int flags, char fill, int width); int pfenv_print_int(const pfenv_t *pfenv, machine_uint_t x, int sgn, int base, int base_char, int flags, char fill, int width); int pfenv_print_mp_int(const pfenv_t *pfenv, mp_obj_t x, int sgn, int base, int base_char, int flags, char fill, int width); -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT int pfenv_print_float(const pfenv_t *pfenv, mp_float_t f, char fmt, int flags, char fill, int width, int prec); #endif diff --git a/py/qstrdefs.h b/py/qstrdefs.h index 4ee56db90..69182f280 100644 --- a/py/qstrdefs.h +++ b/py/qstrdefs.h @@ -263,7 +263,7 @@ Q(iterator) Q(module) Q(slice) -#if MICROPY_PY_FROZENSET +#if MICROPY_PY_BUILTINS_FROZENSET Q(frozenset) #endif @@ -375,7 +375,7 @@ Q(disable) Q(enable) #endif -#if MICROPY_PY_PROPERTY +#if MICROPY_PY_BUILTINS_PROPERTY Q(property) Q(getter) Q(setter) diff --git a/py/runtime.c b/py/runtime.c index a9d57460a..d2219175d 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -353,7 +353,7 @@ mp_obj_t mp_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) { lhs_val = mp_small_int_floor_divide(lhs_val, rhs_val); break; - #if MICROPY_ENABLE_FLOAT + #if MICROPY_PY_BUILTINS_FLOAT case MP_BINARY_OP_TRUE_DIVIDE: case MP_BINARY_OP_INPLACE_TRUE_DIVIDE: if (rhs_val == 0) { @@ -371,7 +371,7 @@ mp_obj_t mp_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) { case MP_BINARY_OP_POWER: case MP_BINARY_OP_INPLACE_POWER: if (rhs_val < 0) { - #if MICROPY_ENABLE_FLOAT + #if MICROPY_PY_BUILTINS_FLOAT lhs = mp_obj_new_float(lhs_val); goto generic_binary_op; #else @@ -418,7 +418,7 @@ mp_obj_t mp_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) { } else { return mp_obj_new_int(lhs_val); } -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT } else if (MP_OBJ_IS_TYPE(rhs, &mp_type_float)) { mp_obj_t res = mp_obj_float_binary_op(op, lhs_val, rhs); if (res == MP_OBJ_NULL) { diff --git a/py/showbc.c b/py/showbc.c index 33c59dcba..fc02f4c58 100644 --- a/py/showbc.c +++ b/py/showbc.c @@ -419,7 +419,7 @@ void mp_bytecode_print2(const byte *ip, int len) { printf("SET_ADD " UINT_FMT, unum); break; -#if MICROPY_PY_SLICE +#if MICROPY_PY_BUILTINS_SLICE case MP_BC_BUILD_SLICE: DECODE_UINT; printf("BUILD_SLICE " UINT_FMT, unum); diff --git a/py/vm.c b/py/vm.c index 783ce1f3d..d739dfe80 100644 --- a/py/vm.c +++ b/py/vm.c @@ -785,7 +785,7 @@ unwind_jump: sp--; DISPATCH(); -#if MICROPY_PY_SLICE +#if MICROPY_PY_BUILTINS_SLICE ENTRY(MP_BC_BUILD_SLICE): DECODE_UINT; if (unum == 2) { diff --git a/stmhal/modtime.c b/stmhal/modtime.c index 2e50a58df..4fbee3129 100644 --- a/stmhal/modtime.c +++ b/stmhal/modtime.c @@ -74,11 +74,11 @@ STATIC mp_obj_t time_localtime(void) { MP_DEFINE_CONST_FUN_OBJ_0(time_localtime_obj, time_localtime); STATIC mp_obj_t time_sleep(mp_obj_t seconds_o) { -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT if (MP_OBJ_IS_INT(seconds_o)) { #endif HAL_Delay(1000 * mp_obj_get_int(seconds_o)); -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT } else { HAL_Delay((uint32_t)(1000 * mp_obj_get_float(seconds_o))); } diff --git a/stmhal/mpconfigport.h b/stmhal/mpconfigport.h index 33b81336c..36a60dfa7 100644 --- a/stmhal/mpconfigport.h +++ b/stmhal/mpconfigport.h @@ -44,7 +44,7 @@ */ #define MICROPY_ENABLE_LFN (1) #define MICROPY_LFN_CODE_PAGE (437) /* 1=SFN/ANSI 437=LFN/U.S.(OEM) */ -#define MICROPY_PY_FROZENSET (1) +#define MICROPY_PY_BUILTINS_FROZENSET (1) #define MICROPY_PY_SYS_EXIT (1) #define MICROPY_PY_SYS_STDFILES (1) #define MICROPY_PY_CMATH (1) diff --git a/stmhal/printf.c b/stmhal/printf.c index 3f88a9c5a..6cfeda263 100644 --- a/stmhal/printf.c +++ b/stmhal/printf.c @@ -41,7 +41,7 @@ #include "uart.h" #include "usb.h" -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT #include "formatfloat.h" #endif @@ -162,7 +162,7 @@ int pfenv_printf(const pfenv_t *pfenv, const char *fmt, va_list args) { case 'P': // ? chrs += pfenv_print_int(pfenv, va_arg(args, int), 0, 16, 'A', flags, fill, width); break; -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT case 'e': case 'E': case 'f': diff --git a/stmhal/servo.c b/stmhal/servo.c index e44e129ef..3da445fa8 100644 --- a/stmhal/servo.c +++ b/stmhal/servo.c @@ -271,7 +271,7 @@ STATIC mp_obj_t pyb_servo_angle(uint n_args, const mp_obj_t *args) { // get angle return mp_obj_new_int((self->pulse_cur - self->pulse_centre) * 90 / self->pulse_angle_90); } else { -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT self->pulse_dest = self->pulse_centre + self->pulse_angle_90 * mp_obj_get_float(args[1]) / 90.0; #else self->pulse_dest = self->pulse_centre + self->pulse_angle_90 * mp_obj_get_int(args[1]) / 90; @@ -301,7 +301,7 @@ STATIC mp_obj_t pyb_servo_speed(uint n_args, const mp_obj_t *args) { // get speed return mp_obj_new_int((self->pulse_cur - self->pulse_centre) * 100 / self->pulse_speed_100); } else { -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT self->pulse_dest = self->pulse_centre + self->pulse_speed_100 * mp_obj_get_float(args[1]) / 100.0; #else self->pulse_dest = self->pulse_centre + self->pulse_speed_100 * mp_obj_get_int(args[1]) / 100; diff --git a/teensy/mpconfigport.h b/teensy/mpconfigport.h index c01f13a6d..f7c66d887 100644 --- a/teensy/mpconfigport.h +++ b/teensy/mpconfigport.h @@ -6,7 +6,7 @@ #define MICROPY_EMIT_INLINE_THUMB (1) #define MICROPY_ENABLE_GC (1) #define MICROPY_HELPER_REPL (1) -#define MICROPY_ENABLE_FLOAT (1) +#define MICROPY_PY_BUILTINS_FLOAT (1) // type definitions for the specific machine diff --git a/unix/modtime.c b/unix/modtime.c index 77d2945b8..f957b9678 100644 --- a/unix/modtime.c +++ b/unix/modtime.c @@ -64,7 +64,7 @@ void msec_sleep_tv(struct timeval *tv) { #endif STATIC mp_obj_t mod_time_time() { -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT struct timeval tv; gettimeofday(&tv, NULL); mp_float_t val = tv.tv_sec + (mp_float_t)tv.tv_usec / 1000000; @@ -77,7 +77,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_time_time_obj, mod_time_time); // Note: this is deprecated since CPy3.3, but pystone still uses it. STATIC mp_obj_t mod_time_clock() { -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT // float cannot represent full range of int32 precisely, so we pre-divide // int to reduce resolution, and then actually do float division hoping // to preserve integer part resolution. @@ -89,7 +89,7 @@ STATIC mp_obj_t mod_time_clock() { STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_time_clock_obj, mod_time_clock); STATIC mp_obj_t mod_time_sleep(mp_obj_t arg) { -#if MICROPY_ENABLE_FLOAT +#if MICROPY_PY_BUILTINS_FLOAT struct timeval tv; mp_float_t val = mp_obj_get_float(arg); double ipart; diff --git a/unix/mpconfigport.h b/unix/mpconfigport.h index c56c9fa1a..1b1d938a8 100644 --- a/unix/mpconfigport.h +++ b/unix/mpconfigport.h @@ -41,7 +41,7 @@ #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ) #define MICROPY_STREAMS_NON_BLOCK (1) #define MICROPY_OPT_COMPUTED_GOTO (1) -#define MICROPY_PY_FROZENSET (1) +#define MICROPY_PY_BUILTINS_FROZENSET (1) #define MICROPY_PY_SYS_EXIT (1) #define MICROPY_PY_SYS_STDFILES (1) #define MICROPY_PY_CMATH (1) diff --git a/windows/mpconfigport.h b/windows/mpconfigport.h index 0ac715f40..94304e20d 100644 --- a/windows/mpconfigport.h +++ b/windows/mpconfigport.h @@ -39,7 +39,7 @@ #define MICROPY_DEBUG_PRINTERS (1) #define MICROPY_HELPER_REPL (1) #define MICROPY_HELPER_LEXER_UNIX (1) -#define MICROPY_PY_FROZENSET (1) +#define MICROPY_PY_BUILTINS_FROZENSET (1) #define MICROPY_PY_CMATH (1) #define MICROPY_PY_SYS_STDFILES (1) #define MICROPY_PY_SYS_EXIT (1)