py/objmodule: Workaround for MSVC with no module delegation.

When compiling mpy-cross, there is no `sys` module, and so there will
be no entries in the `mp_builtin_module_delegation_table`.

MSVC doesn't like this, so instead pretend as if the feature isn't
enabled at all.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This commit is contained in:
Jim Mussared 2023-06-06 22:49:50 +10:00
parent 13c817e61c
commit e6926d6021
2 changed files with 4 additions and 1 deletions

View File

@ -103,6 +103,9 @@ def generate_module_table_header(modules):
def generate_module_delegations(delegations): def generate_module_delegations(delegations):
if not delegations:
return
print("\n#define MICROPY_MODULE_DELEGATIONS \\") print("\n#define MICROPY_MODULE_DELEGATIONS \\")
for obj_module, fun_name in delegations: for obj_module, fun_name in delegations:
print( print(

View File

@ -230,7 +230,7 @@ mp_obj_t mp_module_get_builtin(qstr module_name, bool extensible) {
} }
STATIC void module_attr_try_delegation(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { STATIC void module_attr_try_delegation(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
#if MICROPY_MODULE_ATTR_DELEGATION #if MICROPY_MODULE_ATTR_DELEGATION && defined(MICROPY_MODULE_DELEGATIONS)
// Delegate lookup to a module's custom attr method. // Delegate lookup to a module's custom attr method.
size_t n = MP_ARRAY_SIZE(mp_builtin_module_delegation_table); size_t n = MP_ARRAY_SIZE(mp_builtin_module_delegation_table);
for (size_t i = 0; i < n; ++i) { for (size_t i = 0; i < n; ++i) {