Commit ee3fd46f authored by Damien George's avatar Damien George
Browse files

Rename configuration variables controling Python features.

Now of the form MICROPY_PY_*.  See issue #35.
parent d0ceb04b
...@@ -12,13 +12,13 @@ ...@@ -12,13 +12,13 @@
#define MICROPY_HELPER_REPL (0) #define MICROPY_HELPER_REPL (0)
#define MICROPY_HELPER_LEXER_UNIX (0) #define MICROPY_HELPER_LEXER_UNIX (0)
#define MICROPY_ENABLE_SOURCE_LINE (0) #define MICROPY_ENABLE_SOURCE_LINE (0)
#define MICROPY_ENABLE_MOD_COLLECTIONS (0) #define MICROPY_PY_COLLECTIONS (0)
#define MICROPY_ENABLE_MOD_MATH (0) #define MICROPY_PY_MATH (0)
#define MICROPY_ENABLE_MOD_CMATH (0) #define MICROPY_PY_CMATH (0)
#define MICROPY_ENABLE_MOD_IO (0) #define MICROPY_PY_IO (0)
#define MICROPY_ENABLE_MOD_STRUCT (0) #define MICROPY_PY_STRUCT (0)
#define MICROPY_ENABLE_MOD_SYS (0) #define MICROPY_PY_SYS (0)
#define MICROPY_ENABLE_PROPERTY (0) #define MICROPY_PY_PROPERTY (0)
#define MICROPY_CPYTHON_COMPAT (0) #define MICROPY_CPYTHON_COMPAT (0)
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE) #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE)
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE) #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE)
......
...@@ -73,7 +73,7 @@ mp_import_stat_t find_file(const char *file_str, uint file_len, vstr_t *dest) { ...@@ -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 // extract the list of paths
uint path_num = 0; uint path_num = 0;
mp_obj_t *path_items; 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); mp_obj_list_get(mp_sys_path, &path_num, &path_items);
#endif #endif
......
...@@ -53,14 +53,14 @@ STATIC const mp_map_elem_t mp_builtin_object_table[] = { ...@@ -53,14 +53,14 @@ STATIC const mp_map_elem_t mp_builtin_object_table[] = {
#if MICROPY_ENABLE_FLOAT #if MICROPY_ENABLE_FLOAT
{ MP_OBJ_NEW_QSTR(MP_QSTR_float), (mp_obj_t)&mp_type_float }, { MP_OBJ_NEW_QSTR(MP_QSTR_float), (mp_obj_t)&mp_type_float },
#endif #endif
#if MICROPY_ENABLE_FROZENSET #if MICROPY_PY_FROZENSET
{ MP_OBJ_NEW_QSTR(MP_QSTR_frozenset), (mp_obj_t)&mp_type_frozenset }, { MP_OBJ_NEW_QSTR(MP_QSTR_frozenset), (mp_obj_t)&mp_type_frozenset },
#endif #endif
{ MP_OBJ_NEW_QSTR(MP_QSTR_int), (mp_obj_t)&mp_type_int }, { 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_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_map), (mp_obj_t)&mp_type_map },
{ MP_OBJ_NEW_QSTR(MP_QSTR_object), (mp_obj_t)&mp_type_object }, { 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 }, { MP_OBJ_NEW_QSTR(MP_QSTR_property), (mp_obj_t)&mp_type_property },
#endif #endif
{ MP_OBJ_NEW_QSTR(MP_QSTR_range), (mp_obj_t)&mp_type_range }, { 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[] = { ...@@ -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_micropython), (mp_obj_t)&mp_module_micropython },
{ MP_OBJ_NEW_QSTR(MP_QSTR_array), (mp_obj_t)&mp_module_array }, { 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 }, { MP_OBJ_NEW_QSTR(MP_QSTR_io), (mp_obj_t)&mp_module_io },
#endif #endif
#if MICROPY_ENABLE_MOD_COLLECTIONS #if MICROPY_PY_COLLECTIONS
{ MP_OBJ_NEW_QSTR(MP_QSTR__collections), (mp_obj_t)&mp_module_collections }, { MP_OBJ_NEW_QSTR(MP_QSTR__collections), (mp_obj_t)&mp_module_collections },
#endif #endif
#if MICROPY_ENABLE_MOD_STRUCT #if MICROPY_PY_STRUCT
{ MP_OBJ_NEW_QSTR(MP_QSTR_struct), (mp_obj_t)&mp_module_struct }, { MP_OBJ_NEW_QSTR(MP_QSTR_struct), (mp_obj_t)&mp_module_struct },
#endif #endif
#if MICROPY_ENABLE_FLOAT #if MICROPY_ENABLE_FLOAT
{ MP_OBJ_NEW_QSTR(MP_QSTR_math), (mp_obj_t)&mp_module_math }, { 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 }, { MP_OBJ_NEW_QSTR(MP_QSTR_cmath), (mp_obj_t)&mp_module_cmath },
#endif #endif
#endif #endif
#if MICROPY_ENABLE_MOD_SYS #if MICROPY_PY_SYS
{ MP_OBJ_NEW_QSTR(MP_QSTR_sys), (mp_obj_t)&mp_module_sys }, { MP_OBJ_NEW_QSTR(MP_QSTR_sys), (mp_obj_t)&mp_module_sys },
#endif #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 }, { MP_OBJ_NEW_QSTR(MP_QSTR_gc), (mp_obj_t)&mp_module_gc },
#endif #endif
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include "obj.h" #include "obj.h"
#include "builtin.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 // These are defined in modmath.c
extern const mp_obj_float_t mp_math_e_obj; extern const mp_obj_float_t mp_math_e_obj;
...@@ -154,4 +154,4 @@ const mp_obj_module_t mp_module_cmath = { ...@@ -154,4 +154,4 @@ const mp_obj_module_t mp_module_cmath = {
.globals = (mp_obj_dict_t*)&mp_module_cmath_globals, .globals = (mp_obj_dict_t*)&mp_module_cmath_globals,
}; };
#endif // MICROPY_ENABLE_FLOAT && MICROPY_ENABLE_MOD_CMATH #endif // MICROPY_ENABLE_FLOAT && MICROPY_PY_CMATH
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#include "obj.h" #include "obj.h"
#include "builtin.h" #include "builtin.h"
#if MICROPY_ENABLE_MOD_COLLECTIONS #if MICROPY_PY_COLLECTIONS
STATIC const mp_map_elem_t mp_module_collections_globals_table[] = { 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) }, { 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 = { ...@@ -54,4 +54,4 @@ const mp_obj_module_t mp_module_collections = {
.globals = (mp_obj_dict_t*)&mp_module_collections_globals, .globals = (mp_obj_dict_t*)&mp_module_collections_globals,
}; };
#endif // MICROPY_ENABLE_MOD_COLLECTIONS #endif // MICROPY_PY_COLLECTIONS
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#include "objstr.h" #include "objstr.h"
#include "gc.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) { STATIC mp_obj_t py_gc_collect(void) {
gc_collect(); gc_collect();
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#include "obj.h" #include "obj.h"
#include "builtin.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_fileio;
extern const mp_obj_type_t mp_type_textio; extern const mp_obj_type_t mp_type_textio;
...@@ -40,14 +40,14 @@ STATIC const mp_map_elem_t mp_module_io_globals_table[] = { ...@@ -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 // Note: mp_builtin_open_obj should be defined by port, it's not
// part of the core. // part of the core.
{ MP_OBJ_NEW_QSTR(MP_QSTR_open), (mp_obj_t)&mp_builtin_open_obj }, { 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 }, { MP_OBJ_NEW_QSTR(MP_QSTR_FileIO), (mp_obj_t)&mp_type_fileio },
#endif #endif
#if MICROPY_CPYTHON_COMPAT #if MICROPY_CPYTHON_COMPAT
{ MP_OBJ_NEW_QSTR(MP_QSTR_TextIOWrapper), (mp_obj_t)&mp_type_textio }, { MP_OBJ_NEW_QSTR(MP_QSTR_TextIOWrapper), (mp_obj_t)&mp_type_textio },
#endif #endif
{ MP_OBJ_NEW_QSTR(MP_QSTR_StringIO), (mp_obj_t)&mp_type_stringio }, { 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 }, { MP_OBJ_NEW_QSTR(MP_QSTR_BytesIO), (mp_obj_t)&mp_type_bytesio },
#endif #endif
}; };
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include "obj.h" #include "obj.h"
#include "builtin.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 //TODO: Change macros to check for overflow and raise OverflowError or RangeError
#define MATH_FUN_1(py_name, c_name) \ #define MATH_FUN_1(py_name, c_name) \
...@@ -184,4 +184,4 @@ const mp_obj_module_t mp_module_math = { ...@@ -184,4 +184,4 @@ const mp_obj_module_t mp_module_math = {
.globals = (mp_obj_dict_t*)&mp_module_math_globals, .globals = (mp_obj_dict_t*)&mp_module_math_globals,
}; };
#endif // MICROPY_ENABLE_FLOAT && MICROPY_ENABLE_MOD_MATH #endif // MICROPY_ENABLE_FLOAT && MICROPY_PY_MATH
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#include "binary.h" #include "binary.h"
#include "parsenum.h" #include "parsenum.h"
#if MICROPY_ENABLE_MOD_STRUCT #if MICROPY_PY_STRUCT
STATIC char get_fmt_type(const char **fmt) { STATIC char get_fmt_type(const char **fmt) {
char t = **fmt; char t = **fmt;
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include "objtuple.h" #include "objtuple.h"
#include "objstr.h" #include "objstr.h"
#if MICROPY_ENABLE_MOD_SYS #if MICROPY_PY_SYS
// These should be implemented by ports, specific types don't matter, // These should be implemented by ports, specific types don't matter,
// only addresses. // only addresses.
...@@ -65,11 +65,11 @@ STATIC const mp_map_elem_t mp_module_sys_globals_table[] = { ...@@ -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) }, { MP_OBJ_NEW_QSTR(MP_QSTR_byteorder), MP_OBJ_NEW_QSTR(MP_QSTR_big) },
#endif #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 }, { MP_OBJ_NEW_QSTR(MP_QSTR_exit), (mp_obj_t)&mp_sys_exit_obj },
#endif #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_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_stdout), (mp_obj_t)&mp_sys_stdout_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_stderr), (mp_obj_t)&mp_sys_stderr_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_stderr), (mp_obj_t)&mp_sys_stderr_obj },
......
...@@ -131,7 +131,16 @@ ...@@ -131,7 +131,16 @@
#endif #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 // Whether to include the garbage collector
#ifndef MICROPY_ENABLE_GC #ifndef MICROPY_ENABLE_GC
...@@ -209,92 +218,91 @@ typedef double mp_float_t; ...@@ -209,92 +218,91 @@ typedef double mp_float_t;
#define MICROPY_ENABLE_FLOAT (0) #define MICROPY_ENABLE_FLOAT (0)
#endif #endif
// Whether to provide "collections" module // Enable features which improve CPython compatibility
#ifndef MICROPY_ENABLE_MOD_COLLECTIONS // but may lead to more code size/memory usage.
#define MICROPY_ENABLE_MOD_COLLECTIONS (1) // TODO: Originally intended as generic category to not
// add bunch of once-off options. May need refactoring later
#ifndef MICROPY_CPYTHON_COMPAT
#define MICROPY_CPYTHON_COMPAT (1)
#endif #endif
// Whether to provide "math" module // Whether POSIX-semantics non-blocking streams are supported
#ifndef MICROPY_ENABLE_MOD_MATH #ifndef MICROPY_STREAMS_NON_BLOCK
#define MICROPY_ENABLE_MOD_MATH (1) #define MICROPY_STREAMS_NON_BLOCK (0)
#endif #endif
// Whether to provide "cmath" module /*****************************************************************************/
#ifndef MICROPY_ENABLE_MOD_CMATH /* Fine control over Python builtins, classes, modules, etc */
#define MICROPY_ENABLE_MOD_CMATH (0)
#endif
// Whether to provide "gc" module // Whether to support slice object and correspondingly
#ifndef MICROPY_ENABLE_MOD_GC // slice subscript operators
#define MICROPY_ENABLE_MOD_GC (1) #ifndef MICROPY_PY_SLICE
#define MICROPY_PY_SLICE (1)
#endif #endif
// Whether to provide "io" module // Whether to support frozenset object
#ifndef MICROPY_ENABLE_MOD_IO #ifndef MICROPY_PY_FROZENSET
#define MICROPY_ENABLE_MOD_IO (1) #define MICROPY_PY_FROZENSET (0)
#endif #endif
#ifndef MICROPY_MOD_IO_FILEIO // Whether to support the property object
#define MICROPY_MOD_IO_FILEIO (0) #ifndef MICROPY_PY_PROPERTY
#define MICROPY_PY_PROPERTY (1)
#endif #endif
#ifndef MICROPY_IO_BYTESIO // Whether to provide "collections" module
#define MICROPY_IO_BYTESIO (1) #ifndef MICROPY_PY_COLLECTIONS
#define MICROPY_PY_COLLECTIONS (1)
#endif #endif
// Whether to provide "struct" module // Whether to provide "math" module
#ifndef MICROPY_ENABLE_MOD_STRUCT #ifndef MICROPY_PY_MATH
#define MICROPY_ENABLE_MOD_STRUCT (1) #define MICROPY_PY_MATH (1)
#endif #endif
// Whether to provide "sys" module // Whether to provide "cmath" module
#ifndef MICROPY_ENABLE_MOD_SYS #ifndef MICROPY_PY_CMATH
#define MICROPY_ENABLE_MOD_SYS (1) #define MICROPY_PY_CMATH (0)
#endif #endif
// sys.exit() availability // Whether to provide "gc" module
#ifndef MICROPY_MOD_SYS_EXIT #ifndef MICROPY_PY_GC
#define MICROPY_MOD_SYS_EXIT (0) #define MICROPY_PY_GC (1)
#endif #endif
// sys.{stdin,stdout,stderr} availability // Whether to provide "io" module
#ifndef MICROPY_MOD_SYS_STDFILES #ifndef MICROPY_PY_IO
#define MICROPY_MOD_SYS_STDFILES (0) #define MICROPY_PY_IO (1)
#endif #endif
// Whether to support slice object and correspondingly // Whether to provide "io.FileIO" class
// slice subscript operators #ifndef MICROPY_PY_IO_FILEIO
#ifndef MICROPY_ENABLE_SLICE #define MICROPY_PY_IO_FILEIO (0)
#define MICROPY_ENABLE_SLICE (1)
#endif #endif
// Whether to support frozenset object // Whether to provide "io.BytesIO" class
#ifndef MICROPY_ENABLE_FROZENSET #ifndef MICROPY_PY_IO_BYTESIO
#define MICROPY_ENABLE_FROZENSET (0) #define MICROPY_PY_IO_BYTESIO (1)
#endif #endif
// Whether to support the property object // Whether to provide "struct" module
#ifndef MICROPY_ENABLE_PROPERTY #ifndef MICROPY_PY_STRUCT
#define MICROPY_ENABLE_PROPERTY (1) #define MICROPY_PY_STRUCT (1)
#endif #endif
// Enable features which improve CPython compatibility // Whether to provide "sys" module
// but may lead to more code size/memory usage. #ifndef MICROPY_PY_SYS
// TODO: Originally intended as generic category to not #define MICROPY_PY_SYS (1)
// add bunch of once-off options. May need refactoring later
#ifndef MICROPY_CPYTHON_COMPAT
#define MICROPY_CPYTHON_COMPAT (1)
#endif #endif
// Whether POSIX-semantics non-blocking streams are supported // Whether to provide "sys.exit" function
#ifndef MICROPY_STREAMS_NON_BLOCK #ifndef MICROPY_PY_SYS_EXIT
#define MICROPY_STREAMS_NON_BLOCK (0) #define MICROPY_PY_SYS_EXIT (0)
#endif #endif
// Whether to use computed gotos in the VM, or a switch // Whether to provide sys.{stdin,stdout,stderr} objects
// Computed gotos are roughly 10% faster, and increase VM code size by a little #ifndef MICROPY_PY_SYS_STDFILES
#ifndef MICROPY_OPT_COMPUTED_GOTO #define MICROPY_PY_SYS_STDFILES (0)
#define MICROPY_OPT_COMPUTED_GOTO (0)
#endif #endif
/*****************************************************************************/ /*****************************************************************************/
......
...@@ -150,7 +150,7 @@ STATIC mp_obj_t list_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) { ...@@ -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) { STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
if (value == MP_OBJ_NULL) { if (value == MP_OBJ_NULL) {
// delete // delete
#if MICROPY_ENABLE_SLICE #if MICROPY_PY_SLICE
if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) {
mp_obj_list_t *self = self_in; mp_obj_list_t *self = self_in;
machine_uint_t start, stop; 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) { ...@@ -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) { } else if (value == MP_OBJ_SENTINEL) {
// load // load
mp_obj_list_t *self = self_in; mp_obj_list_t *self = self_in;
#if MICROPY_ENABLE_SLICE #if MICROPY_PY_SLICE
if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) {
machine_uint_t start, stop; machine_uint_t start, stop;
if (!mp_seq_get_fast_slice_indexes(self->len, index, &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) { ...@@ -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); uint index_val = mp_get_index(self->base.type, self->len, index, false);
return self->items[index_val]; return self->items[index_val];
} else { } else {
#if MICROPY_ENABLE_SLICE #if MICROPY_PY_SLICE
if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) {
mp_obj_list_t *self = self_in; mp_obj_list_t *self = self_in;
assert(MP_OBJ_IS_TYPE(value, &mp_type_list)); assert(MP_OBJ_IS_TYPE(value, &mp_type_list));
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include "obj.h" #include "obj.h"
#include "objtuple.h" #include "objtuple.h"
#if MICROPY_ENABLE_MOD_COLLECTIONS #if MICROPY_PY_COLLECTIONS
typedef struct _mp_obj_namedtuple_type_t { typedef struct _mp_obj_namedtuple_type_t {
mp_obj_type_t base; 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) { ...@@ -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); MP_DEFINE_CONST_FUN_OBJ_2(mp_namedtuple_obj, new_namedtuple_type);
#endif // MICROPY_ENABLE_MOD_COLLECTIONS #endif // MICROPY_PY_COLLECTIONS
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include "obj.h" #include "obj.h"
#include "runtime.h" #include "runtime.h"
#if MICROPY_ENABLE_PROPERTY #if MICROPY_PY_PROPERTY
typedef struct _mp_obj_property_t { typedef struct _mp_obj_property_t {
mp_obj_base_t base; mp_obj_base_t base;
...@@ -115,4 +115,4 @@ const mp_obj_t *mp_obj_property_get(mp_obj_t self_in) { ...@@ -115,4 +115,4 @@ const mp_obj_t *mp_obj_property_get(mp_obj_t self_in) {
return self->proxy; return self->proxy;
} }
#endif // MICROPY_ENABLE_PROPERTY #endif // MICROPY_PY_PROPERTY
<
...@@ -52,13 +52,13 @@ STATIC mp_obj_t set_it_iternext(mp_obj_t self_in); ...@@ -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) { STATIC bool is_set_or_frozenset(mp_obj_t o) {
return MP_OBJ_IS_TYPE(o, &mp_type_set) 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) || MP_OBJ_IS_TYPE(o, &mp_type_frozenset)
#endif #endif
; ;
} }
#if MICROPY_ENABLE_FROZENSET #if MICROPY_PY_FROZENSET
STATIC void check_set_or_frozenset(mp_obj_t o) { STATIC void check_set_or_frozenset(mp_obj_t o) {
if (!is_set_or_frozenset(o)) { if (!is_set_or_frozenset(o)) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, "'set' object required")); 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) { ...@@ -72,7 +72,7 @@ STATIC void check_set(mp_obj_t o) {
if (!MP_OBJ_IS_TYPE(o, &mp_type_set)) { if (!MP_OBJ_IS_TYPE(o, &mp_type_set)) {
// Emulate CPython behavior // Emulate CPython behavior
// AttributeError: 'frozenset' object has no attribute 'add' // AttributeError: 'frozenset' object has no attribute 'add'
#if MICROPY_ENABLE_FROZENSET #if MICROPY_PY_FROZENSET
if (MP_OBJ_IS_TYPE(o, &mp_type_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")); 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) { ...@@ -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) { 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; 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); bool is_frozen = MP_OBJ_IS_TYPE(self_in, &mp_type_frozenset);
#endif #endif
if (self->set.used == 0) { if (self->set.used == 0) {
#if MICROPY_ENABLE_FROZENSET #if MICROPY_PY_FROZENSET
if (is_frozen) { if (is_frozen) {
print(env, "frozen"); print(env, "frozen");
} }
...@@ -96,7 +96,7 @@ STATIC void set_print(void (*print)(void *env, const char *fmt, ...), void *env, ...@@ -96,7 +96,7 @@ STATIC void set_print(void (*print)(void *env, const char *fmt, ...), void *env,
return; return;
} }
bool first = true; bool first = true;
#if MICROPY_ENABLE_FROZENSET #if MICROPY_PY_FROZENSET
if (is_frozen) { if (is_frozen) {
print(env, "frozenset("); print(env, "frozenset(");