diff options
author | Damien George <damien.p.george@gmail.com> | 2019-09-26 16:24:06 +1000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2019-09-26 16:24:06 +1000 |
commit | 96f2a3807583945042b628b5184b0c91cf2714a2 (patch) | |
tree | f7e10e8f770c7e1d66c2ced9c263a2ff339cb0a8 /py | |
parent | 7d58a197cffa7c0dd3686402d2e381812bb8ddeb (diff) |
py/nativeglue: Make mp_fun_table fixed size regardless of config.
So that mpy files with native code will always work correctly, and raise an
exception if a feature is used that is not supported by the runtime.
Diffstat (limited to 'py')
-rw-r--r-- | py/nativeglue.c | 27 | ||||
-rw-r--r-- | py/runtime0.h | 4 |
2 files changed, 23 insertions, 8 deletions
diff --git a/py/nativeglue.c b/py/nativeglue.c index 596793a4f..62b76eb6b 100644 --- a/py/nativeglue.c +++ b/py/nativeglue.c @@ -97,6 +97,29 @@ mp_obj_t mp_native_to_obj(mp_uint_t val, mp_uint_t type) { #if MICROPY_EMIT_NATIVE && !MICROPY_DYNAMIC_COMPILER +#if !MICROPY_PY_BUILTINS_SET +mp_obj_t mp_obj_new_set(size_t n_args, mp_obj_t *items) { + (void)n_args; + (void)items; + mp_raise_msg(&mp_type_RuntimeError, "set unsupported"); +} + +void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item) { + (void)self_in; + (void)item; + mp_raise_msg(&mp_type_RuntimeError, "set unsupported"); +} +#endif + +#if !MICROPY_PY_BUILTINS_SLICE +mp_obj_t mp_obj_new_slice(mp_obj_t ostart, mp_obj_t ostop, mp_obj_t ostep) { + (void)ostart; + (void)ostop; + (void)ostep; + mp_raise_msg(&mp_type_RuntimeError, "slice unsupported"); +} +#endif + STATIC mp_obj_dict_t *mp_native_swap_globals(mp_obj_dict_t *new_globals) { if (new_globals == NULL) { // Globals were the originally the same so don't restore them @@ -211,10 +234,8 @@ const void *const mp_fun_table[MP_F_NUMBER_OF] = { mp_obj_new_tuple, mp_obj_new_list, mp_obj_new_dict, -#if MICROPY_PY_BUILTINS_SET mp_obj_new_set, mp_obj_set_store, -#endif mp_obj_list_append, mp_obj_dict_store, mp_make_function_from_raw_code, @@ -229,9 +250,7 @@ const void *const mp_fun_table[MP_F_NUMBER_OF] = { mp_import_name, mp_import_from, mp_import_all, -#if MICROPY_PY_BUILTINS_SLICE mp_obj_new_slice, -#endif mp_unpack_sequence, mp_unpack_ex, mp_delete_name, diff --git a/py/runtime0.h b/py/runtime0.h index ef1160859..fd284d47b 100644 --- a/py/runtime0.h +++ b/py/runtime0.h @@ -173,10 +173,8 @@ typedef enum { MP_F_BUILD_TUPLE, MP_F_BUILD_LIST, MP_F_BUILD_MAP, -#if MICROPY_PY_BUILTINS_SET MP_F_BUILD_SET, MP_F_STORE_SET, -#endif MP_F_LIST_APPEND, MP_F_STORE_MAP, MP_F_MAKE_FUNCTION_FROM_RAW_CODE, @@ -191,9 +189,7 @@ typedef enum { MP_F_IMPORT_NAME, MP_F_IMPORT_FROM, MP_F_IMPORT_ALL, -#if MICROPY_PY_BUILTINS_SLICE MP_F_NEW_SLICE, -#endif MP_F_UNPACK_SEQUENCE, MP_F_UNPACK_EX, MP_F_DELETE_NAME, |