Skip to content

Commit

Permalink
extmod: Make extmod modules use MP_REGISTER_MODULE.
Browse files Browse the repository at this point in the history
Signed-off-by: Jim Mussared <[email protected]>
  • Loading branch information
jimmo committed May 18, 2022
1 parent 4694501 commit 4eab44a
Show file tree
Hide file tree
Showing 35 changed files with 69 additions and 74 deletions.
2 changes: 2 additions & 0 deletions extmod/modbluetooth.c
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,8 @@ const mp_obj_module_t mp_module_ubluetooth = {
.globals = (mp_obj_dict_t *)&mp_module_bluetooth_globals,
};

MP_REGISTER_MODULE(MP_QSTR_ubluetooth, mp_module_ubluetooth, MICROPY_PY_BLUETOOTH);

// Helpers

#if !MICROPY_PY_BLUETOOTH_USE_SYNC_EVENTS
Expand Down
2 changes: 2 additions & 0 deletions extmod/modbtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,8 @@ const mp_obj_module_t mp_module_btree = {
.base = { &mp_type_module },
.globals = (mp_obj_dict_t *)&mp_module_btree_globals,
};

MP_REGISTER_MODULE(MP_QSTR_btree, mp_module_btree, MICROPY_PY_BTREE);
#endif

#endif // MICROPY_PY_BTREE
2 changes: 2 additions & 0 deletions extmod/modframebuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,8 @@ const mp_obj_module_t mp_module_framebuf = {
.base = { &mp_type_module },
.globals = (mp_obj_dict_t *)&framebuf_module_globals,
};

MP_REGISTER_MODULE(MP_QSTR_framebuf, mp_module_framebuf, MICROPY_PY_FRAMEBUF);
#endif

#endif // MICROPY_PY_FRAMEBUF
2 changes: 2 additions & 0 deletions extmod/modlwip.c
Original file line number Diff line number Diff line change
Expand Up @@ -1778,4 +1778,6 @@ const mp_obj_module_t mp_module_lwip = {
.globals = (mp_obj_dict_t *)&mp_module_lwip_globals,
};

MP_REGISTER_MODULE(MP_QSTR_lwip, mp_module_lwip, MICROPY_PY_LWIP);

#endif // MICROPY_PY_LWIP
2 changes: 2 additions & 0 deletions extmod/moduasyncio.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,4 +310,6 @@ const mp_obj_module_t mp_module_uasyncio = {
.globals = (mp_obj_dict_t *)&mp_module_uasyncio_globals,
};

MP_REGISTER_MODULE(MP_QSTR__uasyncio, mp_module_uasyncio, MICROPY_PY_UASYNCIO);

#endif // MICROPY_PY_UASYNCIO
2 changes: 2 additions & 0 deletions extmod/modubinascii.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,4 +258,6 @@ const mp_obj_module_t mp_module_ubinascii = {
.globals = (mp_obj_dict_t *)&mp_module_binascii_globals,
};

MP_REGISTER_MODULE(MP_QSTR_ubinascii, mp_module_ubinascii, MICROPY_PY_UBINASCII);

#endif // MICROPY_PY_UBINASCII
2 changes: 2 additions & 0 deletions extmod/moducryptolib.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,4 +374,6 @@ const mp_obj_module_t mp_module_ucryptolib = {
.globals = (mp_obj_dict_t *)&mp_module_ucryptolib_globals,
};

MP_REGISTER_MODULE(MP_QSTR_ucryptolib, mp_module_ucryptolib, MICROPY_PY_UCRYPTOLIB);

#endif // MICROPY_PY_UCRYPTOLIB
2 changes: 2 additions & 0 deletions extmod/moductypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -717,4 +717,6 @@ const mp_obj_module_t mp_module_uctypes = {
.globals = (mp_obj_dict_t *)&mp_module_uctypes_globals,
};

MP_REGISTER_MODULE(MP_QSTR_uctypes, mp_module_uctypes, MICROPY_PY_UCTYPES);

#endif
2 changes: 2 additions & 0 deletions extmod/moduhashlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,4 +371,6 @@ const mp_obj_module_t mp_module_uhashlib = {
.globals = (mp_obj_dict_t *)&mp_module_uhashlib_globals,
};

MP_REGISTER_MODULE(MP_QSTR_uhashlib, mp_module_uhashlib, MICROPY_PY_UHASHLIB);

#endif // MICROPY_PY_UHASHLIB
2 changes: 2 additions & 0 deletions extmod/moduheapq.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ const mp_obj_module_t mp_module_uheapq = {
.base = { &mp_type_module },
.globals = (mp_obj_dict_t *)&mp_module_uheapq_globals,
};

