8000 extmod: Make port-included extmod modules use MP_REGISTER_MODULES. · larsks/micropython@bb794f0 · GitHub
[go: up one dir, main page]

Skip to content

Commit bb794f0

Browse files
committed
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 8000 Mussared <jim.mussared@gmail.com>
1 parent d8d3e6a commit bb794f0

File tree

12 files changed

+22
-74
lines changed

12 files changed

+22
-74
lines changed

extmod/modlwip.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1780,4 +1780,7 @@ const mp_obj_module_t mp_module_lwip = {
17801780

17811781
MP_REGISTER_MODULE(MP_QSTR_lwip, mp_module_lwip, MICROPY_PY_LWIP);
17821782

1783+
// On LWIP-ports, this is the usocket module (replaces extmod/modusocket.c).
1784+
MP_REGISTER_MODULE(MP_QSTR_socket, mp_module_lwip, MICROPY_PY_LWIP);
1785+
17831786
#endif // MICROPY_PY_LWIP

extmod/modnetwork.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ const mp_obj_module_t mp_module_network = {
102102
.globals = (mp_obj_dict_t *)&mp_module_network_globals,
103103
};
104104

105+
MP_REGISTER_MODULE(MP_QSTR_network, mp_module_network, MICROPY_PY_NETWORK);
106+
105107
/*******************************************************************************/
106108
// Implementations of network methods that can be used by any interface
107109

extmod/modonewire.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,6 @@ const mp_obj_module_t mp_module_onewire = {
163163
.globals = (mp_obj_dict_t *)&onewire_module_globals,
164164
};
165165

166+
MP_REGISTER_MODULE(MP_QSTR__onewire, mp_module_onewire, MICROPY_PY_ONEWIRE);
167+
166168
#endif // MICROPY_PY_ONEWIRE

extmod/modusocket.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,4 +588,6 @@ const mp_obj_module_t mp_module_usocket = {
588588
.globals = (mp_obj_dict_t *)&mp_module_usocket_globals,
589589
};
590590

591+
MP_REGISTER_MODULE(MP_QSTR_socket, mp_module_usocket, MICROPY_PY_NETWORK && MICROPY_PY_USOCKET && !MICROPY_PY_LWIP);
592+
591593
#endif // MICROPY_PY_NETWORK && MICROPY_PY_USOCKET && !MICROPY_PY_LWIP

ports/esp32/modnetwork.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,3 +295,7 @@ const mp_obj_module_t mp_module_network = {
295295
.base = { &mp_type_module },
296296
.globals = (mp_obj_dict_t *)&mp_module_network_globals,
297297
};
298+
299+
// Note: This port doesn't define MICROPY_PY_NETWORK so this will not conflict
300+
// with the common implementation provided by extmod/modnetwork.c.
301+
MP_REGISTER_MODULE(MP_QSTR_network, mp_module_network, 1);

ports/esp32/modsocket.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,3 +867,8 @@ const mp_obj_module_t mp_module_usocket = {
867867
.base = { &mp_type_module },
868868
.globals = (mp_obj_dict_t *)&mp_module_socket_globals,
869869
};
870+
871+
// Note: This port doesn't define MICROPY_PY_USOCKET or MICROPY_PY_LWIP so
872+
// this will not conflict with the common implementation provided by
873+
// extmod/mod{lwip,usocket}.c.
874+
MP_REGISTER_MODULE(MP_QSTR_usocket, mp_module_usocket, 1);

ports/esp32/mpconfigport.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,17 +140,11 @@
140140
extern const struct _mp_obj_module_t esp_module;
141141
extern const struct _mp_obj_module_t esp32_module;
142142
extern const struct _mp_obj_module_t utime_module;
143-
extern const struct _mp_obj_module_t mp_module_usocket;
144-
extern const struct _mp_obj_module_t mp_module_network;
145-
extern const struct _mp_obj_module_t mp_module_onewire;
146143

147144
#define MICROPY_PORT_BUILTIN_MODULES \
148145
{ MP_OBJ_NEW_QSTR(MP_QSTR_esp), (mp_obj_t)&esp_module }, \
149146
{ MP_OBJ_NEW_QSTR(MP_QSTR_esp32), (mp_obj_t)&esp32_module }, \
150147
{ MP_OBJ_NEW_QSTR(MP_QSTR_utime), (mp_obj_t)&utime_module }, \
151-
{ MP_OBJ_NEW_QSTR(MP_QSTR_usocket), (mp_obj_t)&mp_module_usocket }, \
152-
{ MP_OBJ_NEW_QSTR(MP_QSTR_network), (mp_obj_t)&mp_module_network }, \
153-
{ MP_OBJ_NEW_QSTR(MP_QSTR__onewire), (mp_obj_t)&mp_module_onewire }, A93C \
154148

155149
#define MP_STATE_PORT MP_STATE_VM
156150

ports/esp8266/modnetwork.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,3 +545,7 @@ const mp_obj_module_t network_module = {
545545
.base = { &mp_type_module },
546546
.globals = (mp_obj_dict_t *)&mp_module_network_globals,
547547
};
548+
549+
// Note: This port doesn't define MICROPY_PY_NETWORK so this will not conflict
550+
// with the common implementation provided by extmod/modnetwork.c.
551+
MP_REGISTER_MODULE(MP_QSTR_network, network_module, 1);

ports/esp8266/mpconfigport.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,17 +161,11 @@ extern const struct _mp_print_t mp_debug_print;
161161

162162
// extra built in modules to add to the list of known ones
163163
extern const struct _mp_obj_module_t esp_module;
164-
extern const struct _mp_obj_module_t network_module;
165164
extern const struct _mp_obj_module_t utime_module;
166-
extern const struct _mp_obj_module_t mp_module_lwip;
167-
extern const struct _mp_obj_module_t mp_module_onewire;
168165

169166
#define MICROPY_PORT_BUILTIN_MODULES \
170167
{ MP_ROM_QSTR(MP_QSTR_esp), MP_ROM_PTR(&esp_module) }, \
171-
{ MP_ROM_QSTR(MP_QSTR_usocket), MP_ROM_PTR(&mp_module_lwip) }, \
172-
{ MP_ROM_QSTR(MP_QSTR_network), MP_ROM_PTR(&network_module) }, \
173168
{ MP_ROM_QSTR(MP_QSTR_utime), MP_ROM_PTR(&utime_module) }, \
174-
{ MP_ROM_QSTR(MP_QSTR__onewire), MP_ROM_PTR(&mp_module_onewire) }, \
175169

176170
#define MP_STATE_PORT MP_STATE_VM
177171

ports/mimxrt/mpconfigport.h

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -229,27 +229,7 @@ static inline void restore_irq_pri(uint32_t basepri) {
229229
{ MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&mp_builtin_open_obj) },
230230

231231
extern const struct _mp_obj_module_t mp_module_mimxrt;
232-
extern const struct _mp_obj_module_t mp_module_onewire;
233232
extern const struct _mp_obj_module_t mp_module_utime;
234-
extern const struct _mp_obj_module_t mp_module_usocket;
235-
extern const struct _mp_obj_module_t mp_module_network;
236-
237-
#if MICROPY_PY_NETWORK
238-
#define NETWORK_BUILTIN_MODULE { MP_ROM_QSTR(MP_QSTR_network), MP_ROM_PTR(&mp_module_network) },
239-
#else
240-
#define NETWORK_BUILTIN_MODULE
241-
#endif
242-
243-
#if MICROPY_PY_USOCKET && MICROPY_PY_LWIP
244-
// usocket implementation provided by lwIP
245-
#define SOCKET_BUILTIN_MODULE { MP_ROM_QSTR(MP_QSTR_usocket), MP_ROM_PTR(&mp_module_lwip) },
246-
#elif MICROPY_PY_USOCKET
247-
// usocket implementation provided by skeleton wrapper
248-
#define SOCKET_BUILTIN_MODULE { MP_ROM_QSTR(MP_QSTR_usocket), MP_ROM_PTR(&mp_module_usocket) },
249-
#else
250-
// no usocket module
251-
#define SOCKET_BUILTIN_MODULE
252-
#endif
253233

254234
#if defined(MICROPY_HW_ETH_MDC)
255235
extern const struct _mp_obj_type_t network_lan_type;
@@ -261,9 +241,6 @@ extern const struct _mp_obj_type_t network_lan_type;
261241
#define MICROPY_PORT_BUILTIN_MODULES \
262242 5D30
{ MP_ROM_QSTR(MP_QSTR_mimxrt), (mp_obj_t)&mp_module_mimxrt }, \
263243
{ MP_ROM_QSTR(MP_QSTR_utime), MP_ROM_PTR(&mp_module_utime) }, \
264-
{ MP_ROM_QSTR(MP_QSTR__onewire), MP_ROM_PTR(&mp_module_onewire) }, \
265-
SOCKET_BUILTIN_MODULE \
266-
NETWORK_BUILTIN_MODULE \
267244

268245
#ifndef MICROPY_BOARD_NETWORK_INTERFACES
269246
#define MICROPY_BOARD_NETWORK_INTERFACES

0 commit comments

Comments
 (0)
0