aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-08-12 19:16:24 +0800
committerGitHub <noreply@github.com>2022-08-12 19:16:24 +0800
commitf79773a3b4b3ce5a3b37652a72b12089880f32a4 (patch)
treef86eb1b3bf90d13844a7b2c43065e380ffd1bb13
parent1cf3a4b4095913ff9a241c07294af74e573eed54 (diff)
downloadrneovim-f79773a3b4b3ce5a3b37652a72b12089880f32a4.tar.gz
rneovim-f79773a3b4b3ce5a3b37652a72b12089880f32a4.tar.bz2
rneovim-f79773a3b4b3ce5a3b37652a72b12089880f32a4.zip
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.
-rw-r--r--src/nvim/api/command.c1
-rw-r--r--src/nvim/api/private/helpers.c5
-rw-r--r--src/nvim/api/private/helpers.h10
-rw-r--r--src/nvim/api/vim.c1
-rw-r--r--src/nvim/autocmd.c1
-rw-r--r--src/nvim/eval.c1
-rw-r--r--src/nvim/eval/funcs.c1
-rw-r--r--src/nvim/eval/userfunc.c1
-rw-r--r--src/nvim/eval/vars.c1
-rw-r--r--src/nvim/ex_docmd.c8
-rw-r--r--src/nvim/ex_eval.c14
-rw-r--r--src/nvim/ex_eval.h76
-rw-r--r--src/nvim/ex_eval_defs.h77
-rw-r--r--src/nvim/globals.h4
-rw-r--r--src/nvim/if_cscope.c1
-rw-r--r--src/nvim/insexpand.c1
-rw-r--r--src/nvim/lua/stdlib.c1
-rw-r--r--src/nvim/runtime.c1
18 files changed, 110 insertions, 95 deletions
diff --git a/src/nvim/api/command.c b/src/nvim/api/command.c
index d264237e37..e77add6210 100644
--- a/src/nvim/api/command.c
+++ b/src/nvim/api/command.c
@@ -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"
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c
index fad75d55be..315df72a53 100644
--- a/src/nvim/api/private/helpers.c
+++ b/src/nvim/api/private/helpers.c
@@ -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;
diff --git a/src/nvim/api/private/helpers.h b/src/nvim/api/private/helpers.h
index 1441da853c..4608554448 100644
--- a/src/nvim/api/private/helpers.h
+++ b/src/nvim/api/private/helpers.h
@@ -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 \
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index e2f58dba62..2842f3a43b 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -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"
diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c
index 1186eea62c..4ffd7a4850 100644
--- a/src/nvim/autocmd.c
+++ b/src/nvim/autocmd.c
@@ -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"
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 42a3c7df80..c08b3e41d4 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -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"
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index 5c21825897..bb3418a392 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -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"
diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c
index 72a8c45326..6c437c1ff4 100644
--- a/src/nvim/eval/userfunc.c
+++ b/src/nvim/eval/userfunc.c
@@ -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"
diff --git a/src/nvim/eval/vars.c b/src/nvim/eval/vars.c
index cf2755f639..ffaf636208 100644
--- a/src/nvim/eval/vars.c
+++ b/src/nvim/eval/vars.c
@@ -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"
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index e482c9e9cf..f4a0f462e2 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -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
diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c
index f67c8a6720..4e50a51a8a 100644
--- a/src/nvim/ex_eval.c
+++ b/src/nvim/ex_eval.c
@@ -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);
diff --git a/src/nvim/ex_eval.h b/src/nvim/ex_eval.h
index 235875fb91..9e3ac5e9c1 100644
--- a/src/nvim/ex_eval.h
+++ b/src/nvim/ex_eval.h
@@ -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"
diff --git a/src/nvim/ex_eval_defs.h b/src/nvim/ex_eval_defs.h
new file mode 100644
index 0000000000..75150d6da4
--- /dev/null
+++ b/src/nvim/ex_eval_defs.h
@@ -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
diff --git a/src/nvim/globals.h b/src/nvim/globals.h
index 317423ffa0..199dd7e8e2 100644
--- a/src/nvim/globals.h
+++ b/src/nvim/globals.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
diff --git a/src/nvim/if_cscope.c b/src/nvim/if_cscope.c
index 8d08c2fc19..e8bf528f4e 100644
--- a/src/nvim/if_cscope.c
+++ b/src/nvim/if_cscope.c
@@ -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"
diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c
index bddeee119d..581ba853a2 100644
--- a/src/nvim/insexpand.c
+++ b/src/nvim/insexpand.c
@@ -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"
diff --git a/src/nvim/lua/stdlib.c b/src/nvim/lua/stdlib.c
index 6ba0056f48..f9592919ea 100644
--- a/src/nvim/lua/stdlib.c
+++ b/src/nvim/lua/stdlib.c
@@ -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"
diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c
index fc88babfc9..394fe351c6 100644
--- a/src/nvim/runtime.c
+++ b/src/nvim/runtime.c
@@ -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"