py: Move weak-link map to objmodule.c, and expose module maps as public.

This commit is contained in:
Damien George 2017-01-20 10:21:30 +11:00
parent 1864f90e9a
commit 9de91914fb
3 changed files with 12 additions and 9 deletions

View File

@ -47,14 +47,6 @@
#define PATH_SEP_CHAR '/'
#if MICROPY_MODULE_WEAK_LINKS
STATIC const mp_rom_map_elem_t mp_builtin_module_weak_links_table[] = {
MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS
};
STATIC MP_DEFINE_CONST_MAP(mp_builtin_module_weak_links_map, mp_builtin_module_weak_links_table);
#endif
bool mp_obj_is_package(mp_obj_t module) {
mp_obj_t dest[2];
mp_load_method_maybe(module, MP_QSTR___path__, dest);

View File

@ -227,7 +227,15 @@ STATIC const mp_rom_map_elem_t mp_builtin_module_table[] = {
MICROPY_PORT_BUILTIN_MODULES
};
STATIC MP_DEFINE_CONST_MAP(mp_builtin_module_map, mp_builtin_module_table);
MP_DEFINE_CONST_MAP(mp_builtin_module_map, mp_builtin_module_table);
#if MICROPY_MODULE_WEAK_LINKS
STATIC const mp_rom_map_elem_t mp_builtin_module_weak_links_table[] = {
MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS
};
MP_DEFINE_CONST_MAP(mp_builtin_module_weak_links_map, mp_builtin_module_weak_links_table);
#endif
void mp_module_init(void) {
mp_obj_dict_init(&MP_STATE_VM(mp_loaded_modules_dict), 3);

View File

@ -28,6 +28,9 @@
#include "py/obj.h"
extern const mp_map_t mp_builtin_module_map;
extern const mp_map_t mp_builtin_module_weak_links_map;
void mp_module_init(void);
void mp_module_deinit(void);
mp_obj_t mp_module_get(qstr module_name);