extmod: Make port-included extmod modules use MP_REGISTER_MODULES.
_onewire, socket, and network were previously added by the port rather than objmodule.c. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This commit is contained in:
parent
d8d3e6ae78
commit
bb794f05b7
|
@ -1780,4 +1780,7 @@ const mp_obj_module_t mp_module_lwip = {
|
|||
|
||||
MP_REGISTER_MODULE(MP_QSTR_lwip, mp_module_lwip, MICROPY_PY_LWIP);
|
||||
|
||||
// On LWIP-ports, this is the usocket module (replaces extmod/modusocket.c).
|
||||
MP_REGISTER_MODULE(MP_QSTR_socket, mp_module_lwip, MICROPY_PY_LWIP);
|
||||
|
||||
#endif // MICROPY_PY_LWIP
|
||||
|
|
|
@ -102,6 +102,8 @@ const mp_obj_module_t mp_module_network = {
|
|||
.globals = (mp_obj_dict_t *)&mp_module_network_globals,
|
||||
};
|
||||
|
||||
MP_REGISTER_MODULE(MP_QSTR_network, mp_module_network, MICROPY_PY_NETWORK);
|
||||
|
||||
/*******************************************************************************/
|
||||
// Implementations of network methods that can be used by any interface
|
||||
|
||||
|
|
|
@ -163,4 +163,6 @@ const mp_obj_module_t mp_module_onewire = {
|
|||
.globals = (mp_obj_dict_t *)&onewire_module_globals,
|
||||
};
|
||||
|
||||
MP_REGISTER_MODULE(MP_QSTR__onewire, mp_module_onewire, MICROPY_PY_ONEWIRE);
|
||||
|
||||
#endif // MICROPY_PY_ONEWIRE
|
||||
|
|
|
@ -588,4 +588,6 @@ const mp_obj_module_t mp_module_usocket = {
|
|||
.globals = (mp_obj_dict_t *)&mp_module_usocket_globals,
|
||||
};
|
||||
|
||||
MP_REGISTER_MODULE(MP_QSTR_socket, mp_module_usocket, MICROPY_PY_NETWORK && MICROPY_PY_USOCKET && !MICROPY_PY_LWIP);
|
||||
|
||||
#endif // MICROPY_PY_NETWORK && MICROPY_PY_USOCKET && !MICROPY_PY_LWIP
|
||||
|
|
|
@ -295,3 +295,7 @@ const mp_obj_module_t mp_module_network = {
|
|||
.base = { &mp_type_module },
|
||||
.globals = (mp_obj_dict_t *)&mp_module_network_globals,
|
||||
};
|
||||
|
||||
// Note: This port doesn't define MICROPY_PY_NETWORK so this will not conflict
|
||||
// with the common implementation provided by extmod/modnetwork.c.
|
||||
MP_REGISTER_MODULE(MP_QSTR_network, mp_module_network, 1);
|
||||
|
|
|
@ -867,3 +867,8 @@ const mp_obj_module_t mp_module_usocket = {
|
|||
.base = { &mp_type_module },
|
||||
.globals = (mp_obj_dict_t *)&mp_module_socket_globals,
|
||||
};
|
||||
|
||||
// Note: This port doesn't define MICROPY_PY_USOCKET or MICROPY_PY_LWIP so
|
||||
// this will not conflict with the common implementation provided by
|
||||
// extmod/mod{lwip,usocket}.c.
|
||||
MP_REGISTER_MODULE(MP_QSTR_usocket, mp_module_usocket, 1);
|
||||
|
|
|
@ -140,17 +140,11 @@
|
|||
extern const struct _mp_obj_module_t esp_module;
|
||||
extern const struct _mp_obj_module_t esp32_module;
|
||||
extern const struct _mp_obj_module_t utime_module;
|
||||
extern const struct _mp_obj_module_t mp_module_usocket;
|
||||
extern const struct _mp_obj_module_t mp_module_network;
|
||||
extern const struct _mp_obj_module_t mp_module_onewire;
|
||||
|
||||
#define MICROPY_PORT_BUILTIN_MODULES \
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_esp), (mp_obj_t)&esp_module }, \
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_esp32), (mp_obj_t)&esp32_module }, \
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_utime), (mp_obj_t)&utime_module }, \
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_usocket), (mp_obj_t)&mp_module_usocket }, \
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_network), (mp_obj_t)&mp_module_network }, \
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR__onewire), (mp_obj_t)&mp_module_onewire }, \
|
||||
|
||||
#define MP_STATE_PORT MP_STATE_VM
|
||||
|
||||
|
|
|
@ -545,3 +545,7 @@ const mp_obj_module_t network_module = {
|
|||
.base = { &mp_type_module },
|
||||
.globals = (mp_obj_dict_t *)&mp_module_network_globals,
|
||||
};
|
||||
|
||||
// Note: This port doesn't define MICROPY_PY_NETWORK so this will not conflict
|
||||
// with the common implementation provided by extmod/modnetwork.c.
|
||||
MP_REGISTER_MODULE(MP_QSTR_network, network_module, 1);
|
||||
|
|
|
@ -161,17 +161,11 @@ extern const struct _mp_print_t mp_debug_print;
|
|||
|
||||
// extra built in modules to add to the list of known ones
|
||||
extern const struct _mp_obj_module_t esp_module;
|
||||
extern const struct _mp_obj_module_t network_module;
|
||||
extern const struct _mp_obj_module_t utime_module;
|
||||
extern const struct _mp_obj_module_t mp_module_lwip;
|
||||
extern const struct _mp_obj_module_t mp_module_onewire;
|
||||
|
||||
#define MICROPY_PORT_BUILTIN_MODULES \
|
||||
{ MP_ROM_QSTR(MP_QSTR_esp), MP_ROM_PTR(&esp_module) }, \
|
||||
{ MP_ROM_QSTR(MP_QSTR_usocket), MP_ROM_PTR(&mp_module_lwip) }, \
|
||||
{ MP_ROM_QSTR(MP_QSTR_network), MP_ROM_PTR(&network_module) }, \
|
||||
{ MP_ROM_QSTR(MP_QSTR_utime), MP_ROM_PTR(&utime_module) }, \
|
||||
{ MP_ROM_QSTR(MP_QSTR__onewire), MP_ROM_PTR(&mp_module_onewire) }, \
|
||||
|
||||
#define MP_STATE_PORT MP_STATE_VM
|
||||
|
||||
|
|
|
@ -229,27 +229,7 @@ static inline void restore_irq_pri(uint32_t basepri) {
|
|||
{ MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&mp_builtin_open_obj) },
|
||||
|
||||
extern const struct _mp_obj_module_t mp_module_mimxrt;
|
||||
extern const struct _mp_obj_module_t mp_module_onewire;
|
||||
extern const struct _mp_obj_module_t mp_module_utime;
|
||||
extern const struct _mp_obj_module_t mp_module_usocket;
|
||||
extern const struct _mp_obj_module_t mp_module_network;
|
||||
|
||||
#if MICROPY_PY_NETWORK
|
||||
#define NETWORK_BUILTIN_MODULE { MP_ROM_QSTR(MP_QSTR_network), MP_ROM_PTR(&mp_module_network) },
|
||||
#else
|
||||
#define NETWORK_BUILTIN_MODULE
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_USOCKET && MICROPY_PY_LWIP
|
||||
// usocket implementation provided by lwIP
|
||||
#define SOCKET_BUILTIN_MODULE { MP_ROM_QSTR(MP_QSTR_usocket), MP_ROM_PTR(&mp_module_lwip) },
|
||||
#elif MICROPY_PY_USOCKET
|
||||
// usocket implementation provided by skeleton wrapper
|
||||
#define SOCKET_BUILTIN_MODULE { MP_ROM_QSTR(MP_QSTR_usocket), MP_ROM_PTR(&mp_module_usocket) },
|
||||
#else
|
||||
// no usocket module
|
||||
#define SOCKET_BUILTIN_MODULE
|
||||
#endif
|
||||
|
||||
#if defined(MICROPY_HW_ETH_MDC)
|
||||
extern const struct _mp_obj_type_t network_lan_type;
|
||||
|
@ -261,9 +241,6 @@ extern const struct _mp_obj_type_t network_lan_type;
|
|||
#define MICROPY_PORT_BUILTIN_MODULES \
|
||||
{ MP_ROM_QSTR(MP_QSTR_mimxrt), (mp_obj_t)&mp_module_mimxrt }, \
|
||||
{ MP_ROM_QSTR(MP_QSTR_utime), MP_ROM_PTR(&mp_module_utime) }, \
|
||||
{ MP_ROM_QSTR(MP_QSTR__onewire), MP_ROM_PTR(&mp_module_onewire) }, \
|
||||
SOCKET_BUILTIN_MODULE \
|
||||
NETWORK_BUILTIN_MODULE \
|
||||
|
||||
#ifndef MICROPY_BOARD_NETWORK_INTERFACES
|
||||
#define MICROPY_BOARD_NETWORK_INTERFACES
|
||||
|
|
|
@ -134,22 +134,12 @@
|
|||
#define MICROPY_PORT_BUILTINS \
|
||||
{ MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&mp_builtin_open_obj) },
|
||||
|
||||
extern const struct _mp_obj_module_t mp_module_network;
|
||||
extern const struct _mp_obj_module_t mp_module_onewire;
|
||||
extern const struct _mp_obj_module_t mp_module_rp2;
|
||||
extern const struct _mp_obj_module_t mp_module_usocket;
|
||||
extern const struct _mp_obj_module_t mp_module_utime;
|
||||
|
||||
#if MICROPY_PY_USOCKET
|
||||
#define SOCKET_BUILTIN_MODULE { MP_ROM_QSTR(MP_QSTR_usocket), MP_ROM_PTR(&mp_module_usocket) },
|
||||
#else
|
||||
#define SOCKET_BUILTIN_MODULE
|
||||
#endif
|
||||
#if MICROPY_PY_NETWORK
|
||||
#define NETWORK_BUILTIN_MODULE { MP_ROM_QSTR(MP_QSTR_network), MP_ROM_PTR(&mp_module_network) },
|
||||
#define NETWORK_ROOT_POINTERS mp_obj_list_t mod_network_nic_list;
|
||||
#else
|
||||
#define NETWORK_BUILTIN_MODULE
|
||||
#define NETWORK_ROOT_POINTERS
|
||||
#endif
|
||||
|
||||
|
@ -182,11 +172,8 @@ extern const struct _mod_network_nic_type_t mod_network_nic_type_nina;
|
|||
#endif
|
||||
|
||||
#define MICROPY_PORT_BUILTIN_MODULES \
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR__onewire), (mp_obj_t)&mp_module_onewire }, \
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR__rp2), (mp_obj_t)&mp_module_rp2 }, \
|
||||
{ MP_ROM_QSTR(MP_QSTR_utime), MP_ROM_PTR(&mp_module_utime) }, \
|
||||
SOCKET_BUILTIN_MODULE \
|
||||
NETWORK_BUILTIN_MODULE \
|
||||
|
||||
#ifndef MICROPY_BOARD_NETWORK_INTERFACES
|
||||
#define MICROPY_BOARD_NETWORK_INTERFACES
|
||||
|
|
|
@ -212,29 +212,6 @@ extern const struct _mp_obj_module_t mp_module_onewire;
|
|||
#define UTIME_BUILTIN_MODULE
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_USOCKET && MICROPY_PY_LWIP
|
||||
// usocket implementation provided by lwIP
|
||||
#define SOCKET_BUILTIN_MODULE { MP_ROM_QSTR(MP_QSTR_usocket), MP_ROM_PTR(&mp_module_lwip) },
|
||||
#elif MICROPY_PY_USOCKET
|
||||
// usocket implementation provided by skeleton wrapper
|
||||
#define SOCKET_BUILTIN_MODULE { MP_ROM_QSTR(MP_QSTR_usocket), MP_ROM_PTR(&mp_module_usocket) },
|
||||
#else
|
||||
// no usocket module
|
||||
#define SOCKET_BUILTIN_MODULE
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_NETWORK
|
||||
#define NETWORK_BUILTIN_MODULE { MP_ROM_QSTR(MP_QSTR_network), MP_ROM_PTR(&mp_module_network) },
|
||||
#else
|
||||
#define NETWORK_BUILTIN_MODULE
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_ONEWIRE
|
||||
#define ONEWIRE_BUILTIN_MODULE { MP_ROM_QSTR(MP_QSTR__onewire), MP_ROM_PTR(&mp_module_onewire) },
|
||||
#else
|
||||
#define ONEWIRE_BUILTIN_MODULE
|
||||
#endif
|
||||
|
||||
#if defined(MICROPY_HW_ETH_MDC)
|
||||
extern const struct _mp_obj_type_t network_lan_type;
|
||||
#define MICROPY_HW_NIC_ETH { MP_ROM_QSTR(MP_QSTR_LAN), MP_ROM_PTR(&network_lan_type) },
|
||||
|
@ -271,9 +248,6 @@ extern const struct _mod_network_nic_type_t mod_network_nic_type_cc3k;
|
|||
PYB_BUILTIN_MODULE \
|
||||
STM_BUILTIN_MODULE \
|
||||
UTIME_BUILTIN_MODULE \
|
||||
SOCKET_BUILTIN_MODULE \
|
||||
NETWORK_BUILTIN_MODULE \
|
||||
ONEWIRE_BUILTIN_MODULE \
|
||||
|
||||
// extra constants
|
||||
#define MICROPY_PORT_CONSTANTS \
|
||||
|
|
Loading…
Reference in New Issue