py: Add MICROPY_PY_BUILTINS_REVERSED, disable for minimal ports.

This commit is contained in:
Paul Sokolovsky 2015-04-07 00:16:51 +03:00
parent e2d44e30c7
commit 282ca09f8e
5 changed files with 13 additions and 0 deletions

View File

@ -23,6 +23,7 @@
#define MICROPY_PY_BUILTINS_MEMORYVIEW (0)
#define MICROPY_PY_BUILTINS_ENUMERATE (0)
#define MICROPY_PY_BUILTINS_FROZENSET (0)
#define MICROPY_PY_BUILTINS_REVERSED (0)
#define MICROPY_PY_BUILTINS_SET (0)
#define MICROPY_PY_BUILTINS_SLICE (0)
#define MICROPY_PY_BUILTINS_PROPERTY (0)

View File

@ -615,7 +615,9 @@ STATIC const mp_map_elem_t mp_module_builtins_globals_table[] = {
{ 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 },
#if MICROPY_PY_BUILTINS_REVERSED
{ MP_OBJ_NEW_QSTR(MP_QSTR_reversed), (mp_obj_t)&mp_type_reversed },
#endif
#if MICROPY_PY_BUILTINS_SET
{ MP_OBJ_NEW_QSTR(MP_QSTR_set), (mp_obj_t)&mp_type_set },
#endif

View File

@ -469,6 +469,11 @@ typedef double mp_float_t;
#define MICROPY_PY_BUILTINS_EXECFILE (0)
#endif
// Whether to support reversed function(type)
#ifndef MICROPY_PY_BUILTINS_REVERSED
#define MICROPY_PY_BUILTINS_REVERSED (1)
#endif
// Whether to set __file__ for imported modules
#ifndef MICROPY_PY___FILE__
#define MICROPY_PY___FILE__ (1)

View File

@ -30,6 +30,8 @@
#include "py/nlr.h"
#include "py/runtime.h"
#if MICROPY_PY_BUILTINS_REVERSED
typedef struct _mp_obj_reversed_t {
mp_obj_base_t base;
mp_obj_t seq; // sequence object that we are reversing
@ -75,3 +77,5 @@ const mp_obj_type_t mp_type_reversed = {
.getiter = mp_identity,
.iternext = reversed_iternext,
};
#endif // MICROPY_PY_BUILTINS_REVERSED

View File

@ -50,6 +50,7 @@
#define MICROPY_PY_BUILTINS_COMPILE (0)
#define MICROPY_PY_BUILTINS_ENUMERATE (0)
#define MICROPY_PY_BUILTINS_FROZENSET (0)
#define MICROPY_PY_BUILTINS_REVERSED (0)
#define MICROPY_PY_BUILTINS_SET (0)
#define MICROPY_PY_BUILTINS_SLICE (0)
#define MICROPY_PY_BUILTINS_STR_UNICODE (0)