MP_REGISTER_MODULE(MP_QSTR_uheapq, mp_module_uheapq, MICROPY_PY_UHEAPQ);
#endif

#endif // MICROPY_PY_UHEAPQ
2 changes: 2 additions & 0 deletions extmod/modujson.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,4 +381,6 @@ const mp_obj_module_t mp_module_ujson = {
.globals = (mp_obj_dict_t *)&mp_module_ujson_globals,
};

MP_REGISTER_MODULE(MP_QSTR_ujson, mp_module_ujson, MICROPY_PY_UJSON);

#endif // MICROPY_PY_UJSON
2 changes: 2 additions & 0 deletions extmod/moduos.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,6 @@ const mp_obj_module_t mp_module_uos = {
.globals = (mp_obj_dict_t *)&os_module_globals,
};

MP_REGISTER_MODULE(MP_QSTR_uos, mp_module_uos, MICROPY_PY_UOS);

#endif // MICROPY_PY_UOS
2 changes: 2 additions & 0 deletions extmod/moduplatform.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,6 @@ const mp_obj_module_t mp_module_uplatform = {
.globals = (mp_obj_dict_t *)&modplatform_globals,
};

MP_REGISTER_MODULE(MP_QSTR_uplatform, mp_module_uplatform, MICROPY_PY_UPLATFORM);

#endif // MICROPY_PY_UPLATFORM
2 changes: 2 additions & 0 deletions extmod/modurandom.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ const mp_obj_module_t mp_module_urandom = {
.base = { &mp_type_module },
.globals = (mp_obj_dict_t *)&mp_module_urandom_globals,
};

MP_REGISTER_MODULE(MP_QSTR_urandom, mp_module_urandom, MICROPY_PY_URANDOM);
#endif

#endif // MICROPY_PY_URANDOM
2 changes: 2 additions & 0 deletions extmod/modure.c
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,8 @@ const mp_obj_module_t mp_module_ure = {
.base = { &mp_type_module },
.globals = (mp_obj_dict_t *)&mp_module_re_globals,
};

MP_REGISTER_MODULE(MP_QSTR_ure, mp_module_ure, MICROPY_PY_URE);
#endif

// Source files #include'd here to make sure they're compiled in
Expand Down
2 changes: 2 additions & 0 deletions extmod/moduselect.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,4 +373,6 @@ const mp_obj_module_t mp_module_uselect = {
.globals = (mp_obj_dict_t *)&mp_module_select_globals,
};

MP_REGISTER_MODULE(MP_QSTR_uselect, mp_module_uselect, MICROPY_PY_USELECT);

#endif // MICROPY_PY_USELECT
4 changes: 3 additions & 1 deletion extmod/modussl_axtls.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,4 +358,6 @@ const mp_obj_module_t mp_module_ussl = {
.globals = (mp_obj_dict_t *)&mp_module_ssl_globals,
};

#endif // MICROPY_PY_USSL
MP_REGISTER_MODULE(MP_QSTR_ussl, mp_module_ussl, MICROPY_PY_USSL && MICROPY_SSL_AXTLS);

#endif // MICROPY_PY_USSL && MICROPY_SSL_AXTLS
4 changes: 3 additions & 1 deletion extmod/modussl_mbedtls.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,4 +418,6 @@ const mp_obj_module_t mp_module_ussl = {
.globals = (mp_obj_dict_t *)&mp_module_ssl_globals,
};

#endif // MICROPY_PY_USSL
MP_REGISTER_MODULE(MP_QSTR_ussl, mp_module_ussl, MICROPY_PY_USSL && MICROPY_SSL_MBEDTLS);

#endif // MICROPY_PY_USSL && MICROPY_SSL_MBEDTLS
1 change: 1 addition & 0 deletions extmod/modutimeq.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,5 @@ const mp_obj_module_t mp_module_utimeq = {
.globals = (mp_obj_dict_t *)&mp_module_utimeq_globals,
};

MP_REGISTER_MODULE(MP_QSTR_utimeq, mp_module_utimeq, MICROPY_PY_UTIMEQ);
#endif // MICROPY_PY_UTIMEQ
2 changes: 2 additions & 0 deletions extmod/moduwebsocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,4 +310,6 @@ const mp_obj_module_t mp_module_uwebsocket = {
.globals = (mp_obj_dict_t *)&uwebsocket_module_globals,
};

MP_REGISTER_MODULE(MP_QSTR_uwebsocket, mp_module_uwebsocket, MICROPY_PY_UWEBSOCKET);

#endif // MICROPY_PY_UWEBSOCKET
3 changes: 3 additions & 0 deletions extmod/moduzlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ const mp_obj_module_t mp_module_uzlib = {
.base = { &mp_type_module },
.globals = (mp_obj_dict_t *)&mp_module_uzlib_globals,
};


