diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2017-12-05 00:38:41 +0200 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2017-12-05 00:38:41 +0200 |
commit | 62b96147e6126961c5d1d6bb28b7ac7034fa9322 (patch) | |
tree | 35b8c63969876e7b6d21ff2660f55883bc3dd78c /py/runtime.h | |
parent | 3ff7040c8ab268777e940a9bed4aa7c24f50ba31 (diff) |
py: mp_call_function_*_protected(): Pass-thru return value if possible.
Return the result of called function. If exception happened, return
MP_OBJ_NULL. Allows to use mp_call_function_*_protected() with callbacks
returning values, etc.
Diffstat (limited to 'py/runtime.h')
-rw-r--r-- | py/runtime.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/py/runtime.h b/py/runtime.h index 9c1921cb5..3f0d1104e 100644 --- a/py/runtime.h +++ b/py/runtime.h @@ -106,8 +106,9 @@ mp_obj_t mp_call_method_n_kw(size_t n_args, size_t n_kw, const mp_obj_t *args); mp_obj_t mp_call_method_n_kw_var(bool have_self, size_t n_args_n_kw, const mp_obj_t *args); mp_obj_t mp_call_method_self_n_kw(mp_obj_t meth, mp_obj_t self, size_t n_args, size_t n_kw, const mp_obj_t *args); // Call function and catch/dump exception - for Python callbacks from C code -void mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); -void mp_call_function_2_protected(mp_obj_t fun, mp_obj_t arg1, mp_obj_t arg2); +// (return MP_OBJ_NULL in case of exception). +mp_obj_t mp_call_function_1_protected(mp_obj_t fun, mp_obj_t arg); +mp_obj_t mp_call_function_2_protected(mp_obj_t fun, mp_obj_t arg1, mp_obj_t arg2); typedef struct _mp_call_args_t { mp_obj_t fun; |