kopia lustrzana https://github.com/micropython/micropython
py: Make collections module configurable, enabled by default.
rodzic
1463c1fa82
commit
107c9fb235
|
@ -132,7 +132,9 @@ STATIC const mp_map_elem_t mp_builtin_module_table[] = {
|
||||||
#if MICROPY_ENABLE_MOD_IO
|
#if MICROPY_ENABLE_MOD_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
|
||||||
{ 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
|
||||||
#if MICROPY_ENABLE_MOD_STRUCT
|
#if MICROPY_ENABLE_MOD_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
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
#include "obj.h"
|
#include "obj.h"
|
||||||
#include "builtin.h"
|
#include "builtin.h"
|
||||||
|
|
||||||
|
#if MICROPY_ENABLE_MOD_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) },
|
||||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_namedtuple), (mp_obj_t)&mp_namedtuple_obj },
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_namedtuple), (mp_obj_t)&mp_namedtuple_obj },
|
||||||
|
@ -25,3 +27,5 @@ const mp_obj_module_t mp_module_collections = {
|
||||||
.name = MP_QSTR__collections,
|
.name = MP_QSTR__collections,
|
||||||
.globals = (mp_obj_dict_t*)&mp_module_collections_globals,
|
.globals = (mp_obj_dict_t*)&mp_module_collections_globals,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif // MICROPY_ENABLE_MOD_COLLECTIONS
|
||||||
|
|
|
@ -115,6 +115,11 @@ typedef double mp_float_t;
|
||||||
#define MICROPY_ENABLE_FLOAT (0)
|
#define MICROPY_ENABLE_FLOAT (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Whether to provide "collections" module
|
||||||
|
#ifndef MICROPY_ENABLE_MOD_COLLECTIONS
|
||||||
|
#define MICROPY_ENABLE_MOD_COLLECTIONS (1)
|
||||||
|
#endif
|
||||||
|
|
||||||
// Whether to provide "math" module
|
// Whether to provide "math" module
|
||||||
#ifndef MICROPY_ENABLE_MOD_MATH
|
#ifndef MICROPY_ENABLE_MOD_MATH
|
||||||
#define MICROPY_ENABLE_MOD_MATH (1)
|
#define MICROPY_ENABLE_MOD_MATH (1)
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
#include "obj.h"
|
#include "obj.h"
|
||||||
#include "objtuple.h"
|
#include "objtuple.h"
|
||||||
|
|
||||||
|
#if MICROPY_ENABLE_MOD_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;
|
||||||
const char *fields;
|
const char *fields;
|
||||||
|
@ -143,3 +145,5 @@ STATIC mp_obj_t new_namedtuple_type(mp_obj_t name_in, mp_obj_t fields_in) {
|
||||||
return mp_obj_new_namedtuple_type(name, fields);
|
return mp_obj_new_namedtuple_type(name, fields);
|
||||||
}
|
}
|
||||||
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
|
||||||
|
|
Ładowanie…
Reference in New Issue