MP_REGISTER_MODULE(MP_QSTR_uzlib, mp_module_uzlib, MICROPY_PY_UZLIB);
#endif

// Source files #include'd here to make sure they're compiled in
Expand Down
2 changes: 2 additions & 0 deletions extmod/modwebrepl.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,4 +363,6 @@ const mp_obj_module_t mp_module_webrepl = {
.globals = (mp_obj_dict_t *)&webrepl_module_globals,
};

MP_REGISTER_MODULE(MP_QSTR__webrepl, mp_module_webrepl, MICROPY_PY_WEBREPL);

#endif // MICROPY_PY_WEBREPL
2 changes: 2 additions & 0 deletions ports/cc3200/mods/modmachine.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,5 @@ const mp_obj_module_t mp_module_machine = {
.base = { &mp_type_module },
.globals = (mp_obj_dict_t*)&machine_module_globals,
};

MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine, MICROPY_PY_MACHINE);
2 changes: 2 additions & 0 deletions ports/esp32/modmachine.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,4 +337,6 @@ const mp_obj_module_t mp_module_machine = {
.globals = (mp_obj_dict_t *)&machine_module_globals,
};

MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine, MICROPY_PY_MACHINE);

#endif // MICROPY_PY_MACHINE
2 changes: 2 additions & 0 deletions ports/esp8266/modmachine.c
Original file line number Diff line number Diff line change
Expand Up @@ -453,4 +453,6 @@ const mp_obj_module_t mp_module_machine = {
.globals = (mp_obj_dict_t *)&machine_module_globals,
};

MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine, MICROPY_PY_MACHINE);

#endif // MICROPY_PY_MACHINE
2 changes: 2 additions & 0 deletions ports/mimxrt/modmachine.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,5 @@ const mp_obj_module_t mp_module_machine = {
.base = { &mp_type_module },
.globals = (mp_obj_dict_t *)&machine_module_globals,
};

MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine, MICROPY_PY_MACHINE);
1 change: 1 addition & 0 deletions ports/nrf/modules/machine/modmachine.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,4 @@ const mp_obj_module_t mp_module_machine = {
.globals = (mp_obj_dict_t*)&machine_module_globals,
};

MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine, MICROPY_PY_MACHINE);
2 changes: 2 additions & 0 deletions ports/qemu-arm/modmachine.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ const mp_obj_module_t mp_module_machine = {
.base = { &mp_type_module },
.globals = (mp_obj_dict_t *)&machine_module_globals,
};

MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine, MICROPY_PY_MACHINE);
2 changes: 2 additions & 0 deletions ports/rp2/modmachine.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,5 @@ const mp_obj_module_t mp_module_machine = {
.base = { &mp_type_module },
.globals = (mp_obj_dict_t *)&machine_module_globals,
};

MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine, MICROPY_PY_MACHINE);
2 changes: 2 additions & 0 deletions ports/samd/modmachine.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,5 @@ const mp_obj_module_t mp_module_machine = {
.base = { &mp_type_module },
.globals = (mp_obj_dict_t *)&machine_module_globals,
};

MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine, MICROPY_PY_MACHINE);
2 changes: 2 additions & 0 deletions ports/stm32/modmachine.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,3 +480,5 @@ const mp_obj_module_t mp_module_machine = {
.base = { &mp_type_module },
.globals = (mp_obj_dict_t *)&machine_module_globals,
};

MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine, MICROPY_PY_MACHINE);
2 changes: 2 additions & 0 deletions ports/unix/modmachine.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,6 @@ const mp_obj_module_t mp_module_machine = {
.globals = (mp_obj_dict_t *)&machine_module_globals,
};

MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine, MICROPY_PY_MACHINE);

#endif // MICROPY_PY_MACHINE
2 changes: 2 additions & 0 deletions ports/zephyr/modmachine.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,6 @@ const mp_obj_module_t mp_module_machine = {
.globals = (mp_obj_dict_t *)&machine_module_globals,
};

MP_REGISTER_MODULE(MP_QSTR_umachine, mp_module_machine, MICROPY_PY_MACHINE);

#endif // MICROPY_PY_MACHINE
2 changes: 2 additions & 0 deletions py/moduerrno.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ const mp_obj_module_t mp_module_uerrno = {
.globals = (mp_obj_dict_t *)&mp_module_uerrno_globals,
};

MP_REGISTER_MODULE(MP_QSTR_uerrno, mp_module_uerrno, MICROPY_PY_UERRNO);

