From 295c90989d10bf221eff7babc1cf9484ec0f4560 Mon Sep 17 00:00:00 2001 From: relnod Date: Sat, 15 Jul 2017 14:27:59 +0200 Subject: [PATCH 1/6] refactor/single-include: terminal.h --- src/nvim/CMakeLists.txt | 1 - src/nvim/terminal.h | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index e2f1f16635..da8ec354d9 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -543,7 +543,6 @@ set(NO_SINGLE_CHECK_HEADERS os/pty_process_win.h regexp_defs.h syntax_defs.h - terminal.h undo.h undo_defs.h ) diff --git a/src/nvim/terminal.h b/src/nvim/terminal.h index 25e609fb68..f2b0e232c3 100644 --- a/src/nvim/terminal.h +++ b/src/nvim/terminal.h @@ -10,6 +10,8 @@ typedef void (*terminal_write_cb)(char *buffer, size_t size, void *data); typedef void (*terminal_resize_cb)(uint16_t width, uint16_t height, void *data); typedef void (*terminal_close_cb)(void *data); +#include "nvim/buffer_defs.h" + typedef struct { void *data; uint16_t width, height; From 69199958b7ed9ec87a83b2ac0fd37a0c3e41a506 Mon Sep 17 00:00:00 2001 From: relnod Date: Sat, 15 Jul 2017 16:44:06 +0200 Subject: [PATCH 2/6] refactor/single-include: regexp_defs.h --- src/nvim/CMakeLists.txt | 1 - src/nvim/regexp_defs.h | 46 +++++++++++++++++++++++------------------ 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index da8ec354d9..7bd121050e 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -541,7 +541,6 @@ endfunction() set(NO_SINGLE_CHECK_HEADERS os/win_defs.h os/pty_process_win.h - regexp_defs.h syntax_defs.h undo.h undo_defs.h diff --git a/src/nvim/regexp_defs.h b/src/nvim/regexp_defs.h index 6426ee441b..7492a86697 100644 --- a/src/nvim/regexp_defs.h +++ b/src/nvim/regexp_defs.h @@ -15,6 +15,8 @@ #include #include "nvim/pos.h" +#include "nvim/types.h" +#include "nvim/profile.h" /* * The number of sub-matches is limited to 10. @@ -41,18 +43,38 @@ #define NFA_ENGINE 2 typedef struct regengine regengine_T; +typedef struct regprog regprog_T; +typedef struct reg_extmatch reg_extmatch_T; + +/* + * Structure to be used for multi-line matching. + * Sub-match "no" starts in line "startpos[no].lnum" column "startpos[no].col" + * and ends in line "endpos[no].lnum" just before column "endpos[no].col". + * The line numbers are relative to the first line, thus startpos[0].lnum is + * always 0. + * When there is no match, the line number is -1. + */ +typedef struct { + regprog_T *regprog; + lpos_T startpos[NSUBEXP]; + lpos_T endpos[NSUBEXP]; + int rmm_ic; + colnr_T rmm_maxcol; /* when not zero: maximum column */ +} regmmatch_T; + +#include "nvim/buffer_defs.h" /* * Structure returned by vim_regcomp() to pass on to vim_regexec(). * This is the general structure. For the actual matcher, two specific * structures are used. See code below. */ -typedef struct regprog { +struct regprog { regengine_T *engine; unsigned regflags; unsigned re_engine; ///< Automatic, backtracking or NFA engine. unsigned re_flags; ///< Second argument for vim_regcomp(). -} regprog_T; +}; /* * Structure used by the back track matcher. @@ -125,31 +147,15 @@ typedef struct { bool rm_ic; } regmatch_T; -/* - * Structure to be used for multi-line matching. - * Sub-match "no" starts in line "startpos[no].lnum" column "startpos[no].col" - * and ends in line "endpos[no].lnum" just before column "endpos[no].col". - * The line numbers are relative to the first line, thus startpos[0].lnum is - * always 0. - * When there is no match, the line number is -1. - */ -typedef struct { - regprog_T *regprog; - lpos_T startpos[NSUBEXP]; - lpos_T endpos[NSUBEXP]; - int rmm_ic; - colnr_T rmm_maxcol; /* when not zero: maximum column */ -} regmmatch_T; - /* * Structure used to store external references: "\z\(\)" to "\z\1". * Use a reference count to avoid the need to copy this around. When it goes * from 1 to zero the matches need to be freed. */ -typedef struct { +struct reg_extmatch { short refcnt; char_u *matches[NSUBEXP]; -} reg_extmatch_T; +}; struct regengine { regprog_T *(*regcomp)(char_u*, int); From 4b0a086d165013ff5726b987b353d88a863491a9 Mon Sep 17 00:00:00 2001 From: relnod Date: Sat, 15 Jul 2017 16:47:12 +0200 Subject: [PATCH 3/6] refactor/single-include: syntax_defs.h --- src/nvim/CMakeLists.txt | 1 - src/nvim/syntax_defs.h | 8 +++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index 7bd121050e..2cc236101c 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -541,7 +541,6 @@ endfunction() set(NO_SINGLE_CHECK_HEADERS os/win_defs.h os/pty_process_win.h - syntax_defs.h undo.h undo_defs.h ) diff --git a/src/nvim/syntax_defs.h b/src/nvim/syntax_defs.h index 56fadbe7f6..7260853703 100644 --- a/src/nvim/syntax_defs.h +++ b/src/nvim/syntax_defs.h @@ -2,7 +2,6 @@ #define NVIM_SYNTAX_DEFS_H #include "nvim/highlight_defs.h" -#include "nvim/regexp_defs.h" # define SST_MIN_ENTRIES 150 /* minimal size for state stack array */ # define SST_MAX_ENTRIES 1000 /* maximal size for state stack array */ @@ -10,6 +9,11 @@ # define SST_DIST 16 /* normal distance between entries */ # define SST_INVALID (synstate_T *)-1 /* invalid syn_state pointer */ +typedef struct syn_state synstate_T; + +#include "nvim/buffer_defs.h" +#include "nvim/regexp_defs.h" + typedef unsigned short disptick_T; /* display tick type */ /* struct passed to in_id_list() */ @@ -48,8 +52,6 @@ typedef struct buf_state { * syn_state contains the syntax state stack for the start of one line. * Used by b_sst_array[]. */ -typedef struct syn_state synstate_T; - struct syn_state { synstate_T *sst_next; /* next entry in used or free list */ linenr_T sst_lnum; /* line number for this state */ From 14e63271cc216ef60036891f7f79d8509c8f52c1 Mon Sep 17 00:00:00 2001 From: relnod Date: Sat, 15 Jul 2017 16:50:22 +0200 Subject: [PATCH 4/6] refactor/single-include: undo_defs.h --- src/nvim/CMakeLists.txt | 1 - src/nvim/undo_defs.h | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index 2cc236101c..09d50f0f00 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -542,7 +542,6 @@ set(NO_SINGLE_CHECK_HEADERS os/win_defs.h os/pty_process_win.h undo.h - undo_defs.h ) foreach(hfile ${NVIM_HEADERS}) get_test_target(test-includes "${hfile}" relative_path texe) diff --git a/src/nvim/undo_defs.h b/src/nvim/undo_defs.h index d841210815..6c7e2bba41 100644 --- a/src/nvim/undo_defs.h +++ b/src/nvim/undo_defs.h @@ -4,9 +4,10 @@ #include // for time_t #include "nvim/pos.h" -#include "nvim/buffer_defs.h" #include "nvim/mark_defs.h" +typedef struct u_header u_header_T; + /* Structure to store info about the Visual area. */ typedef struct { pos_T vi_start; /* start pos of last VIsual */ @@ -15,8 +16,9 @@ typedef struct { colnr_T vi_curswant; /* MAXCOL from w_curswant */ } visualinfo_T; +#include "nvim/buffer_defs.h" + typedef struct u_entry u_entry_T; -typedef struct u_header u_header_T; struct u_entry { u_entry_T *ue_next; /* pointer to next entry in list */ linenr_T ue_top; /* number of line above undo block */ From 0f74b7afeb3a4b85302268e7cb04f0faefda397d Mon Sep 17 00:00:00 2001 From: relnod Date: Sat, 15 Jul 2017 16:52:32 +0200 Subject: [PATCH 5/6] refactor/single-include: undo.h --- src/nvim/CMakeLists.txt | 1 - src/nvim/undo.h | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index 09d50f0f00..eb3b60f0b5 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -541,7 +541,6 @@ endfunction() set(NO_SINGLE_CHECK_HEADERS os/win_defs.h os/pty_process_win.h - undo.h ) foreach(hfile ${NVIM_HEADERS}) get_test_target(test-includes "${hfile}" relative_path texe) diff --git a/src/nvim/undo.h b/src/nvim/undo.h index ab8584fbb2..802cdc5583 100644 --- a/src/nvim/undo.h +++ b/src/nvim/undo.h @@ -2,6 +2,7 @@ #define NVIM_UNDO_H #include "nvim/undo_defs.h" +#include "nvim/ex_cmds_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "undo.h.generated.h" From dde3ece10ed4ee62744009fa1fd347be740fc845 Mon Sep 17 00:00:00 2001 From: relnod Date: Sat, 15 Jul 2017 17:52:06 +0200 Subject: [PATCH 6/6] lint --- src/nvim/regexp_defs.h | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/nvim/regexp_defs.h b/src/nvim/regexp_defs.h index 7492a86697..b5d56e07fc 100644 --- a/src/nvim/regexp_defs.h +++ b/src/nvim/regexp_defs.h @@ -46,20 +46,18 @@ typedef struct regengine regengine_T; typedef struct regprog regprog_T; typedef struct reg_extmatch reg_extmatch_T; -/* - * Structure to be used for multi-line matching. - * Sub-match "no" starts in line "startpos[no].lnum" column "startpos[no].col" - * and ends in line "endpos[no].lnum" just before column "endpos[no].col". - * The line numbers are relative to the first line, thus startpos[0].lnum is - * always 0. - * When there is no match, the line number is -1. - */ +/// Structure to be used for multi-line matching. +/// Sub-match "no" starts in line "startpos[no].lnum" column "startpos[no].col" +/// and ends in line "endpos[no].lnum" just before column "endpos[no].col". +/// The line numbers are relative to the first line, thus startpos[0].lnum is +/// always 0. +/// When there is no match, the line number is -1. typedef struct { regprog_T *regprog; lpos_T startpos[NSUBEXP]; lpos_T endpos[NSUBEXP]; int rmm_ic; - colnr_T rmm_maxcol; /* when not zero: maximum column */ + colnr_T rmm_maxcol; /// when not zero: maximum column } regmmatch_T; #include "nvim/buffer_defs.h" @@ -153,7 +151,7 @@ typedef struct { * from 1 to zero the matches need to be freed. */ struct reg_extmatch { - short refcnt; + int16_t refcnt; char_u *matches[NSUBEXP]; };