aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2016-09-14 11:15:01 +0200
committerBjörn Linse <bjorn.linse@gmail.com>2016-09-15 10:44:38 +0200
commitc61bf43a90238f20716d48554ddc536b485ec1bf (patch)
treed814e411d697dd1b546702b3fb4040ac09d3f4f9
parentfee961c8ddda9de00db19895e189a174896d6534 (diff)
downloadrneovim-c61bf43a90238f20716d48554ddc536b485ec1bf.tar.gz
rneovim-c61bf43a90238f20716d48554ddc536b485ec1bf.tar.bz2
rneovim-c61bf43a90238f20716d48554ddc536b485ec1bf.zip
gendispatch: warn for deprecated alias if the deprecated function has implemation
-rw-r--r--scripts/gendispatch.lua17
-rw-r--r--src/nvim/CMakeLists.txt3
-rw-r--r--src/nvim/api/dispatch_deprecated.lua (renamed from scripts/dispatch_deprecated.lua)0
3 files changed, 16 insertions, 4 deletions
diff --git a/scripts/gendispatch.lua b/scripts/gendispatch.lua
index 96322ccf73..40507d0afe 100644
--- a/scripts/gendispatch.lua
+++ b/scripts/gendispatch.lua
@@ -46,8 +46,8 @@ grammar = Ct((c_proto + c_comment + c_preproc + ws) ^ 1)
assert(#arg >= 3)
functions = {}
-local scriptdir = arg[1]
-package.path = scriptdir .. '/?.lua;' .. package.path
+local nvimsrcdir = arg[1]
+package.path = nvimsrcdir .. '/?.lua;' .. package.path
-- names of all headers relative to the source root (for inclusion in the
-- generated file)
@@ -57,6 +57,9 @@ outputf = arg[#arg-1]
-- output mpack file (metadata)
mpack_outputf = arg[#arg]
+-- set of function names, used to detect duplicates
+function_names = {}
+
-- read each input file, parse and append to the api metadata
for i = 2, #arg - 2 do
local full_path = arg[i]
@@ -72,6 +75,7 @@ for i = 2, #arg - 2 do
local fn = tmp[i]
if not fn.noexport then
functions[#functions + 1] = tmp[i]
+ function_names[fn.name] = true
if #fn.parameters ~= 0 and fn.parameters[1][2] == 'channel_id' then
-- this function should receive the channel id
fn.receives_channel_id = true
@@ -104,7 +108,7 @@ end
-- Export functions under older deprecated names.
-- These will be removed eventually.
-local deprecated_aliases = require("dispatch_deprecated")
+local deprecated_aliases = require("api.dispatch_deprecated")
for i,f in ipairs(shallowcopy(functions)) do
local ismethod = false
if startswith(f.name, "nvim_buf_") then
@@ -120,6 +124,13 @@ for i,f in ipairs(shallowcopy(functions)) do
f.method = ismethod
local newname = deprecated_aliases[f.name]
if newname ~= nil then
+ if function_names[newname] then
+ -- duplicate
+ print("Function "..f.name.." has deprecated alias\n"
+ ..newname.." which has a separate implementation.\n"..
+ "Please remove it from src/nvim/api/dispatch_deprecated.lua")
+ os.exit(1)
+ end
local newf = shallowcopy(f)
newf.name = newname
newf.impl_name = f.name
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt
index 2b29482a13..7c2c2feebc 100644
--- a/src/nvim/CMakeLists.txt
+++ b/src/nvim/CMakeLists.txt
@@ -204,11 +204,12 @@ add_custom_command(OUTPUT ${GENERATED_UNICODE_TABLES}
)
add_custom_command(OUTPUT ${GENERATED_API_DISPATCH} ${API_METADATA}
- COMMAND ${LUA_PRG} ${DISPATCH_GENERATOR} ${PROJECT_SOURCE_DIR}/scripts ${API_HEADERS} ${GENERATED_API_DISPATCH} ${API_METADATA}
+ COMMAND ${LUA_PRG} ${DISPATCH_GENERATOR} ${CMAKE_CURRENT_LIST_DIR} ${API_HEADERS} ${GENERATED_API_DISPATCH} ${API_METADATA}
DEPENDS
${API_HEADERS}
${MSGPACK_RPC_HEADERS}
${DISPATCH_GENERATOR}
+ ${CMAKE_CURRENT_LIST_DIR}/api/dispatch_deprecated.lua
)
list(APPEND NEOVIM_GENERATED_SOURCES
diff --git a/scripts/dispatch_deprecated.lua b/src/nvim/api/dispatch_deprecated.lua
index f3b299e3fc..f3b299e3fc 100644
--- a/scripts/dispatch_deprecated.lua
+++ b/src/nvim/api/dispatch_deprecated.lua