qstr mp_errno_to_str(mp_obj_t errno_val) {
#if MICROPY_PY_UERRNO_ERRORCODE
// We have the errorcode dict so can do a lookup using the hash map
Expand Down
72 changes: 0 additions & 72 deletions py/objmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,78 +193,6 @@ STATIC const mp_rom_map_elem_t mp_builtin_module_table[] = {
{ MP_ROM_QSTR(MP_QSTR__thread), MP_ROM_PTR(&mp_module_thread) },
#endif

// extmod modules

#if MICROPY_PY_UASYNCIO
{ MP_ROM_QSTR(MP_QSTR__uasyncio), MP_ROM_PTR(&mp_module_uasyncio) },
#endif
#if MICROPY_PY_UERRNO
{ MP_ROM_QSTR(MP_QSTR_uerrno), MP_ROM_PTR(&mp_module_uerrno) },
#endif
#if MICROPY_PY_UCTYPES
{ MP_ROM_QSTR(MP_QSTR_uctypes), MP_ROM_PTR(&mp_module_uctypes) },
#endif
#if MICROPY_PY_UZLIB
{ MP_ROM_QSTR(MP_QSTR_uzlib), MP_ROM_PTR(&mp_module_uzlib) },
#endif
#if MICROPY_PY_UJSON
{ MP_ROM_QSTR(MP_QSTR_ujson), MP_ROM_PTR(&mp_module_ujson) },
#endif
#if MICROPY_PY_UOS
{ MP_ROM_QSTR(MP_QSTR_uos), MP_ROM_PTR(&mp_module_uos) },
#endif
#if MICROPY_PY_URE
{ MP_ROM_QSTR(MP_QSTR_ure), MP_ROM_PTR(&mp_module_ure) },
#endif
#if MICROPY_PY_UHEAPQ
{ MP_ROM_QSTR(MP_QSTR_uheapq), MP_ROM_PTR(&mp_module_uheapq) },
#endif
#if MICROPY_PY_UTIMEQ
{ MP_ROM_QSTR(MP_QSTR_utimeq), MP_ROM_PTR(&mp_module_utimeq) },
#endif
#if MICROPY_PY_UHASHLIB
{ MP_ROM_QSTR(MP_QSTR_uhashlib), MP_ROM_PTR(&mp_module_uhashlib) },
#endif
#if MICROPY_PY_UCRYPTOLIB
{ MP_ROM_QSTR(MP_QSTR_ucryptolib), MP_ROM_PTR(&mp_module_ucryptolib) },
#endif
#if MICROPY_PY_UBINASCII
{ MP_ROM_QSTR(MP_QSTR_ubinascii), MP_ROM_PTR(&mp_module_ubinascii) },
#endif
#if MICROPY_PY_URANDOM
{ MP_ROM_QSTR(MP_QSTR_urandom), MP_ROM_PTR(&mp_module_urandom) },
#endif
#if MICROPY_PY_USELECT
{ MP_ROM_QSTR(MP_QSTR_uselect), MP_ROM_PTR(&mp_module_uselect) },
#endif
#if MICROPY_PY_USSL
{ MP_ROM_QSTR(MP_QSTR_ussl), MP_ROM_PTR(&mp_module_ussl) },
#endif
#if MICROPY_PY_LWIP
{ MP_ROM_QSTR(MP_QSTR_lwip), MP_ROM_PTR(&mp_module_lwip) },
#endif
#if MICROPY_PY_MACHINE
{ MP_ROM_QSTR(MP_QSTR_umachine), MP_ROM_PTR(&mp_module_machine) },
#endif
#if MICROPY_PY_UWEBSOCKET
{ MP_ROM_QSTR(MP_QSTR_uwebsocket), MP_ROM_PTR(&mp_module_uwebsocket) },
#endif
#if MICROPY_PY_WEBREPL
{ MP_ROM_QSTR(MP_QSTR__webrepl), MP_ROM_PTR(&mp_module_webrepl) },
#endif
#if MICROPY_PY_FRAMEBUF
{ MP_ROM_QSTR(MP_QSTR_framebuf), MP_ROM_PTR(&mp_module_framebuf) },
#endif
#if MICROPY_PY_BTREE
{ MP_ROM_QSTR(MP_QSTR_btree), MP_ROM_PTR(&mp_module_btree) },
#endif
#if MICROPY_PY_BLUETOOTH
{ MP_ROM_QSTR(MP_QSTR_ubluetooth), MP_ROM_PTR(&mp_module_ubluetooth) },
#endif
#if MICROPY_PY_UPLATFORM
{ MP_ROM_QSTR(MP_QSTR_uplatform), MP_ROM_PTR(&mp_module_uplatform) },
#endif

// extra builtin modules as defined by a port
MICROPY_PORT_BUILTIN_MODULES

Expand Down

0 comments on commit 4eab44a

Please sign in to comment.