mirror of
https://github.com/neovim/neovim.git
synced 2025-09-23 11:38:31 +00:00
refactor: move non-symbols in ex_eval.h to ex_eval_defs.h (#19739)
This avoids including ex_eval.h in any other header, thus preventing future circular includes.
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include "nvim/api/private/helpers.h"
|
||||
#include "nvim/autocmd.h"
|
||||
#include "nvim/ex_docmd.h"
|
||||
#include "nvim/ex_eval.h"
|
||||
#include "nvim/lua/executor.h"
|
||||
#include "nvim/ops.h"
|
||||
#include "nvim/regexp.h"
|
||||
|
@@ -19,6 +19,7 @@
|
||||
#include "nvim/eval.h"
|
||||
#include "nvim/eval/typval.h"
|
||||
#include "nvim/ex_cmds_defs.h"
|
||||
#include "nvim/ex_eval.h"
|
||||
#include "nvim/extmark.h"
|
||||
#include "nvim/fileio.h"
|
||||
#include "nvim/highlight_group.h"
|
||||
@@ -54,7 +55,7 @@ void try_enter(TryState *const tstate)
|
||||
// save_dbg_stuff()/restore_dbg_stuff().
|
||||
*tstate = (TryState) {
|
||||
.current_exception = current_exception,
|
||||
.msg_list = (const struct msglist *const *)msg_list,
|
||||
.msg_list = (const msglist_T *const *)msg_list,
|
||||
.private_msg_list = NULL,
|
||||
.trylevel = trylevel,
|
||||
.got_int = got_int,
|
||||
@@ -89,7 +90,7 @@ bool try_leave(const TryState *const tstate, Error *const err)
|
||||
assert(msg_list == &tstate->private_msg_list);
|
||||
assert(*msg_list == NULL);
|
||||
assert(current_exception == NULL);
|
||||
msg_list = (struct msglist **)tstate->msg_list;
|
||||
msg_list = (msglist_T **)tstate->msg_list;
|
||||
current_exception = tstate->current_exception;
|
||||
trylevel = tstate->trylevel;
|
||||
got_int = tstate->got_int;
|
||||
|
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "nvim/api/private/defs.h"
|
||||
#include "nvim/decoration.h"
|
||||
#include "nvim/ex_eval.h"
|
||||
#include "nvim/ex_eval_defs.h"
|
||||
#include "nvim/getchar.h"
|
||||
#include "nvim/lib/kvec.h"
|
||||
#include "nvim/memory.h"
|
||||
@@ -130,8 +130,8 @@ EXTERN PMap(handle_T) tabpage_handles INIT(= MAP_INIT);
|
||||
/// processed and that “other VimL code” must not be affected.
|
||||
typedef struct {
|
||||
except_T *current_exception;
|
||||
struct msglist *private_msg_list;
|
||||
const struct msglist *const *msg_list;
|
||||
msglist_T *private_msg_list;
|
||||
const msglist_T *const *msg_list;
|
||||
int trylevel;
|
||||
int got_int;
|
||||
int need_rethrow;
|
||||
@@ -144,8 +144,8 @@ typedef struct {
|
||||
// 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; \
|
||||
msglist_T **saved_msg_list = msg_list; \
|
||||
msglist_T *private_msg_list; \
|
||||
msg_list = &private_msg_list; \
|
||||
private_msg_list = NULL; \
|
||||
code \
|
||||
|
@@ -30,6 +30,7 @@
|
||||
#include "nvim/ex_cmds2.h"
|
||||
#include "nvim/ex_cmds_defs.h"
|
||||
#include "nvim/ex_docmd.h"
|
||||
#include "nvim/ex_eval.h"
|
||||
#include "nvim/file_search.h"
|
||||
#include "nvim/fileio.h"
|
||||
#include "nvim/getchar.h"
|
||||
|
@@ -16,6 +16,7 @@
|
||||
#include "nvim/eval/userfunc.h"
|
||||
#include "nvim/eval/vars.h"
|
||||
#include "nvim/ex_docmd.h"
|
||||
#include "nvim/ex_eval.h"
|
||||
#include "nvim/ex_getln.h"
|
||||
#include "nvim/fileio.h"
|
||||
#include "nvim/getchar.h"
|
||||
|
@@ -30,6 +30,7 @@
|
||||
#include "nvim/eval/userfunc.h"
|
||||
#include "nvim/eval/vars.h"
|
||||
#include "nvim/ex_cmds2.h"
|
||||
#include "nvim/ex_eval.h"
|
||||
#include "nvim/ex_getln.h"
|
||||
#include "nvim/ex_session.h"
|
||||
#include "nvim/fileio.h"
|
||||
|
@@ -28,6 +28,7 @@
|
||||
#include "nvim/eval/userfunc.h"
|
||||
#include "nvim/eval/vars.h"
|
||||
#include "nvim/ex_docmd.h"
|
||||
#include "nvim/ex_eval.h"
|
||||
#include "nvim/ex_getln.h"
|
||||
#include "nvim/file_search.h"
|
||||
#include "nvim/fileio.h"
|
||||
|
@@ -14,6 +14,7 @@
|
||||
#include "nvim/eval/vars.h"
|
||||
#include "nvim/ex_cmds2.h"
|
||||
#include "nvim/ex_docmd.h"
|
||||
#include "nvim/ex_eval.h"
|
||||
#include "nvim/ex_getln.h"
|
||||
#include "nvim/fileio.h"
|
||||
#include "nvim/getchar.h"
|
||||
|
@@ -15,6 +15,7 @@
|
||||
#include "nvim/eval/vars.h"
|
||||
#include "nvim/ex_cmds.h"
|
||||
#include "nvim/ex_docmd.h"
|
||||
#include "nvim/ex_eval.h"
|
||||
#include "nvim/ops.h"
|
||||
#include "nvim/option.h"
|
||||
#include "nvim/search.h"
|
||||
|
@@ -321,8 +321,8 @@ int do_cmdline(char *cmdline, LineGetter fgetline, void *cookie, int flags)
|
||||
int *dbg_tick = NULL; // ptr to dbg_tick field in cookie
|
||||
struct dbg_stuff debug_saved; // saved things for debug mode
|
||||
int initial_trylevel;
|
||||
struct msglist **saved_msg_list = NULL;
|
||||
struct msglist *private_msg_list;
|
||||
msglist_T **saved_msg_list = NULL;
|
||||
msglist_T *private_msg_list;
|
||||
|
||||
// "fgetline" and "cookie" passed to do_one_cmd()
|
||||
char *(*cmd_getline)(int, void *, int, bool);
|
||||
@@ -802,8 +802,8 @@ int do_cmdline(char *cmdline, LineGetter fgetline, void *cookie, int flags)
|
||||
char *p = NULL;
|
||||
char *saved_sourcing_name;
|
||||
linenr_T saved_sourcing_lnum;
|
||||
struct msglist *messages = NULL;
|
||||
struct msglist *next;
|
||||
msglist_T *messages = NULL;
|
||||
msglist_T *next;
|
||||
|
||||
/*
|
||||
* If the uncaught exception is a user exception, report it as an
|
||||
|
@@ -151,8 +151,8 @@ int aborted_in_try(void)
|
||||
bool cause_errthrow(const char *mesg, bool severe, bool *ignore)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
struct msglist *elem;
|
||||
struct msglist **plist;
|
||||
msglist_T *elem;
|
||||
msglist_T **plist;
|
||||
|
||||
/*
|
||||
* Do nothing when displaying the interrupt message or reporting an
|
||||
@@ -254,7 +254,7 @@ bool cause_errthrow(const char *mesg, bool severe, bool *ignore)
|
||||
plist = &(*plist)->next;
|
||||
}
|
||||
|
||||
elem = xmalloc(sizeof(struct msglist));
|
||||
elem = xmalloc(sizeof(msglist_T));
|
||||
elem->msg = xstrdup(mesg);
|
||||
elem->next = NULL;
|
||||
elem->throw_msg = NULL;
|
||||
@@ -281,9 +281,9 @@ bool cause_errthrow(const char *mesg, bool severe, bool *ignore)
|
||||
}
|
||||
|
||||
/// Free a "msg_list" and the messages it contains.
|
||||
static void free_msglist(struct msglist *l)
|
||||
static void free_msglist(msglist_T *l)
|
||||
{
|
||||
struct msglist *messages, *next;
|
||||
msglist_T *messages, *next;
|
||||
|
||||
messages = l;
|
||||
while (messages != NULL) {
|
||||
@@ -389,7 +389,7 @@ char *get_exception_string(void *value, except_type_T type, char *cmdname, int *
|
||||
|
||||
if (type == ET_ERROR) {
|
||||
*should_free = true;
|
||||
mesg = ((struct msglist *)value)->throw_msg;
|
||||
mesg = ((msglist_T *)value)->throw_msg;
|
||||
if (cmdname != NULL && *cmdname != NUL) {
|
||||
size_t cmdlen = STRLEN(cmdname);
|
||||
ret = xstrnsave("Vim(", 4 + cmdlen + 2 + STRLEN(mesg));
|
||||
@@ -469,7 +469,7 @@ static int throw_exception(void *value, except_type_T type, char *cmdname)
|
||||
if (type == ET_ERROR) {
|
||||
// Store the original message and prefix the exception value with
|
||||
// "Vim:" or, if a command name is given, "Vim(cmdname):".
|
||||
excp->messages = (struct msglist *)value;
|
||||
excp->messages = (msglist_T *)value;
|
||||
}
|
||||
|
||||
excp->value = get_exception_string(value, type, cmdname, &should_free);
|
||||
|
@@ -2,81 +2,7 @@
|
||||
#define NVIM_EX_EVAL_H
|
||||
|
||||
#include "nvim/ex_cmds_defs.h" // for exarg_T
|
||||
#include "nvim/pos.h" // for linenr_T
|
||||
|
||||
/* There is no CSF_IF, the lack of CSF_WHILE, CSF_FOR and CSF_TRY means ":if"
|
||||
* was used. */
|
||||
#define CSF_TRUE 0x0001 // condition was TRUE
|
||||
#define CSF_ACTIVE 0x0002 // current state is active
|
||||
#define CSF_ELSE 0x0004 // ":else" has been passed
|
||||
#define CSF_WHILE 0x0008 // is a ":while"
|
||||
#define CSF_FOR 0x0010 // is a ":for"
|
||||
|
||||
#define CSF_TRY 0x0100 // is a ":try"
|
||||
#define CSF_FINALLY 0x0200 // ":finally" has been passed
|
||||
#define CSF_THROWN 0x0800 // exception thrown to this try conditional
|
||||
#define CSF_CAUGHT 0x1000 // exception caught by this try conditional
|
||||
#define CSF_FINISHED 0x2000 // CSF_CAUGHT was handled by finish_exception()
|
||||
#define CSF_SILENT 0x4000 // "emsg_silent" reset by ":try"
|
||||
// Note that CSF_ELSE is only used when CSF_TRY and CSF_WHILE are unset
|
||||
// (an ":if"), and CSF_SILENT is only used when CSF_TRY is set.
|
||||
|
||||
/*
|
||||
* What's pending for being reactivated at the ":endtry" of this try
|
||||
* conditional:
|
||||
*/
|
||||
#define CSTP_NONE 0 // nothing pending in ":finally" clause
|
||||
#define CSTP_ERROR 1 // an error is pending
|
||||
#define CSTP_INTERRUPT 2 // an interrupt is pending
|
||||
#define CSTP_THROW 4 // a throw is pending
|
||||
#define CSTP_BREAK 8 // ":break" is pending
|
||||
#define CSTP_CONTINUE 16 // ":continue" is pending
|
||||
#define CSTP_RETURN 24 // ":return" is pending
|
||||
#define CSTP_FINISH 32 // ":finish" is pending
|
||||
|
||||
/*
|
||||
* A list of error messages that can be converted to an exception. "throw_msg"
|
||||
* is only set in the first element of the list. Usually, it points to the
|
||||
* original message stored in that element, but sometimes it points to a later
|
||||
* message in the list. See cause_errthrow() below.
|
||||
*/
|
||||
struct msglist {
|
||||
char *msg; // original message
|
||||
char *throw_msg; // msg to throw: usually original one
|
||||
struct msglist *next; // next of several messages in a row
|
||||
};
|
||||
|
||||
// The exception types.
|
||||
typedef enum {
|
||||
ET_USER, // exception caused by ":throw" command
|
||||
ET_ERROR, // error exception
|
||||
ET_INTERRUPT, // interrupt exception triggered by Ctrl-C
|
||||
} except_type_T;
|
||||
|
||||
/*
|
||||
* Structure describing an exception.
|
||||
* (don't use "struct exception", it's used by the math library).
|
||||
*/
|
||||
typedef struct vim_exception except_T;
|
||||
struct vim_exception {
|
||||
except_type_T type; // exception type
|
||||
char *value; // exception value
|
||||
struct msglist *messages; // message(s) causing error exception
|
||||
char *throw_name; // name of the throw point
|
||||
linenr_T throw_lnum; // line number of the throw point
|
||||
except_T *caught; // next exception on the caught stack
|
||||
};
|
||||
|
||||
/*
|
||||
* Structure to save the error/interrupt/exception state between calls to
|
||||
* enter_cleanup() and leave_cleanup(). Must be allocated as an automatic
|
||||
* variable by the (common) caller of these functions.
|
||||
*/
|
||||
typedef struct cleanup_stuff cleanup_T;
|
||||
struct cleanup_stuff {
|
||||
int pending; // error/interrupt/exception state
|
||||
except_T *exception; // exception value
|
||||
};
|
||||
#include "nvim/ex_eval_defs.h"
|
||||
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
# include "ex_eval.h.generated.h"
|
||||
|
77
src/nvim/ex_eval_defs.h
Normal file
77
src/nvim/ex_eval_defs.h
Normal file
@@ -0,0 +1,77 @@
|
||||
#ifndef NVIM_EX_EVAL_DEFS_H
|
||||
#define NVIM_EX_EVAL_DEFS_H
|
||||
|
||||
#include "nvim/pos.h" // for linenr_T
|
||||
|
||||
/// There is no CSF_IF, the lack of CSF_WHILE, CSF_FOR and CSF_TRY means ":if"
|
||||
/// was used.
|
||||
enum {
|
||||
CSF_TRUE = 0x0001, ///< condition was TRUE
|
||||
CSF_ACTIVE = 0x0002, ///< current state is active
|
||||
CSF_ELSE = 0x0004, ///< ":else" has been passed
|
||||
CSF_WHILE = 0x0008, ///< is a ":while"
|
||||
CSF_FOR = 0x0010, ///< is a ":for"
|
||||
|
||||
CSF_TRY = 0x0100, ///< is a ":try"
|
||||
CSF_FINALLY = 0x0200, ///< ":finally" has been passed
|
||||
CSF_THROWN = 0x0800, ///< exception thrown to this try conditional
|
||||
CSF_CAUGHT = 0x1000, ///< exception caught by this try conditional
|
||||
CSF_FINISHED = 0x2000, ///< CSF_CAUGHT was handled by finish_exception()
|
||||
CSF_SILENT = 0x4000, ///< "emsg_silent" reset by ":try"
|
||||
};
|
||||
// Note that CSF_ELSE is only used when CSF_TRY and CSF_WHILE are unset
|
||||
// (an ":if"), and CSF_SILENT is only used when CSF_TRY is set.
|
||||
|
||||
/// What's pending for being reactivated at the ":endtry" of this try
|
||||
/// conditional:
|
||||
enum {
|
||||
CSTP_NONE = 0, ///< nothing pending in ":finally" clause
|
||||
CSTP_ERROR = 1, ///< an error is pending
|
||||
CSTP_INTERRUPT = 2, ///< an interrupt is pending
|
||||
CSTP_THROW = 4, ///< a throw is pending
|
||||
CSTP_BREAK = 8, ///< ":break" is pending
|
||||
CSTP_CONTINUE = 16, ///< ":continue" is pending
|
||||
CSTP_RETURN = 24, ///< ":return" is pending
|
||||
CSTP_FINISH = 32, ///< ":finish" is pending
|
||||
};
|
||||
|
||||
/// A list of error messages that can be converted to an exception. "throw_msg"
|
||||
/// is only set in the first element of the list. Usually, it points to the
|
||||
/// original message stored in that element, but sometimes it points to a later
|
||||
/// message in the list. See cause_errthrow() below.
|
||||
typedef struct msglist msglist_T;
|
||||
struct msglist {
|
||||
char *msg; ///< original message
|
||||
char *throw_msg; ///< msg to throw: usually original one
|
||||
msglist_T *next; ///< next of several messages in a row
|
||||
};
|
||||
|
||||
/// The exception types.
|
||||
typedef enum {
|
||||
ET_USER, ///< exception caused by ":throw" command
|
||||
ET_ERROR, ///< error exception
|
||||
ET_INTERRUPT, ///< interrupt exception triggered by Ctrl-C
|
||||
} except_type_T;
|
||||
|
||||
/// Structure describing an exception.
|
||||
/// (don't use "struct exception", it's used by the math library).
|
||||
typedef struct vim_exception except_T;
|
||||
struct vim_exception {
|
||||
except_type_T type; ///< exception type
|
||||
char *value; ///< exception value
|
||||
msglist_T *messages; ///< message(s) causing error exception
|
||||
char *throw_name; ///< name of the throw point
|
||||
linenr_T throw_lnum; ///< line number of the throw point
|
||||
except_T *caught; ///< next exception on the caught stack
|
||||
};
|
||||
|
||||
/// Structure to save the error/interrupt/exception state between calls to
|
||||
/// enter_cleanup() and leave_cleanup(). Must be allocated as an automatic
|
||||
/// variable by the (common) caller of these functions.
|
||||
typedef struct cleanup_stuff cleanup_T;
|
||||
struct cleanup_stuff {
|
||||
int pending; ///< error/interrupt/exception state
|
||||
except_T *exception; ///< exception value
|
||||
};
|
||||
|
||||
#endif // NVIM_EX_EVAL_DEFS_H
|
@@ -6,7 +6,7 @@
|
||||
|
||||
#include "nvim/ascii.h"
|
||||
#include "nvim/event/loop.h"
|
||||
#include "nvim/ex_eval.h"
|
||||
#include "nvim/ex_eval_defs.h"
|
||||
#include "nvim/iconv.h"
|
||||
#include "nvim/macros.h"
|
||||
#include "nvim/mbyte.h"
|
||||
@@ -296,7 +296,7 @@ EXTERN int force_abort INIT(= false);
|
||||
/// same as the "msg" field of that element, but can be identical to the "msg"
|
||||
/// field of a later list element, when the "emsg_severe" flag was set when the
|
||||
/// emsg() call was made.
|
||||
EXTERN struct msglist **msg_list INIT(= NULL);
|
||||
EXTERN msglist_T **msg_list INIT(= NULL);
|
||||
|
||||
/// When set, don't convert an error to an exception. Used when displaying the
|
||||
/// interrupt message or reporting an exception that is still uncaught at the
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#include "nvim/buffer.h"
|
||||
#include "nvim/charset.h"
|
||||
#include "nvim/event/stream.h"
|
||||
#include "nvim/ex_eval.h"
|
||||
#include "nvim/fileio.h"
|
||||
#include "nvim/if_cscope.h"
|
||||
#include "nvim/memory.h"
|
||||
|
@@ -17,6 +17,7 @@
|
||||
#include "nvim/eval.h"
|
||||
#include "nvim/eval/typval.h"
|
||||
#include "nvim/ex_docmd.h"
|
||||
#include "nvim/ex_eval.h"
|
||||
#include "nvim/ex_getln.h"
|
||||
#include "nvim/fileio.h"
|
||||
#include "nvim/getchar.h"
|
||||
|
@@ -20,6 +20,7 @@
|
||||
#include "nvim/event/loop.h"
|
||||
#include "nvim/event/time.h"
|
||||
#include "nvim/ex_cmds2.h"
|
||||
#include "nvim/ex_eval.h"
|
||||
#include "nvim/ex_getln.h"
|
||||
#include "nvim/extmark.h"
|
||||
#include "nvim/func_attr.h"
|
||||
|
@@ -14,6 +14,7 @@
|
||||
#include "nvim/eval/userfunc.h"
|
||||
#include "nvim/ex_cmds.h"
|
||||
#include "nvim/ex_cmds2.h"
|
||||
#include "nvim/ex_eval.h"
|
||||
#include "nvim/ex_getln.h"
|
||||
#include "nvim/lua/executor.h"
|
||||
#include "nvim/memline.h"
|
||||
|
Reference in New Issue
Block a user