Merge pull request #941 from aktau/improve-luajit-ffi-preproc

refactor includes + improve testing infrastructure
This commit is contained in:
Justin M. Keyes
2014-07-16 17:07:58 -04:00
25 changed files with 95 additions and 49 deletions

View File

@@ -1,6 +1,9 @@
#ifndef 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() */
#define GETF_SETMARK 0x01 /* set pcmark before jumping */
#define GETF_ALT 0x02 /* jumping to alternate file (not buf num) */

View File

@@ -2,10 +2,12 @@
#define NVIM_BUFFER_DEFS_H
#include <stdbool.h>
// for FILE
#include <stdio.h>
// for garray_T
#include "nvim/garray.h"
// for pos_T and lpos_T
// for pos_T, lpos_T and linenr_T
#include "nvim/pos.h"
// for the number window-local and buffer-local options
#include "nvim/option_defs.h"

View File

@@ -16,6 +16,7 @@
#include <stdbool.h>
#include "nvim/pos.h" // for linenr_T
#include "nvim/normal.h"
/*

View File

@@ -1,6 +1,9 @@
#ifndef 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
* value of "emsg_silent" if it was non-zero. When this is done, the CSF_SILENT

View File

@@ -51,6 +51,7 @@
#include "nvim/strings.h"
#include "nvim/tempfile.h"
#include "nvim/term.h"
#include "nvim/types.h"
#include "nvim/ui.h"
#include "nvim/undo.h"
#include "nvim/window.h"

View File

@@ -13,6 +13,7 @@
#include "nvim/ex_eval.h"
#include "nvim/mbyte.h"
#include "nvim/menu.h"
#include "nvim/syntax_defs.h"
/*
* definition of global variables

View File

@@ -1,7 +1,9 @@
#ifndef 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).
typedef size_t hash_T;

View File

@@ -128,6 +128,7 @@ int main() {
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <stdint.h>
#include "nvim/memory.h"

View File

@@ -1,6 +1,8 @@
#ifndef NVIM_MEMFILE_DEFS_H
#define NVIM_MEMFILE_DEFS_H
#include "nvim/types.h"
typedef struct block_hdr bhdr_T;
typedef long blocknr_T;

View File

@@ -1,8 +1,7 @@
#ifndef NVIM_MEMORY_H
#define NVIM_MEMORY_H
#include <stddef.h>
#include "nvim/vim.h"
#include <stddef.h> // for size_t
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "memory.h.generated.h"

View File

@@ -2,6 +2,7 @@
#define NVIM_MESSAGE_H
#include <stdbool.h>
#include "nvim/eval_defs.h" // for typval_T
/*
* Types of dialogs passed to do_dialog().

View File

@@ -2,6 +2,7 @@
#define NVIM_NORMAL_H
#include "nvim/pos.h"
#include "nvim/buffer_defs.h" // for win_T
/* Values for find_ident_under_cursor() */
#define FIND_IDENT 1 /* find identifier (word) */

View File

@@ -54,6 +54,7 @@
#include "nvim/syntax.h"
#include "nvim/tempfile.h"
#include "nvim/term.h"
#include "nvim/types.h"
#include "nvim/ui.h"
#include "nvim/os/os.h"
#include "nvim/os/time.h"

View File

@@ -1,6 +1,7 @@
#ifndef NVIM_OS_UNIX_H
#define NVIM_OS_UNIX_H
#include "nvim/types.h" // for vim_acl_T
#include "nvim/os/shell.h"
/* Values returned by mch_nodetype() */

View File

@@ -1,6 +1,12 @@
#ifndef 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
*/

View File

@@ -42,6 +42,7 @@
#include "nvim/regexp.h"
#include "nvim/screen.h"
#include "nvim/strings.h"
#include "nvim/syntax_defs.h"
#include "nvim/term.h"
#include "nvim/ui.h"
#include "nvim/os/os.h"

View File

@@ -9,6 +9,8 @@
# define SST_DIST 16 /* normal distance between entries */
# 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 sp_syn {
int inc_tag; /* ":syn include" unique tag */

View File

@@ -10,6 +10,14 @@
#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
* already defined, so we use char_u to avoid trouble.

View File

@@ -107,6 +107,7 @@
#include "nvim/screen.h"
#include "nvim/sha256.h"
#include "nvim/strings.h"
#include "nvim/types.h"
#include "nvim/os/os.h"
#include "nvim/os/time.h"

View File

@@ -1,6 +1,8 @@
#ifndef NVIM_UNDO_DEFS_H
#define NVIM_UNDO_DEFS_H
#include <time.h> // for time_t
#include "nvim/pos.h"
/* Structure to store info about the Visual area. */

View File

@@ -9,6 +9,7 @@
# define NVIM_VIM_H
#include "nvim/types.h"
#include "nvim/pos.h" // for linenr_T, MAXCOL, etc...
/* Some defines from the old feature.h */
#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 */
// 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
/*
@@ -359,18 +355,9 @@ enum {
#define PERROR(msg) \
(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 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.
* On some systems case in a file name does not matter, on others it does.

View File

@@ -97,6 +97,17 @@ cstr = ffi.typeof 'char[?]'
to_cstr = (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 {
cimport: cimport
cppimport: cppimport
@@ -107,4 +118,5 @@ return {
lib: libnvim
cstr: cstr
to_cstr: to_cstr
vim_init: vim_init
}

View File

@@ -57,37 +57,6 @@ describe 'fs function', ->
buf = cstr (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) ->
fs.os_isdir (to_cstr name)

View File

@@ -10,6 +10,43 @@ OK = 1
FAIL = 0
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', ->
path_full_compare = (s1, s2, cn) ->

View File

@@ -85,6 +85,8 @@ class Gcc
'-D "__asm(ARGS)="',
'-D "__asm__(ARGS)="',
'-D "__inline__="',
'-D "EXTERN=extern"',
'-D "INIT(...)="',
'-D_GNU_SOURCE',
'-DINCLUDE_GENERATED_DECLARATIONS'
}