mirror of
https://github.com/neovim/neovim.git
synced 2025-09-14 15:28:17 +00:00
eval: use gperf to generate the hash of builtin functions
make api functions highlighted as builtins in vim.vim
This commit is contained in:
@@ -17,7 +17,7 @@ set PATH=C:\Program Files (x86)\CMake\bin\cpack.exe;%PATH%
|
|||||||
|
|
||||||
:: Build third-party dependencies
|
:: Build third-party dependencies
|
||||||
C:\msys64\usr\bin\bash -lc "pacman --verbose --noconfirm -Su" || goto :error
|
C:\msys64\usr\bin\bash -lc "pacman --verbose --noconfirm -Su" || goto :error
|
||||||
C:\msys64\usr\bin\bash -lc "pacman --verbose --noconfirm --needed -S mingw-w64-%ARCH%-cmake mingw-w64-%ARCH%-perl mingw-w64-%ARCH%-python2 mingw-w64-%ARCH%-diffutils" || goto :error
|
C:\msys64\usr\bin\bash -lc "pacman --verbose --noconfirm --needed -S mingw-w64-%ARCH%-cmake mingw-w64-%ARCH%-perl mingw-w64-%ARCH%-python2 mingw-w64-%ARCH%-diffutils gperf" || goto :error
|
||||||
|
|
||||||
mkdir .deps
|
mkdir .deps
|
||||||
cd .deps
|
cd .deps
|
||||||
@@ -28,7 +28,7 @@ cd ..
|
|||||||
:: Build Neovim
|
:: Build Neovim
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -DBUSTED_OUTPUT_TYPE=gtest .. || goto :error
|
cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -DBUSTED_OUTPUT_TYPE=gtest -DGPERF_PRG="C:\msys64\usr\bin\gperf.exe" .. || goto :error
|
||||||
mingw32-make VERBOSE=1 || goto :error
|
mingw32-make VERBOSE=1 || goto :error
|
||||||
bin\nvim --version || goto :error
|
bin\nvim --version || goto :error
|
||||||
|
|
||||||
|
@@ -407,6 +407,8 @@ endif()
|
|||||||
|
|
||||||
find_program(LUACHECK_PRG luacheck)
|
find_program(LUACHECK_PRG luacheck)
|
||||||
|
|
||||||
|
find_program(GPERF_PRG gperf)
|
||||||
|
|
||||||
include(InstallHelpers)
|
include(InstallHelpers)
|
||||||
|
|
||||||
file(GLOB MANPAGES
|
file(GLOB MANPAGES
|
||||||
|
@@ -3,6 +3,7 @@ set(GENERATED_RUNTIME_DIR ${PROJECT_BINARY_DIR}/runtime)
|
|||||||
set(GENERATED_SYN_VIM ${GENERATED_RUNTIME_DIR}/syntax/vim/generated.vim)
|
set(GENERATED_SYN_VIM ${GENERATED_RUNTIME_DIR}/syntax/vim/generated.vim)
|
||||||
set(GENERATED_HELP_TAGS ${GENERATED_RUNTIME_DIR}/doc/tags)
|
set(GENERATED_HELP_TAGS ${GENERATED_RUNTIME_DIR}/doc/tags)
|
||||||
set(GENERATED_PACKAGE_DIR ${GENERATED_RUNTIME_DIR}/pack/dist/opt)
|
set(GENERATED_PACKAGE_DIR ${GENERATED_RUNTIME_DIR}/pack/dist/opt)
|
||||||
|
set(FUNCS_DATA ${PROJECT_BINARY_DIR}/funcs_data.mpack)
|
||||||
|
|
||||||
file(MAKE_DIRECTORY ${GENERATED_RUNTIME_DIR})
|
file(MAKE_DIRECTORY ${GENERATED_RUNTIME_DIR})
|
||||||
file(MAKE_DIRECTORY ${GENERATED_RUNTIME_DIR}/syntax)
|
file(MAKE_DIRECTORY ${GENERATED_RUNTIME_DIR}/syntax)
|
||||||
@@ -10,13 +11,14 @@ file(MAKE_DIRECTORY ${GENERATED_RUNTIME_DIR}/syntax/vim)
|
|||||||
|
|
||||||
add_custom_command(OUTPUT ${GENERATED_SYN_VIM}
|
add_custom_command(OUTPUT ${GENERATED_SYN_VIM}
|
||||||
COMMAND ${LUA_PRG} ${SYN_VIM_GENERATOR}
|
COMMAND ${LUA_PRG} ${SYN_VIM_GENERATOR}
|
||||||
${PROJECT_SOURCE_DIR}/src/nvim ${GENERATED_SYN_VIM}
|
${PROJECT_SOURCE_DIR}/src/nvim ${GENERATED_SYN_VIM} ${FUNCS_DATA}
|
||||||
DEPENDS
|
DEPENDS
|
||||||
${SYN_VIM_GENERATOR}
|
${SYN_VIM_GENERATOR}
|
||||||
${PROJECT_SOURCE_DIR}/src/nvim/ex_cmds.lua
|
${PROJECT_SOURCE_DIR}/src/nvim/ex_cmds.lua
|
||||||
${PROJECT_SOURCE_DIR}/src/nvim/auevents.lua
|
${PROJECT_SOURCE_DIR}/src/nvim/auevents.lua
|
||||||
${PROJECT_SOURCE_DIR}/src/nvim/options.lua
|
${PROJECT_SOURCE_DIR}/src/nvim/options.lua
|
||||||
${PROJECT_SOURCE_DIR}/src/nvim/eval.c
|
${PROJECT_SOURCE_DIR}/src/nvim/eval.c
|
||||||
|
${FUNCS_DATA}
|
||||||
)
|
)
|
||||||
|
|
||||||
if(POLICY CMP0054)
|
if(POLICY CMP0054)
|
||||||
|
@@ -3,6 +3,7 @@ mpack = require('mpack')
|
|||||||
local nvimsrcdir = arg[1]
|
local nvimsrcdir = arg[1]
|
||||||
local autodir = arg[2]
|
local autodir = arg[2]
|
||||||
local metadata_file = arg[3]
|
local metadata_file = arg[3]
|
||||||
|
local funcs_file = arg[4]
|
||||||
|
|
||||||
if nvimsrcdir == '--help' then
|
if nvimsrcdir == '--help' then
|
||||||
print([[
|
print([[
|
||||||
@@ -19,20 +20,34 @@ package.path = nvimsrcdir .. '/?.lua;' .. package.path
|
|||||||
|
|
||||||
local funcsfname = autodir .. '/funcs.generated.h'
|
local funcsfname = autodir .. '/funcs.generated.h'
|
||||||
|
|
||||||
local funcspipe = io.open(funcsfname .. '.hsh', 'w')
|
local gperfpipe = io.open(funcsfname .. '.gperf', 'wb')
|
||||||
|
|
||||||
local funcs = require('eval').funcs
|
local funcs = require('eval').funcs
|
||||||
|
|
||||||
local metadata = mpack.unpack(io.open(arg[3], 'rb'):read("*all"))
|
local metadata = mpack.unpack(io.open(arg[3], 'rb'):read("*all"))
|
||||||
|
|
||||||
for i,fun in ipairs(metadata) do
|
for i,fun in ipairs(metadata) do
|
||||||
funcs['api_'..fun.name] = {
|
funcs['api_'..fun.name] = {
|
||||||
args=#fun.parameters,
|
args=#fun.parameters,
|
||||||
func='api_wrapper',
|
func='api_wrapper',
|
||||||
data='handle_'..fun.name,
|
data='&handle_'..fun.name,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local funcsdata = io.open(funcs_file, 'w')
|
||||||
|
funcsdata:write(mpack.pack(funcs))
|
||||||
|
funcsdata:close()
|
||||||
|
|
||||||
|
gperfpipe:write([[
|
||||||
|
%language=ANSI-C
|
||||||
|
%global-table
|
||||||
|
%define initializer-suffix ,0,0,NULL,NULL
|
||||||
|
%define word-array-name functions
|
||||||
|
%define hash-function-name hash_internal_func_gperf
|
||||||
|
%define lookup-function-name find_internal_func_gperf
|
||||||
|
%omit-struct-type
|
||||||
|
%struct-type
|
||||||
|
VimLFuncDef;
|
||||||
|
%%
|
||||||
|
]])
|
||||||
|
|
||||||
for name, def in pairs(funcs) do
|
for name, def in pairs(funcs) do
|
||||||
args = def.args or 0
|
args = def.args or 0
|
||||||
@@ -43,7 +58,7 @@ for name, def in pairs(funcs) do
|
|||||||
end
|
end
|
||||||
func = def.func or ('f_' .. name)
|
func = def.func or ('f_' .. name)
|
||||||
data = def.data or "NULL"
|
data = def.data or "NULL"
|
||||||
local val = ('{ %s, %s, &%s, %s }'):format(args[1], args[2], func, data)
|
gperfpipe:write(('%s, %s, %s, &%s, (FunPtr)%s\n')
|
||||||
funcspipe:write(name .. '\n' .. val .. '\n')
|
:format(name, args[1], args[2], func, data))
|
||||||
end
|
end
|
||||||
funcspipe:close()
|
gperfpipe:close()
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
mpack = require('mpack')
|
||||||
|
|
||||||
if arg[1] == '--help' then
|
if arg[1] == '--help' then
|
||||||
print('Usage: lua genvimvim.lua src/nvim runtime/syntax/vim/generated.vim')
|
print('Usage: lua genvimvim.lua src/nvim runtime/syntax/vim/generated.vim')
|
||||||
os.exit(0)
|
os.exit(0)
|
||||||
@@ -5,6 +7,7 @@ end
|
|||||||
|
|
||||||
local nvimsrcdir = arg[1]
|
local nvimsrcdir = arg[1]
|
||||||
local syntax_file = arg[2]
|
local syntax_file = arg[2]
|
||||||
|
local funcs_file = arg[3]
|
||||||
|
|
||||||
package.path = nvimsrcdir .. '/?.lua;' .. package.path
|
package.path = nvimsrcdir .. '/?.lua;' .. package.path
|
||||||
|
|
||||||
@@ -23,7 +26,6 @@ end
|
|||||||
local options = require('options')
|
local options = require('options')
|
||||||
local auevents = require('auevents')
|
local auevents = require('auevents')
|
||||||
local ex_cmds = require('ex_cmds')
|
local ex_cmds = require('ex_cmds')
|
||||||
local eval = require('eval')
|
|
||||||
|
|
||||||
local cmd_kw = function(prev_cmd, cmd)
|
local cmd_kw = function(prev_cmd, cmd)
|
||||||
if not prev_cmd then
|
if not prev_cmd then
|
||||||
@@ -112,9 +114,9 @@ end
|
|||||||
w('\n\nsyn case match')
|
w('\n\nsyn case match')
|
||||||
local vimfun_start = 'syn keyword vimFuncName contained '
|
local vimfun_start = 'syn keyword vimFuncName contained '
|
||||||
w('\n\n' .. vimfun_start)
|
w('\n\n' .. vimfun_start)
|
||||||
eval_fd = io.open(nvimsrcdir .. '/eval.c', 'r')
|
funcs = mpack.unpack(io.open(funcs_file):read("*all"))
|
||||||
local started = 0
|
local started = 0
|
||||||
for name, def in pairs(eval.funcs) do
|
for name, def in pairs(funcs) do
|
||||||
if name then
|
if name then
|
||||||
if lld.line_length > 850 then
|
if lld.line_length > 850 then
|
||||||
w('\n' .. vimfun_start)
|
w('\n' .. vimfun_start)
|
||||||
@@ -122,7 +124,6 @@ for name, def in pairs(eval.funcs) do
|
|||||||
w(' ' .. name)
|
w(' ' .. name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
eval_fd:close()
|
|
||||||
|
|
||||||
w('\n')
|
w('\n')
|
||||||
syn_fd:close()
|
syn_fd:close()
|
||||||
|
106
src/genhash.c
106
src/genhash.c
@@ -1,106 +0,0 @@
|
|||||||
// Program used to generate static hashes
|
|
||||||
//
|
|
||||||
// Uses hashes from khash.h macros library.
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#define USE_LIBC_ALLOCATOR
|
|
||||||
#include "nvim/lib/khash.h"
|
|
||||||
|
|
||||||
KHASH_MAP_INIT_STR(hash, char *)
|
|
||||||
|
|
||||||
#define CHECK_FAIL(cond, ...) \
|
|
||||||
do { \
|
|
||||||
if (cond) { \
|
|
||||||
fprintf(stderr, __VA_ARGS__); \
|
|
||||||
putc('\n', stderr); \
|
|
||||||
return 1; \
|
|
||||||
} \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
if (argc == 2 && strcmp(argv[1], "--help") == 0) {
|
|
||||||
puts("Usage:");
|
|
||||||
puts(" genhash SOURCE TARGET TYPE NAME VALTYPE NULLVAL");
|
|
||||||
puts("Transforms keys and values in a form \"key\\nval\\n\" into a hash");
|
|
||||||
puts("literal.");
|
|
||||||
puts("");
|
|
||||||
puts("SOURCE is the file name to read keys and values from.");
|
|
||||||
puts("TARGET is the file name to write to.");
|
|
||||||
puts("TYPE is the name of the hash type (khash_t argument).");
|
|
||||||
puts("NAME is the name of the generated hash.");
|
|
||||||
puts("VALTYPE is the name of the value type.");
|
|
||||||
puts("NULLVAL is the value used when no value is available.");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
CHECK_FAIL(argc != 7, "Expecting six arguments, got %i.", argc);
|
|
||||||
|
|
||||||
const char *const source = argv[1];
|
|
||||||
const char *const target = argv[2];
|
|
||||||
const char *const type = argv[3];
|
|
||||||
const char *const name = argv[4];
|
|
||||||
const char *const valtype = argv[5];
|
|
||||||
const char *const nullval = argv[6];
|
|
||||||
|
|
||||||
FILE *fin = fopen(source, "r");
|
|
||||||
CHECK_FAIL(!fin, "Failed to open source: %s.", strerror(errno));
|
|
||||||
|
|
||||||
char keybuf[80];
|
|
||||||
char valbuf[4096];
|
|
||||||
khash_t(hash) hash = KHASH_EMPTY_TABLE(hash);
|
|
||||||
while (fgets(keybuf, sizeof(keybuf), fin) != NULL) {
|
|
||||||
CHECK_FAIL(ferror(fin), "Failed to read key %i from source: %s",
|
|
||||||
(int) kh_size(&hash), strerror(ferror(fin)));
|
|
||||||
keybuf[strlen(keybuf) - 1] = 0;
|
|
||||||
CHECK_FAIL(!fgets(valbuf, sizeof(valbuf), fin),
|
|
||||||
"Failed to read value for key %i (%s): %s",
|
|
||||||
(int) kh_size(&hash), keybuf, (ferror(fin)
|
|
||||||
? strerror(ferror(fin))
|
|
||||||
: "EOF found"));
|
|
||||||
valbuf[strlen(valbuf) - 1] = 0;
|
|
||||||
char *const key_copy = strdup(keybuf);
|
|
||||||
CHECK_FAIL(!key_copy, "Failed to allocate memory for a key");
|
|
||||||
int put_ret;
|
|
||||||
const khiter_t k = kh_put(hash, &hash, key_copy, &put_ret);
|
|
||||||
CHECK_FAIL(put_ret != 1, "Expecting unused non-empty bucket for key %s",
|
|
||||||
key_copy);
|
|
||||||
kh_value(&hash, k) = strdup(valbuf);
|
|
||||||
CHECK_FAIL(!kh_value(&hash, k), "Failed to allocate memory for a value");
|
|
||||||
}
|
|
||||||
CHECK_FAIL(fclose(fin), "Failed to close source: %s", strerror(errno));
|
|
||||||
|
|
||||||
FILE *f = fopen(target, "w");
|
|
||||||
CHECK_FAIL(!f, strerror(errno));
|
|
||||||
fprintf(f, "static const khash_t(%s) %s = {", type, name);
|
|
||||||
fprintf(f, " .n_buckets = %i,\n", (int) hash.n_buckets);
|
|
||||||
fprintf(f, " .size = %i,\n", (int) hash.size);
|
|
||||||
fprintf(f, " .n_occupied = %i,\n", (int) hash.n_occupied);
|
|
||||||
fprintf(f, " .upper_bound = %i,\n", (int) hash.upper_bound);
|
|
||||||
fprintf(f, " .flags = (khint32_t[]) {\n");
|
|
||||||
for (khint_t i = 0; i < kh_end(&hash); i++) {
|
|
||||||
fprintf(f, " %i,\n", (int) hash.flags[i]);
|
|
||||||
}
|
|
||||||
fprintf(f, " },\n");
|
|
||||||
fprintf(f, " .keys = (const char*[]) {\n");
|
|
||||||
for (khint_t i = 0; i < kh_end(&hash); i++) {
|
|
||||||
if (kh_exist(&hash, i)) {
|
|
||||||
fprintf(f, " \"%s\",\n", hash.keys[i]);
|
|
||||||
} else {
|
|
||||||
fprintf(f, " NULL,\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fprintf(f, " },\n");
|
|
||||||
fprintf(f, " .vals = (%s[]) {\n", valtype);
|
|
||||||
for (khint_t i = 0; i < kh_end(&hash); i++) {
|
|
||||||
fprintf(f, " %s,\n", (kh_exist(&hash, i) ? hash.vals[i] : nullval));
|
|
||||||
}
|
|
||||||
fprintf(f, " },\n");
|
|
||||||
fprintf(f, "};\n");
|
|
||||||
fclose(f);
|
|
||||||
return 0;
|
|
||||||
}
|
|
@@ -15,12 +15,13 @@ set(DISPATCH_GENERATOR ${PROJECT_SOURCE_DIR}/scripts/gendispatch.lua)
|
|||||||
file(GLOB API_HEADERS api/*.h)
|
file(GLOB API_HEADERS api/*.h)
|
||||||
file(GLOB MSGPACK_RPC_HEADERS msgpack_rpc/*.h)
|
file(GLOB MSGPACK_RPC_HEADERS msgpack_rpc/*.h)
|
||||||
set(API_METADATA ${PROJECT_BINARY_DIR}/api_metadata.mpack)
|
set(API_METADATA ${PROJECT_BINARY_DIR}/api_metadata.mpack)
|
||||||
|
set(FUNCS_DATA ${PROJECT_BINARY_DIR}/funcs_data.mpack)
|
||||||
set(HEADER_GENERATOR ${PROJECT_SOURCE_DIR}/scripts/gendeclarations.lua)
|
set(HEADER_GENERATOR ${PROJECT_SOURCE_DIR}/scripts/gendeclarations.lua)
|
||||||
set(GENERATED_INCLUDES_DIR ${PROJECT_BINARY_DIR}/include)
|
set(GENERATED_INCLUDES_DIR ${PROJECT_BINARY_DIR}/include)
|
||||||
set(GENERATED_API_DISPATCH ${GENERATED_DIR}/api/private/dispatch.c)
|
set(GENERATED_API_DISPATCH ${GENERATED_DIR}/api/private/dispatch.c)
|
||||||
set(GENERATED_EX_CMDS_ENUM ${GENERATED_INCLUDES_DIR}/ex_cmds_enum.generated.h)
|
set(GENERATED_EX_CMDS_ENUM ${GENERATED_INCLUDES_DIR}/ex_cmds_enum.generated.h)
|
||||||
set(GENERATED_EX_CMDS_DEFS ${GENERATED_DIR}/ex_cmds_defs.generated.h)
|
set(GENERATED_EX_CMDS_DEFS ${GENERATED_DIR}/ex_cmds_defs.generated.h)
|
||||||
set(GENERATED_FUNCS_HASH_INPUT ${GENERATED_DIR}/funcs.generated.h.hsh)
|
set(GENERATED_FUNCS_HASH_INPUT ${GENERATED_DIR}/funcs.generated.h.gperf)
|
||||||
set(GENERATED_FUNCS ${GENERATED_DIR}/funcs.generated.h)
|
set(GENERATED_FUNCS ${GENERATED_DIR}/funcs.generated.h)
|
||||||
set(GENERATED_EVENTS_ENUM ${GENERATED_INCLUDES_DIR}/auevents_enum.generated.h)
|
set(GENERATED_EVENTS_ENUM ${GENERATED_INCLUDES_DIR}/auevents_enum.generated.h)
|
||||||
set(GENERATED_EVENTS_NAMES_MAP ${GENERATED_DIR}/auevents_name_map.generated.h)
|
set(GENERATED_EVENTS_NAMES_MAP ${GENERATED_DIR}/auevents_name_map.generated.h)
|
||||||
@@ -39,9 +40,9 @@ set(UNICODEDATA_FILE ${UNICODE_DIR}/UnicodeData.txt)
|
|||||||
set(CASEFOLDING_FILE ${UNICODE_DIR}/CaseFolding.txt)
|
set(CASEFOLDING_FILE ${UNICODE_DIR}/CaseFolding.txt)
|
||||||
set(EASTASIANWIDTH_FILE ${UNICODE_DIR}/EastAsianWidth.txt)
|
set(EASTASIANWIDTH_FILE ${UNICODE_DIR}/EastAsianWidth.txt)
|
||||||
set(GENERATED_UNICODE_TABLES ${GENERATED_DIR}/unicode_tables.generated.h)
|
set(GENERATED_UNICODE_TABLES ${GENERATED_DIR}/unicode_tables.generated.h)
|
||||||
set(GENHASH_SOURCE ${PROJECT_SOURCE_DIR}/src/genhash.c)
|
|
||||||
|
|
||||||
include_directories(${GENERATED_DIR})
|
include_directories(${GENERATED_DIR})
|
||||||
|
include_directories(${CACHED_GENERATED_DIR})
|
||||||
include_directories(${GENERATED_INCLUDES_DIR})
|
include_directories(${GENERATED_INCLUDES_DIR})
|
||||||
|
|
||||||
file(MAKE_DIRECTORY ${GENERATED_DIR})
|
file(MAKE_DIRECTORY ${GENERATED_DIR})
|
||||||
@@ -118,6 +119,10 @@ endforeach()
|
|||||||
if(NOT MSVC)
|
if(NOT MSVC)
|
||||||
set_source_files_properties(
|
set_source_files_properties(
|
||||||
${CONV_SOURCES} PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -Wno-conversion")
|
${CONV_SOURCES} PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -Wno-conversion")
|
||||||
|
# gperf generates ANSI-C with incorrect linkage, ignore it.
|
||||||
|
set_source_files_properties(
|
||||||
|
eval.c PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -Wno-static-in-inline -Wno-conversion")
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(DEFINED MIN_LOG_LEVEL)
|
if(DEFINED MIN_LOG_LEVEL)
|
||||||
@@ -210,7 +215,6 @@ list(APPEND NEOVIM_GENERATED_SOURCES
|
|||||||
"${GENERATED_EVENTS_NAMES_MAP}"
|
"${GENERATED_EVENTS_NAMES_MAP}"
|
||||||
"${GENERATED_OPTIONS}"
|
"${GENERATED_OPTIONS}"
|
||||||
"${GENERATED_UNICODE_TABLES}"
|
"${GENERATED_UNICODE_TABLES}"
|
||||||
"${GENERATED_FUNCS}"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
add_custom_command(OUTPUT ${GENERATED_EX_CMDS_ENUM} ${GENERATED_EX_CMDS_DEFS}
|
add_custom_command(OUTPUT ${GENERATED_EX_CMDS_ENUM} ${GENERATED_EX_CMDS_DEFS}
|
||||||
@@ -219,13 +223,18 @@ add_custom_command(OUTPUT ${GENERATED_EX_CMDS_ENUM} ${GENERATED_EX_CMDS_DEFS}
|
|||||||
DEPENDS ${EX_CMDS_GENERATOR} ${EX_CMDS_DEFS_FILE}
|
DEPENDS ${EX_CMDS_GENERATOR} ${EX_CMDS_DEFS_FILE}
|
||||||
)
|
)
|
||||||
|
|
||||||
add_custom_command(OUTPUT ${GENERATED_FUNCS}
|
if(NOT GPERF_PRG)
|
||||||
|
message(FATAL_ERROR "gperf was not found.")
|
||||||
|
endif()
|
||||||
|
add_custom_command(OUTPUT ${GENERATED_FUNCS} ${FUNCS_DATA}
|
||||||
COMMAND ${LUA_PRG} ${FUNCS_GENERATOR}
|
COMMAND ${LUA_PRG} ${FUNCS_GENERATOR}
|
||||||
${PROJECT_SOURCE_DIR}/src/nvim ${GENERATED_DIR} ${API_METADATA}
|
${PROJECT_SOURCE_DIR}/src/nvim ${GENERATED_DIR} ${API_METADATA} ${FUNCS_DATA}
|
||||||
COMMAND $<TARGET_FILE:genhash>
|
COMMAND ${GPERF_PRG}
|
||||||
${GENERATED_FUNCS_HASH_INPUT} ${GENERATED_FUNCS} functions functions VimLFuncDef "NOFUNC"
|
${GENERATED_FUNCS_HASH_INPUT} --output-file=${GENERATED_FUNCS}
|
||||||
DEPENDS ${FUNCS_GENERATOR} ${EVAL_DEFS_FILE} ${API_METADATA} genhash
|
DEPENDS ${FUNCS_GENERATOR} ${EVAL_DEFS_FILE} ${API_METADATA}
|
||||||
)
|
)
|
||||||
|
list(APPEND NEOVIM_GENERATED_SOURCES
|
||||||
|
"${GENERATED_FUNCS}")
|
||||||
|
|
||||||
add_custom_command(OUTPUT ${GENERATED_EVENTS_ENUM} ${GENERATED_EVENTS_NAMES_MAP}
|
add_custom_command(OUTPUT ${GENERATED_EVENTS_ENUM} ${GENERATED_EVENTS_NAMES_MAP}
|
||||||
COMMAND ${LUA_PRG} ${EVENTS_GENERATOR}
|
COMMAND ${LUA_PRG} ${EVENTS_GENERATOR}
|
||||||
@@ -293,8 +302,6 @@ if(WIN32)
|
|||||||
DESTINATION ${CMAKE_INSTALL_BINDIR})
|
DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_executable(genhash ${GENHASH_SOURCE} ${NEOVIM_HEADERS})
|
|
||||||
|
|
||||||
if(CLANG_ASAN_UBSAN)
|
if(CLANG_ASAN_UBSAN)
|
||||||
message(STATUS "Enabling Clang address sanitizer and undefined behavior sanitizer for nvim.")
|
message(STATUS "Enabling Clang address sanitizer and undefined behavior sanitizer for nvim.")
|
||||||
check_c_compiler_flag(-fno-sanitize-recover=all SANITIZE_RECOVER_ALL)
|
check_c_compiler_flag(-fno-sanitize-recover=all SANITIZE_RECOVER_ALL)
|
||||||
|
770
src/nvim/eval.c
770
src/nvim/eval.c
File diff suppressed because it is too large
Load Diff
@@ -15,7 +15,7 @@ end
|
|||||||
return {
|
return {
|
||||||
funcs={
|
funcs={
|
||||||
abs={args=1},
|
abs={args=1},
|
||||||
acos={args=1}, -- WJMc
|
acos={args=1, func="float_op_wrapper", data="&acos"}, -- WJMc
|
||||||
add={args=2},
|
add={args=2},
|
||||||
['and']={args=2},
|
['and']={args=2},
|
||||||
api_info={},
|
api_info={},
|
||||||
@@ -24,7 +24,7 @@ return {
|
|||||||
argidx={},
|
argidx={},
|
||||||
arglistid={args={0, 2}},
|
arglistid={args={0, 2}},
|
||||||
argv={args={0, 1}},
|
argv={args={0, 1}},
|
||||||
asin={args=1}, -- WJMc
|
asin={args=1, func="float_op_wrapper", data="&asin"}, -- WJMc
|
||||||
assert_equal={args={2, 3}},
|
assert_equal={args={2, 3}},
|
||||||
assert_exception={args={1, 2}},
|
assert_exception={args={1, 2}},
|
||||||
assert_fails={args={1, 2}},
|
assert_fails={args={1, 2}},
|
||||||
@@ -33,7 +33,7 @@ return {
|
|||||||
assert_notequal={args={2, 3}},
|
assert_notequal={args={2, 3}},
|
||||||
assert_notmatch={args={2, 3}},
|
assert_notmatch={args={2, 3}},
|
||||||
assert_true={args={1, 2}},
|
assert_true={args={1, 2}},
|
||||||
atan={args=1, func="float_op_wrapper", data="atan"},
|
atan={args=1, func="float_op_wrapper", data="&atan"},
|
||||||
atan2={args=2},
|
atan2={args=2},
|
||||||
browse={args=4},
|
browse={args=4},
|
||||||
browsedir={args=2},
|
browsedir={args=2},
|
||||||
@@ -50,7 +50,7 @@ return {
|
|||||||
byteidx={args=2},
|
byteidx={args=2},
|
||||||
byteidxcomp={args=2},
|
byteidxcomp={args=2},
|
||||||
call={args={2, 3}},
|
call={args={2, 3}},
|
||||||
ceil={args=1},
|
ceil={args=1, func="float_op_wrapper", data="&ceil"},
|
||||||
changenr={},
|
changenr={},
|
||||||
char2nr={args={1, 2}},
|
char2nr={args={1, 2}},
|
||||||
cindent={args=1},
|
cindent={args=1},
|
||||||
@@ -61,8 +61,8 @@ return {
|
|||||||
complete_check={},
|
complete_check={},
|
||||||
confirm={args={1, 4}},
|
confirm={args={1, 4}},
|
||||||
copy={args=1},
|
copy={args=1},
|
||||||
cos={args=1},
|
cos={args=1, func="float_op_wrapper", data="&cos"},
|
||||||
cosh={args=1},
|
cosh={args=1, func="float_op_wrapper", data="&cosh"},
|
||||||
count={args={2, 4}},
|
count={args={2, 4}},
|
||||||
cscope_connection={args={0, 3}},
|
cscope_connection={args={0, 3}},
|
||||||
cursor={args={1, 3}},
|
cursor={args={1, 3}},
|
||||||
@@ -81,7 +81,7 @@ return {
|
|||||||
execute={args=1},
|
execute={args=1},
|
||||||
exepath={args=1},
|
exepath={args=1},
|
||||||
exists={args=1},
|
exists={args=1},
|
||||||
exp={args=1},
|
exp={args=1, func="float_op_wrapper", data="&exp"},
|
||||||
expand={args={1, 3}},
|
expand={args={1, 3}},
|
||||||
extend={args={2, 3}},
|
extend={args={2, 3}},
|
||||||
feedkeys={args={1, 2}},
|
feedkeys={args={1, 2}},
|
||||||
@@ -92,7 +92,7 @@ return {
|
|||||||
finddir={args={1, 3}},
|
finddir={args={1, 3}},
|
||||||
findfile={args={1, 3}},
|
findfile={args={1, 3}},
|
||||||
float2nr={args=1},
|
float2nr={args=1},
|
||||||
floor={args=1},
|
floor={args=1, func="float_op_wrapper", data="&floor"},
|
||||||
fmod={args=2},
|
fmod={args=2},
|
||||||
fnameescape={args=1},
|
fnameescape={args=1},
|
||||||
fnamemodify={args=2},
|
fnamemodify={args=2},
|
||||||
@@ -184,8 +184,8 @@ return {
|
|||||||
line2byte={args=1},
|
line2byte={args=1},
|
||||||
lispindent={args=1},
|
lispindent={args=1},
|
||||||
localtime={},
|
localtime={},
|
||||||
log={args=1},
|
log={args=1, func="float_op_wrapper", data="&log"},
|
||||||
log10={args=1},
|
log10={args=1, func="float_op_wrapper", data="&log10"},
|
||||||
map={args=2},
|
map={args=2},
|
||||||
maparg={args={1, 4}},
|
maparg={args={1, 4}},
|
||||||
mapcheck={args={1, 3}},
|
mapcheck={args={1, 3}},
|
||||||
@@ -223,7 +223,7 @@ return {
|
|||||||
['repeat']={args=2},
|
['repeat']={args=2},
|
||||||
resolve={args=1},
|
resolve={args=1},
|
||||||
reverse={args=1},
|
reverse={args=1},
|
||||||
round={args=1},
|
round={args=1, func="float_op_wrapper", data="&round"},
|
||||||
rpcnotify={args=varargs(2)},
|
rpcnotify={args=varargs(2)},
|
||||||
rpcrequest={args=varargs(2)},
|
rpcrequest={args=varargs(2)},
|
||||||
rpcstart={args={1, 2}},
|
rpcstart={args={1, 2}},
|
||||||
@@ -257,14 +257,14 @@ return {
|
|||||||
shellescape={args={1, 2}},
|
shellescape={args={1, 2}},
|
||||||
shiftwidth={},
|
shiftwidth={},
|
||||||
simplify={args=1},
|
simplify={args=1},
|
||||||
sin={args=1},
|
sin={args=1, func="float_op_wrapper", data="&sin"},
|
||||||
sinh={args=1},
|
sinh={args=1, func="float_op_wrapper", data="&sinh"},
|
||||||
sort={args={1, 3}},
|
sort={args={1, 3}},
|
||||||
soundfold={args=1},
|
soundfold={args=1},
|
||||||
spellbadword={args={0, 1}},
|
spellbadword={args={0, 1}},
|
||||||
spellsuggest={args={1, 3}},
|
spellsuggest={args={1, 3}},
|
||||||
split={args={1, 3}},
|
split={args={1, 3}},
|
||||||
sqrt={args=1},
|
sqrt={args=1, func="float_op_wrapper", data="&sqrt"},
|
||||||
str2float={args=1},
|
str2float={args=1},
|
||||||
str2nr={args={1, 2}},
|
str2nr={args={1, 2}},
|
||||||
strchars={args={1,2}},
|
strchars={args={1,2}},
|
||||||
@@ -291,8 +291,8 @@ return {
|
|||||||
tabpagewinnr={args={1, 2}},
|
tabpagewinnr={args={1, 2}},
|
||||||
tagfiles={},
|
tagfiles={},
|
||||||
taglist={args=1},
|
taglist={args=1},
|
||||||
tan={args=1},
|
tan={args=1, func="float_op_wrapper", data="&tan"},
|
||||||
tanh={args=1},
|
tanh={args=1, func="float_op_wrapper", data="&tanh"},
|
||||||
tempname={},
|
tempname={},
|
||||||
termopen={args={1, 2}},
|
termopen={args={1, 2}},
|
||||||
test={args=1},
|
test={args=1},
|
||||||
@@ -301,7 +301,7 @@ return {
|
|||||||
tolower={args=1},
|
tolower={args=1},
|
||||||
toupper={args=1},
|
toupper={args=1},
|
||||||
tr={args=3},
|
tr={args=3},
|
||||||
trunc={args=1},
|
trunc={args=1, func="float_op_wrapper", data="&trunc"},
|
||||||
type={args=1},
|
type={args=1},
|
||||||
undofile={args=1},
|
undofile={args=1},
|
||||||
undotree={},
|
undotree={},
|
||||||
|
@@ -130,9 +130,7 @@ int main() {
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#ifndef USE_LIBC_ALLOCATOR
|
#include "nvim/memory.h"
|
||||||
# include "nvim/memory.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "nvim/func_attr.h"
|
#include "nvim/func_attr.h"
|
||||||
|
|
||||||
@@ -173,32 +171,17 @@ typedef khint_t khiter_t;
|
|||||||
#define kroundup32(x) (--(x), (x)|=(x)>>1, (x)|=(x)>>2, (x)|=(x)>>4, (x)|=(x)>>8, (x)|=(x)>>16, ++(x))
|
#define kroundup32(x) (--(x), (x)|=(x)>>1, (x)|=(x)>>2, (x)|=(x)>>4, (x)|=(x)>>8, (x)|=(x)>>16, ++(x))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_LIBC_ALLOCATOR
|
#ifndef kcalloc
|
||||||
# ifndef kcalloc
|
#define kcalloc(N,Z) xcalloc(N,Z)
|
||||||
# define kcalloc(N,Z) calloc(N,Z)
|
#endif
|
||||||
# endif
|
#ifndef kmalloc
|
||||||
# ifndef kmalloc
|
#define kmalloc(Z) xmalloc(Z)
|
||||||
# define kmalloc(Z) malloc(Z)
|
#endif
|
||||||
# endif
|
#ifndef krealloc
|
||||||
# ifndef krealloc
|
#define krealloc(P,Z) xrealloc(P,Z)
|
||||||
# define krealloc(P,Z) realloc(P,Z)
|
#endif
|
||||||
# endif
|
#ifndef kfree
|
||||||
# ifndef kfree
|
#define kfree(P) xfree(P)
|
||||||
# define kfree(P) free(P)
|
|
||||||
# endif
|
|
||||||
#else
|
|
||||||
# ifndef kcalloc
|
|
||||||
# define kcalloc(N,Z) xcalloc(N,Z)
|
|
||||||
# endif
|
|
||||||
# ifndef kmalloc
|
|
||||||
# define kmalloc(Z) xmalloc(Z)
|
|
||||||
# endif
|
|
||||||
# ifndef krealloc
|
|
||||||
# define krealloc(P,Z) xrealloc(P,Z)
|
|
||||||
# endif
|
|
||||||
# ifndef kfree
|
|
||||||
# define kfree(P) xfree(P)
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define __ac_HASH_UPPER 0.77
|
#define __ac_HASH_UPPER 0.77
|
||||||
|
13
third-party/CMakeLists.txt
vendored
13
third-party/CMakeLists.txt
vendored
@@ -32,6 +32,12 @@ option(USE_BUNDLED_LUV "Use the bundled version of luv." ${USE_BUNDLED})
|
|||||||
# build it unless explicitly requested
|
# build it unless explicitly requested
|
||||||
option(USE_BUNDLED_LUA "Use the bundled version of lua." OFF)
|
option(USE_BUNDLED_LUA "Use the bundled version of lua." OFF)
|
||||||
|
|
||||||
|
if(USE_BUNDLED AND (NOT WIN32))
|
||||||
|
option(USE_BUNDLED_GPERF "Use the bundled version of gperf." ON)
|
||||||
|
else()
|
||||||
|
option(USE_BUNDLED_GPERF "Use the bundled version of gperf." OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
option(USE_EXISTING_SRC_DIR "Skip download of deps sources in case of existing source directory." OFF)
|
option(USE_EXISTING_SRC_DIR "Skip download of deps sources in case of existing source directory." OFF)
|
||||||
|
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
@@ -111,6 +117,9 @@ set(JEMALLOC_SHA256 5630650d5c1caab95d2f0898de4fe5ab8519dc680b04963b38bb425ef6a4
|
|||||||
set(LUV_URL https://github.com/luvit/luv/archive/146f1ce4c08c3b67f604c9ee1e124b1cf5c15cf3.tar.gz)
|
set(LUV_URL https://github.com/luvit/luv/archive/146f1ce4c08c3b67f604c9ee1e124b1cf5c15cf3.tar.gz)
|
||||||
set(LUV_SHA256 3d537f8eb9fa5adb146a083eae22af886aee324ec268e2aa0fa75f2f1c52ca7a)
|
set(LUV_SHA256 3d537f8eb9fa5adb146a083eae22af886aee324ec268e2aa0fa75f2f1c52ca7a)
|
||||||
|
|
||||||
|
set(GPERF_URL http://ftp.gnu.org/pub/gnu/gperf/gperf-3.0.4.tar.gz)
|
||||||
|
set(GPERF_SHA256 767112a204407e62dbc3106647cf839ed544f3cf5d0f0523aaa2508623aad63e)
|
||||||
|
|
||||||
if(USE_BUNDLED_UNIBILIUM)
|
if(USE_BUNDLED_UNIBILIUM)
|
||||||
include(BuildUnibilium)
|
include(BuildUnibilium)
|
||||||
endif()
|
endif()
|
||||||
@@ -151,6 +160,10 @@ if(USE_BUNDLED_LUV)
|
|||||||
include(BuildLuv)
|
include(BuildLuv)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(USE_BUNDLED_GPERF)
|
||||||
|
include(BuildGperf)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_custom_target(clean-shared-libraries
|
add_custom_target(clean-shared-libraries
|
||||||
COMMAND ${CMAKE_COMMAND}
|
COMMAND ${CMAKE_COMMAND}
|
||||||
-DREMOVE_FILE_GLOB=${DEPS_INSTALL_DIR}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}*${CMAKE_SHARED_LIBRARY_SUFFIX}*
|
-DREMOVE_FILE_GLOB=${DEPS_INSTALL_DIR}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}*${CMAKE_SHARED_LIBRARY_SUFFIX}*
|
||||||
|
51
third-party/cmake/BuildGperf.cmake
vendored
Normal file
51
third-party/cmake/BuildGperf.cmake
vendored
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
# Gperf recipe. Gperf is only required when building Neovim, when
|
||||||
|
# cross compiling we still want to build for the HOST system, whenever
|
||||||
|
# writing a recipe that is meant for cross-compile, use the HOSTDEPS_* variables
|
||||||
|
# instead of DEPS_* - check the main CMakeLists.txt for a list.
|
||||||
|
|
||||||
|
# BuildGperf(CONFIGURE_COMMAND ... BUILD_COMMAND ... INSTALL_COMMAND ...)
|
||||||
|
# Reusable function to build Gperf, wraps ExternalProject_Add.
|
||||||
|
# Failing to pass a command argument will result in no command being run
|
||||||
|
function(BuildGperf)
|
||||||
|
cmake_parse_arguments(_gperf
|
||||||
|
""
|
||||||
|
""
|
||||||
|
"CONFIGURE_COMMAND;BUILD_COMMAND;INSTALL_COMMAND"
|
||||||
|
${ARGN})
|
||||||
|
|
||||||
|
if(NOT _gperf_CONFIGURE_COMMAND AND NOT _gperf_BUILD_COMMAND
|
||||||
|
AND NOT _gperf_INSTALL_COMMAND)
|
||||||
|
message(FATAL_ERROR "Must pass at least one of CONFIGURE_COMMAND, BUILD_COMMAND, INSTALL_COMMAND")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
ExternalProject_Add(gperf
|
||||||
|
PREFIX ${DEPS_BUILD_DIR}
|
||||||
|
URL ${GPERF_URL}
|
||||||
|
DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}/gperf
|
||||||
|
DOWNLOAD_COMMAND ${CMAKE_COMMAND}
|
||||||
|
-DPREFIX=${DEPS_BUILD_DIR}
|
||||||
|
-DDOWNLOAD_DIR=${DEPS_DOWNLOAD_DIR}/gperf
|
||||||
|
-DURL=${GPERF_URL}
|
||||||
|
-DEXPECTED_SHA256=${GPERF_SHA256}
|
||||||
|
-DTARGET=gperf
|
||||||
|
-DUSE_EXISTING_SRC_DIR=${USE_EXISTING_SRC_DIR}
|
||||||
|
-P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/DownloadAndExtractFile.cmake
|
||||||
|
BUILD_IN_SOURCE 1
|
||||||
|
CONFIGURE_COMMAND "${_gperf_CONFIGURE_COMMAND}"
|
||||||
|
BUILD_COMMAND "${_gperf_BUILD_COMMAND}"
|
||||||
|
INSTALL_COMMAND "${_gperf_INSTALL_COMMAND}")
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
set(GPERF_BUILDARGS CC=${HOSTDEPS_C_COMPILER} LD=${HOSTDEPS_C_COMPILER})
|
||||||
|
|
||||||
|
if(UNIX OR (MINGW AND CMAKE_CROSSCOMPILING))
|
||||||
|
|
||||||
|
BuildGperf(
|
||||||
|
CONFIGURE_COMMAND ${DEPS_BUILD_DIR}/src/gperf/configure
|
||||||
|
--prefix=${HOSTDEPS_INSTALL_DIR}
|
||||||
|
INSTALL_COMMAND ${MAKE_PRG} install)
|
||||||
|
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Trying to build gperf in an unsupported system ${CMAKE_SYSTEM_NAME}/${CMAKE_C_COMPILER_ID}")
|
||||||
|
endif()
|
||||||
|
|
Reference in New Issue
Block a user