mirror of
https://github.com/neovim/neovim.git
synced 2025-09-12 06:18:16 +00:00
Merge pull request #941 from aktau/improve-luajit-ffi-preproc
refactor includes + improve testing infrastructure
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
#ifndef NVIM_BUFFER_H
|
#ifndef NVIM_BUFFER_H
|
||||||
#define NVIM_BUFFER_H
|
#define NVIM_BUFFER_H
|
||||||
|
|
||||||
|
#include "nvim/pos.h" // for linenr_T
|
||||||
|
#include "nvim/ex_cmds_defs.h" // for exarg_T
|
||||||
|
|
||||||
/* Values for buflist_getfile() */
|
/* Values for buflist_getfile() */
|
||||||
#define GETF_SETMARK 0x01 /* set pcmark before jumping */
|
#define GETF_SETMARK 0x01 /* set pcmark before jumping */
|
||||||
#define GETF_ALT 0x02 /* jumping to alternate file (not buf num) */
|
#define GETF_ALT 0x02 /* jumping to alternate file (not buf num) */
|
||||||
|
@@ -2,10 +2,12 @@
|
|||||||
#define NVIM_BUFFER_DEFS_H
|
#define NVIM_BUFFER_DEFS_H
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
// for FILE
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
// for garray_T
|
// for garray_T
|
||||||
#include "nvim/garray.h"
|
#include "nvim/garray.h"
|
||||||
// for pos_T and lpos_T
|
// for pos_T, lpos_T and linenr_T
|
||||||
#include "nvim/pos.h"
|
#include "nvim/pos.h"
|
||||||
// for the number window-local and buffer-local options
|
// for the number window-local and buffer-local options
|
||||||
#include "nvim/option_defs.h"
|
#include "nvim/option_defs.h"
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include "nvim/pos.h" // for linenr_T
|
||||||
#include "nvim/normal.h"
|
#include "nvim/normal.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -1,6 +1,9 @@
|
|||||||
#ifndef NVIM_EX_EVAL_H
|
#ifndef NVIM_EX_EVAL_H
|
||||||
#define NVIM_EX_EVAL_H
|
#define NVIM_EX_EVAL_H
|
||||||
|
|
||||||
|
#include "nvim/pos.h" // for linenr_T
|
||||||
|
#include "nvim/ex_cmds_defs.h" // for exarg_T
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A list used for saving values of "emsg_silent". Used by ex_try() to save the
|
* 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
|
* value of "emsg_silent" if it was non-zero. When this is done, the CSF_SILENT
|
||||||
|
@@ -51,6 +51,7 @@
|
|||||||
#include "nvim/strings.h"
|
#include "nvim/strings.h"
|
||||||
#include "nvim/tempfile.h"
|
#include "nvim/tempfile.h"
|
||||||
#include "nvim/term.h"
|
#include "nvim/term.h"
|
||||||
|
#include "nvim/types.h"
|
||||||
#include "nvim/ui.h"
|
#include "nvim/ui.h"
|
||||||
#include "nvim/undo.h"
|
#include "nvim/undo.h"
|
||||||
#include "nvim/window.h"
|
#include "nvim/window.h"
|
||||||
|
@@ -13,6 +13,7 @@
|
|||||||
#include "nvim/ex_eval.h"
|
#include "nvim/ex_eval.h"
|
||||||
#include "nvim/mbyte.h"
|
#include "nvim/mbyte.h"
|
||||||
#include "nvim/menu.h"
|
#include "nvim/menu.h"
|
||||||
|
#include "nvim/syntax_defs.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* definition of global variables
|
* definition of global variables
|
||||||
|
@@ -1,7 +1,9 @@
|
|||||||
#ifndef NVIM_HASHTAB_H
|
#ifndef NVIM_HASHTAB_H
|
||||||
#define NVIM_HASHTAB_H
|
#define NVIM_HASHTAB_H
|
||||||
|
|
||||||
#include "nvim/vim.h"
|
#include <stddef.h>
|
||||||
|
|
||||||
|
#include "nvim/types.h"
|
||||||
|
|
||||||
/// Type for hash number (hash calculation result).
|
/// Type for hash number (hash calculation result).
|
||||||
typedef size_t hash_T;
|
typedef size_t hash_T;
|
||||||
|
@@ -128,6 +128,7 @@ int main() {
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "nvim/memory.h"
|
#include "nvim/memory.h"
|
||||||
|
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
#ifndef NVIM_MEMFILE_DEFS_H
|
#ifndef NVIM_MEMFILE_DEFS_H
|
||||||
#define NVIM_MEMFILE_DEFS_H
|
#define NVIM_MEMFILE_DEFS_H
|
||||||
|
|
||||||
|
#include "nvim/types.h"
|
||||||
|
|
||||||
typedef struct block_hdr bhdr_T;
|
typedef struct block_hdr bhdr_T;
|
||||||
typedef long blocknr_T;
|
typedef long blocknr_T;
|
||||||
|
|
||||||
|
@@ -1,8 +1,7 @@
|
|||||||
#ifndef NVIM_MEMORY_H
|
#ifndef NVIM_MEMORY_H
|
||||||
#define NVIM_MEMORY_H
|
#define NVIM_MEMORY_H
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h> // for size_t
|
||||||
#include "nvim/vim.h"
|
|
||||||
|
|
||||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||||
# include "memory.h.generated.h"
|
# include "memory.h.generated.h"
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
#define NVIM_MESSAGE_H
|
#define NVIM_MESSAGE_H
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include "nvim/eval_defs.h" // for typval_T
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Types of dialogs passed to do_dialog().
|
* Types of dialogs passed to do_dialog().
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
#define NVIM_NORMAL_H
|
#define NVIM_NORMAL_H
|
||||||
|
|
||||||
#include "nvim/pos.h"
|
#include "nvim/pos.h"
|
||||||
|
#include "nvim/buffer_defs.h" // for win_T
|
||||||
|
|
||||||
/* Values for find_ident_under_cursor() */
|
/* Values for find_ident_under_cursor() */
|
||||||
#define FIND_IDENT 1 /* find identifier (word) */
|
#define FIND_IDENT 1 /* find identifier (word) */
|
||||||
|
@@ -54,6 +54,7 @@
|
|||||||
#include "nvim/syntax.h"
|
#include "nvim/syntax.h"
|
||||||
#include "nvim/tempfile.h"
|
#include "nvim/tempfile.h"
|
||||||
#include "nvim/term.h"
|
#include "nvim/term.h"
|
||||||
|
#include "nvim/types.h"
|
||||||
#include "nvim/ui.h"
|
#include "nvim/ui.h"
|
||||||
#include "nvim/os/os.h"
|
#include "nvim/os/os.h"
|
||||||
#include "nvim/os/time.h"
|
#include "nvim/os/time.h"
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
#ifndef NVIM_OS_UNIX_H
|
#ifndef NVIM_OS_UNIX_H
|
||||||
#define NVIM_OS_UNIX_H
|
#define NVIM_OS_UNIX_H
|
||||||
|
|
||||||
|
#include "nvim/types.h" // for vim_acl_T
|
||||||
#include "nvim/os/shell.h"
|
#include "nvim/os/shell.h"
|
||||||
|
|
||||||
/* Values returned by mch_nodetype() */
|
/* Values returned by mch_nodetype() */
|
||||||
|
@@ -1,6 +1,12 @@
|
|||||||
#ifndef NVIM_POS_H
|
#ifndef NVIM_POS_H
|
||||||
#define NVIM_POS_H
|
#define NVIM_POS_H
|
||||||
|
|
||||||
|
typedef long linenr_T; // line number type
|
||||||
|
typedef int colnr_T; // column number type
|
||||||
|
|
||||||
|
#define MAXLNUM (0x7fffffffL) // maximum (invalid) line number
|
||||||
|
#define MAXCOL (0x7fffffffL) // maximum column number, 31 bits
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* position in file or buffer
|
* position in file or buffer
|
||||||
*/
|
*/
|
||||||
|
@@ -42,6 +42,7 @@
|
|||||||
#include "nvim/regexp.h"
|
#include "nvim/regexp.h"
|
||||||
#include "nvim/screen.h"
|
#include "nvim/screen.h"
|
||||||
#include "nvim/strings.h"
|
#include "nvim/strings.h"
|
||||||
|
#include "nvim/syntax_defs.h"
|
||||||
#include "nvim/term.h"
|
#include "nvim/term.h"
|
||||||
#include "nvim/ui.h"
|
#include "nvim/ui.h"
|
||||||
#include "nvim/os/os.h"
|
#include "nvim/os/os.h"
|
||||||
|
@@ -9,6 +9,8 @@
|
|||||||
# define SST_DIST 16 /* normal distance between entries */
|
# define SST_DIST 16 /* normal distance between entries */
|
||||||
# define SST_INVALID (synstate_T *)-1 /* invalid syn_state pointer */
|
# define SST_INVALID (synstate_T *)-1 /* invalid syn_state pointer */
|
||||||
|
|
||||||
|
typedef unsigned short disptick_T; /* display tick type */
|
||||||
|
|
||||||
/* struct passed to in_id_list() */
|
/* struct passed to in_id_list() */
|
||||||
struct sp_syn {
|
struct sp_syn {
|
||||||
int inc_tag; /* ":syn include" unique tag */
|
int inc_tag; /* ":syn include" unique tag */
|
||||||
|
@@ -10,6 +10,14 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
// dummy to pass an ACL to a function
|
||||||
|
typedef void *vim_acl_T;
|
||||||
|
|
||||||
|
// Make sure long_u is big enough to hold a pointer.
|
||||||
|
// On Win64, longs are 32 bits and pointers are 64 bits.
|
||||||
|
// For printf() and scanf(), we need to take care of long_u specifically.
|
||||||
|
typedef unsigned long long_u;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Shorthand for unsigned variables. Many systems, but not all, have u_char
|
* Shorthand for unsigned variables. Many systems, but not all, have u_char
|
||||||
* already defined, so we use char_u to avoid trouble.
|
* already defined, so we use char_u to avoid trouble.
|
||||||
|
@@ -107,6 +107,7 @@
|
|||||||
#include "nvim/screen.h"
|
#include "nvim/screen.h"
|
||||||
#include "nvim/sha256.h"
|
#include "nvim/sha256.h"
|
||||||
#include "nvim/strings.h"
|
#include "nvim/strings.h"
|
||||||
|
#include "nvim/types.h"
|
||||||
#include "nvim/os/os.h"
|
#include "nvim/os/os.h"
|
||||||
#include "nvim/os/time.h"
|
#include "nvim/os/time.h"
|
||||||
|
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
#ifndef NVIM_UNDO_DEFS_H
|
#ifndef NVIM_UNDO_DEFS_H
|
||||||
#define NVIM_UNDO_DEFS_H
|
#define NVIM_UNDO_DEFS_H
|
||||||
|
|
||||||
|
#include <time.h> // for time_t
|
||||||
|
|
||||||
#include "nvim/pos.h"
|
#include "nvim/pos.h"
|
||||||
|
|
||||||
/* Structure to store info about the Visual area. */
|
/* Structure to store info about the Visual area. */
|
||||||
|
@@ -9,6 +9,7 @@
|
|||||||
# define NVIM_VIM_H
|
# define NVIM_VIM_H
|
||||||
|
|
||||||
#include "nvim/types.h"
|
#include "nvim/types.h"
|
||||||
|
#include "nvim/pos.h" // for linenr_T, MAXCOL, etc...
|
||||||
|
|
||||||
/* Some defines from the old feature.h */
|
/* Some defines from the old feature.h */
|
||||||
#define SESSION_FILE "Session.vim"
|
#define SESSION_FILE "Session.vim"
|
||||||
@@ -58,11 +59,6 @@ Error: configure did not run properly.Check auto/config.log.
|
|||||||
|
|
||||||
#define NUMBUFLEN 30 /* length of a buffer to store a number in ASCII */
|
#define NUMBUFLEN 30 /* length of a buffer to store a number in ASCII */
|
||||||
|
|
||||||
// Make sure long_u is big enough to hold a pointer.
|
|
||||||
// On Win64, longs are 32 bits and pointers are 64 bits.
|
|
||||||
// For printf() and scanf(), we need to take care of long_u specifically.
|
|
||||||
typedef unsigned long long_u;
|
|
||||||
|
|
||||||
# define MAX_TYPENR 65535
|
# define MAX_TYPENR 65535
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -359,18 +355,9 @@ enum {
|
|||||||
#define PERROR(msg) \
|
#define PERROR(msg) \
|
||||||
(void) emsg3((char_u *) "%s: %s", (char_u *)msg, (char_u *)strerror(errno))
|
(void) emsg3((char_u *) "%s: %s", (char_u *)msg, (char_u *)strerror(errno))
|
||||||
|
|
||||||
typedef long linenr_T; /* line number type */
|
|
||||||
typedef int colnr_T; /* column number type */
|
|
||||||
typedef unsigned short disptick_T; /* display tick type */
|
|
||||||
|
|
||||||
#define MAXLNUM (0x7fffffffL) /* maximum (invalid) line number */
|
|
||||||
#define MAXCOL (0x7fffffffL) /* maximum column number, 31 bits */
|
|
||||||
|
|
||||||
#define SHOWCMD_COLS 10 /* columns needed by shown command */
|
#define SHOWCMD_COLS 10 /* columns needed by shown command */
|
||||||
#define STL_MAX_ITEM 80 /* max nr of %<flag> in statusline */
|
#define STL_MAX_ITEM 80 /* max nr of %<flag> in statusline */
|
||||||
|
|
||||||
typedef void *vim_acl_T; /* dummy to pass an ACL to a function */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* fnamecmp() is used to compare file names.
|
* fnamecmp() is used to compare file names.
|
||||||
* On some systems case in a file name does not matter, on others it does.
|
* On some systems case in a file name does not matter, on others it does.
|
||||||
|
@@ -97,6 +97,17 @@ cstr = ffi.typeof 'char[?]'
|
|||||||
to_cstr = (string) ->
|
to_cstr = (string) ->
|
||||||
cstr (string.len string) + 1, string
|
cstr (string.len string) + 1, string
|
||||||
|
|
||||||
|
export vim_init_called
|
||||||
|
-- initialize some global variables, this is still necessary to unit test
|
||||||
|
-- functions that rely on global state.
|
||||||
|
vim_init = ->
|
||||||
|
if vim_init_called ~= nil
|
||||||
|
return
|
||||||
|
-- import os_unix.h for mch_early_init(), which initializes some globals
|
||||||
|
os = cimport './src/nvim/os_unix.h'
|
||||||
|
os.mch_early_init!
|
||||||
|
vim_init_called = true
|
||||||
|
|
||||||
return {
|
return {
|
||||||
cimport: cimport
|
cimport: cimport
|
||||||
cppimport: cppimport
|
cppimport: cppimport
|
||||||
@@ -107,4 +118,5 @@ return {
|
|||||||
lib: libnvim
|
lib: libnvim
|
||||||
cstr: cstr
|
cstr: cstr
|
||||||
to_cstr: to_cstr
|
to_cstr: to_cstr
|
||||||
|
vim_init: vim_init
|
||||||
}
|
}
|
||||||
|
@@ -57,37 +57,6 @@ describe 'fs function', ->
|
|||||||
buf = cstr (len-1), ''
|
buf = cstr (len-1), ''
|
||||||
eq FAIL, (os_dirname buf, (len-1))
|
eq FAIL, (os_dirname buf, (len-1))
|
||||||
|
|
||||||
describe 'path_full_dir_name', ->
|
|
||||||
path_full_dir_name = (directory, buffer, len) ->
|
|
||||||
directory = to_cstr directory
|
|
||||||
fs.path_full_dir_name directory, buffer, len
|
|
||||||
|
|
||||||
before_each ->
|
|
||||||
-- Create empty string buffer which will contain the resulting path.
|
|
||||||
export len = (string.len lfs.currentdir!) + 22
|
|
||||||
export buffer = cstr len, ''
|
|
||||||
|
|
||||||
it 'returns the absolute directory name of a given relative one', ->
|
|
||||||
result = path_full_dir_name '..', buffer, len
|
|
||||||
eq OK, result
|
|
||||||
old_dir = lfs.currentdir!
|
|
||||||
lfs.chdir '..'
|
|
||||||
expected = lfs.currentdir!
|
|
||||||
lfs.chdir old_dir
|
|
||||||
eq expected, (ffi.string buffer)
|
|
||||||
|
|
||||||
it 'returns the current directory name if the given string is empty', ->
|
|
||||||
eq OK, (path_full_dir_name '', buffer, len)
|
|
||||||
eq lfs.currentdir!, (ffi.string buffer)
|
|
||||||
|
|
||||||
it 'fails if the given directory does not exist', ->
|
|
||||||
eq FAIL, path_full_dir_name('does_not_exist', buffer, len)
|
|
||||||
|
|
||||||
it 'works with a normal relative dir', ->
|
|
||||||
result = path_full_dir_name('unit-test-directory', buffer, len)
|
|
||||||
eq lfs.currentdir! .. '/unit-test-directory', (ffi.string buffer)
|
|
||||||
eq OK, result
|
|
||||||
|
|
||||||
os_isdir = (name) ->
|
os_isdir = (name) ->
|
||||||
fs.os_isdir (to_cstr name)
|
fs.os_isdir (to_cstr name)
|
||||||
|
|
||||||
|
@@ -10,6 +10,43 @@ OK = 1
|
|||||||
FAIL = 0
|
FAIL = 0
|
||||||
|
|
||||||
describe 'path function', ->
|
describe 'path function', ->
|
||||||
|
describe 'path_full_dir_name', ->
|
||||||
|
setup ->
|
||||||
|
lfs.mkdir 'unit-test-directory'
|
||||||
|
|
||||||
|
teardown ->
|
||||||
|
lfs.rmdir 'unit-test-directory'
|
||||||
|
|
||||||
|
path_full_dir_name = (directory, buffer, len) ->
|
||||||
|
directory = to_cstr directory
|
||||||
|
path.path_full_dir_name directory, buffer, len
|
||||||
|
|
||||||
|
before_each ->
|
||||||
|
-- Create empty string buffer which will contain the resulting path.
|
||||||
|
export len = (string.len lfs.currentdir!) + 22
|
||||||
|
export buffer = cstr len, ''
|
||||||
|
|
||||||
|
it 'returns the absolute directory name of a given relative one', ->
|
||||||
|
result = path_full_dir_name '..', buffer, len
|
||||||
|
eq OK, result
|
||||||
|
old_dir = lfs.currentdir!
|
||||||
|
lfs.chdir '..'
|
||||||
|
expected = lfs.currentdir!
|
||||||
|
lfs.chdir old_dir
|
||||||
|
eq expected, (ffi.string buffer)
|
||||||
|
|
||||||
|
it 'returns the current directory name if the given string is empty', ->
|
||||||
|
eq OK, (path_full_dir_name '', buffer, len)
|
||||||
|
eq lfs.currentdir!, (ffi.string buffer)
|
||||||
|
|
||||||
|
it 'fails if the given directory does not exist', ->
|
||||||
|
eq FAIL, path_full_dir_name('does_not_exist', buffer, len)
|
||||||
|
|
||||||
|
it 'works with a normal relative dir', ->
|
||||||
|
result = path_full_dir_name('unit-test-directory', buffer, len)
|
||||||
|
eq lfs.currentdir! .. '/unit-test-directory', (ffi.string buffer)
|
||||||
|
eq OK, result
|
||||||
|
|
||||||
describe 'path_full_compare', ->
|
describe 'path_full_compare', ->
|
||||||
|
|
||||||
path_full_compare = (s1, s2, cn) ->
|
path_full_compare = (s1, s2, cn) ->
|
||||||
|
@@ -85,6 +85,8 @@ class Gcc
|
|||||||
'-D "__asm(ARGS)="',
|
'-D "__asm(ARGS)="',
|
||||||
'-D "__asm__(ARGS)="',
|
'-D "__asm__(ARGS)="',
|
||||||
'-D "__inline__="',
|
'-D "__inline__="',
|
||||||
|
'-D "EXTERN=extern"',
|
||||||
|
'-D "INIT(...)="',
|
||||||
'-D_GNU_SOURCE',
|
'-D_GNU_SOURCE',
|
||||||
'-DINCLUDE_GENERATED_DECLARATIONS'
|
'-DINCLUDE_GENERATED_DECLARATIONS'
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user