mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
lua/executor.c: use TRY_WRAP
This commit is contained in:
parent
83b6d9f197
commit
efaf4732e2
@ -102,6 +102,20 @@ typedef struct {
|
|||||||
int did_emsg;
|
int did_emsg;
|
||||||
} TryState;
|
} TryState;
|
||||||
|
|
||||||
|
// `msg_list` controls the collection of abort-causing non-exception errors,
|
||||||
|
// which would otherwise be ignored. This pattern is from do_cmdline().
|
||||||
|
//
|
||||||
|
// TODO(bfredl): prepare error-handling at "top level" (nv_event).
|
||||||
|
#define TRY_WRAP(code) \
|
||||||
|
do { \
|
||||||
|
struct msglist **saved_msg_list = msg_list; \
|
||||||
|
struct msglist *private_msg_list; \
|
||||||
|
msg_list = &private_msg_list; \
|
||||||
|
private_msg_list = NULL; \
|
||||||
|
code \
|
||||||
|
msg_list = saved_msg_list; /* Restore the exception context. */ \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||||
# include "api/private/helpers.h.generated.h"
|
# include "api/private/helpers.h.generated.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -53,20 +53,6 @@
|
|||||||
# include "api/vim.c.generated.h"
|
# include "api/vim.c.generated.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// `msg_list` controls the collection of abort-causing non-exception errors,
|
|
||||||
// which would otherwise be ignored. This pattern is from do_cmdline().
|
|
||||||
//
|
|
||||||
// TODO(bfredl): prepare error-handling at "top level" (nv_event).
|
|
||||||
#define TRY_WRAP(code) \
|
|
||||||
do { \
|
|
||||||
struct msglist **saved_msg_list = msg_list; \
|
|
||||||
struct msglist *private_msg_list; \
|
|
||||||
msg_list = &private_msg_list; \
|
|
||||||
private_msg_list = NULL; \
|
|
||||||
code \
|
|
||||||
msg_list = saved_msg_list; /* Restore the exception context. */ \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
void api_vim_init(void)
|
void api_vim_init(void)
|
||||||
FUNC_API_NOEXPORT
|
FUNC_API_NOEXPORT
|
||||||
{
|
{
|
||||||
|
@ -563,11 +563,8 @@ int nlua_call(lua_State *lstate)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TRY_WRAP({
|
||||||
// TODO(bfredl): this should be simplified in error handling refactor
|
// TODO(bfredl): this should be simplified in error handling refactor
|
||||||
struct msglist **saved_msg_list = msg_list;
|
|
||||||
struct msglist *private_msg_list = NULL;
|
|
||||||
msg_list = &private_msg_list;
|
|
||||||
|
|
||||||
force_abort = false;
|
force_abort = false;
|
||||||
suppress_errthrow = false;
|
suppress_errthrow = false;
|
||||||
current_exception = NULL;
|
current_exception = NULL;
|
||||||
@ -577,7 +574,7 @@ int nlua_call(lua_State *lstate)
|
|||||||
typval_T rettv;
|
typval_T rettv;
|
||||||
int dummy;
|
int dummy;
|
||||||
// call_func() retval is deceptive, ignore it. Instead we set `msg_list`
|
// call_func() retval is deceptive, ignore it. Instead we set `msg_list`
|
||||||
// (see above) to capture abort-causing non-exception errors.
|
// (TRY_WRAP) to capture abort-causing non-exception errors.
|
||||||
(void)call_func(name, (int)name_len, &rettv, nargs,
|
(void)call_func(name, (int)name_len, &rettv, nargs,
|
||||||
vim_args, NULL, curwin->w_cursor.lnum, curwin->w_cursor.lnum,
|
vim_args, NULL, curwin->w_cursor.lnum, curwin->w_cursor.lnum,
|
||||||
&dummy, true, NULL, NULL);
|
&dummy, true, NULL, NULL);
|
||||||
@ -585,8 +582,7 @@ int nlua_call(lua_State *lstate)
|
|||||||
nlua_push_typval(lstate, &rettv, false);
|
nlua_push_typval(lstate, &rettv, false);
|
||||||
}
|
}
|
||||||
tv_clear(&rettv);
|
tv_clear(&rettv);
|
||||||
|
});
|
||||||
msg_list = saved_msg_list;
|
|
||||||
|
|
||||||
free_vim_args:
|
free_vim_args:
|
||||||
while (i > 0) {
|
while (i > 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user