Skip to content

Commit 282ca09

Browse files
committed
py: Add MICROPY_PY_BUILTINS_REVERSED, disable for minimal ports.
1 parent e2d44e3 commit 282ca09

5 files changed

Lines changed: 13 additions & 0 deletions

File tree

minimal/mpconfigport.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#define MICROPY_PY_BUILTINS_MEMORYVIEW (0)
2424
#define MICROPY_PY_BUILTINS_ENUMERATE (0)
2525
#define MICROPY_PY_BUILTINS_FROZENSET (0)
26+
#define MICROPY_PY_BUILTINS_REVERSED (0)
2627
#define MICROPY_PY_BUILTINS_SET (0)
2728
#define MICROPY_PY_BUILTINS_SLICE (0)
2829
#define MICROPY_PY_BUILTINS_PROPERTY (0)

py/modbuiltins.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,9 @@ STATIC const mp_map_elem_t mp_module_builtins_globals_table[] = {
615615
{ MP_OBJ_NEW_QSTR(MP_QSTR_property), (mp_obj_t)&mp_type_property },
616616
#endif
617617
{ MP_OBJ_NEW_QSTR(MP_QSTR_range), (mp_obj_t)&mp_type_range },
618+
#if MICROPY_PY_BUILTINS_REVERSED
618619
{ MP_OBJ_NEW_QSTR(MP_QSTR_reversed), (mp_obj_t)&mp_type_reversed },
620+
#endif
619621
#if MICROPY_PY_BUILTINS_SET
620622
{ MP_OBJ_NEW_QSTR(MP_QSTR_set), (mp_obj_t)&mp_type_set },
621623
#endif

py/mpconfig.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,11 @@ typedef double mp_float_t;
469469
#define MICROPY_PY_BUILTINS_EXECFILE (0)
470470
#endif
471471

472+
// Whether to support reversed function(type)
473+
#ifndef MICROPY_PY_BUILTINS_REVERSED
474+
#define MICROPY_PY_BUILTINS_REVERSED (1)
475+
#endif
476+
472477
// Whether to set __file__ for imported modules
473478
#ifndef MICROPY_PY___FILE__
474479
#define MICROPY_PY___FILE__ (1)

py/objreversed.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#include "py/nlr.h"
3131
#include "py/runtime.h"
3232

33+
#if MICROPY_PY_BUILTINS_REVERSED
34+
3335
typedef struct _mp_obj_reversed_t {
3436
mp_obj_base_t base;
3537
mp_obj_t seq; // sequence object that we are reversing
@@ -75,3 +77,5 @@ const mp_obj_type_t mp_type_reversed = {
7577
.getiter = mp_identity,
7678
.iternext = reversed_iternext,
7779
};
80+
81+
#endif // MICROPY_PY_BUILTINS_REVERSED

unix/mpconfigport_minimal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#define MICROPY_PY_BUILTINS_COMPILE (0)
5151
#define MICROPY_PY_BUILTINS_ENUMERATE (0)
5252
#define MICROPY_PY_BUILTINS_FROZENSET (0)
53+
#define MICROPY_PY_BUILTINS_REVERSED (0)
5354
#define MICROPY_PY_BUILTINS_SET (0)
5455
#define MICROPY_PY_BUILTINS_SLICE (0)
5556
#define MICROPY_PY_BUILTINS_STR_UNICODE (0)

0 commit comments

Comments
 (0)