From 7789cd5f16b068f032e58be8e5e60bf17cb03d40 Mon Sep 17 00:00:00 2001 From: Damien George Date: Sat, 31 Oct 2020 00:22:11 +1100 Subject: [PATCH] lib/utils/pyexec: Add MICROPY_BOARD hooks before/after executing code. Signed-off-by: Damien George --- lib/utils/pyexec.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/utils/pyexec.c b/lib/utils/pyexec.c index 2c8ca2de0c..2b86af3bba 100644 --- a/lib/utils/pyexec.c +++ b/lib/utils/pyexec.c @@ -68,10 +68,15 @@ STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input uint32_t start = 0; #endif + #ifdef MICROPY_BOARD_BEFORE_PYTHON_EXEC + MICROPY_BOARD_BEFORE_PYTHON_EXEC(input_kind, exec_flags); + #endif + // by default a SystemExit exception returns 0 pyexec_system_exit = 0; nlr_buf_t nlr; + nlr.ret_val = NULL; if (nlr_push(&nlr) == 0) { mp_obj_t module_fun; #if MICROPY_MODULE_FROZEN_MPY @@ -157,6 +162,10 @@ STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input mp_hal_stdout_tx_strn("\x04", 1); } + #ifdef MICROPY_BOARD_AFTER_PYTHON_EXEC + MICROPY_BOARD_AFTER_PYTHON_EXEC(input_kind, exec_flags, nlr.ret_val, &ret); + #endif + return ret; }