diff options
author | Felipe Oliveira Carvalho <felipekde@gmail.com> | 2014-03-13 02:40:51 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-03-18 20:19:19 -0300 |
commit | 59f2430a8d543fc57a31d489a649ec87a6ca9715 (patch) | |
tree | 69d4e89c8f37efc3b5e20ab05e70a9eb4e4c1c05 /src/ex_eval.h | |
parent | 1fcd332e8e3d2c6c22fa548cc96b1d9dde2f5651 (diff) | |
download | rneovim-59f2430a8d543fc57a31d489a649ec87a6ca9715.tar.gz rneovim-59f2430a8d543fc57a31d489a649ec87a6ca9715.tar.bz2 rneovim-59f2430a8d543fc57a31d489a649ec87a6ca9715.zip |
Delete structs.h by spliting it and moving code to other headers
Here's the list of squashed commits (for more info, see PR #378).
- Define guicolor_T as a typedef in syntax.h
- Move a big chunk of code from structs.h to buffer_defs.h
- Move aco_save_T from structs.h to fileio.h
- Move option_table_T from structs.h to hardcopy.h
Aditionally:
- Move the printer_opts global to hardcopy.c
- Delete structs.h. Include buffer_defs.h where structs.h was included
before.
- Add header guards to option_defs.h
- Put mark types and constants in new mark_defs.h
- Move undo structs to undo_defs.h
- Move memfile structs to new memfile_defs.h
- Move expand_T and cmdmod_T to ex_cmds_defs.h
- Move memline_T to memline_defs.h
- Move many defs and types to ex_eval.h
- Move syntax related types to syntax_defs.h
- Move struct memfile to memfile_defs.h
- struct buffblock and struct buffheader moved back to buffer_defs.h
- Move some datatypes to hashtab.h and eval_defs.h
- Move the buffer_defs.h include and TODOs for remaining unrelated types in buffer_defs.h
Diffstat (limited to 'src/ex_eval.h')
-rw-r--r-- | src/ex_eval.h | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/src/ex_eval.h b/src/ex_eval.h index d16465f644..8690247489 100644 --- a/src/ex_eval.h +++ b/src/ex_eval.h @@ -1,5 +1,123 @@ #ifndef NEOVIM_EX_EVAL_H #define NEOVIM_EX_EVAL_H + +/* + * A list used for saving values of "emsg_silent". Used by ex_try() to save the + * value of "emsg_silent" if it was non-zero. When this is done, the CSF_SILENT + * flag below is set. + */ + +typedef struct eslist_elem eslist_T; +struct eslist_elem { + int saved_emsg_silent; /* saved value of "emsg_silent" */ + eslist_T *next; /* next element on the list */ +}; + +/* + * For conditional commands a stack is kept of nested conditionals. + * When cs_idx < 0, there is no conditional command. + */ +#define CSTACK_LEN 50 + +struct condstack { + short cs_flags[CSTACK_LEN]; /* CSF_ flags */ + char cs_pending[CSTACK_LEN]; /* CSTP_: what's pending in ":finally"*/ + union { + void *csp_rv[CSTACK_LEN]; /* return typeval for pending return */ + void *csp_ex[CSTACK_LEN]; /* exception for pending throw */ + } cs_pend; + void *cs_forinfo[CSTACK_LEN]; /* info used by ":for" */ + int cs_line[CSTACK_LEN]; /* line nr of ":while"/":for" line */ + int cs_idx; /* current entry, or -1 if none */ + int cs_looplevel; /* nr of nested ":while"s and ":for"s */ + int cs_trylevel; /* nr of nested ":try"s */ + eslist_T *cs_emsg_silent_list; /* saved values of "emsg_silent" */ + char cs_lflags; /* loop flags: CSL_ flags */ +}; +# define cs_rettv cs_pend.csp_rv +# define cs_exception cs_pend.csp_ex + +/* 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 0x0400 /* exception thrown to this try conditional */ +# define CSF_CAUGHT 0x0800 /* exception caught by this try conditional */ +# define CSF_SILENT 0x1000 /* "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 */ + +/* + * Flags for the cs_lflags item in struct condstack. + */ +# define CSL_HAD_LOOP 1 /* just found ":while" or ":for" */ +# define CSL_HAD_ENDLOOP 2 /* just found ":endwhile" or ":endfor" */ +# define CSL_HAD_CONT 4 /* just found ":continue" */ +# define CSL_HAD_FINA 8 /* just found ":finally" */ + +/* + * 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_u *msg; /* original message */ + char_u *throw_msg; /* msg to throw: usually original one */ + struct msglist *next; /* next of several messages in a row */ +}; + +/* + * 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 { + int type; /* exception type */ + char_u *value; /* exception value */ + struct msglist *messages; /* message(s) causing error exception */ + char_u *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 */ +}; + +/* + * The exception types. + */ +#define ET_USER 0 /* exception caused by ":throw" command */ +#define ET_ERROR 1 /* error exception */ +#define ET_INTERRUPT 2 /* interrupt exception triggered by Ctrl-C */ + +/* + * 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 */ +}; + /* ex_eval.c */ int aborting(void); void update_force_abort(void); |