From ee3fd46f1383e984c968c4a82d634d7b0cea49b8 Mon Sep 17 00:00:00 2001 From: Damien George Date: Sat, 24 May 2014 23:03:12 +0100 Subject: [PATCH] Rename configuration variables controling Python features. Now of the form MICROPY_PY_*. See issue #35. --- bare-arm/mpconfigport.h | 14 ++-- py/builtinimport.c | 2 +- py/builtintables.c | 16 ++--- py/modcmath.c | 4 +- py/modcollections.c | 4 +- py/modgc.c | 2 +- py/modio.c | 6 +- py/modmath.c | 4 +- py/modstruct.c | 2 +- py/modsys.c | 6 +- py/mpconfig.h | 156 +++++++++++++++++++++------------------- py/objlist.c | 6 +- py/objnamedtuple.c | 4 +- py/objproperty.c | 4 +- py/objset.c | 16 ++--- py/objslice.c | 2 +- py/objstr.c | 2 +- py/objstringio.c | 4 +- py/objtuple.c | 2 +- py/objtype.c | 4 +- py/qstrdefs.h | 18 ++--- py/showbc.c | 2 +- py/vm.c | 2 +- qemu-arm/mpconfigport.h | 2 +- stmhal/mpconfigport.h | 8 +-- unix-cpy/mpconfigport.h | 2 +- unix/Makefile | 10 +-- unix/file.c | 4 +- unix/mpconfigport.h | 26 +++---- unix/mpconfigport.mk | 4 +- windows/mpconfigport.h | 8 +-- windows/mpconfigport.mk | 4 +- 32 files changed, 179 insertions(+), 171 deletions(-) diff --git a/bare-arm/mpconfigport.h b/bare-arm/mpconfigport.h index 54e1171fdd..3a3c8615d0 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_ENABLE_MOD_COLLECTIONS (0) -#define MICROPY_ENABLE_MOD_MATH (0) -#define MICROPY_ENABLE_MOD_CMATH (0) -#define MICROPY_ENABLE_MOD_IO (0) -#define MICROPY_ENABLE_MOD_STRUCT (0) -#define MICROPY_ENABLE_MOD_SYS (0) -#define MICROPY_ENABLE_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/builtinimport.c b/py/builtinimport.c index d2b18701b4..fa1a8397e1 100644 --- a/py/builtinimport.c +++ b/py/builtinimport.c @@ -73,7 +73,7 @@ mp_import_stat_t find_file(const char *file_str, uint file_len, vstr_t *dest) { // extract the list of paths uint path_num = 0; mp_obj_t *path_items; -#if MICROPY_ENABLE_MOD_SYS +#if MICROPY_PY_SYS mp_obj_list_get(mp_sys_path, &path_num, &path_items); #endif diff --git a/py/builtintables.c b/py/builtintables.c index d51c0198b2..1d22683d97 100644 --- a/py/builtintables.c +++ b/py/builtintables.c @@ -53,14 +53,14 @@ STATIC const mp_map_elem_t mp_builtin_object_table[] = { #if MICROPY_ENABLE_FLOAT { MP_OBJ_NEW_QSTR(MP_QSTR_float), (mp_obj_t)&mp_type_float }, #endif -#if MICROPY_ENABLE_FROZENSET +#if MICROPY_PY_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_ENABLE_PROPERTY +#if MICROPY_PY_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 }, @@ -159,26 +159,26 @@ STATIC const mp_map_elem_t mp_builtin_module_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_micropython), (mp_obj_t)&mp_module_micropython }, { MP_OBJ_NEW_QSTR(MP_QSTR_array), (mp_obj_t)&mp_module_array }, -#if MICROPY_ENABLE_MOD_IO +#if MICROPY_PY_IO { MP_OBJ_NEW_QSTR(MP_QSTR_io), (mp_obj_t)&mp_module_io }, #endif -#if MICROPY_ENABLE_MOD_COLLECTIONS +#if MICROPY_PY_COLLECTIONS { MP_OBJ_NEW_QSTR(MP_QSTR__collections), (mp_obj_t)&mp_module_collections }, #endif -#if MICROPY_ENABLE_MOD_STRUCT +#if MICROPY_PY_STRUCT { MP_OBJ_NEW_QSTR(MP_QSTR_struct), (mp_obj_t)&mp_module_struct }, #endif #if MICROPY_ENABLE_FLOAT { MP_OBJ_NEW_QSTR(MP_QSTR_math), (mp_obj_t)&mp_module_math }, -#if MICROPY_ENABLE_MOD_CMATH +#if MICROPY_PY_CMATH { MP_OBJ_NEW_QSTR(MP_QSTR_cmath), (mp_obj_t)&mp_module_cmath }, #endif #endif -#if MICROPY_ENABLE_MOD_SYS +#if MICROPY_PY_SYS { MP_OBJ_NEW_QSTR(MP_QSTR_sys), (mp_obj_t)&mp_module_sys }, #endif -#if MICROPY_ENABLE_MOD_GC && MICROPY_ENABLE_GC +#if MICROPY_PY_GC && MICROPY_ENABLE_GC { MP_OBJ_NEW_QSTR(MP_QSTR_gc), (mp_obj_t)&mp_module_gc }, #endif diff --git a/py/modcmath.c b/py/modcmath.c index fc41c44b0b..9e4de2585f 100644 --- a/py/modcmath.c +++ b/py/modcmath.c @@ -32,7 +32,7 @@ #include "obj.h" #include "builtin.h" -#if MICROPY_ENABLE_FLOAT && MICROPY_ENABLE_MOD_CMATH +#if MICROPY_ENABLE_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_ENABLE_MOD_CMATH +#endif // MICROPY_ENABLE_FLOAT && MICROPY_PY_CMATH diff --git a/py/modcollections.c b/py/modcollections.c index a7ed273ac3..9e3da7e666 100644 --- a/py/modcollections.c +++ b/py/modcollections.c @@ -30,7 +30,7 @@ #include "obj.h" #include "builtin.h" -#if MICROPY_ENABLE_MOD_COLLECTIONS +#if MICROPY_PY_COLLECTIONS STATIC const mp_map_elem_t mp_module_collections_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR__collections) }, @@ -54,4 +54,4 @@ const mp_obj_module_t mp_module_collections = { .globals = (mp_obj_dict_t*)&mp_module_collections_globals, }; -#endif // MICROPY_ENABLE_MOD_COLLECTIONS +#endif // MICROPY_PY_COLLECTIONS diff --git a/py/modgc.c b/py/modgc.c index de6ecd5867..03b520b949 100644 --- a/py/modgc.c +++ b/py/modgc.c @@ -35,7 +35,7 @@ #include "objstr.h" #include "gc.h" -#if MICROPY_ENABLE_MOD_GC && MICROPY_ENABLE_GC +#if MICROPY_PY_GC && MICROPY_ENABLE_GC STATIC mp_obj_t py_gc_collect(void) { gc_collect(); diff --git a/py/modio.c b/py/modio.c index b1f0d880ae..e1761f7ea6 100644 --- a/py/modio.c +++ b/py/modio.c @@ -30,7 +30,7 @@ #include "obj.h" #include "builtin.h" -#if MICROPY_ENABLE_MOD_IO +#if MICROPY_PY_IO extern const mp_obj_type_t mp_type_fileio; extern const mp_obj_type_t mp_type_textio; @@ -40,14 +40,14 @@ STATIC const mp_map_elem_t mp_module_io_globals_table[] = { // Note: mp_builtin_open_obj should be defined by port, it's not // part of the core. { MP_OBJ_NEW_QSTR(MP_QSTR_open), (mp_obj_t)&mp_builtin_open_obj }, - #if MICROPY_MOD_IO_FILEIO + #if MICROPY_PY_IO_FILEIO { MP_OBJ_NEW_QSTR(MP_QSTR_FileIO), (mp_obj_t)&mp_type_fileio }, #endif #if MICROPY_CPYTHON_COMPAT { MP_OBJ_NEW_QSTR(MP_QSTR_TextIOWrapper), (mp_obj_t)&mp_type_textio }, #endif { MP_OBJ_NEW_QSTR(MP_QSTR_StringIO), (mp_obj_t)&mp_type_stringio }, - #if MICROPY_IO_BYTESIO + #if MICROPY_PY_IO_BYTESIO { MP_OBJ_NEW_QSTR(MP_QSTR_BytesIO), (mp_obj_t)&mp_type_bytesio }, #endif }; diff --git a/py/modmath.c b/py/modmath.c index 485d9462a9..e0ff163436 100644 --- a/py/modmath.c +++ b/py/modmath.c @@ -32,7 +32,7 @@ #include "obj.h" #include "builtin.h" -#if MICROPY_ENABLE_FLOAT && MICROPY_ENABLE_MOD_MATH +#if MICROPY_ENABLE_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_ENABLE_MOD_MATH +#endif // MICROPY_ENABLE_FLOAT && MICROPY_PY_MATH diff --git a/py/modstruct.c b/py/modstruct.c index 19cf9cfd6c..39571e3efa 100644 --- a/py/modstruct.c +++ b/py/modstruct.c @@ -37,7 +37,7 @@ #include "binary.h" #include "parsenum.h" -#if MICROPY_ENABLE_MOD_STRUCT +#if MICROPY_PY_STRUCT STATIC char get_fmt_type(const char **fmt) { char t = **fmt; diff --git a/py/modsys.c b/py/modsys.c index 954711a5a9..738758bdf4 100644 --- a/py/modsys.c +++ b/py/modsys.c @@ -34,7 +34,7 @@ #include "objtuple.h" #include "objstr.h" -#if MICROPY_ENABLE_MOD_SYS +#if MICROPY_PY_SYS // These should be implemented by ports, specific types don't matter, // only addresses. @@ -65,11 +65,11 @@ STATIC const mp_map_elem_t mp_module_sys_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_byteorder), MP_OBJ_NEW_QSTR(MP_QSTR_big) }, #endif -#if MICROPY_MOD_SYS_EXIT +#if MICROPY_PY_SYS_EXIT { MP_OBJ_NEW_QSTR(MP_QSTR_exit), (mp_obj_t)&mp_sys_exit_obj }, #endif -#if MICROPY_MOD_SYS_STDFILES +#if MICROPY_PY_SYS_STDFILES { MP_OBJ_NEW_QSTR(MP_QSTR_stdin), (mp_obj_t)&mp_sys_stdin_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_stdout), (mp_obj_t)&mp_sys_stdout_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_stderr), (mp_obj_t)&mp_sys_stderr_obj }, diff --git a/py/mpconfig.h b/py/mpconfig.h index 5104f39721..853d475c3e 100644 --- a/py/mpconfig.h +++ b/py/mpconfig.h @@ -131,7 +131,16 @@ #endif /*****************************************************************************/ -/* Fine control over Python features */ +/* Optimisations */ + +// Whether to use computed gotos in the VM, or a switch +// Computed gotos are roughly 10% faster, and increase VM code size by a little +#ifndef MICROPY_OPT_COMPUTED_GOTO +#define MICROPY_OPT_COMPUTED_GOTO (0) +#endif + +/*****************************************************************************/ +/* Python internal features */ // Whether to include the garbage collector #ifndef MICROPY_ENABLE_GC @@ -209,75 +218,6 @@ typedef double mp_float_t; #define MICROPY_ENABLE_FLOAT (0) #endif -// Whether to provide "collections" module -#ifndef MICROPY_ENABLE_MOD_COLLECTIONS -#define MICROPY_ENABLE_MOD_COLLECTIONS (1) -#endif - -// Whether to provide "math" module -#ifndef MICROPY_ENABLE_MOD_MATH -#define MICROPY_ENABLE_MOD_MATH (1) -#endif - -// Whether to provide "cmath" module -#ifndef MICROPY_ENABLE_MOD_CMATH -#define MICROPY_ENABLE_MOD_CMATH (0) -#endif - -// Whether to provide "gc" module -#ifndef MICROPY_ENABLE_MOD_GC -#define MICROPY_ENABLE_MOD_GC (1) -#endif - -// Whether to provide "io" module -#ifndef MICROPY_ENABLE_MOD_IO -#define MICROPY_ENABLE_MOD_IO (1) -#endif - -#ifndef MICROPY_MOD_IO_FILEIO -#define MICROPY_MOD_IO_FILEIO (0) -#endif - -#ifndef MICROPY_IO_BYTESIO -#define MICROPY_IO_BYTESIO (1) -#endif - -// Whether to provide "struct" module -#ifndef MICROPY_ENABLE_MOD_STRUCT -#define MICROPY_ENABLE_MOD_STRUCT (1) -#endif - -// Whether to provide "sys" module -#ifndef MICROPY_ENABLE_MOD_SYS -#define MICROPY_ENABLE_MOD_SYS (1) -#endif - -// sys.exit() availability -#ifndef MICROPY_MOD_SYS_EXIT -#define MICROPY_MOD_SYS_EXIT (0) -#endif - -// sys.{stdin,stdout,stderr} availability -#ifndef MICROPY_MOD_SYS_STDFILES -#define MICROPY_MOD_SYS_STDFILES (0) -#endif - -// Whether to support slice object and correspondingly -// slice subscript operators -#ifndef MICROPY_ENABLE_SLICE -#define MICROPY_ENABLE_SLICE (1) -#endif - -// Whether to support frozenset object -#ifndef MICROPY_ENABLE_FROZENSET -#define MICROPY_ENABLE_FROZENSET (0) -#endif - -// Whether to support the property object -#ifndef MICROPY_ENABLE_PROPERTY -#define MICROPY_ENABLE_PROPERTY (1) -#endif - // Enable features which improve CPython compatibility // but may lead to more code size/memory usage. // TODO: Originally intended as generic category to not @@ -291,10 +231,78 @@ typedef double mp_float_t; #define MICROPY_STREAMS_NON_BLOCK (0) #endif -// Whether to use computed gotos in the VM, or a switch -// Computed gotos are roughly 10% faster, and increase VM code size by a little -#ifndef MICROPY_OPT_COMPUTED_GOTO -#define MICROPY_OPT_COMPUTED_GOTO (0) +/*****************************************************************************/ +/* 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) +#endif + +// Whether to support frozenset object +#ifndef MICROPY_PY_FROZENSET +#define MICROPY_PY_FROZENSET (0) +#endif + +// Whether to support the property object +#ifndef MICROPY_PY_PROPERTY +#define MICROPY_PY_PROPERTY (1) +#endif + +// Whether to provide "collections" module +#ifndef MICROPY_PY_COLLECTIONS +#define MICROPY_PY_COLLECTIONS (1) +#endif + +// Whether to provide "math" module +#ifndef MICROPY_PY_MATH +#define MICROPY_PY_MATH (1) +#endif + +// Whether to provide "cmath" module +#ifndef MICROPY_PY_CMATH +#define MICROPY_PY_CMATH (0) +#endif + +// Whether to provide "gc" module +#ifndef MICROPY_PY_GC +#define MICROPY_PY_GC (1) +#endif + +// Whether to provide "io" module +#ifndef MICROPY_PY_IO +#define MICROPY_PY_IO (1) +#endif + +// Whether to provide "io.FileIO" class +#ifndef MICROPY_PY_IO_FILEIO +#define MICROPY_PY_IO_FILEIO (0) +#endif + +// Whether to provide "io.BytesIO" class +#ifndef MICROPY_PY_IO_BYTESIO +#define MICROPY_PY_IO_BYTESIO (1) +#endif + +// Whether to provide "struct" module +#ifndef MICROPY_PY_STRUCT +#define MICROPY_PY_STRUCT (1) +#endif + +// Whether to provide "sys" module +#ifndef MICROPY_PY_SYS +#define MICROPY_PY_SYS (1) +#endif + +// Whether to provide "sys.exit" function +#ifndef MICROPY_PY_SYS_EXIT +#define MICROPY_PY_SYS_EXIT (0) +#endif + +// Whether to provide sys.{stdin,stdout,stderr} objects +#ifndef MICROPY_PY_SYS_STDFILES +#define MICROPY_PY_SYS_STDFILES (0) #endif /*****************************************************************************/ diff --git a/py/objlist.c b/py/objlist.c index ee74926923..7a15006adf 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_ENABLE_SLICE +#if MICROPY_PY_SLICE if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { mp_obj_list_t *self = self_in; machine_uint_t start, stop; @@ -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_ENABLE_SLICE +#if MICROPY_PY_SLICE if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { machine_uint_t start, stop; if (!mp_seq_get_fast_slice_indexes(self->len, index, &start, &stop)) { @@ -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_ENABLE_SLICE +#if MICROPY_PY_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/objnamedtuple.c b/py/objnamedtuple.c index a55dd643b0..6f228a8f09 100644 --- a/py/objnamedtuple.c +++ b/py/objnamedtuple.c @@ -34,7 +34,7 @@ #include "obj.h" #include "objtuple.h" -#if MICROPY_ENABLE_MOD_COLLECTIONS +#if MICROPY_PY_COLLECTIONS typedef struct _mp_obj_namedtuple_type_t { mp_obj_type_t base; @@ -174,4 +174,4 @@ STATIC mp_obj_t new_namedtuple_type(mp_obj_t name_in, mp_obj_t fields_in) { } MP_DEFINE_CONST_FUN_OBJ_2(mp_namedtuple_obj, new_namedtuple_type); -#endif // MICROPY_ENABLE_MOD_COLLECTIONS +#endif // MICROPY_PY_COLLECTIONS diff --git a/py/objproperty.c b/py/objproperty.c index b4f2e7d490..147a755a42 100644 --- a/py/objproperty.c +++ b/py/objproperty.c @@ -34,7 +34,7 @@ #include "obj.h" #include "runtime.h" -#if MICROPY_ENABLE_PROPERTY +#if MICROPY_PY_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_ENABLE_PROPERTY +#endif // MICROPY_PY_PROPERTY diff --git a/py/objset.c b/py/objset.c index 32c194db12..6a6a375faa 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_ENABLE_FROZENSET +#if MICROPY_PY_FROZENSET || MP_OBJ_IS_TYPE(o, &mp_type_frozenset) #endif ; } -#if MICROPY_ENABLE_FROZENSET +#if MICROPY_PY_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_ENABLE_FROZENSET + #if MICROPY_PY_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_ENABLE_FROZENSET + #if MICROPY_PY_FROZENSET bool is_frozen = MP_OBJ_IS_TYPE(self_in, &mp_type_frozenset); #endif if (self->set.used == 0) { - #if MICROPY_ENABLE_FROZENSET + #if MICROPY_PY_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_ENABLE_FROZENSET + #if MICROPY_PY_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_ENABLE_FROZENSET + #if MICROPY_PY_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_ENABLE_FROZENSET +#if MICROPY_PY_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 a51a65c11e..8fe65de1f8 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_ENABLE_SLICE +#if MICROPY_PY_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 323f329575..4ec1034e1e 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -349,7 +349,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_ENABLE_SLICE +#if MICROPY_PY_SLICE if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { machine_uint_t start, stop; if (!mp_seq_get_fast_slice_indexes(self_len, index, &start, &stop)) { diff --git a/py/objstringio.c b/py/objstringio.c index a1a765f89c..7a3e0f8939 100644 --- a/py/objstringio.c +++ b/py/objstringio.c @@ -37,7 +37,7 @@ #include "stream.h" #include "objstr.h" -#if MICROPY_ENABLE_MOD_IO +#if MICROPY_PY_IO typedef struct _mp_obj_stringio_t { mp_obj_base_t base; @@ -156,7 +156,7 @@ const mp_obj_type_t mp_type_stringio = { .locals_dict = (mp_obj_t)&stringio_locals_dict, }; -#if MICROPY_IO_BYTESIO +#if MICROPY_PY_IO_BYTESIO const mp_obj_type_t mp_type_bytesio = { { &mp_type_type }, .name = MP_QSTR_BytesIO, diff --git a/py/objtuple.c b/py/objtuple.c index 46515378f0..b56c6433f6 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_ENABLE_SLICE +#if MICROPY_PY_SLICE if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { machine_uint_t start, stop; if (!mp_seq_get_fast_slice_indexes(self->len, index, &start, &stop)) { diff --git a/py/objtype.c b/py/objtype.c index 1d4f90819b..0561282b8a 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_ENABLE_PROPERTY +#if MICROPY_PY_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_ENABLE_PROPERTY +#if MICROPY_PY_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/qstrdefs.h b/py/qstrdefs.h index 1081d04410..1de0989190 100644 --- a/py/qstrdefs.h +++ b/py/qstrdefs.h @@ -125,7 +125,7 @@ Q(bool) Q(bytearray) Q(bytes) Q(callable) -#if MICROPY_ENABLE_MOD_STRUCT +#if MICROPY_PY_STRUCT Q(calcsize) #endif Q(chr) @@ -257,11 +257,11 @@ Q(iterator) Q(module) Q(slice) -#if MICROPY_ENABLE_FROZENSET +#if MICROPY_PY_FROZENSET Q(frozenset) #endif -#if MICROPY_ENABLE_MOD_MATH || MICROPY_ENABLE_MOD_CMATH +#if MICROPY_PY_MATH || MICROPY_PY_CMATH Q(math) Q(e) Q(pi) @@ -305,7 +305,7 @@ Q(gamma) Q(lgamma) #endif -#if MICROPY_ENABLE_MOD_CMATH +#if MICROPY_PY_CMATH Q(cmath) Q(phase) Q(polar) @@ -331,7 +331,7 @@ Q(decode) Q(utf-8) #endif -#if MICROPY_ENABLE_MOD_SYS +#if MICROPY_PY_SYS Q(argv) Q(byteorder) Q(big) @@ -344,13 +344,13 @@ Q(version) Q(version_info) #endif -#if MICROPY_ENABLE_MOD_STRUCT +#if MICROPY_PY_STRUCT Q(struct) Q(pack) Q(unpack) #endif -#if MICROPY_ENABLE_MOD_IO +#if MICROPY_PY_IO Q(io) Q(readall) Q(readline) @@ -362,14 +362,14 @@ Q(BytesIO) Q(getvalue) #endif -#if MICROPY_ENABLE_MOD_GC +#if MICROPY_PY_GC Q(gc) Q(collect) Q(disable) Q(enable) #endif -#if MICROPY_ENABLE_PROPERTY +#if MICROPY_PY_PROPERTY Q(property) Q(getter) Q(setter) diff --git a/py/showbc.c b/py/showbc.c index 91b7572db9..33c59dcba9 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_ENABLE_SLICE +#if MICROPY_PY_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 ee2ec23607..1f3f693c97 100644 --- a/py/vm.c +++ b/py/vm.c @@ -762,7 +762,7 @@ unwind_jump: sp--; DISPATCH(); -#if MICROPY_ENABLE_SLICE +#if MICROPY_PY_SLICE ENTRY(MP_BC_BUILD_SLICE): DECODE_UINT; if (unum == 2) { diff --git a/qemu-arm/mpconfigport.h b/qemu-arm/mpconfigport.h index f760a47639..f464712f50 100644 --- a/qemu-arm/mpconfigport.h +++ b/qemu-arm/mpconfigport.h @@ -14,7 +14,7 @@ #define MICROPY_ENABLE_SOURCE_LINE (0) #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE) #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE) -#define MICROPY_ENABLE_MOD_IO (0) +#define MICROPY_PY_IO (0) // type definitions for the specific machine diff --git a/stmhal/mpconfigport.h b/stmhal/mpconfigport.h index d10e3142f6..33b81336ca 100644 --- a/stmhal/mpconfigport.h +++ b/stmhal/mpconfigport.h @@ -33,7 +33,6 @@ #define MICROPY_ENABLE_FINALISER (1) #define MICROPY_HELPER_REPL (1) #define MICROPY_ENABLE_SOURCE_LINE (1) -#define MICROPY_ENABLE_FROZENSET (1) #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ) #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT) #define MICROPY_OPT_COMPUTED_GOTO (1) @@ -45,9 +44,10 @@ */ #define MICROPY_ENABLE_LFN (1) #define MICROPY_LFN_CODE_PAGE (437) /* 1=SFN/ANSI 437=LFN/U.S.(OEM) */ -#define MICROPY_MOD_SYS_EXIT (1) -#define MICROPY_MOD_SYS_STDFILES (1) -#define MICROPY_ENABLE_MOD_CMATH (1) +#define MICROPY_PY_FROZENSET (1) +#define MICROPY_PY_SYS_EXIT (1) +#define MICROPY_PY_SYS_STDFILES (1) +#define MICROPY_PY_CMATH (1) // extra built in names to add to the global namespace extern const struct _mp_obj_fun_native_t mp_builtin_help_obj; diff --git a/unix-cpy/mpconfigport.h b/unix-cpy/mpconfigport.h index 99b735870d..78d197033a 100644 --- a/unix-cpy/mpconfigport.h +++ b/unix-cpy/mpconfigport.h @@ -29,7 +29,7 @@ #define MICROPY_EMIT_CPYTHON (1) #define MICROPY_HELPER_LEXER_UNIX (1) #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE) -#define MICROPY_ENABLE_MOD_IO (0) +#define MICROPY_PY_IO (0) // type definitions for the specific machine diff --git a/unix/Makefile b/unix/Makefile index 4dcba22e23..ffc3391a14 100644 --- a/unix/Makefile +++ b/unix/Makefile @@ -27,7 +27,7 @@ UNAME_S := $(shell uname -s) ifeq ($(MICROPY_FORCE_32BIT),1) CFLAGS += -m32 LDFLAGS += -m32 -ifeq ($(MICROPY_MOD_FFI),1) +ifeq ($(MICROPY_PY_FFI),1) ifeq ($(UNAME_S),Linux) CFLAGS_MOD += -I/usr/include/i686-linux-gnu endif @@ -40,14 +40,14 @@ LDFLAGS_MOD += -lreadline # the following is needed for BSD #LDFLAGS_MOD += -ltermcap endif -ifeq ($(MICROPY_MOD_TIME),1) -CFLAGS_MOD += -DMICROPY_MOD_TIME=1 +ifeq ($(MICROPY_PY_TIME),1) +CFLAGS_MOD += -DMICROPY_PY_TIME=1 SRC_MOD += modtime.c endif -ifeq ($(MICROPY_MOD_FFI),1) +ifeq ($(MICROPY_PY_FFI),1) LIBFFI_LDFLAGS_MOD := $(shell pkg-config --libs libffi) LIBFFI_CFLAGS_MOD := $(shell pkg-config --cflags libffi) -CFLAGS_MOD += $(LIBFFI_CFLAGS_MOD) -DMICROPY_MOD_FFI=1 +CFLAGS_MOD += $(LIBFFI_CFLAGS_MOD) -DMICROPY_PY_FFI=1 LDFLAGS_MOD += -ldl $(LIBFFI_LDFLAGS_MOD) SRC_MOD += modffi.c endif diff --git a/unix/file.c b/unix/file.c index 7f45ac4a33..386f018bdd 100644 --- a/unix/file.c +++ b/unix/file.c @@ -131,7 +131,7 @@ STATIC mp_obj_t fdfile_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const case '+': mode |= O_RDWR; break; - #if MICROPY_MOD_IO_FILEIO + #if MICROPY_PY_IO_FILEIO // If we don't have io.FileIO, then files are in text mode implicitly case 'b': type = &mp_type_fileio; @@ -173,7 +173,7 @@ STATIC const mp_map_elem_t rawfile_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(rawfile_locals_dict, rawfile_locals_dict_table); -#if MICROPY_MOD_IO_FILEIO +#if MICROPY_PY_IO_FILEIO STATIC const mp_stream_p_t fileio_stream_p = { .read = fdfile_read, .write = fdfile_write, diff --git a/unix/mpconfigport.h b/unix/mpconfigport.h index ec8989f2f8..c56c9fa1a6 100644 --- a/unix/mpconfigport.h +++ b/unix/mpconfigport.h @@ -32,7 +32,6 @@ #define MICROPY_EMIT_INLINE_THUMB (0) #define MICROPY_ENABLE_GC (1) #define MICROPY_ENABLE_FINALISER (1) -#define MICROPY_ENABLE_FROZENSET (1) #define MICROPY_MEM_STATS (1) #define MICROPY_DEBUG_PRINTERS (1) #define MICROPY_HELPER_REPL (1) @@ -42,10 +41,11 @@ #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ) #define MICROPY_STREAMS_NON_BLOCK (1) #define MICROPY_OPT_COMPUTED_GOTO (1) -#define MICROPY_MOD_SYS_EXIT (1) -#define MICROPY_MOD_SYS_STDFILES (1) -#define MICROPY_ENABLE_MOD_CMATH (1) -#define MICROPY_MOD_IO_FILEIO (1) +#define MICROPY_PY_FROZENSET (1) +#define MICROPY_PY_SYS_EXIT (1) +#define MICROPY_PY_SYS_STDFILES (1) +#define MICROPY_PY_CMATH (1) +#define MICROPY_PY_IO_FILEIO (1) // Define to MICROPY_ERROR_REPORTING_DETAILED to get function, etc. // names in exception messages (may require more RAM). #define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_DETAILED) @@ -55,20 +55,20 @@ extern const struct _mp_obj_module_t mp_module_time; extern const struct _mp_obj_module_t mp_module_socket; extern const struct _mp_obj_module_t mp_module_ffi; -#if MICROPY_MOD_FFI -#define MICROPY_MOD_FFI_DEF { MP_OBJ_NEW_QSTR(MP_QSTR_ffi), (mp_obj_t)&mp_module_ffi }, +#if MICROPY_PY_FFI +#define MICROPY_PY_FFI_DEF { MP_OBJ_NEW_QSTR(MP_QSTR_ffi), (mp_obj_t)&mp_module_ffi }, #else -#define MICROPY_MOD_FFI_DEF +#define MICROPY_PY_FFI_DEF #endif -#if MICROPY_MOD_TIME -#define MICROPY_MOD_TIME_DEF { MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&mp_module_time }, +#if MICROPY_PY_TIME +#define MICROPY_PY_TIME_DEF { MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&mp_module_time }, #else -#define MICROPY_MOD_TIME_DEF +#define MICROPY_PY_TIME_DEF #endif #define MICROPY_PORT_BUILTIN_MODULES \ - MICROPY_MOD_FFI_DEF \ - MICROPY_MOD_TIME_DEF \ + MICROPY_PY_FFI_DEF \ + MICROPY_PY_TIME_DEF \ { MP_OBJ_NEW_QSTR(MP_QSTR_microsocket), (mp_obj_t)&mp_module_socket }, \ { MP_OBJ_NEW_QSTR(MP_QSTR__os), (mp_obj_t)&mp_module_os }, \ diff --git a/unix/mpconfigport.mk b/unix/mpconfigport.mk index 352d010676..f9b99e234c 100644 --- a/unix/mpconfigport.mk +++ b/unix/mpconfigport.mk @@ -7,7 +7,7 @@ MICROPY_FORCE_32BIT = 0 MICROPY_USE_READLINE = 1 # Subset of CPython time module -MICROPY_MOD_TIME = 1 +MICROPY_PY_TIME = 1 # ffi module requires libffi (libffi-dev Debian package) -MICROPY_MOD_FFI = 1 +MICROPY_PY_FFI = 1 diff --git a/windows/mpconfigport.h b/windows/mpconfigport.h index d6ab70b874..760596b0ea 100644 --- a/windows/mpconfigport.h +++ b/windows/mpconfigport.h @@ -39,10 +39,10 @@ #define MICROPY_DEBUG_PRINTERS (1) #define MICROPY_HELPER_REPL (1) #define MICROPY_HELPER_LEXER_UNIX (1) -#define MICROPY_ENABLE_MOD_CMATH (1) -#define MICROPY_MOD_SYS_STDFILES (1) -#define MICROPY_MOD_SYS_EXIT (1) -#define MICROPY_ENABLE_FROZENSET (1) +#define MICROPY_PY_FROZENSET (1) +#define MICROPY_PY_CMATH (1) +#define MICROPY_PY_SYS_STDFILES (1) +#define MICROPY_PY_SYS_EXIT (1) #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE) #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ) #define MICROPY_PORT_INIT_FUNC init() diff --git a/windows/mpconfigport.mk b/windows/mpconfigport.mk index 458f23dd1e..f1d406d573 100644 --- a/windows/mpconfigport.mk +++ b/windows/mpconfigport.mk @@ -7,7 +7,7 @@ MICROPY_FORCE_32BIT = 0 MICROPY_USE_READLINE = 0 # Subset of CPython time module -MICROPY_MOD_TIME = 1 +MICROPY_PY_TIME = 1 # ffi module requires libffi (libffi-dev Debian package) -MICROPY_MOD_FFI = 0 +MICROPY_PY_FFI = 0