summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--py/builtin.c4
-rw-r--r--py/builtinimport.c4
-rw-r--r--py/map.c3
-rw-r--r--py/modarray.c17
-rw-r--r--py/modcollections.c17
-rw-r--r--py/modio.c17
-rw-r--r--py/modmath.c17
-rw-r--r--py/modmicropython.c17
-rw-r--r--py/obj.h9
-rw-r--r--py/objcell.c1
-rw-r--r--py/objdict.c14
-rw-r--r--py/objmodule.c10
-rw-r--r--py/objset.c8
-rw-r--r--py/runtime.c19
-rw-r--r--stm/pybmodule.c17
-rw-r--r--stmhal/help.c2
-rw-r--r--stmhal/modos.c17
-rw-r--r--stmhal/modpyb.c17
-rw-r--r--stmhal/modtime.c17
19 files changed, 129 insertions, 98 deletions
diff --git a/py/builtin.c b/py/builtin.c
index 22c5ecfde3..11268aed18 100644
--- a/py/builtin.c
+++ b/py/builtin.c
@@ -157,7 +157,7 @@ STATIC mp_obj_t mp_builtin_dir(uint n_args, const mp_obj_t *args) {
} else { // n_args == 1
// make a list of names in the given object
if (MP_OBJ_IS_TYPE(args[0], &mp_type_module)) {
- map = mp_obj_module_get_globals(args[0]);
+ map = mp_obj_dict_get_map(mp_obj_module_get_globals(args[0]));
} else {
mp_obj_type_t *type;
if (MP_OBJ_IS_TYPE(args[0], &mp_type_type)) {
@@ -174,7 +174,7 @@ STATIC mp_obj_t mp_builtin_dir(uint n_args, const mp_obj_t *args) {
mp_obj_t dir = mp_obj_new_list(0, NULL);
if (map != NULL) {
for (uint i = 0; i < map->alloc; i++) {
- if (map->table[i].key != MP_OBJ_NULL) {
+ if (MP_MAP_SLOT_IS_FILLED(map, i)) {
mp_obj_list_append(dir, map->table[i].key);
}
}
diff --git a/py/builtinimport.c b/py/builtinimport.c
index ae59ea795d..fd0689c681 100644
--- a/py/builtinimport.c
+++ b/py/builtinimport.c
@@ -87,8 +87,8 @@ void do_load(mp_obj_t module_obj, vstr_t *file) {
mp_map_t *old_globals = mp_globals_get();
// set the new context
- mp_locals_set(mp_obj_module_get_globals(module_obj));
- mp_globals_set(mp_obj_module_get_globals(module_obj));
+ mp_locals_set(mp_obj_dict_get_map(mp_obj_module_get_globals(module_obj)));
+ mp_globals_set(mp_obj_dict_get_map(mp_obj_module_get_globals(module_obj)));
// parse the imported script
mp_parse_error_kind_t parse_error_kind;
diff --git a/py/map.c b/py/map.c
index 933b5f8e29..5b9e803774 100644
--- a/py/map.c
+++ b/py/map.c
@@ -1,4 +1,5 @@
#include <stdlib.h>
+#include <assert.h>
#include "misc.h"
#include "mpconfig.h"
@@ -285,7 +286,7 @@ mp_obj_t mp_set_lookup(mp_set_t *set, mp_obj_t index, mp_map_lookup_kind_t looku
mp_obj_t mp_set_remove_first(mp_set_t *set) {
for (uint pos = 0; pos < set->alloc; pos++) {
- if (set->table[pos] != MP_OBJ_NULL && set->table[pos] != MP_OBJ_SENTINEL) {
+ if (MP_SET_SLOT_IS_FILLED(set, pos)) {
mp_obj_t elem = set->table[pos];
// delete element
set->used--;
diff --git a/py/modarray.c b/py/modarray.c
index 51c221fff3..d8ff7158ff 100644
--- a/py/modarray.c
+++ b/py/modarray.c
@@ -9,16 +9,19 @@ STATIC const mp_map_elem_t mp_module_array_globals_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_array), (mp_obj_t)&mp_type_array },
};
-STATIC const mp_map_t mp_module_array_globals = {
- .all_keys_are_qstrs = 1,
- .table_is_fixed_array = 1,
- .used = sizeof(mp_module_array_globals_table) / sizeof(mp_map_elem_t),
- .alloc = sizeof(mp_module_array_globals_table) / sizeof(mp_map_elem_t),
- .table = (mp_map_elem_t*)mp_module_array_globals_table,
+STATIC const mp_obj_dict_t mp_module_array_globals = {
+ .base = {&mp_type_dict},
+ .map = {
+ .all_keys_are_qstrs = 1,
+ .table_is_fixed_array = 1,
+ .used = sizeof(mp_module_array_globals_table) / sizeof(mp_map_elem_t),
+ .alloc = sizeof(mp_module_array_globals_table) / sizeof(mp_map_elem_t),
+ .table = (mp_map_elem_t*)mp_module_array_globals_table,
+ },
};
const mp_obj_module_t mp_module_array = {
.base = { &mp_type_module },
.name = MP_QSTR_array,
- .globals = (mp_map_t*)&mp_module_array_globals,
+ .globals = (mp_obj_dict_t*)&mp_module_array_globals,
};
diff --git a/py/modcollections.c b/py/modcollections.c
index 3401600bb1..dbd1896f20 100644
--- a/py/modcollections.c
+++ b/py/modcollections.c
@@ -9,16 +9,19 @@ STATIC const mp_map_elem_t mp_module_collections_globals_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_namedtuple), (mp_obj_t)&mp_namedtuple_obj },
};
-STATIC const mp_map_t mp_module_collections_globals = {
- .all_keys_are_qstrs = 1,
- .table_is_fixed_array = 1,
- .used = sizeof(mp_module_collections_globals_table) / sizeof(mp_map_elem_t),
- .alloc = sizeof(mp_module_collections_globals_table) / sizeof(mp_map_elem_t),
- .table = (mp_map_elem_t*)mp_module_collections_globals_table,
+STATIC const mp_obj_dict_t mp_module_collections_globals = {
+ .base = {&mp_type_dict},
+ .map = {
+ .all_keys_are_qstrs = 1,
+ .table_is_fixed_array = 1,
+ .used = sizeof(mp_module_collections_globals_table) / sizeof(mp_map_elem_t),
+ .alloc = sizeof(mp_module_collections_globals_table) / sizeof(mp_map_elem_t),
+ .table = (mp_map_elem_t*)mp_module_collections_globals_table,
+ },
};
const mp_obj_module_t mp_module_collections = {
.base = { &mp_type_module },
.name = MP_QSTR_collections,
- .globals = (mp_map_t*)&mp_module_collections_globals,
+ .globals = (mp_obj_dict_t*)&mp_module_collections_globals,
};
diff --git a/py/modio.c b/py/modio.c
index ced3983581..ac5c7df9de 100644
--- a/py/modio.c
+++ b/py/modio.c
@@ -13,18 +13,21 @@ STATIC const mp_map_elem_t mp_module_io_globals_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_open), (mp_obj_t)&mp_builtin_open_obj },
};
-STATIC const mp_map_t mp_module_io_globals = {
- .all_keys_are_qstrs = 1,
- .table_is_fixed_array = 1,
- .used = sizeof(mp_module_io_globals_table) / sizeof(mp_map_elem_t),
- .alloc = sizeof(mp_module_io_globals_table) / sizeof(mp_map_elem_t),
- .table = (mp_map_elem_t*)mp_module_io_globals_table,
+STATIC const mp_obj_dict_t mp_module_io_globals = {
+ .base = {&mp_type_dict},
+ .map = {
+ .all_keys_are_qstrs = 1,
+ .table_is_fixed_array = 1,
+ .used = sizeof(mp_module_io_globals_table) / sizeof(mp_map_elem_t),
+ .alloc = sizeof(mp_module_io_globals_table) / sizeof(mp_map_elem_t),
+ .table = (mp_map_elem_t*)mp_module_io_globals_table,
+ },
};
const mp_obj_module_t mp_module_io = {
.base = { &mp_type_module },
.name = MP_QSTR_io,
- .globals = (mp_map_t*)&mp_module_io_globals,
+ .globals = (mp_obj_dict_t*)&mp_module_io_globals,
};
#endif
diff --git a/py/modmath.c b/py/modmath.c
index f80b73ab52..c26ba16189 100644
--- a/py/modmath.c
+++ b/py/modmath.c
@@ -139,18 +139,21 @@ STATIC const mp_map_elem_t mp_module_math_globals_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_lgamma), (mp_obj_t)&mp_math_lgamma_obj },
};
-STATIC const mp_map_t mp_module_math_globals = {
- .all_keys_are_qstrs = 1,
- .table_is_fixed_array = 1,
- .used = sizeof(mp_module_math_globals_table) / sizeof(mp_map_elem_t),
- .alloc = sizeof(mp_module_math_globals_table) / sizeof(mp_map_elem_t),
- .table = (mp_map_elem_t*)mp_module_math_globals_table,
+STATIC const mp_obj_dict_t mp_module_math_globals = {
+ .base = {&mp_type_dict},
+ .map = {
+ .all_keys_are_qstrs = 1,
+ .table_is_fixed_array = 1,
+ .used = sizeof(mp_module_math_globals_table) / sizeof(mp_map_elem_t),
+ .alloc = sizeof(mp_module_math_globals_table) / sizeof(mp_map_elem_t),
+ .table = (mp_map_elem_t*)mp_module_math_globals_table,
+ },
};
const mp_obj_module_t mp_module_math = {
.base = { &mp_type_module },
.name = MP_QSTR_math,
- .globals = (mp_map_t*)&mp_module_math_globals,
+ .globals = (mp_obj_dict_t*)&mp_module_math_globals,
};
#endif // MICROPY_ENABLE_FLOAT
diff --git a/py/modmicropython.c b/py/modmicropython.c
index 23187c03e9..ed245969cf 100644
--- a/py/modmicropython.c
+++ b/py/modmicropython.c
@@ -34,16 +34,19 @@ STATIC const mp_map_elem_t mp_module_micropython_globals_table[] = {
#endif
};
-STATIC const mp_map_t mp_module_micropython_globals = {
- .all_keys_are_qstrs = 1,
- .table_is_fixed_array = 1,
- .used = sizeof(mp_module_micropython_globals_table) / sizeof(mp_map_elem_t),
- .alloc = sizeof(mp_module_micropython_globals_table) / sizeof(mp_map_elem_t),
- .table = (mp_map_elem_t*)mp_module_micropython_globals_table,
+STATIC const mp_obj_dict_t mp_module_micropython_globals = {
+ .base = {&mp_type_dict},
+ .map = {
+ .all_keys_are_qstrs = 1,
+ .table_is_fixed_array = 1,
+ .used = sizeof(mp_module_micropython_globals_table) / sizeof(mp_map_elem_t),
+ .alloc = sizeof(mp_module_micropython_globals_table) / sizeof(mp_map_elem_t),
+ .table = (mp_map_elem_t*)mp_module_micropython_globals_table,
+ },
};
const mp_obj_module_t mp_module_micropython = {
.base = { &mp_type_module },
.name = MP_QSTR_micropython,
- .globals = (mp_map_t*)&mp_module_micropython_globals,
+ .globals = (mp_obj_dict_t*)&mp_module_micropython_globals,
};
diff --git a/py/obj.h b/py/obj.h
index eb447f916c..e800addade 100644
--- a/py/obj.h
+++ b/py/obj.h
@@ -115,6 +115,8 @@ typedef enum _mp_map_lookup_kind_t {
MP_MAP_LOOKUP_REMOVE_IF_FOUND, // 2
} mp_map_lookup_kind_t;
+#define MP_MAP_SLOT_IS_FILLED(map, pos) ((map)->table[pos].key != MP_OBJ_NULL && (map)->table[pos].key != MP_OBJ_SENTINEL)
+
void mp_map_init(mp_map_t *map, int n);
void mp_map_init_fixed_table(mp_map_t *map, int n, const mp_obj_t *table);
mp_map_t *mp_map_new(int n);
@@ -132,6 +134,8 @@ typedef struct _mp_set_t {
mp_obj_t *table;
} mp_set_t;
+#define MP_SET_SLOT_IS_FILLED(set, pos) ((set)->table[pos] != MP_OBJ_NULL && (set)->table[pos] != MP_OBJ_SENTINEL)
+
void mp_set_init(mp_set_t *set, int n);
mp_obj_t mp_set_lookup(mp_set_t *set, mp_obj_t index, mp_map_lookup_kind_t lookup_kind);
mp_obj_t mp_set_remove_first(mp_set_t *set);
@@ -444,6 +448,7 @@ typedef struct _mp_obj_dict_t {
mp_obj_base_t base;
mp_map_t map;
} mp_obj_dict_t;
+void mp_obj_dict_init(mp_obj_dict_t *dict, int n_args);
uint mp_obj_dict_len(mp_obj_t self_in);
mp_obj_t mp_obj_dict_store(mp_obj_t self_in, mp_obj_t key, mp_obj_t value);
mp_obj_t mp_obj_dict_delete(mp_obj_t self_in, mp_obj_t key);
@@ -483,9 +488,9 @@ MP_DECLARE_CONST_FUN_OBJ(mp_identity_obj);
typedef struct _mp_obj_module_t {
mp_obj_base_t base;
qstr name;
- mp_map_t *globals;
+ mp_obj_dict_t *globals;
} mp_obj_module_t;
-mp_map_t *mp_obj_module_get_globals(mp_obj_t self_in);
+mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in);
// staticmethod and classmethod types; defined here so we can make const versions
// this structure is used for instances of both staticmethod and classmethod
diff --git a/py/objcell.c b/py/objcell.c
index a6922b018a..d8517587df 100644
--- a/py/objcell.c
+++ b/py/objcell.c
@@ -1,4 +1,3 @@
-
#include "nlr.h"
#include "misc.h"
#include "mpconfig.h"
diff --git a/py/objdict.c b/py/objdict.c
index c09ccfbeec..5a314aed80 100644
--- a/py/objdict.c
+++ b/py/objdict.c
@@ -100,12 +100,12 @@ typedef struct _mp_obj_dict_it_t {
STATIC mp_map_elem_t *dict_it_iternext_elem(mp_obj_t self_in) {
mp_obj_dict_it_t *self = self_in;
machine_uint_t max = self->dict->map.alloc;
- mp_map_elem_t *table = self->dict->map.table;
+ mp_map_t *map = &self->dict->map;
for (int i = self->cur; i < max; i++) {
- if (table[i].key != MP_OBJ_NULL && table[i].key != MP_OBJ_SENTINEL) {
+ if (MP_MAP_SLOT_IS_FILLED(map, i)) {
self->cur = i + 1;
- return &(table[i]);
+ return &(map->table[i]);
}
}
@@ -463,10 +463,14 @@ const mp_obj_type_t mp_type_dict = {
.locals_dict = (mp_obj_t)&dict_locals_dict,
};
+void mp_obj_dict_init(mp_obj_dict_t *dict, int n_args) {
+ dict->base.type = &mp_type_dict;
+ mp_map_init(&dict->map, n_args);
+}
+
mp_obj_t mp_obj_new_dict(int n_args) {
mp_obj_dict_t *o = m_new_obj(mp_obj_dict_t);
- o->base.type = &mp_type_dict;
- mp_map_init(&o->map, n_args);
+ mp_obj_dict_init(o, n_args);
return o;
}
diff --git a/py/objmodule.c b/py/objmodule.c
index cc5944b665..783aa8a6fc 100644
--- a/py/objmodule.c
+++ b/py/objmodule.c
@@ -19,7 +19,7 @@ STATIC void module_print(void (*print)(void *env, const char *fmt, ...), void *e
STATIC void module_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
mp_obj_module_t *self = self_in;
- mp_map_elem_t *elem = mp_map_lookup(self->globals, MP_OBJ_NEW_QSTR(attr), MP_MAP_LOOKUP);
+ mp_map_elem_t *elem = mp_map_lookup(&self->globals->map, MP_OBJ_NEW_QSTR(attr), MP_MAP_LOOKUP);
if (elem != NULL) {
dest[0] = elem->value;
}
@@ -28,7 +28,7 @@ STATIC void module_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
STATIC bool module_store_attr(mp_obj_t self_in, qstr attr, mp_obj_t value) {
mp_obj_module_t *self = self_in;
// TODO CPython allows STORE_ATTR to a module, but is this the correct implementation?
- mp_map_lookup(self->globals, MP_OBJ_NEW_QSTR(attr), MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = value;
+ mp_obj_dict_store(self->globals, MP_OBJ_NEW_QSTR(attr), value);
return true;
}
@@ -52,10 +52,10 @@ mp_obj_t mp_obj_new_module(qstr module_name) {
mp_obj_module_t *o = m_new_obj(mp_obj_module_t);
o->base.type = &mp_type_module;
o->name = module_name;
- o->globals = mp_map_new(1);
+ o->globals = mp_obj_new_dict(1);
// store __name__ entry in the module
- mp_map_lookup(o->globals, MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = MP_OBJ_NEW_QSTR(module_name);
+ mp_obj_dict_store(o->globals, MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(module_name));
// store the new module into the slot in the global dict holding all modules
el->value = o;
@@ -64,7 +64,7 @@ mp_obj_t mp_obj_new_module(qstr module_name) {
return o;
}
-mp_map_t *mp_obj_module_get_globals(mp_obj_t self_in) {
+mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in) {
assert(MP_OBJ_IS_TYPE(self_in, &mp_type_module));
mp_obj_module_t *self = self_in;
return self->globals;
diff --git a/py/objset.c b/py/objset.c
index 12c8cd25a5..9a7e6751f5 100644
--- a/py/objset.c
+++ b/py/objset.c
@@ -32,7 +32,7 @@ STATIC void set_print(void (*print)(void *env, const char *fmt, ...), void *env,
bool first = true;
print(env, "{");
for (int i = 0; i < self->set.alloc; i++) {
- if (self->set.table[i] != MP_OBJ_NULL && self->set.table[i] != MP_OBJ_SENTINEL) {
+ if (MP_SET_SLOT_IS_FILLED(&self->set, i)) {
if (!first) {
print(env, ", ");
}
@@ -80,12 +80,12 @@ STATIC mp_obj_t set_it_iternext(mp_obj_t self_in) {
assert(MP_OBJ_IS_TYPE(self_in, &mp_type_set_it));
mp_obj_set_it_t *self = self_in;
machine_uint_t max = self->set->set.alloc;
- mp_obj_t *table = self->set->set.table;
+ mp_set_t *set = &self->set->set;
for (machine_uint_t i = self->cur; i < max; i++) {
- if (table[i] != MP_OBJ_NULL && table[i] != MP_OBJ_SENTINEL) {
+ if (MP_SET_SLOT_IS_FILLED(set, i)) {
self->cur = i + 1;
- return table[i];
+ return set->table[i];
}
}
diff --git a/py/runtime.c b/py/runtime.c
index c7b34c1e17..a8bd36bfac 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -33,31 +33,26 @@ STATIC mp_map_t *map_locals;
STATIC mp_map_t *map_globals;
STATIC mp_map_t map_builtins;
-STATIC mp_map_t map_main;
+STATIC mp_obj_dict_t dict_main;
const mp_obj_module_t mp_module___main__ = {
.base = { &mp_type_module },
.name = MP_QSTR___main__,
- .globals = (mp_map_t*)&map_main,
+ .globals = (mp_obj_dict_t*)&dict_main,
};
-// a good optimising compiler will inline this if necessary
-STATIC void mp_map_add_qstr(mp_map_t *map, qstr qstr, mp_obj_t value) {
- mp_map_lookup(map, MP_OBJ_NEW_QSTR(qstr), MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = value;
-}
-
void mp_init(void) {
mp_emit_glue_init();
// init global module stuff
mp_module_init();
- mp_map_init(&map_main, 1);
+ mp_obj_dict_init(&dict_main, 1);
// add some builtins that can't be done in ROM
- mp_map_add_qstr(&map_main, MP_QSTR___name__, MP_OBJ_NEW_QSTR(MP_QSTR___main__));
+ mp_obj_dict_store(&dict_main, MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR___main__));
// locals = globals for outer module (see Objects/frameobject.c/PyFrame_New())
- map_locals = map_globals = &map_main;
+ map_locals = map_globals = &dict_main.map;
// init built-in hash table
mp_map_init(&map_builtins, 3);
@@ -1017,9 +1012,9 @@ mp_obj_t mp_import_from(mp_obj_t module, qstr name) {
void mp_import_all(mp_obj_t module) {
DEBUG_printf("import all %p\n", module);
- mp_map_t *map = mp_obj_module_get_globals(module);
+ mp_map_t *map = mp_obj_dict_get_map(mp_obj_module_get_globals(module));
for (uint i = 0; i < map->alloc; i++) {
- if (map->table[i].key != MP_OBJ_NULL) {
+ if (MP_MAP_SLOT_IS_FILLED(map, i)) {
mp_store_name(MP_OBJ_QSTR_VALUE(map->table[i].key), map->table[i].value);
}
}
diff --git a/stm/pybmodule.c b/stm/pybmodule.c
index 5ae65ad229..40275949fd 100644
--- a/stm/pybmodule.c
+++ b/stm/pybmodule.c
@@ -273,16 +273,19 @@ STATIC const mp_map_elem_t pyb_module_globals_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_Exti), (mp_obj_t)&exti_obj_type },
};
-STATIC const mp_map_t pyb_module_globals = {
- .all_keys_are_qstrs = 1,
- .table_is_fixed_array = 1,
- .used = sizeof(pyb_module_globals_table) / sizeof(mp_map_elem_t),
- .alloc = sizeof(pyb_module_globals_table) / sizeof(mp_map_elem_t),
- .table = (mp_map_elem_t*)pyb_module_globals_table,
+STATIC const mp_obj_dict_t pyb_module_globals = {
+ .base = {&mp_type_dict},
+ .map = {
+ .all_keys_are_qstrs = 1,
+ .table_is_fixed_array = 1,
+ .used = sizeof(pyb_module_globals_table) / sizeof(mp_map_elem_t),
+ .alloc = sizeof(pyb_module_globals_table) / sizeof(mp_map_elem_t),
+ .table = (mp_map_elem_t*)pyb_module_globals_table,
+ },
};
const mp_obj_module_t pyb_module = {
.base = { &mp_type_module },
.name = MP_QSTR_pyb,
- .globals = (mp_map_t*)&pyb_module_globals,
+ .globals = (mp_obj_dict_t*)&pyb_module_globals,
};
diff --git a/stmhal/help.c b/stmhal/help.c
index 66484576bc..25d3fcb57e 100644
--- a/stmhal/help.c
+++ b/stmhal/help.c
@@ -59,7 +59,7 @@ STATIC mp_obj_t pyb_help(uint n_args, const mp_obj_t *args) {
mp_map_t *map = NULL;
if (MP_OBJ_IS_TYPE(args[0], &mp_type_module)) {
- map = mp_obj_module_get_globals(args[0]);
+ map = mp_obj_dict_get_map(mp_obj_module_get_globals(args[0]));
} else {
mp_obj_type_t *type;
if (MP_OBJ_IS_TYPE(args[0], &mp_type_type)) {
diff --git a/stmhal/modos.c b/stmhal/modos.c
index 6103b1b4fd..f160627525 100644
--- a/stmhal/modos.c
+++ b/stmhal/modos.c
@@ -162,16 +162,19 @@ STATIC const mp_map_elem_t os_module_globals_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_urandom), (mp_obj_t)&os_urandom_obj },
};
-STATIC const mp_map_t os_module_globals = {
- .all_keys_are_qstrs = 1,
- .table_is_fixed_array = 1,
- .used = sizeof(os_module_globals_table) / sizeof(mp_map_elem_t),
- .alloc = sizeof(os_module_globals_table) / sizeof(mp_map_elem_t),
- .table = (mp_map_elem_t*)os_module_globals_table,
+STATIC const mp_obj_dict_t os_module_globals = {
+ .base = {&mp_type_dict},
+ .map = {
+ .all_keys_are_qstrs = 1,
+ .table_is_fixed_array = 1,
+ .used = sizeof(os_module_globals_table) / sizeof(mp_map_elem_t),
+ .alloc = sizeof(os_module_globals_table) / sizeof(mp_map_elem_t),
+ .table = (mp_map_elem_t*)os_module_globals_table,
+ },
};
const mp_obj_module_t os_module = {
.base = { &mp_type_module },
.name = MP_QSTR_os,
- .globals = (mp_map_t*)&os_module_globals,
+ .globals = (mp_obj_dict_t*)&os_module_globals,
};
diff --git a/stmhal/modpyb.c b/stmhal/modpyb.c
index 6784081029..a6cb5adb6d 100644
--- a/stmhal/modpyb.c
+++ b/stmhal/modpyb.c
@@ -287,16 +287,19 @@ STATIC const mp_map_elem_t pyb_module_globals_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_Exti), (mp_obj_t)&exti_obj_type },
};
-STATIC const mp_map_t pyb_module_globals = {
- .all_keys_are_qstrs = 1,
- .table_is_fixed_array = 1,
- .used = sizeof(pyb_module_globals_table) / sizeof(mp_map_elem_t),
- .alloc = sizeof(pyb_module_globals_table) / sizeof(mp_map_elem_t),
- .table = (mp_map_elem_t*)pyb_module_globals_table,
+STATIC const mp_obj_dict_t pyb_module_globals = {
+ .base = {&mp_type_dict},
+ .map = {
+ .all_keys_are_qstrs = 1,
+ .table_is_fixed_array = 1,
+ .used = sizeof(pyb_module_globals_table) / sizeof(mp_map_elem_t),
+ .alloc = sizeof(pyb_module_globals_table) / sizeof(mp_map_elem_t),
+ .table = (mp_map_elem_t*)pyb_module_globals_table,
+ },
};
const mp_obj_module_t pyb_module = {
.base = { &mp_type_module },
.name = MP_QSTR_pyb,
- .globals = (mp_map_t*)&pyb_module_globals,
+ .globals = (mp_obj_dict_t*)&pyb_module_globals,
};
diff --git a/stmhal/modtime.c b/stmhal/modtime.c
index 9756ec3b5a..c20752e21d 100644
--- a/stmhal/modtime.c
+++ b/stmhal/modtime.c
@@ -28,16 +28,19 @@ STATIC const mp_map_elem_t time_module_globals_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_sleep), (mp_obj_t)&time_sleep_obj },
};
-STATIC const mp_map_t time_module_globals = {
- .all_keys_are_qstrs = 1,
- .table_is_fixed_array = 1,
- .used = sizeof(time_module_globals_table) / sizeof(mp_map_elem_t),
- .alloc = sizeof(time_module_globals_table) / sizeof(mp_map_elem_t),
- .table = (mp_map_elem_t*)time_module_globals_table,
+STATIC const mp_obj_dict_t time_module_globals = {
+ .base = {&mp_type_dict},
+ .map = {
+ .all_keys_are_qstrs = 1,
+ .table_is_fixed_array = 1,
+ .used = sizeof(time_module_globals_table) / sizeof(mp_map_elem_t),
+ .alloc = sizeof(time_module_globals_table) / sizeof(mp_map_elem_t),
+ .table = (mp_map_elem_t*)time_module_globals_table,
+ },
};
const mp_obj_module_t time_module = {
.base = { &mp_type_module },
.name = MP_QSTR_time,
- .globals = (mp_map_t*)&time_module_globals,
+ .globals = (mp_obj_dict_t*)&time_module_globals,
};